Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 5a4522bf authored by Joey's avatar Joey Committed by Michael Bestas
Browse files

Trebuchet: allow disabling workspace edit



Co-authored-by: default avatarMichael W <baddaemon87@gmail.com>
Co-authored-by: default avatarHan Wang <416810799@qq.com>
Change-Id: I503e19cbc512eac0e4a8c8bccc16a6ccc0e805da
parent 7868f5d9
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -17,6 +17,14 @@
    <!-- Application name -->
    <string name="lineageos_app_name" translatable="false">Trebuchet</string>

    <!-- Settings -->

    <!-- Edit workspace -->
    <string name="settings_lock_layout_title">Lock layout</string>
    <string name="settings_lock_layout_summary_on">Icons and widgets can\'t be added, removed and moved on the homescreen</string>
    <string name="settings_lock_layout_summary_off">Icons and widgets can be added, removed and moved on the homescreen</string>
    <string name="settings_edit_widgets_error">It\'s not possible to add widgets to the home screen</string>

    <!-- Folder titles -->
    <string name="google_folder_title" translatable="false">Google</string>
</resources>
+8 −0
Original line number Diff line number Diff line
@@ -18,6 +18,14 @@
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res-auto">

    <SwitchPreference
        android:defaultValue="false"
        android:key="pref_workspace_lock"
        android:persistent="true"
        android:title="@string/settings_lock_layout_title"
        android:summaryOn="@string/settings_lock_layout_summary_on"
        android:summaryOff="@string/settings_lock_layout_summary_off" />

    <com.android.launcher3.settings.NotificationDotsPreference
        android:key="pref_icon_badging"
        android:title="@string/notification_dots_title"
+2 −0
Original line number Diff line number Diff line
@@ -88,6 +88,8 @@ public class InvariantDeviceProfile {

    private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48;

    public static final String KEY_WORKSPACE_LOCK = "pref_workspace_lock";

    // Constants that affects the interpolation curve between statically defined device profile
    // buckets.
    private static final float KNEARESTNEIGHBOR = 3;
+5 −0
Original line number Diff line number Diff line
@@ -931,4 +931,9 @@ public final class Utilities {
        }
        return options;
    }

    public static boolean isWorkspaceEditAllowed(Context context) {
        SharedPreferences prefs = getPrefs(context.getApplicationContext());
        return !prefs.getBoolean(InvariantDeviceProfile.KEY_WORKSPACE_LOCK, false);
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import androidx.annotation.Nullable;

import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
import com.android.launcher3.Utilities;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
@@ -394,6 +395,11 @@ public abstract class DragController<T extends ActivityContext>
            return false;
        }

        if (!Utilities.isWorkspaceEditAllowed(mActivity.getDragLayer().getContext())) {
            cancelDrag();
            return false;
        }

        Point dragLayerPos = getClampedDragLayerPos(getX(ev), getY(ev));
        mLastTouch.set(dragLayerPos.x,  dragLayerPos.y);
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
Loading