summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3
diff options
context:
space:
mode:
authorJoey <joey@lineageos.org>2018-02-04 11:36:32 +0100
committerJoey <joey@lineageos.org>2018-12-27 12:42:40 +0100
commit514e4c750ffe8e9049f64fe86c61a7e5d6872f15 (patch)
treeeccbbac3cd51f533b96a2f69316997805ef31edc /src/com/android/launcher3
parentfe9c56fe329cc7c8f01aef929cb66fe0904dea1a (diff)
downloadandroid_packages_apps_Trebuchet-514e4c750ffe8e9049f64fe86c61a7e5d6872f15.tar.gz
android_packages_apps_Trebuchet-514e4c750ffe8e9049f64fe86c61a7e5d6872f15.tar.bz2
android_packages_apps_Trebuchet-514e4c750ffe8e9049f64fe86c61a7e5d6872f15.zip
Trebuchet: allow disabling workspace edit
Change-Id: I503e19cbc512eac0e4a8c8bccc16a6ccc0e805da Signed-off-by: Joey <joey@lineageos.org>
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r--src/com/android/launcher3/SettingsActivity.java4
-rw-r--r--src/com/android/launcher3/Utilities.java5
-rw-r--r--src/com/android/launcher3/dragndrop/DragController.java9
-rw-r--r--src/com/android/launcher3/popup/PopupContainerWithArrow.java3
-rw-r--r--src/com/android/launcher3/popup/SystemShortcut.java5
-rw-r--r--src/com/android/launcher3/views/OptionsPopupView.java6
6 files changed, 29 insertions, 3 deletions
diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java
index 990c1b358..26ca61a82 100644
--- a/src/com/android/launcher3/SettingsActivity.java
+++ b/src/com/android/launcher3/SettingsActivity.java
@@ -81,6 +81,8 @@ public class SettingsActivity extends Activity {
private static final String KEY_SHOW_DESKTOP_LABELS = "pref_desktop_show_labels";
private static final String KEY_SHOW_DRAWER_LABELS = "pref_drawer_show_labels";
+ public static final String KEY_WORKSPACE_EDIT = "pref_workspace_edit";
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -100,7 +102,7 @@ public class SettingsActivity extends Activity {
/**
* This fragment shows the launcher preferences.
*/
- public static class LauncherSettingsFragment extends PreferenceFragment
+ public static class LauncherSettingsFragment extends PreferenceFragment
implements SharedPreferences.OnSharedPreferenceChangeListener {
private IconBadgingObserver mIconBadgingObserver;
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 0e6d56799..2330b10e3 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -619,4 +619,9 @@ public final class Utilities {
msg.setAsynchronous(true);
handler.sendMessage(msg);
}
+
+ 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 8a216fc17..97c0fa916 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -37,6 +37,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;
@@ -407,10 +408,18 @@ public class DragController implements DragDriver.EventListener, TouchController
* Call this from a drag source view.
*/
public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
+ boolean isEditDisabled = !Utilities.isWorkspaceEditAllowed(
+ mLauncher.getApplicationContext());
+
if (mOptions != null && mOptions.isAccessibleDrag) {
return false;
}
+ if (isEditDisabled) {
+ cancelDrag();
+ return false;
+ }
+
// Update the velocity tracker
mFlingToDeleteHelper.recordMotionEvent(ev);
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index 172cf41e0..16514e149 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -51,6 +51,7 @@ import com.android.launcher3.ItemInfoWithIcon;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate;
import com.android.launcher3.badge.BadgeInfo;
@@ -547,6 +548,8 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource,
if (!ItemLongClickListener.canStartDrag(mLauncher)) return false;
// Return early if not the correct view
if (!(v.getParent() instanceof DeepShortcutView)) 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();
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index 3c1cc9057..0348b0bfc 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -14,6 +14,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.model.WidgetItem;
import com.android.launcher3.util.InstantAppResolver;
import com.android.launcher3.util.PackageManagerHelper;
@@ -48,6 +49,10 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite
@Override
public View.OnClickListener getOnClickListener(final Launcher launcher,
final ItemInfo itemInfo) {
+ if (!Utilities.isWorkspaceEditAllowed(launcher.getApplicationContext())) {
+ return null;
+ }
+
final List<WidgetItem> widgets =
launcher.getPopupDataProvider().getWidgetsForPackageUser(new PackageUserKey(
itemInfo.getTargetComponent().getPackageName(), itemInfo.user));
diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java
index db4c49226..29020e739 100644
--- a/src/com/android/launcher3/views/OptionsPopupView.java
+++ b/src/com/android/launcher3/views/OptionsPopupView.java
@@ -144,8 +144,10 @@ public class OptionsPopupView extends ArrowPopup
ArrayList<OptionItem> options = new ArrayList<>();
options.add(new OptionItem(R.string.wallpaper_button_text, R.drawable.ic_wallpaper,
ControlType.WALLPAPER_BUTTON, OptionsPopupView::startWallpaperPicker));
- options.add(new OptionItem(R.string.widget_button_text, R.drawable.ic_widget,
- ControlType.WIDGETS_BUTTON, OptionsPopupView::onWidgetsClicked));
+ if (Utilities.isWorkspaceEditAllowed(launcher)) {
+ options.add(new OptionItem(R.string.widget_button_text, R.drawable.ic_widget,
+ ControlType.WIDGETS_BUTTON, OptionsPopupView::onWidgetsClicked));
+ }
options.add(new OptionItem(R.string.settings_button_text, R.drawable.ic_setting,
ControlType.SETTINGS_BUTTON, OptionsPopupView::startSettings));