From 4b03a1e5a2e07ca0ee2ba3bc9a0f1d7352375630 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 18 Apr 2018 09:56:58 -0700 Subject: [PATCH] Restricting the max duration used for the swipe-down animation > Also changing the interpolator from t^5 to t^2 so that it settles faster. Bug: 78059672 Change-Id: Iae6e6f56eb2e249c11a8e069f04ab0f26a683063 --- .../quickstep/WindowTransformSwipeHandler.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index d456367527..82e64ab845 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -18,7 +18,9 @@ package com.android.quickstep; import static com.android.launcher3.BaseActivity.INVISIBLE_BY_STATE_HANDLER; import static com.android.launcher3.Utilities.postAsyncCallback; import static com.android.launcher3.anim.Interpolators.ACCEL_2; +import static com.android.launcher3.anim.Interpolators.DEACCEL; import static com.android.launcher3.anim.Interpolators.LINEAR; +import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR; import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_START_DURATION; import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL; import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB; @@ -55,7 +57,6 @@ import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; -import com.android.launcher3.anim.Interpolators; import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; @@ -400,7 +401,7 @@ public class WindowTransformSwipeHandler { setStateOnUiThread(STATE_QUICK_SCRUB_START); // Start the window animation without waiting for launcher. - animateToProgress(1f, QUICK_SCRUB_START_DURATION); + animateToProgress(1f, QUICK_SCRUB_START_DURATION, TOUCH_RESPONSE_INTERPOLATOR); } @WorkerThread @@ -573,13 +574,14 @@ public class WindowTransformSwipeHandler { // we want the page's snap velocity to approximately match the velocity at // which the user flings, so we scale the duration by a value near to the - // derivative of the scroll interpolator at zero, ie. 5. - duration = 5 * Math.round(1000 * Math.abs(distanceToTravel / endVelocity)); + // derivative of the scroll interpolator at zero, ie. 2. + long baseDuration = Math.round(1000 * Math.abs(distanceToTravel / endVelocity)); + duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration); } mLogAction = Touch.FLING; } - animateToProgress(endShift, duration); + animateToProgress(endShift, duration, DEACCEL); } private void doLogGesture(boolean toLauncher) { @@ -599,10 +601,10 @@ public class WindowTransformSwipeHandler { } /** Animates to the given progress, where 0 is the current app and 1 is overview. */ - private void animateToProgress(float progress, long duration) { + private void animateToProgress(float progress, long duration, Interpolator interpolator) { mIsGoingToHome = Float.compare(progress, 1) == 0; ObjectAnimator anim = mCurrentShift.animateToValue(progress).setDuration(duration); - anim.setInterpolator(Interpolators.SCROLL); + anim.setInterpolator(interpolator); anim.addListener(new AnimationSuccessListener() { @Override public void onAnimationSuccess(Animator animator) {