diff --git a/lawnchair/src/app/lawnchair/ui/popup/LawnchairShortcut.kt b/lawnchair/src/app/lawnchair/ui/popup/LawnchairShortcut.kt index d1d4655b39..e6e1b3f26e 100644 --- a/lawnchair/src/app/lawnchair/ui/popup/LawnchairShortcut.kt +++ b/lawnchair/src/app/lawnchair/ui/popup/LawnchairShortcut.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.ui.unit.dp import app.lawnchair.LawnchairLauncher import app.lawnchair.override.CustomizeAppDialog +import app.lawnchair.preferences2.PreferenceManager2 import app.lawnchair.views.ComposeBottomSheet import com.android.launcher3.AbstractFloatingView import com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION @@ -16,12 +17,15 @@ import com.android.launcher3.model.data.AppInfo as ModelAppInfo import com.android.launcher3.model.data.ItemInfo import com.android.launcher3.popup.SystemShortcut import com.android.launcher3.util.ComponentKey +import com.patrykmichalik.preferencemanager.firstBlocking class LawnchairShortcut { companion object { - val CUSTOMIZE = SystemShortcut.Factory { activity, itemInfo -> - getAppInfo(activity, itemInfo)?.let { Customize(activity, it, itemInfo) } + + val CUSTOMIZE: SystemShortcut.Factory = SystemShortcut.Factory { activity, itemInfo -> + if (PreferenceManager2.getInstance(activity).lockHomeScreen.firstBlocking()) null + else getAppInfo(activity, itemInfo)?.let { Customize(activity, it, itemInfo) } } private fun getAppInfo(launcher: LawnchairLauncher, itemInfo: ItemInfo): ModelAppInfo? { diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index d91e214137..8dd93cac46 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -55,6 +55,7 @@ import android.os.UserHandle; import android.util.AttributeSet; import android.util.Log; import android.util.SparseArray; +import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -121,6 +122,7 @@ import com.android.launcher3.widget.WidgetManagerHelper; import com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener; import com.android.launcher3.widget.util.WidgetSizes; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay; +import com.patrykmichalik.preferencemanager.PreferenceExtensionsKt; import java.util.ArrayList; import java.util.Collections; @@ -130,6 +132,7 @@ import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; +import app.lawnchair.preferences2.PreferenceManager2; import app.lawnchair.smartspace.SmartspaceAppWidgetProvider; /** @@ -270,6 +273,8 @@ public class Workspace extends PagedView private final StatsLogManager mStatsLogManager; + PreferenceManager2 mPreferenceManager2; + /** * Used to inflate the Workspace from XML. * @@ -293,6 +298,7 @@ public class Workspace extends PagedView mLauncher = Launcher.getLauncher(context); mStateTransitionAnimation = new WorkspaceStateTransitionAnimation(mLauncher, this); mWallpaperManager = WallpaperManager.getInstance(context); + mPreferenceManager2 = PreferenceManager2.getInstance(context); mWallpaperOffset = new WallpaperOffsetInterpolator(this); @@ -1721,6 +1727,15 @@ public class Workspace extends PagedView } } + boolean lockHomeScreen = PreferenceExtensionsKt.firstBlocking(mPreferenceManager2.getLockHomeScreen()); + if (lockHomeScreen) { + child.setVisibility(View.VISIBLE); + + if (dragOptions.preDragCondition != null) { + mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } + return null; + } final DragView dv; if (contentView instanceof View) { if (contentView instanceof LauncherAppWidgetHostView) { diff --git a/src/com/android/launcher3/folder/FolderNameEditText.java b/src/com/android/launcher3/folder/FolderNameEditText.java index 7c657f053c..de5e1fde3e 100644 --- a/src/com/android/launcher3/folder/FolderNameEditText.java +++ b/src/com/android/launcher3/folder/FolderNameEditText.java @@ -18,6 +18,7 @@ package com.android.launcher3.folder; import android.content.Context; import android.util.AttributeSet; import android.util.Log; +import android.view.MotionEvent; import android.view.View; import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.EditorInfo; @@ -26,9 +27,12 @@ import android.view.inputmethod.InputConnectionWrapper; import android.view.inputmethod.InputMethodManager; import com.android.launcher3.ExtendedEditText; +import com.patrykmichalik.preferencemanager.PreferenceExtensionsKt; import java.util.List; +import app.lawnchair.preferences2.PreferenceManager2; + /** * Handles additional edit text functionality to better support folder name suggestion. * First, makes suggestion to the InputMethodManager via {@link #displayCompletions(List)} @@ -39,6 +43,8 @@ public class FolderNameEditText extends ExtendedEditText { private static final String TAG = "FolderNameEditText"; private static final boolean DEBUG = false; + private final PreferenceManager2 mPreferenceManager2 = PreferenceManager2.getInstance(getContext()); + private boolean mEnteredCompose = false; public FolderNameEditText(Context context) { @@ -130,4 +136,10 @@ public class FolderNameEditText extends ExtendedEditText { } hideKeyboard(); } + + @Override + public boolean onTouchEvent(MotionEvent event) { + if (PreferenceExtensionsKt.firstBlocking(mPreferenceManager2.getLockHomeScreen())) return true; + return super.onTouchEvent(event); + } } diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index a042c2ab96..eabee75cea 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -68,6 +68,7 @@ import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.util.ShortcutUtil; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.BaseDragLayer; +import com.patrykmichalik.preferencemanager.PreferenceExtensionsKt; import java.util.ArrayList; import java.util.Arrays; @@ -77,6 +78,7 @@ import java.util.Objects; import java.util.function.Predicate; import java.util.stream.Collectors; +import app.lawnchair.preferences2.PreferenceManager2; import app.lawnchair.theme.color.ColorTokens; import app.lawnchair.theme.drawable.DrawableTokens; @@ -88,6 +90,9 @@ import app.lawnchair.theme.drawable.DrawableTokens; public class PopupContainerWithArrow extends ArrowPopup implements DragSource, DragController.DragListener { + private final PreferenceManager2 preferenceManager2 = PreferenceManager2.getInstance(getContext()); + private final boolean lockHomeScreen = PreferenceExtensionsKt.firstBlocking(preferenceManager2.getLockHomeScreen()); + private final List mShortcuts = new ArrayList<>(); private final PointF mInterceptTouchDown = new PointF(); @@ -650,6 +655,7 @@ public class PopupContainerWithArrow @Override public boolean onLongClick(View v) { + if (mContainer.lockHomeScreen) return false; if (!ItemLongClickListener.canStartDrag(mLauncher)) return false; // Return early if not the correct view if (!(v.getParent() instanceof DeepShortcutView)) return false; diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index af872750a0..81598a79bb 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -27,9 +27,12 @@ import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.widget.WidgetsBottomSheet; +import com.patrykmichalik.preferencemanager.PreferenceExtensionsKt; import java.util.List; +import app.lawnchair.preferences2.PreferenceManager2; + /** * Represents a system shortcut for a given app. The shortcut should have a label and icon, and an * onClickListener that depends on the item that the shortcut services. @@ -108,6 +111,7 @@ public abstract class SystemShortcut extend } public static final Factory WIDGETS = (launcher, itemInfo) -> { + if (PreferenceExtensionsKt.firstBlocking(PreferenceManager2.getInstance(launcher).getLockHomeScreen())) return null; if (itemInfo.getTargetComponent() == null) return null; final List widgets = launcher.getPopupDataProvider().getWidgetsForPackageUser(new PackageUserKey( diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java index ad3f8df04b..a194a630cd 100644 --- a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java +++ b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java @@ -28,13 +28,19 @@ import android.widget.Toast; import com.android.launcher3.BubbleTextView; import com.android.launcher3.R; import com.android.launcher3.Utilities; +import com.patrykmichalik.preferencemanager.PreferenceExtensionsKt; + +import app.lawnchair.preferences2.PreferenceManager2; /** * A {@link BubbleTextView} that has the shortcut icon on the left and drag handle on the right. */ public class DeepShortcutTextView extends BubbleTextView { + + private final PreferenceManager2 mPreferenceManager2 = PreferenceManager2.getInstance(getContext()); + private final Rect mDragHandleBounds = new Rect(); - private final int mDragHandleWidth; + private int mDragHandleWidth; private boolean mShowInstructionToast = false; private Toast mInstructionToast; @@ -61,6 +67,17 @@ public class DeepShortcutTextView extends BubbleTextView { showLoadingState(true); } + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + + if (PreferenceExtensionsKt.firstBlocking(mPreferenceManager2.getLockHomeScreen())) { + setCompoundDrawables(null, null, null, null); + mDragHandleWidth = 0; + mDragHandleBounds.set(0, 0, 0, 0); + } + } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java index 42a6182ea8..1d94aa66cd 100644 --- a/src/com/android/launcher3/views/OptionsPopupView.java +++ b/src/com/android/launcher3/views/OptionsPopupView.java @@ -52,10 +52,13 @@ import com.android.launcher3.shortcuts.DeepShortcutView; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.widget.picker.WidgetsFullSheet; +import com.patrykmichalik.preferencemanager.PreferenceExtensionsKt; import java.util.ArrayList; import java.util.List; +import app.lawnchair.preferences2.PreferenceManager2; + /** * Popup shown on long pressing an empty space in launcher */ @@ -185,7 +188,8 @@ public class OptionsPopupView extends ArrowPopup R.drawable.ic_setting, LAUNCHER_SETTINGS_BUTTON_TAP_OR_LONGPRESS, OptionsPopupView::startSettings)); - if (!WidgetsModel.GO_DISABLE_WIDGETS) { + boolean lockHomeScreen = PreferenceExtensionsKt.firstBlocking(PreferenceManager2.INSTANCE.get(launcher).getLockHomeScreen()); + if (!lockHomeScreen && !WidgetsModel.GO_DISABLE_WIDGETS) { options.add(new OptionItem(launcher, R.string.widget_button_text, R.drawable.ic_widget,