diff options
author | Joey <joey@lineageos.org> | 2018-02-04 11:36:32 +0100 |
---|---|---|
committer | Joey <joey@lineageos.org> | 2018-02-05 19:54:40 +0000 |
commit | 1b2f8875b149fa27f80b6945cb51a5476e709a8b (patch) | |
tree | 296e016387f4813a96aca6b6f92d7e60ef7704f9 /src | |
parent | 8463529145791249bb7118fe96482a5e8e58eac4 (diff) | |
download | android_packages_apps_Trebuchet-1b2f8875b149fa27f80b6945cb51a5476e709a8b.tar.gz android_packages_apps_Trebuchet-1b2f8875b149fa27f80b6945cb51a5476e709a8b.tar.bz2 android_packages_apps_Trebuchet-1b2f8875b149fa27f80b6945cb51a5476e709a8b.zip |
Trebuchet: allow disabling workspace edit
Change-Id: I503e19cbc512eac0e4a8c8bccc16a6ccc0e805da
Signed-off-by: Joey <joey@lineageos.org>
Diffstat (limited to 'src')
6 files changed, 25 insertions, 2 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index b53560d94..0c12469be 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1091,6 +1091,8 @@ public class Launcher extends BaseActivity mLauncherCallbacks.onResume(); } + mWidgetsButton.setVisibility(Utilities.isWorkspaceEditAllowed(getApplicationContext()) ? + View.VISIBLE : View.GONE); } @Override diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java index 8ae76a81a..8cab471e5 100644 --- a/src/com/android/launcher3/SettingsActivity.java +++ b/src/com/android/launcher3/SettingsActivity.java @@ -31,7 +31,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; -import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.preference.ListPreference; @@ -62,6 +61,7 @@ public class SettingsActivity extends Activity { private static final String KEY_SHOW_DRAWER_LABELS = "pref_drawer_show_labels"; static final String KEY_FEED_INTEGRATION = "pref_feed_integration"; + public static final String KEY_WORKSPACE_EDIT = "pref_workspace_edit"; static final String EXTRA_SCHEDULE_RESTART = "extraScheduleRestart"; diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 300df43c6..bbfc06dbe 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -703,4 +703,9 @@ public final class Utilities { SharedPreferences prefs = getPrefs(context.getApplicationContext()); return prefs.getBoolean(SettingsActivity.KEY_FEED_INTEGRATION, false); } + + public static boolean isWorkspaceEditAllowed(Context context) { + SharedPreferences prefs = getPrefs(context.getApplicationContext()); + return prefs.getBoolean(SettingsActivity.KEY_WORKSPACE_EDIT, true); + } } diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index b8527148b..4341e8bbe 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -35,6 +35,7 @@ import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; +import com.android.launcher3.Utilities; import com.android.launcher3.accessibility.DragViewStateAnnouncer; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.Thunk; @@ -391,7 +392,14 @@ public class DragController implements DragDriver.EventListener, TouchController * Call this from a drag source view. */ public boolean onControllerInterceptTouchEvent(MotionEvent ev) { - if (mOptions != null && mOptions.isAccessibleDrag) { + boolean isEditDisabled = !Utilities.isWorkspaceEditAllowed( + mLauncher.getApplicationContext()); + + if ((mOptions != null && mOptions.isAccessibleDrag) || isEditDisabled) { + if (isEditDisabled) { + cancelDrag(); + } + return false; } diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index 587c6682d..0f7519838 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -12,6 +12,7 @@ import com.android.launcher3.InfoDropTarget; import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.model.WidgetItem; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.widget.WidgetsBottomSheet; @@ -56,6 +57,10 @@ public abstract class SystemShortcut extends ItemInfo { @Override public View.OnClickListener getOnClickListener(final Launcher launcher, final ItemInfo itemInfo) { + if (!Utilities.isWorkspaceEditAllowed(launcher.getApplicationContext())) { + return null; + } + final List<WidgetItem> widgets = launcher.getWidgetsForPackageUser(new PackageUserKey( itemInfo.getTargetComponent().getPackageName(), itemInfo.user)); if (widgets == null) { diff --git a/src/com/android/launcher3/shortcuts/ShortcutsItemView.java b/src/com/android/launcher3/shortcuts/ShortcutsItemView.java index b4fa04e42..1df780d4e 100644 --- a/src/com/android/launcher3/shortcuts/ShortcutsItemView.java +++ b/src/com/android/launcher3/shortcuts/ShortcutsItemView.java @@ -34,6 +34,7 @@ import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.anim.PropertyListBuilder; import com.android.launcher3.anim.RoundedRectRevealOutlineProvider; import com.android.launcher3.dragndrop.DragOptions; @@ -110,6 +111,8 @@ public class ShortcutsItemView extends PopupItemView implements View.OnLongClick if (!mLauncher.isDraggingEnabled()) return false; // Return early if an item is already being dragged (e.g. when long-pressing two shortcuts) if (mLauncher.getDragController().isDragging()) return false; + // Return early if workspace edit is disabled + if (!Utilities.isWorkspaceEditAllowed(mLauncher.getApplicationContext())) return false; // Long clicked on a shortcut. DeepShortcutView sv = (DeepShortcutView) v.getParent(); |