Add Manage Windows option to Taskbar long press menu
This change adds an option to the long press menu on Taskbar apps to view open instances of the calling apps. It will only show on apps that support multi instance (ex. Chrome). Bug: 315989246 Test: Manual Flag: com.android.launcher3.enable_multi_instance_menu_taskbar Change-Id: Ie1e001c4cec831c751bcbf448aaa68bb90fb24ca
This commit is contained in:
@@ -201,8 +201,10 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
|
||||
if (com.android.wm.shell.Flags.enableBubbleAnything()) {
|
||||
shortcuts.add(BUBBLE);
|
||||
}
|
||||
|
||||
if (Flags.enableMultiInstanceMenuTaskbar()
|
||||
&& DesktopModeStatus.canEnterDesktopMode(mContext)) {
|
||||
&& DesktopModeStatus.canEnterDesktopMode(mContext)
|
||||
&& !mControllers.taskbarStashController.isInOverview()) {
|
||||
shortcuts.addAll(getMultiInstanceMenuOptions().toList());
|
||||
}
|
||||
return shortcuts.stream();
|
||||
@@ -295,9 +297,9 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
|
||||
* Returns a stream of Multi Instance menu options if an app supports it.
|
||||
*/
|
||||
Stream<SystemShortcut.Factory<BaseTaskbarContext>> getMultiInstanceMenuOptions() {
|
||||
SystemShortcut.Factory<BaseTaskbarContext> factory = createNewWindowShortcutFactory();
|
||||
return factory != null ? Stream.of(factory) : Stream.empty();
|
||||
|
||||
SystemShortcut.Factory<BaseTaskbarContext> f1 = createNewWindowShortcutFactory();
|
||||
SystemShortcut.Factory<BaseTaskbarContext> f2 = createManageWindowsShortcutFactory();
|
||||
return f1 != null ? Stream.of(f1, f2) : Stream.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,6 +318,23 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a factory function representing a "Manage Windows" menu item only if the calling app
|
||||
* supports multi-instance. This menu item shows the open instances of the calling app.
|
||||
* @return A factory function to be used in populating the long-press menu.
|
||||
*/
|
||||
public SystemShortcut.Factory<BaseTaskbarContext> createManageWindowsShortcutFactory() {
|
||||
return (context, itemInfo, originalView) -> {
|
||||
ComponentKey key = itemInfo.getComponentKey();
|
||||
AppInfo app = getApp(key);
|
||||
if (app != null && app.supportsMultiInstance()) {
|
||||
return new ManageWindowsTaskbarShortcut<>(context, itemInfo, originalView,
|
||||
mControllers);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A single menu item ("Split left," "Split right," or "Split top") that executes a split
|
||||
* from the taskbar, as if the user performed a drag and drop split.
|
||||
|
||||
Reference in New Issue
Block a user