mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 19:38:21 +00:00
Merge "pin-shortcut: Add pin shortcut to the context menu" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
ad0b62daad
@@ -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<SystemShortcut.Factory> 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());
|
||||
|
||||
@@ -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<SystemShortcut.Factory> 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);
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
<string name="all_apps_button_personal_label">Personal apps list</string>
|
||||
<string name="all_apps_button_work_label">Work apps list</string>
|
||||
|
||||
<!-- System shortcuts -->
|
||||
<!-- Label for remove drop target (from the homescreen only).
|
||||
May appear next to uninstall_drop_target_label [CHAR_LIMIT=20] -->
|
||||
<string name="remove_drop_target_label">Remove</string>
|
||||
@@ -232,6 +233,8 @@
|
||||
<string name="pin_prediction">Pin Prediction</string>
|
||||
<!-- Label for bubbling a launcher item. [CHAR_LIMIT=20] -->
|
||||
<string name="bubble">Bubble</string>
|
||||
<!-- Label for pinning an item to the taskbar. [CHAR_LIMIT=20] -->
|
||||
<string name="pin_to_taskbar">Pin to taskbar</string>
|
||||
|
||||
<!-- Permissions: -->
|
||||
<skip />
|
||||
|
||||
@@ -210,6 +210,30 @@ public abstract class SystemShortcut<T extends ActivityContext> extends ItemInfo
|
||||
}
|
||||
}
|
||||
|
||||
public static final Factory<ActivityContext> 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<T extends ActivityContext> extends SystemShortcut<T> {
|
||||
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<ActivityContext> PRIVATE_PROFILE_INSTALL =
|
||||
(context, itemInfo, originalView) -> {
|
||||
if (originalView == null) {
|
||||
|
||||
Reference in New Issue
Block a user