diff options
author | Android Build Merger (Role) <noreply-android-build-merger@google.com> | 2018-06-27 19:25:50 +0000 |
---|---|---|
committer | Android Build Merger (Role) <noreply-android-build-merger@google.com> | 2018-06-27 19:25:50 +0000 |
commit | 002560dee7b162aba5997f56db6f93271efd39c8 (patch) | |
tree | d77faba081036b93ce6de1860c1c6ec495b3903e /quickstep | |
parent | a43a22dad7fd11cd98a84ec1fe29dcb6809bc5e4 (diff) | |
parent | cc3755da6e9c7b389fbf44dc6cf0a7faeb8012a7 (diff) | |
download | android_packages_apps_Trebuchet-002560dee7b162aba5997f56db6f93271efd39c8.tar.gz android_packages_apps_Trebuchet-002560dee7b162aba5997f56db6f93271efd39c8.tar.bz2 android_packages_apps_Trebuchet-002560dee7b162aba5997f56db6f93271efd39c8.zip |
[automerger] Swipe up overshoot always plays am: cc3755da6e
Change-Id: I663d742f3349d52e74d84a6d4f5376588abf201c
Diffstat (limited to 'quickstep')
-rw-r--r-- | quickstep/src/com/android/quickstep/LongSwipeHelper.java | 26 | ||||
-rw-r--r-- | quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java | 63 |
2 files changed, 59 insertions, 30 deletions
diff --git a/quickstep/src/com/android/quickstep/LongSwipeHelper.java b/quickstep/src/com/android/quickstep/LongSwipeHelper.java index 078509330..491cbb3d2 100644 --- a/quickstep/src/com/android/quickstep/LongSwipeHelper.java +++ b/quickstep/src/com/android/quickstep/LongSwipeHelper.java @@ -20,17 +20,22 @@ import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.anim.Interpolators.DEACCEL; import static com.android.quickstep.WindowTransformSwipeHandler.MAX_SWIPE_DURATION; +import static com.android.quickstep.WindowTransformSwipeHandler.MIN_OVERSHOOT_DURATION; import android.animation.ValueAnimator; +import android.view.animation.Interpolator; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.LauncherStateManager; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.AnimatorSetBuilder; +import com.android.launcher3.anim.Interpolators; +import com.android.launcher3.anim.Interpolators.OvershootParams; import com.android.launcher3.uioverrides.PortraitStatesTouchController; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; @@ -89,7 +94,9 @@ public class LongSwipeHelper { } public void end(float velocity, boolean isFling, Runnable callback) { + float velocityPxPerMs = velocity / 1000; long duration = MAX_SWIPE_DURATION; + Interpolator interpolator = DEACCEL; final float currentFraction = mAnimator.getProgressFraction(); final boolean toAllApps; @@ -107,6 +114,17 @@ public class LongSwipeHelper { long expectedDuration = Math.abs(Math.round((endProgress - currentFraction) * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER)); duration = Math.min(MAX_SWIPE_DURATION, expectedDuration); + + if (blockedFling && !toAllApps) { + Interpolators.OvershootParams overshoot = new OvershootParams(currentFraction, + currentFraction, endProgress, velocityPxPerMs, (int) mMaxSwipeDistance); + duration = (overshoot.duration + duration) + * LauncherAnimUtils.blockedFlingDurationFactor(0); + duration = Utilities.boundToRange(duration, MIN_OVERSHOOT_DURATION, + MAX_SWIPE_DURATION); + interpolator = overshoot.interpolator; + endProgress = overshoot.end; + } } else { toAllApps = velocity < 0; endProgress = toAllApps ? 1 : 0; @@ -119,18 +137,16 @@ public class LongSwipeHelper { // 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. 2. - long baseDuration = Math.round(1000 * Math.abs(distanceToTravel / velocity)); + long baseDuration = Math.round(Math.abs(distanceToTravel / velocityPxPerMs)); duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration); } } - if (blockedFling && !toAllApps) { - duration *= LauncherAnimUtils.blockedFlingDurationFactor(0); - } final boolean finalIsFling = isFling; mAnimator.setEndAction(() -> onSwipeAnimationComplete(toAllApps, finalIsFling, callback)); + ValueAnimator animator = mAnimator.getAnimationPlayer(); - animator.setDuration(duration).setInterpolator(DEACCEL); + animator.setDuration(duration).setInterpolator(interpolator); animator.setFloatValues(currentFraction, endProgress); animator.start(); } diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index ff3137d44..15ff19e26 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -21,6 +21,7 @@ import static com.android.launcher3.Utilities.SINGLE_FRAME_MS; import static com.android.launcher3.Utilities.postAsyncCallback; import static com.android.launcher3.anim.Interpolators.DEACCEL; import static com.android.launcher3.anim.Interpolators.LINEAR; +import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2; import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_FROM_APP_START_DURATION; import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL; import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB; @@ -163,6 +164,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> { public static final long MAX_SWIPE_DURATION = 350; public static final long MIN_SWIPE_DURATION = 80; + public static final long MIN_OVERSHOOT_DURATION = 120; public static final float MIN_PROGRESS_FOR_OVERVIEW = 0.5f; private static final float SWIPE_DURATION_MULTIPLIER = @@ -498,7 +500,8 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> { setStateOnUiThread(STATE_QUICK_SCRUB_START | STATE_GESTURE_COMPLETED); // Start the window animation without waiting for launcher. - animateToProgress(mCurrentShift.value, 1f, QUICK_SCRUB_FROM_APP_START_DURATION, LINEAR); + animateToProgress(mCurrentShift.value, 1f, QUICK_SCRUB_FROM_APP_START_DURATION, LINEAR, + true /* goingToHome */); } private void shiftAnimationDestinationForQuickscrub() { @@ -699,36 +702,46 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> { private void handleNormalGestureEnd(float endVelocity, boolean isFling) { float velocityPxPerMs = endVelocity / 1000; long duration = MAX_SWIPE_DURATION; - final float endShift; + float currentShift = mCurrentShift.value; + final boolean goingToHome; + float endShift; final float startShift; - final Interpolator interpolator; + Interpolator interpolator = DEACCEL; if (!isFling) { - endShift = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW && mGestureStarted ? 1 : 0; - long expectedDuration = Math.abs(Math.round((endShift - mCurrentShift.value) + goingToHome = currentShift >= MIN_PROGRESS_FOR_OVERVIEW && mGestureStarted; + endShift = goingToHome ? 1 : 0; + long expectedDuration = Math.abs(Math.round((endShift - currentShift) * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER)); duration = Math.min(MAX_SWIPE_DURATION, expectedDuration); - startShift = mCurrentShift.value; - interpolator = DEACCEL; + startShift = currentShift; + interpolator = goingToHome ? OVERSHOOT_1_2 : DEACCEL; } else { - endShift = endVelocity < 0 ? 1 : 0; - interpolator = endVelocity < 0 - ? Interpolators.overshootInterpolatorForVelocity(velocityPxPerMs, 2f) - : DEACCEL; + goingToHome = endVelocity < 0; + endShift = goingToHome ? 1 : 0; + startShift = Utilities.boundToRange(currentShift - velocityPxPerMs + * SINGLE_FRAME_MS / mTransitionDragLength, 0, 1); float minFlingVelocity = mContext.getResources() .getDimension(R.dimen.quickstep_fling_min_velocity); if (Math.abs(endVelocity) > minFlingVelocity && mTransitionDragLength > 0) { - float distanceToTravel = (endShift - mCurrentShift.value) * mTransitionDragLength; - - // 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. 2. - long baseDuration = Math.round(Math.abs(distanceToTravel / velocityPxPerMs)); - duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration); + if (goingToHome) { + Interpolators.OvershootParams overshoot = new Interpolators.OvershootParams( + startShift, endShift, endShift, velocityPxPerMs, mTransitionDragLength); + endShift = overshoot.end; + interpolator = overshoot.interpolator; + duration = Utilities.boundToRange(overshoot.duration, MIN_OVERSHOOT_DURATION, + MAX_SWIPE_DURATION); + } else { + float distanceToTravel = (endShift - currentShift) * mTransitionDragLength; + + // 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. 2. + long baseDuration = Math.round(Math.abs(distanceToTravel / velocityPxPerMs)); + duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration); + } } - startShift = Utilities.boundToRange(mCurrentShift.value - velocityPxPerMs - * SINGLE_FRAME_MS / (mTransitionDragLength), 0, 1); } - animateToProgress(startShift, endShift, duration, interpolator); + animateToProgress(startShift, endShift, duration, interpolator, goingToHome); } private void doLogGesture(boolean toLauncher) { @@ -754,14 +767,14 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> { /** Animates to the given progress, where 0 is the current app and 1 is overview. */ private void animateToProgress(float start, float end, long duration, - Interpolator interpolator) { + Interpolator interpolator, boolean goingToHome) { mRecentsAnimationWrapper.runOnInit(() -> animateToProgressInternal(start, end, duration, - interpolator)); + interpolator, goingToHome)); } private void animateToProgressInternal(float start, float end, long duration, - Interpolator interpolator) { - mIsGoingToHome = Float.compare(end, 1) == 0; + Interpolator interpolator, boolean goingToHome) { + mIsGoingToHome = goingToHome; ObjectAnimator anim = mCurrentShift.animateToValue(start, end).setDuration(duration); anim.setInterpolator(interpolator); anim.addListener(new AnimationSuccessListener() { |