Merge "Prefer launching desktop tasks on freeform display" into main
This commit is contained in:
commit
343333ce8a
6 files changed
+68
-49
No files matched your search
@@ -57,10 +57,17 @@ public abstract class BaseTaskbarContext extends BaseContext
|
||||
public abstract NavigationMode getNavigationMode();
|
||||
|
||||
/**
|
||||
* Returns whether the taskbar is in desktop mode.
|
||||
* Returns whether the taskbar is in desktop mode. Implies that some desktop tasks are currently
|
||||
* visible.
|
||||
*/
|
||||
public abstract boolean isInDesktopMode();
|
||||
|
||||
/**
|
||||
* Returns whether the taskbar is showing desktop tasks, which may happen even outside desktop
|
||||
* mode on freeform displays.
|
||||
*/
|
||||
public abstract boolean isTaskbarShowingDesktopTasks();
|
||||
|
||||
/**
|
||||
* Returns whether the taskbar is forced to be pinned when home is visible.
|
||||
*/
|
||||
|
||||
@@ -442,6 +442,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
&& mControllers.taskbarDesktopModeController.isInDesktopMode(getDisplayId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTaskbarShowingDesktopTasks() {
|
||||
return mControllers != null
|
||||
&& mControllers.taskbarDesktopModeController.shouldShowDesktopTasksInTaskbar(
|
||||
getDisplayId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showLockedTaskbarOnHome() {
|
||||
return DisplayController.showLockedTaskbarOnHome(this);
|
||||
@@ -1468,6 +1475,28 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
mControllers.uiController.startSplitSelection(splitSelectSource);
|
||||
}
|
||||
|
||||
// If in overview, and a desktop task is available, launches the overview desktop task and
|
||||
// schedules the provided runnable.
|
||||
// Returns whether the runnable has been posted.
|
||||
private boolean runAfterLaunchingDesktopTaskIfInOverview(
|
||||
RecentsView recents,
|
||||
Runnable runnableToRun) {
|
||||
if (recents == null || !isTaskbarShowingDesktopTasks()
|
||||
|| !mControllers.uiController.isInOverviewUi()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RunnableList runnableList = recents.launchRunningDesktopTaskView();
|
||||
// Wrapping it in runnable so we post after DW is ready for the app
|
||||
// launch.
|
||||
if (runnableList == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
runnableList.add(() -> UI_HELPER_EXECUTOR.execute(runnableToRun));
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void onTaskbarIconClicked(View view) {
|
||||
TaskbarUIController taskbarUIController = mControllers.uiController;
|
||||
RecentsView recents = taskbarUIController.getRecentsView();
|
||||
@@ -1479,25 +1508,17 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
// TODO: b/316004172, b/343289567: Handle `DesktopTask` and `SplitTask`.
|
||||
if (tag instanceof SingleTask singleTask) {
|
||||
RemoteTransition remoteTransition =
|
||||
(isInDesktopMode() && canUnminimizeDesktopTask(
|
||||
(isTaskbarShowingDesktopTasks() && canUnminimizeDesktopTask(
|
||||
singleTask.getTask().key.id))
|
||||
? createDesktopAppLaunchRemoteTransition(AppLaunchType.UNMINIMIZE,
|
||||
Cuj.CUJ_DESKTOP_MODE_APP_LAUNCH_FROM_ICON)
|
||||
: null;
|
||||
if (isInDesktopMode() && mControllers.uiController.isInOverviewUi()) {
|
||||
RunnableList runnableList = recents.launchRunningDesktopTaskView();
|
||||
// Wrapping it in runnable so we post after DW is ready for the app
|
||||
// launch.
|
||||
if (runnableList != null) {
|
||||
runnableList.add(() -> UI_HELPER_EXECUTOR.execute(
|
||||
() -> handleGroupTaskLaunch(singleTask, remoteTransition,
|
||||
isInDesktopMode(),
|
||||
DesktopTaskToFrontReason.TASKBAR_TAP)));
|
||||
}
|
||||
} else {
|
||||
handleGroupTaskLaunch(singleTask, remoteTransition, isInDesktopMode(),
|
||||
DesktopTaskToFrontReason.TASKBAR_TAP);
|
||||
Runnable launchTask = () -> handleGroupTaskLaunch(singleTask, remoteTransition,
|
||||
isTaskbarShowingDesktopTasks(), DesktopTaskToFrontReason.TASKBAR_TAP);
|
||||
if (!runAfterLaunchingDesktopTaskIfInOverview(recents, launchTask)) {
|
||||
launchTask.run();
|
||||
}
|
||||
|
||||
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
|
||||
} else if (tag instanceof FolderInfo) {
|
||||
// Tapping an expandable folder icon on Taskbar
|
||||
@@ -1520,24 +1541,12 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
AppLaunchType.UNMINIMIZE, Cuj.CUJ_DESKTOP_MODE_APP_LAUNCH_FROM_ICON)
|
||||
: null;
|
||||
|
||||
|
||||
if (isInDesktopMode() && mControllers.uiController.isInOverviewUi()) {
|
||||
RunnableList runnableList = recents.launchRunningDesktopTaskView();
|
||||
if (runnableList != null) {
|
||||
runnableList.add(() ->
|
||||
// wrapped it in runnable here since we need the post for DW to be
|
||||
// ready. if we don't other DW will be gone and only the launched
|
||||
// task will show.
|
||||
UI_HELPER_EXECUTOR.execute(() ->
|
||||
SystemUiProxy.INSTANCE.get(this).showDesktopApp(
|
||||
info.getTaskId(), remoteTransition,
|
||||
DesktopTaskToFrontReason.TASKBAR_TAP)));
|
||||
}
|
||||
} else {
|
||||
UI_HELPER_EXECUTOR.execute(() ->
|
||||
SystemUiProxy.INSTANCE.get(this).showDesktopApp(
|
||||
info.getTaskId(), remoteTransition,
|
||||
DesktopTaskToFrontReason.TASKBAR_TAP));
|
||||
Runnable launchTask = () ->
|
||||
SystemUiProxy.INSTANCE.get(this).showDesktopApp(
|
||||
info.getTaskId(), remoteTransition,
|
||||
DesktopTaskToFrontReason.TASKBAR_TAP);
|
||||
if (!runAfterLaunchingDesktopTaskIfInOverview(recents, launchTask)) {
|
||||
UI_HELPER_EXECUTOR.execute(launchTask);
|
||||
}
|
||||
|
||||
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(
|
||||
@@ -1794,17 +1803,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
.launchAppPair((AppPairIcon) launchingIconView,
|
||||
-1 /*cuj*/)));
|
||||
} else {
|
||||
if (isInDesktopMode()
|
||||
&& mControllers.uiController.isInOverviewUi()) {
|
||||
RunnableList runnableList = recents.launchRunningDesktopTaskView();
|
||||
// Wrapping it in runnable so we post after DW is ready for the app
|
||||
// launch.
|
||||
if (runnableList != null) {
|
||||
runnableList.add(() -> UI_HELPER_EXECUTOR.execute(
|
||||
() -> startItemInfoActivity(itemInfos.get(0), foundTask)));
|
||||
}
|
||||
} else {
|
||||
startItemInfoActivity(itemInfos.get(0), foundTask);
|
||||
Runnable launchTask =
|
||||
() -> startItemInfoActivity(itemInfos.get(0), foundTask);
|
||||
if (!runAfterLaunchingDesktopTaskIfInOverview(recents, launchTask)) {
|
||||
launchTask.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1840,7 +1842,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isInDesktopMode()
|
||||
if (isTaskbarShowingDesktopTasks()
|
||||
&& DesktopModeFlags.ENABLE_DESKTOP_APP_LAUNCH_TRANSITIONS_BUGFIX.isTrue()) {
|
||||
launchDesktopApp(intent, info, displayId);
|
||||
} else {
|
||||
|
||||
@@ -48,8 +48,12 @@ class TaskbarDesktopModeController(
|
||||
}
|
||||
|
||||
fun shouldShowDesktopTasksInTaskbar(): Boolean {
|
||||
return shouldShowDesktopTasksInTaskbar(context.displayId)
|
||||
}
|
||||
|
||||
fun shouldShowDesktopTasksInTaskbar(displayId: Int): Boolean {
|
||||
val activityContext = taskbarControllers.taskbarActivityContext
|
||||
return isInDesktopMode(context.displayId) ||
|
||||
return isInDesktopMode(displayId) ||
|
||||
activityContext.showDesktopTaskbarForFreeformDisplay() ||
|
||||
(activityContext.showLockedTaskbarOnHome() &&
|
||||
taskbarControllers.taskbarStashController.isOnHome)
|
||||
|
||||
@@ -471,7 +471,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
}
|
||||
|
||||
// Recents divider takes priority.
|
||||
if (!mAddedDividerForRecents && !mActivityContext.isInDesktopMode()) {
|
||||
if (!mAddedDividerForRecents && !mActivityContext.isTaskbarShowingDesktopTasks()) {
|
||||
updateAllAppsDivider();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -756,8 +756,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
||||
}
|
||||
|
||||
private boolean shouldUpdateIconContentDescription(BubbleTextView btv) {
|
||||
boolean isInDesktopMode = mControllers.taskbarDesktopModeController.isInDesktopMode(
|
||||
DEFAULT_DISPLAY);
|
||||
boolean isInDesktopMode =
|
||||
mControllers.taskbarDesktopModeController.shouldShowDesktopTasksInTaskbar(
|
||||
DEFAULT_DISPLAY);
|
||||
boolean isAllAppsButton = btv instanceof TaskbarAllAppsButtonContainer;
|
||||
boolean isDividerButton = btv instanceof TaskbarDividerContainer;
|
||||
return isInDesktopMode && !isAllAppsButton && !isDividerButton;
|
||||
|
||||
@@ -162,6 +162,11 @@ public class TaskbarOverlayContext extends BaseTaskbarContext {
|
||||
return mTaskbarContext.isInDesktopMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTaskbarShowingDesktopTasks() {
|
||||
return mTaskbarContext.isTaskbarShowingDesktopTasks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showLockedTaskbarOnHome() {
|
||||
return mTaskbarContext.showLockedTaskbarOnHome();
|
||||
|
||||
Reference in new issue
Block a user