From 86ac825061d48d169998485f419208e851ee402c Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Tue, 15 Jun 2021 15:09:11 +0100 Subject: [PATCH] Move focused task to front when attaching RecentsView - Only move focused task it's the first time attaching RecentsView - Simpily remove and re-add focused task to move it to front Bug: 192471181 Test: manual Change-Id: I95b29c39328911beec7fd3d254f7a22be5e10cc1 --- .../android/quickstep/AbsSwipeUpHandler.java | 18 ++++++++++-- .../quickstep/BaseActivityInterface.java | 13 +++++++++ .../android/quickstep/views/RecentsView.java | 29 +++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 9180bd026f..bda2b77bb3 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -539,7 +539,7 @@ public abstract class AbsSwipeUpHandler, @Override public void onMotionPauseDetected() { mHasMotionEverBeenPaused = true; - maybeUpdateRecentsAttachedState(); + maybeUpdateRecentsAttachedState(true/* animate */, true/* moveFocusedTask */); performHapticFeedback(); } @@ -550,18 +550,24 @@ public abstract class AbsSwipeUpHandler, }; } - public void maybeUpdateRecentsAttachedState() { + private void maybeUpdateRecentsAttachedState() { maybeUpdateRecentsAttachedState(true /* animate */); } + private void maybeUpdateRecentsAttachedState(boolean animate) { + maybeUpdateRecentsAttachedState(animate, false /* moveFocusedTask */); + } + /** * Determines whether to show or hide RecentsView. The window is always * synchronized with its corresponding TaskView in RecentsView, so if * RecentsView is shown, it will appear to be attached to the window. * * 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 */ - private void maybeUpdateRecentsAttachedState(boolean animate) { + private void maybeUpdateRecentsAttachedState(boolean animate, boolean moveFocusedTask) { if (!mDeviceState.isFullyGesturalNavMode() || mRecentsView == null) { return; } @@ -580,6 +586,12 @@ public abstract class AbsSwipeUpHandler, } else { recentsAttachedToAppWindow = mHasMotionEverBeenPaused || mIsLikelyToStartNewTask; } + if (moveFocusedTask && !mAnimationFactory.hasRecentsEverAttachedToAppWindow() + && recentsAttachedToAppWindow) { + // Only move focused task if RecentsView has never been attached before, to avoid + // TaskView jumping to new position as we move the tasks. + mRecentsView.moveFocusedTaskToFront(); + } mAnimationFactory.setRecentsAttachedToAppWindow(recentsAttachedToAppWindow, animate); // Reapply window transform throughout the attach animation, as the animation affects how diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java index 1412b1add6..389509f978 100644 --- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -396,6 +396,10 @@ public abstract class BaseActivityInterface mCallback; private boolean mIsAttachedToWindow; + private boolean mHasEverAttachedToWindow; DefaultAnimationFactory(Consumer callback) { mCallback = callback; @@ -458,6 +463,9 @@ public abstract class BaseActivityInterface tasks) { if (mPendingAnimation != null) { mPendingAnimation.addEndListener(success -> applyLoadPlan(tasks));