Merge "pin-shortcut: Tracks hotseat states and adds unpin option for taskbar" into main
This commit is contained in:
commit
8444f38c92
9 files changed
+113
-34
No files matched your search
@@ -16,18 +16,20 @@
|
||||
package com.android.launcher3.taskbar;
|
||||
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_ALL_APPS;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
|
||||
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;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.graphics.Point;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseArray;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.internal.logging.InstanceId;
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
@@ -81,6 +83,8 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
|
||||
private TaskbarControllers mControllers;
|
||||
private boolean mAllowInitialSplitSelection;
|
||||
private AppInfo[] mAppInfosList;
|
||||
// Saves the ItemInfos in the hotseat without the predicted items.
|
||||
private SparseArray<ItemInfo> mHotseatInfosList;
|
||||
private ManageWindowsTaskbarShortcut<BaseTaskbarContext> mManageWindowsTaskbarShortcut;
|
||||
|
||||
|
||||
@@ -149,6 +153,14 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// TODO(b/375648361): Revisit to see if this can be implemented within getSystemShortcuts().
|
||||
if (Flags.enablePinningAppWithContextMenu()) {
|
||||
SystemShortcut shortcut = createPinShortcut(context, item, icon);
|
||||
if (shortcut != null) {
|
||||
systemShortcuts.add(0, shortcut);
|
||||
}
|
||||
}
|
||||
|
||||
container = (PopupContainerWithArrow) context.getLayoutInflater().inflate(
|
||||
R.layout.popup_container, context.getDragLayer(), false);
|
||||
container.populateAndShowRows(icon, deepShortcutCount, systemShortcuts);
|
||||
@@ -172,9 +184,6 @@ 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
|
||||
.isInDesktopModeAndNotInOverview(mContext.getDisplayId())) {
|
||||
@@ -193,6 +202,24 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
|
||||
return shortcuts.stream();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private SystemShortcut createPinShortcut(BaseTaskbarContext target, ItemInfo itemInfo,
|
||||
BubbleTextView originalView) {
|
||||
// Predicted items use {@code HotseatPredictionController.PinPrediction} shortcut to pin.
|
||||
if (itemInfo.isPredictedItem()) {
|
||||
return null;
|
||||
}
|
||||
if (itemInfo.container == CONTAINER_HOTSEAT) {
|
||||
return new PinToTaskbarShortcut<>(target, itemInfo, originalView, false);
|
||||
}
|
||||
if (mHotseatInfosList.size()
|
||||
< mContext.getTaskbarSpecsEvaluator().getNumShownHotseatIcons()) {
|
||||
return new PinToTaskbarShortcut<>(target, itemInfo, originalView, true);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpLogs(String prefix, PrintWriter pw) {
|
||||
pw.println(prefix + "TaskbarPopupController:");
|
||||
@@ -276,6 +303,10 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
|
||||
return index < 0 ? null : mAppInfosList[index];
|
||||
}
|
||||
|
||||
public void setHotseatInfosList(SparseArray<ItemInfo> info) {
|
||||
mHotseatInfosList = info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream of Multi Instance menu options if an app supports it.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user