From 6a6301c569b58d49d731f3bd4e6f30595084ad4e Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 22 Apr 2020 18:42:40 -0500 Subject: [PATCH] Always return RecentsView to translation 0 on drag end After reaching overview, we let the user translate RecentsView if they continue dragging around. But when they let go, we need to return RecentsView to translation 0 since that's no longer part of the state machine. Change-Id: I30b51485339a3b6c3dd52bda113b1a05b6e885fa --- ...ButtonNavbarToOverviewTouchController.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 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 71aa2e8d99..381ecf1c4b 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 @@ -166,8 +166,8 @@ public class NoButtonNavbarToOverviewTouchController extends FlingAndHoldTouchCo float velocityDp = dpiFromPx(velocity); boolean isFling = Math.abs(velocityDp) > 1; LauncherStateManager stateManager = mLauncher.getStateManager(); - if (isFling) { - // When flinging, go back to home instead of overview. + boolean goToHomeInsteadOfOverview = isFling; + if (goToHomeInsteadOfOverview) { if (velocity > 0) { stateManager.goToState(NORMAL, true, () -> onSwipeInteractionCompleted(NORMAL, Touch.FLING)); @@ -187,20 +187,21 @@ public class NoButtonNavbarToOverviewTouchController extends FlingAndHoldTouchCo () -> onSwipeInteractionCompleted(NORMAL, Touch.SWIPE))); anim.start(); } - } else { - if (mReachedOverview) { - float distanceDp = dpiFromPx(Math.max( - Math.abs(mRecentsView.getTranslationX()), - Math.abs(mRecentsView.getTranslationY()))); - long duration = (long) Math.max(TRANSLATION_ANIM_MIN_DURATION_MS, - distanceDp / TRANSLATION_ANIM_VELOCITY_DP_PER_MS); - mRecentsView.animate() - .translationX(0) - .translationY(0) - .setInterpolator(ACCEL_DEACCEL) - .setDuration(duration) - .withEndAction(this::maybeSwipeInteractionToOverviewComplete); - } + } + if (mReachedOverview) { + float distanceDp = dpiFromPx(Math.max( + Math.abs(mRecentsView.getTranslationX()), + Math.abs(mRecentsView.getTranslationY()))); + long duration = (long) Math.max(TRANSLATION_ANIM_MIN_DURATION_MS, + distanceDp / TRANSLATION_ANIM_VELOCITY_DP_PER_MS); + mRecentsView.animate() + .translationX(0) + .translationY(0) + .setInterpolator(ACCEL_DEACCEL) + .setDuration(duration) + .withEndAction(goToHomeInsteadOfOverview + ? null + : this::maybeSwipeInteractionToOverviewComplete); } }