diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java index abf35a21b9..772d45d73c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java @@ -17,6 +17,7 @@ package com.android.launcher3.taskbar; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_ALL_APPS; import static com.android.launcher3.model.data.AppInfo.COMPONENT_KEY_COMPARATOR; +import static com.android.launcher3.popup.SystemShortcut.PIN_UNPIN_ITEM; import static com.android.launcher3.util.SplitConfigurationOptions.getLogEventForPosition; import android.content.Intent; @@ -195,6 +196,9 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba // append split options to APP_INFO shortcut if not in Desktop Windowing mode, the order // here will reflect in the popup ArrayList shortcuts = new ArrayList<>(); + if (Flags.enablePinningAppWithContextMenu()) { + shortcuts.add(PIN_UNPIN_ITEM); + } shortcuts.add(APP_INFO); if (!mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) { shortcuts.addAll(mControllers.uiController.getSplitMenuOptions().toList()); diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 3fd9970a52..e17771cdf9 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -48,6 +48,7 @@ import static com.android.launcher3.popup.SystemShortcut.APP_INFO; import static com.android.launcher3.popup.SystemShortcut.BUBBLE_SHORTCUT; import static com.android.launcher3.popup.SystemShortcut.DONT_SUGGEST_APP; import static com.android.launcher3.popup.SystemShortcut.INSTALL; +import static com.android.launcher3.popup.SystemShortcut.PIN_UNPIN_ITEM; import static com.android.launcher3.popup.SystemShortcut.PRIVATE_PROFILE_INSTALL; import static com.android.launcher3.popup.SystemShortcut.UNINSTALL_APP; import static com.android.launcher3.popup.SystemShortcut.WIDGETS; @@ -457,6 +458,10 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, // Order matters as it affects order of appearance in popup container List shortcuts = new ArrayList(Arrays.asList( APP_INFO, WellbeingModel.SHORTCUT_FACTORY, mHotseatPredictionController)); + + if (Flags.enablePinningAppWithContextMenu()) { + shortcuts.add(0, PIN_UNPIN_ITEM); + } shortcuts.addAll(getSplitShortcuts()); shortcuts.add(WIDGETS); shortcuts.add(INSTALL); diff --git a/res/values/strings.xml b/res/values/strings.xml index cdfbefea64..2fc039e36d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -212,6 +212,7 @@ Personal apps list Work apps list + Remove @@ -232,6 +233,8 @@ Pin Prediction Bubble + + Pin to taskbar diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index 63c9d94795..329d9df4f1 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -210,6 +210,30 @@ public abstract class SystemShortcut extends ItemInfo } } + public static final Factory PIN_UNPIN_ITEM = + (context, itemInfo, originalView) -> { + // Predicted items use {@code HotseatPredictionController.PinPrediction} shortcut + // to pin. + if (itemInfo.isPredictedItem()) { + return null; + } + return new PinUnpinItem<>(context, itemInfo, originalView); + }; + + private static class PinUnpinItem extends SystemShortcut { + PinUnpinItem(T target, ItemInfo itemInfo, @NonNull View originalView) { + // TODO(b/375648361): Check the pin state of the item to determine if the pin or the + // unpin option should be used. + super(R.drawable.ic_pin, R.string.pin_to_taskbar, target, + itemInfo, originalView); + } + + @Override + public void onClick(View view) { + // TODO(b/375648361): Pin/Unpin the item here. + } + } + public static final Factory PRIVATE_PROFILE_INSTALL = (context, itemInfo, originalView) -> { if (originalView == null) {