From aec9d3136fe3f9664b72cbb342f114c64c53022b Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Mon, 16 Jan 2023 15:51:13 +0000 Subject: [PATCH] Remove focus task - Focus task is only removed under ENABLE_GRID_ONLY_OVERVIEW, but many fixes/refactoring are generic and apply with the flag off - Keep moving running task to front if go to overvied after quick switch, so live tile is always on top right Grid calculation: - Fixed some top/bottom calculation assumption that assume focus task is always present Size calculation: - With ENABLE_GRID_ONLY_OVERVIEW, taskSize == gridTaskSize, and task is aligned to top-right of gridRect (instead of focusTaskRect) Bug: 257952455 Test: Enter overview from home Test: Enter overview from app, with variations that quick switch and enter Test: Dismiss task from different position Test: Split select task from different position Test: Repeat with/without GRID_ONLY_OVERVIEW flag Test: Repeat with handheld Change-Id: I6580a8ac6c2c2059c33c4daca05b7d0354513e74 --- .../android/quickstep/AbsSwipeUpHandler.java | 14 ++--- .../quickstep/BaseActivityInterface.java | 55 ++++++++++++------- .../quickstep/FallbackActivityInterface.java | 2 +- .../quickstep/LauncherActivityInterface.java | 3 +- .../quickstep/OverviewCommandHelper.java | 2 +- .../QuickstepTestInformationHandler.java | 2 +- .../AnimatorControllerWithResistance.java | 3 +- .../android/quickstep/util/LayoutUtils.java | 3 +- .../quickstep/util/TaskViewSimulator.java | 3 +- .../android/quickstep/views/RecentsView.java | 53 ++++++++++-------- 10 files changed, 82 insertions(+), 58 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 1122e00090..e264a7f6b1 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -678,7 +678,7 @@ public abstract class AbsSwipeUpHandler, @Override public void onMotionPauseDetected() { mHasMotionEverBeenPaused = true; - maybeUpdateRecentsAttachedState(true/* animate */, true/* moveFocusedTask */); + maybeUpdateRecentsAttachedState(true/* animate */, true/* moveRunningTask */); Optional.ofNullable(mActivityInterface.getTaskbarController()) .ifPresent(TaskbarUIController::startTranslationSpring); performHapticFeedback(); @@ -696,7 +696,7 @@ public abstract class AbsSwipeUpHandler, } private void maybeUpdateRecentsAttachedState(boolean animate) { - maybeUpdateRecentsAttachedState(animate, false /* moveFocusedTask */); + maybeUpdateRecentsAttachedState(animate, false /* moveRunningTask */); } /** @@ -706,9 +706,9 @@ public abstract class AbsSwipeUpHandler, * * Note this method has no effect unless the navigation mode is NO_BUTTON. * @param animate whether to animate when attaching RecentsView - * @param moveFocusedTask whether to move focused task to front when attaching + * @param moveRunningTask whether to move running task to front when attaching */ - private void maybeUpdateRecentsAttachedState(boolean animate, boolean moveFocusedTask) { + private void maybeUpdateRecentsAttachedState(boolean animate, boolean moveRunningTask) { if (!mDeviceState.isFullyGesturalNavMode() || mRecentsView == null) { return; } @@ -727,11 +727,11 @@ public abstract class AbsSwipeUpHandler, } else { recentsAttachedToAppWindow = mHasMotionEverBeenPaused || mIsLikelyToStartNewTask; } - if (moveFocusedTask && !mAnimationFactory.hasRecentsEverAttachedToAppWindow() + if (moveRunningTask && !mAnimationFactory.hasRecentsEverAttachedToAppWindow() && recentsAttachedToAppWindow) { - // Only move focused task if RecentsView has never been attached before, to avoid + // Only move running task if RecentsView has never been attached before, to avoid // TaskView jumping to new position as we move the tasks. - mRecentsView.moveFocusedTaskToFront(); + mRecentsView.moveRunningTaskToFront(); } mAnimationFactory.setRecentsAttachedToAppWindow(recentsAttachedToAppWindow, animate); diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java index 998439e891..d7ff8ab3fc 100644 --- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -231,17 +231,20 @@ public abstract class BaseActivityInterface visibleRecentsView = activityInterface.getVisibleRecentsView(); if (visibleRecentsView != null) { - visibleRecentsView.moveFocusedTaskToFront(); + visibleRecentsView.moveRunningTaskToFront(); } if (mTaskAnimationManager.isRecentsAnimationRunning()) { cmd.mActiveCallbacks = mTaskAnimationManager.continueRecentsAnimation(gestureState); diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index 54e4a0d3f1..5391f4d46c 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -59,7 +59,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { } Rect focusedTaskRect = new Rect(); LauncherActivityInterface.INSTANCE.calculateTaskSize(mContext, mDeviceProfile, - focusedTaskRect); + focusedTaskRect, PagedOrientationHandler.PORTRAIT); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, focusedTaskRect.height()); return response; } diff --git a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java index 7c838332a6..baca76cfba 100644 --- a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java +++ b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java @@ -158,7 +158,8 @@ public class AnimatorControllerWithResistance { Rect startRect = new Rect(); PagedOrientationHandler orientationHandler = params.recentsOrientedState .getOrientationHandler(); - LauncherActivityInterface.INSTANCE.calculateTaskSize(params.context, params.dp, startRect); + LauncherActivityInterface.INSTANCE.calculateTaskSize(params.context, params.dp, startRect, + orientationHandler); long distanceToCover = startRect.bottom; PendingAnimation resistAnim = params.resistAnim != null ? params.resistAnim diff --git a/quickstep/src/com/android/quickstep/util/LayoutUtils.java b/quickstep/src/com/android/quickstep/util/LayoutUtils.java index f7136a5b68..79656c27a4 100644 --- a/quickstep/src/com/android/quickstep/util/LayoutUtils.java +++ b/quickstep/src/com/android/quickstep/util/LayoutUtils.java @@ -43,7 +43,8 @@ public class LayoutUtils { PagedOrientationHandler orientationHandler) { // Track the bottom of the window. Rect taskSize = new Rect(); - LauncherActivityInterface.INSTANCE.calculateTaskSize(context, dp, taskSize); + LauncherActivityInterface.INSTANCE.calculateTaskSize(context, dp, taskSize, + orientationHandler); return orientationHandler.getDistanceToBottomOfRect(dp, taskSize); } diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index 69f9ce3447..0b83eafa23 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -157,7 +157,8 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { mSizeStrategy.calculateGridTaskSize(mContext, mDp, mTaskRect, mOrientationState.getOrientationHandler()); } else { - mSizeStrategy.calculateTaskSize(mContext, mDp, mTaskRect); + mSizeStrategy.calculateTaskSize(mContext, mDp, mTaskRect, + mOrientationState.getOrientationHandler()); } Rect fullTaskSize; diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 6ec0a4d10d..a02e29c79e 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1479,20 +1479,20 @@ public abstract class RecentsView setCurrentPage(getRunningTaskIndex())); setRunningTaskViewShowScreenshot(false); setRunningTaskHidden(runningTaskTileHidden); @@ -3262,7 +3264,8 @@ public abstract class RecentsView bottomGridRowSize; boolean bottomRowLonger = bottomGridRowSize > topGridRowSize; boolean dismissedTaskFromTop = mTopRowIdSet.contains(dismissedTaskViewId); @@ -3274,8 +3277,10 @@ public abstract class RecentsView