From 80846543b58d54dcd357e2139417b2ffa6fdba01 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Mon, 15 Jun 2020 19:00:50 -0500 Subject: [PATCH] Fix qsb when flinging to home during gesture to overview from home - AllAppsTransitionController should not animate alphas for atomic components even when failing fast (we already had this check for the normal flow where mProgress != targetProgress). - Don't set state to NORMAL until both the workspace stagger anim and overview peek anim are finished Test: swipe up and hold from the nav bar on the home screen, then, without lifting finger, fling upwards to return home; ensure qsb springs in staggered formation with rest of workspace, and alpha matches accordingly Bug: 154637581 Change-Id: Iafeaeac50ee8bce05492628d443c3ca4ab3d26df --- ...ButtonNavbarToOverviewTouchController.java | 26 ++++++++++++++++--- .../util/StaggeredWorkspaceAnim.java | 5 ++++ .../allapps/AllAppsTransitionController.java | 4 ++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java index 966e25bff5..4cc8256360 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java @@ -24,6 +24,7 @@ import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL; import static com.android.launcher3.states.StateAnimationConfig.PLAY_ATOMIC_OVERVIEW_PEEK; import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC; +import android.animation.Animator; import android.animation.AnimatorSet; import android.animation.ValueAnimator; import android.graphics.PointF; @@ -59,6 +60,8 @@ public class NoButtonNavbarToOverviewTouchController extends FlingAndHoldTouchCo private boolean mDidTouchStartInNavBar; private boolean mReachedOverview; + private boolean mIsOverviewRehidden; + private boolean mIsHomeStaggeredAnimFinished; // The last recorded displacement before we reached overview. private PointF mStartDisplacement = new PointF(); @@ -144,6 +147,13 @@ public class NoButtonNavbarToOverviewTouchController extends FlingAndHoldTouchCo } } + // Used if flinging back to home after reaching overview + private void maybeSwipeInteractionToHomeComplete() { + if (mIsHomeStaggeredAnimFinished && mIsOverviewRehidden) { + onSwipeInteractionCompleted(NORMAL, Touch.FLING); + } + } + @Override protected boolean handlingOverviewAnim() { return mDidTouchStartInNavBar && super.handlingOverviewAnim(); @@ -180,9 +190,17 @@ public class NoButtonNavbarToOverviewTouchController extends FlingAndHoldTouchCo stateManager.goToState(NORMAL, true, () -> onSwipeInteractionCompleted(NORMAL, Touch.FLING)); } else { + mIsHomeStaggeredAnimFinished = mIsOverviewRehidden = false; + StaggeredWorkspaceAnim staggeredWorkspaceAnim = new StaggeredWorkspaceAnim( mLauncher, velocity, false /* animateOverviewScrim */); - staggeredWorkspaceAnim.start(); + staggeredWorkspaceAnim.addAnimatorListener(new AnimationSuccessListener() { + @Override + public void onAnimationSuccess(Animator animator) { + mIsHomeStaggeredAnimFinished = true; + maybeSwipeInteractionToHomeComplete(); + } + }).start(); // StaggeredWorkspaceAnim doesn't animate overview, so we handle it here. stateManager.cancelAnimation(); @@ -191,8 +209,10 @@ public class NoButtonNavbarToOverviewTouchController extends FlingAndHoldTouchCo config.animFlags = PLAY_ATOMIC_OVERVIEW_PEEK; AnimatorSet anim = stateManager.createAtomicAnimation( stateManager.getState(), NORMAL, config); - anim.addListener(AnimationSuccessListener.forRunnable( - () -> onSwipeInteractionCompleted(NORMAL, Touch.SWIPE))); + anim.addListener(AnimationSuccessListener.forRunnable(() -> { + mIsOverviewRehidden = true; + maybeSwipeInteractionToHomeComplete(); + })); anim.start(); } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java index 8daa98254a..3cafd423ca 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java @@ -175,6 +175,11 @@ public class StaggeredWorkspaceAnim { return mAnimators; } + public StaggeredWorkspaceAnim addAnimatorListener(Animator.AnimatorListener listener) { + mAnimators.addListener(listener); + return this; + } + /** * Starts the animation. */ diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 1dd81e8305..a9b030e056 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -159,7 +159,9 @@ public class AllAppsTransitionController implements StateHandler, StateAnimationConfig config, PendingAnimation builder) { float targetProgress = toState.getVerticalProgress(mLauncher); if (Float.compare(mProgress, targetProgress) == 0) { - setAlphas(toState, config, builder); + if (!config.onlyPlayAtomicComponent()) { + setAlphas(toState, config, builder); + } // Fail fast onProgressAnimationEnd(); return;