From f6ba9499ded5b87c015598ff800b9968625c40e7 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Tue, 3 Jan 2023 16:50:11 -0800 Subject: [PATCH] Fixes to support transient taskbar in desktop mode Track gesture progress in desktop visibility controller. We need to allow launcher to resume when gesture is in progress and freeform tasks are visible. Update overview state handling in desktop visibility controller. When overview is enabled, launcher should be made visible, regardless of freeform state. When exiting overview state, check freeform state to see what should be shown and enabled. Bug: 263264985 Test: manual, enable transient taskbar, move app to desktop, invoke transient taskbar Test: manual, enable transient taskarb, enable desktop mode, invoke transient taskbar Test: manual, disable transient taskbar, move app to desktop, swipe up to overview Test: manual, disable transient taskbar, enable desktop mode, swipe up to overview Change-Id: I63000441d9cf72769e6efb9d247ab4112c01839d --- .../DesktopVisibilityController.java | 93 ++++++++++++++----- .../uioverrides/QuickstepLauncher.java | 3 +- .../quickstep/views/LauncherRecentsView.java | 24 +++++ 3 files changed, 94 insertions(+), 26 deletions(-) diff --git a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java index bbc0627517..ae121e2ef4 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java @@ -33,6 +33,7 @@ public class DesktopVisibilityController { private boolean mFreeformTasksVisible; private boolean mInOverviewState; + private boolean mGestureInProgress; public DesktopVisibilityController(Launcher launcher) { mLauncher = launcher; @@ -57,9 +58,24 @@ public class DesktopVisibilityController { * Sets whether freeform windows are visible and updates launcher visibility based on that. */ public void setFreeformTasksVisible(boolean freeformTasksVisible) { + if (!isDesktopModeSupported()) { + return; + } if (freeformTasksVisible != mFreeformTasksVisible) { mFreeformTasksVisible = freeformTasksVisible; - updateLauncherVisibility(); + if (mFreeformTasksVisible) { + setLauncherViewsVisibility(View.INVISIBLE); + if (!mInOverviewState) { + // When freeform is visible & we're not in overview, we want launcher to appear + // paused, this ensures that taskbar displays. + markLauncherPaused(); + } + } else { + setLauncherViewsVisibility(View.VISIBLE); + // If freeform isn't visible ensure that launcher appears resumed to behave + // normally. + markLauncherResumed(); + } } } @@ -67,40 +83,67 @@ public class DesktopVisibilityController { * Sets whether the overview is visible and updates launcher visibility based on that. */ public void setOverviewStateEnabled(boolean overviewStateEnabled) { + if (!isDesktopModeSupported()) { + return; + } if (overviewStateEnabled != mInOverviewState) { mInOverviewState = overviewStateEnabled; - updateLauncherVisibility(); + if (mInOverviewState) { + setLauncherViewsVisibility(View.VISIBLE); + markLauncherResumed(); + } else if (mFreeformTasksVisible) { + setLauncherViewsVisibility(View.INVISIBLE); + markLauncherPaused(); + } } } /** - * Updates launcher visibility and state to look like it is paused or resumed depending on - * whether freeform windows are showing in desktop mode. + * Whether recents gesture is currently in progress. */ - private void updateLauncherVisibility() { - StatefulActivity activity = - QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity(); - View workspaceView = mLauncher.getWorkspace(); - if (activity == null || workspaceView == null || !isDesktopModeSupported()) { + public boolean isGestureInProgress() { + return mGestureInProgress; + } + + /** + * Sets whether recents gesture is in progress. + */ + public void setGestureInProgress(boolean gestureInProgress) { + if (!isDesktopModeSupported()) { return; } + if (gestureInProgress != mGestureInProgress) { + mGestureInProgress = gestureInProgress; + } + } - if (mFreeformTasksVisible) { - workspaceView.setVisibility(View.INVISIBLE); - if (!mInOverviewState) { - // When freeform is visible & we're not in overview, we want launcher to appear - // paused, this ensures that taskbar displays. - activity.setPaused(); - } - } else { - workspaceView.setVisibility(View.VISIBLE); - // If freeform isn't visible ensure that launcher appears resumed to behave normally. - // Check activity state before calling setResumed(). Launcher may have been actually - // paused (eg fullscreen task moved to front). - // In this case we should not mark the activity as resumed. - if (activity.isResumed()) { - activity.setResumed(); - } + private void setLauncherViewsVisibility(int visibility) { + View workspaceView = mLauncher.getWorkspace(); + if (workspaceView != null) { + workspaceView.setVisibility(visibility); + } + View dragLayer = mLauncher.getDragLayer(); + if (dragLayer != null) { + dragLayer.setVisibility(visibility); + } + } + + private void markLauncherPaused() { + StatefulActivity activity = + QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity(); + if (activity != null) { + activity.setPaused(); + } + } + + private void markLauncherResumed() { + StatefulActivity activity = + QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity(); + // Check activity state before calling setResumed(). Launcher may have been actually + // paused (eg fullscreen task moved to front). + // In this case we should not mark the activity as resumed. + if (activity != null && activity.isResumed()) { + activity.setResumed(); } } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 9be569e895..28c8980668 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -668,7 +668,8 @@ public class QuickstepLauncher extends Launcher { public void setResumed() { if (DesktopTaskView.DESKTOP_IS_PROTO2_ENABLED) { DesktopVisibilityController controller = mDesktopVisibilityController; - if (controller != null && controller.areFreeformTasksVisible()) { + if (controller != null && controller.areFreeformTasksVisible() + && !controller.isGestureInProgress()) { // Return early to skip setting activity to appear as resumed // TODO(b/255649902): shouldn't be needed when we have a separate launcher state // for desktop that we can use to control other parts of launcher diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java index 6c27587058..cf033a6287 100644 --- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java @@ -36,12 +36,15 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.popup.QuickstepSystemShortcut; import com.android.launcher3.statehandlers.DepthController; +import com.android.launcher3.statehandlers.DesktopVisibilityController; import com.android.launcher3.statemanager.StateManager.StateListener; import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.PendingSplitSelectInfo; import com.android.launcher3.util.SplitConfigurationOptions; import com.android.quickstep.LauncherActivityInterface; +import com.android.quickstep.RotationTouchHelper; import com.android.quickstep.util.SplitSelectStateController; +import com.android.systemui.shared.recents.model.Task; /** * {@link RecentsView} used in Launcher activity @@ -205,4 +208,25 @@ public class LauncherRecentsView extends RecentsView