Don't recreate taskbar in Overview
This cl includes
- when going to overview from Launcher or Desktop Mode don't recreate taskbar and keep it a same variant as the context user was in.
- user will still be able to pin/unpin taskbar in overview, but it will be recreated to the launcher context.
- opening app from taskbar context is now aware of if taskbar is in desktop mode and opens app in Desktop Mode when user oepn any app.
- This cl will not include the animation when taskbar variant is changing between launcher and desktop mode.
Solution
- if desktop tasks are visible we will open any app from taskbar context into Desktop windowing mode after launching the DesktopTaskView manually. We will launch desktop task from recentview first and upon end of recent animation we will launch the app.
Bug: 343882478
Test: Manual
Flag: com.android.window.flags.enable_desktop_windowing_mode
Change-Id: Ib67e1e7150670f901c07c2df188cde81e7d725dc
diff --git a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java
index fd0243a..488cea5 100644
--- a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java
+++ b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java
@@ -111,6 +111,17 @@
public boolean areDesktopTasksVisible() {
boolean desktopTasksVisible = mVisibleDesktopTasksCount > 0;
if (DEBUG) {
+ Log.d(TAG, "areDesktopTasksVisible: desktopVisible=" + desktopTasksVisible);
+ }
+ return desktopTasksVisible;
+ }
+
+ /**
+ * Whether desktop tasks are visible in desktop mode.
+ */
+ public boolean areDesktopTasksVisibleAndNotInOverview() {
+ boolean desktopTasksVisible = mVisibleDesktopTasksCount > 0;
+ if (DEBUG) {
Log.d(TAG, "areDesktopTasksVisible: desktopVisible=" + desktopTasksVisible
+ " overview=" + mInOverviewState);
}
@@ -160,9 +171,9 @@
if (visibleTasksCount != mVisibleDesktopTasksCount) {
final boolean wasVisible = mVisibleDesktopTasksCount > 0;
final boolean isVisible = visibleTasksCount > 0;
- final boolean wereDesktopTasksVisibleBefore = areDesktopTasksVisible();
+ final boolean wereDesktopTasksVisibleBefore = areDesktopTasksVisibleAndNotInOverview();
mVisibleDesktopTasksCount = visibleTasksCount;
- final boolean areDesktopTasksVisibleNow = areDesktopTasksVisible();
+ final boolean areDesktopTasksVisibleNow = areDesktopTasksVisibleAndNotInOverview();
if (wereDesktopTasksVisibleBefore != areDesktopTasksVisibleNow) {
notifyDesktopVisibilityListeners(areDesktopTasksVisibleNow);
}
@@ -219,13 +230,12 @@
+ " currentValue=" + mInOverviewState);
}
if (overviewStateEnabled != mInOverviewState) {
- final boolean wereDesktopTasksVisibleBefore = areDesktopTasksVisible();
+ final boolean wereDesktopTasksVisibleBefore = areDesktopTasksVisibleAndNotInOverview();
mInOverviewState = overviewStateEnabled;
- final boolean areDesktopTasksVisibleNow = areDesktopTasksVisible();
+ final boolean areDesktopTasksVisibleNow = areDesktopTasksVisibleAndNotInOverview();
if (wereDesktopTasksVisibleBefore != areDesktopTasksVisibleNow) {
notifyDesktopVisibilityListeners(areDesktopTasksVisibleNow);
}
-
if (ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue()) {
return;
}
@@ -279,7 +289,7 @@
if (mBackgroundStateEnabled) {
setLauncherViewsVisibility(View.VISIBLE);
markLauncherResumed();
- } else if (areDesktopTasksVisible() && !mGestureInProgress) {
+ } else if (areDesktopTasksVisibleAndNotInOverview() && !mGestureInProgress) {
// Switching out of background state. If desktop tasks are visible, pause launcher.
setLauncherViewsVisibility(View.INVISIBLE);
markLauncherPaused();
diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java
index de42669..cd38e5e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java
@@ -188,8 +188,8 @@
mQuickSwitchViewController = new KeyboardQuickSwitchViewController(
mControllers, mOverlayContext, keyboardQuickSwitchView, mControllerCallbacks);
- final boolean onDesktop =
- mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible();
+ final boolean onDesktop = mControllers.taskbarDesktopModeController
+ .getAreDesktopTasksVisibleAndNotInOverview();
if (mModel.isTaskListValid(mTaskListChangeId)
&& taskIdsToExclude.equals(mExcludedTaskIds)) {
@@ -233,7 +233,7 @@
private void processLoadedTasks(List<GroupTask> tasks, Set<Integer> taskIdsToExclude) {
mHasDesktopTask = false;
mWasDesktopTaskFilteredOut = false;
- if (mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) {
+ if (mControllers.taskbarDesktopModeController.getAreDesktopTasksVisibleAndNotInOverview()) {
processLoadedTasksOnDesktop(tasks, taskIdsToExclude);
} else {
processLoadedTasksOutsideDesktop(tasks, taskIdsToExclude);
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index ea42d77..371a0e8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -245,7 +245,8 @@
}
if (!ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue()
- && mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) {
+ && mControllers.taskbarDesktopModeController
+ .getAreDesktopTasksVisibleAndNotInOverview()) {
// TODO: b/333533253 - Remove after flag rollout
isVisible = false;
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 7b326c1..633806d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -1297,7 +1297,18 @@
RemoteTransition remoteTransition =
(areDesktopTasksVisible() && canUnminimizeDesktopTask(groupTask.task1.key.id))
? createUnminimizeRemoteTransition() : null;
- handleGroupTaskLaunch(groupTask, remoteTransition, areDesktopTasksVisible());
+ if (areDesktopTasksVisible() && 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(groupTask, remoteTransition,
+ areDesktopTasksVisible())));
+ }
+ } else {
+ handleGroupTaskLaunch(groupTask, remoteTransition, areDesktopTasksVisible());
+ }
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
} else if (tag instanceof FolderInfo) {
// Tapping an expandable folder icon on Taskbar
@@ -1317,9 +1328,29 @@
} else if (tag instanceof TaskItemInfo info) {
RemoteTransition remoteTransition = canUnminimizeDesktopTask(info.getTaskId())
? createUnminimizeRemoteTransition() : null;
- UI_HELPER_EXECUTOR.execute(() ->
- SystemUiProxy.INSTANCE.get(this).showDesktopApp(
- info.getTaskId(), remoteTransition));
+
+ TaskView taskView = null;
+ if (recents != null) {
+ taskView = recents.getTaskViewByTaskId(info.getTaskId());
+ }
+
+ if (areDesktopTasksVisible() && taskView != null) {
+ RunnableList runnableList = taskView.launchWithAnimation();
+ 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)));
+ }
+ } else {
+ UI_HELPER_EXECUTOR.execute(() ->
+ SystemUiProxy.INSTANCE.get(this).showDesktopApp(
+ info.getTaskId(), remoteTransition));
+ }
+
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(
/* stash= */ true);
} else if (tag instanceof WorkspaceItemInfo) {
@@ -1563,7 +1594,18 @@
.launchAppPair((AppPairIcon) launchingIconView,
-1 /*cuj*/)));
} else {
- startItemInfoActivity(itemInfos.get(0), foundTask);
+ if (areDesktopTasksVisible()
+ && 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);
+ }
}
}
);
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
index 826722d..af60f10 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
@@ -194,7 +194,7 @@
voiceInteractionWindowController
};
- if (taskbarDesktopModeController.getAreDesktopTasksVisible()) {
+ if (taskbarDesktopModeController.getAreDesktopTasksVisibleAndNotInOverview()) {
mCornerRoundness.value = taskbarDesktopModeController.getTaskbarCornerRoundness(
mSharedState.showCornerRadiusInDesktopMode);
} else {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopModeController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopModeController.kt
index 47a35c5..a7c7381 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopModeController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopModeController.kt
@@ -27,6 +27,9 @@
private lateinit var taskbarControllers: TaskbarControllers
private lateinit var taskbarSharedState: TaskbarSharedState
+ val areDesktopTasksVisibleAndNotInOverview: Boolean
+ get() = desktopVisibilityController.areDesktopTasksVisibleAndNotInOverview()
+
val areDesktopTasksVisible: Boolean
get() = desktopVisibilityController.areDesktopTasksVisible()
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
index fc307b2..a9e8d6d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
@@ -344,7 +344,8 @@
// TODO(297921594) clean it up when taskbar to desktop drag is implemented.
// Pre-drag has ended, start the global system drag.
if (mDisallowGlobalDrag
- || mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) {
+ || mControllers.taskbarDesktopModeController
+ .getAreDesktopTasksVisibleAndNotInOverview()) {
AbstractFloatingView.closeAllOpenViewsExcept(mActivity, TYPE_TASKBAR_ALL_APPS);
return;
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 250e33a..1905561 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -635,7 +635,7 @@
float cornerRoundness = isInLauncher ? 0 : 1;
- if (mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()
+ if (mControllers.taskbarDesktopModeController.getAreDesktopTasksVisibleAndNotInOverview()
&& mControllers.getSharedState() != null) {
cornerRoundness =
mControllers.taskbarDesktopModeController.getTaskbarCornerRoundness(
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt
index bcfc718..23c5070 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt
@@ -57,7 +57,10 @@
return
}
val shouldPinTaskbar =
- if (controllers.taskbarDesktopModeController.areDesktopTasksVisible) {
+ if (
+ controllers.taskbarDesktopModeController
+ .areDesktopTasksVisibleAndNotInOverview
+ ) {
!launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)
} else {
!launcherPrefs.get(TASKBAR_PINNING)
@@ -137,7 +140,7 @@
@VisibleForTesting
fun recreateTaskbarAndUpdatePinningValue() {
updateIsAnimatingTaskbarPinningAndNotifyTaskbarDragLayer(false)
- if (controllers.taskbarDesktopModeController.areDesktopTasksVisible) {
+ if (controllers.taskbarDesktopModeController.areDesktopTasksVisibleAndNotInOverview) {
launcherPrefs.put(
TASKBAR_PINNING_IN_DESKTOP_MODE,
!launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE),
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
index 772d45d..b3698ad 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
@@ -200,7 +200,8 @@
shortcuts.add(PIN_UNPIN_ITEM);
}
shortcuts.add(APP_INFO);
- if (!mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) {
+ if (!mControllers.taskbarDesktopModeController
+ .getAreDesktopTasksVisibleAndNotInOverview()) {
shortcuts.addAll(mControllers.uiController.getSplitMenuOptions().toList());
}
if (com.android.wm.shell.Flags.enableBubbleAnything()) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index 67be8da..7dd40af 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -1180,7 +1180,8 @@
// Do not stash if hardware keyboard is attached, in 3 button nav and desktop windowing mode
if (isHardwareKeyboard()
&& mActivity.isThreeButtonNav()
- && mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) {
+ && mControllers.taskbarDesktopModeController
+ .getAreDesktopTasksVisibleAndNotInOverview()) {
return false;
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index e17771c..dfbb4d7 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -1025,7 +1025,7 @@
DesktopVisibilityController desktopVisibilityController = getDesktopVisibilityController();
if (!ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue()
&& desktopVisibilityController != null
- && desktopVisibilityController.areDesktopTasksVisible()
+ && desktopVisibilityController.areDesktopTasksVisibleAndNotInOverview()
&& !desktopVisibilityController.isRecentsGestureInProgress()) {
// Return early to skip setting activity to appear as resumed
// TODO: b/333533253 - Remove after flag rollout
@@ -1354,7 +1354,7 @@
public boolean areDesktopTasksVisible() {
DesktopVisibilityController desktopVisibilityController = getDesktopVisibilityController();
if (desktopVisibilityController != null) {
- return desktopVisibilityController.areDesktopTasksVisible();
+ return desktopVisibilityController.areDesktopTasksVisibleAndNotInOverview();
}
return false;
}
diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
index 1e755eb..1437a6e 100644
--- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
@@ -87,7 +87,7 @@
// We were on our way to this state when we got canceled, end there instead.
startState = stateFromGestureEndTarget(endTarget);
DesktopVisibilityController controller = getDesktopVisibilityController();
- if (controller != null && controller.areDesktopTasksVisible()
+ if (controller != null && controller.areDesktopTasksVisibleAndNotInOverview()
&& endTarget == LAST_TASK) {
// When we are cancelling the transition and going back to last task, move to
// rest state instead when desktop tasks are visible.
diff --git a/quickstep/src/com/android/quickstep/BaseContainerInterface.java b/quickstep/src/com/android/quickstep/BaseContainerInterface.java
index 2164bc2..2171c47 100644
--- a/quickstep/src/com/android/quickstep/BaseContainerInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseContainerInterface.java
@@ -242,7 +242,7 @@
// We were on our way to this state when we got canceled, end there instead.
startState = stateFromGestureEndTarget(endTarget);
DesktopVisibilityController controller = getDesktopVisibilityController();
- if (controller != null && controller.areDesktopTasksVisible()
+ if (controller != null && controller.areDesktopTasksVisibleAndNotInOverview()
&& endTarget == LAST_TASK) {
// When we are cancelling the transition and going back to last task, move to
// rest state instead when desktop tasks are visible.
diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
index 7dd2f2e..76c14c0 100644
--- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
+++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
@@ -106,7 +106,8 @@
&& workspaceView.isAttachedToWindow()
&& workspaceView.getHeight() > 0
&& (mContainer.getDesktopVisibilityController() == null
- || !mContainer.getDesktopVisibilityController().areDesktopTasksVisible());
+ || !mContainer.getDesktopVisibilityController()
+ .areDesktopTasksVisibleAndNotInOverview());
mContainer.getRootView().setForceHideBackArrow(true);
diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
index 4f823e6..4ee6ef6 100644
--- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
@@ -287,7 +287,7 @@
desktopVisibilityController = mContainer.getDesktopVisibilityController();
endTarget = mCurrentGestureEndTarget;
if (endTarget == GestureState.GestureEndTarget.LAST_TASK
- && desktopVisibilityController.areDesktopTasksVisible()) {
+ && desktopVisibilityController.areDesktopTasksVisibleAndNotInOverview()) {
// Recents gesture was cancelled and we are returning to the previous task.
// After super class has handled clean up, show desktop apps on top again
showDesktopApps = true;
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 499f50e..b432f53 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1525,6 +1525,19 @@
return clearAllScroll + (mIsRtl ? distance : -distance);
}
+ /**
+ * Launch running task view if it is instance of DesktopTaskView.
+ * @return provides runnable list to attach runnable at end of Desktop Mode launch
+ */
+ @Nullable
+ public RunnableList launchRunningDesktopTaskView() {
+ TaskView taskView = getRunningTaskView();
+ if (taskView instanceof DesktopTaskView) {
+ return taskView.launchWithAnimation();
+ }
+ return null;
+ }
+
/*
* Returns if TaskView is within screen bounds defined in [screenStart, screenEnd].
*
diff --git a/quickstep/tests/src/com/android/quickstep/taskbar/controllers/TaskbarPinningControllerTest.kt b/quickstep/tests/src/com/android/quickstep/taskbar/controllers/TaskbarPinningControllerTest.kt
index cb59f7d..3148737 100644
--- a/quickstep/tests/src/com/android/quickstep/taskbar/controllers/TaskbarPinningControllerTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/taskbar/controllers/TaskbarPinningControllerTest.kt
@@ -70,7 +70,10 @@
whenever(taskbarActivityContext.launcherPrefs).thenReturn(launcherPrefs)
whenever(taskbarActivityContext.dragLayer).thenReturn(taskbarDragLayer)
whenever(taskbarActivityContext.statsLogManager).thenReturn(statsLogManager)
- whenever(taskbarControllers.taskbarDesktopModeController.areDesktopTasksVisible)
+ whenever(
+ taskbarControllers.taskbarDesktopModeController
+ .areDesktopTasksVisibleAndNotInOverview
+ )
.thenAnswer { _ -> isInDesktopMode }
pinningController = spy(TaskbarPinningController(taskbarActivityContext))
pinningController.init(taskbarControllers, taskbarSharedState)