From b8b3e957a6049ba0cd3ed48623a1666bae80b25e Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 5 Aug 2020 18:43:53 -0700 Subject: [PATCH] Fix TaskViewTouchController success progress to match haptic We use the interpolated progress of the animation contoller target to determine success, but only the child animation had the interpolator set. Updating the parent to use the same interpolator ensures getInterpolatedProgress() returns the same one used to play the haptic. Fixes: 161536946 Change-Id: Ibc2aef67f53efa01f2b185cf03140bad4bb5c421 --- .../touchcontrollers/TaskViewTouchController.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java index 0ee5d047c6..7bae2e5d86 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java @@ -25,6 +25,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.view.MotionEvent; import android.view.View; +import android.view.animation.Interpolator; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseDraggingActivity; @@ -206,14 +207,19 @@ public abstract class TaskViewTouchController long maxDuration = 2 * secondaryLayerDimension; int verticalFactor = orientationHandler.getTaskDragDisplacementFactor(mIsRtl); int secondaryTaskDimension = orientationHandler.getSecondaryDimension(mTaskBeingDragged); + // The interpolator controlling the most prominent visual movement. We use this to determine + // whether we passed SUCCESS_TRANSITION_PROGRESS. + final Interpolator currentInterpolator; if (goingUp) { + currentInterpolator = Interpolators.LINEAR; mPendingAnimation = mRecentsView.createTaskDismissAnimation(mTaskBeingDragged, true /* animateTaskView */, true /* removeTask */, maxDuration); mEndDisplacement = -secondaryTaskDimension; } else { + currentInterpolator = Interpolators.ZOOM_IN; mPendingAnimation = mRecentsView.createTaskLaunchAnimation( - mTaskBeingDragged, maxDuration, Interpolators.ZOOM_IN); + mTaskBeingDragged, maxDuration, currentInterpolator); // Since the thumbnail is what is filling the screen, based the end displacement on it. View thumbnailView = mTaskBeingDragged.getThumbnail(); @@ -228,6 +234,9 @@ public abstract class TaskViewTouchController } mCurrentAnimation = mPendingAnimation.createPlaybackController() .setOnCancelRunnable(this::clearState); + // Setting this interpolator doesn't affect the visual motion, but is used to determine + // whether we successfully reached the target state in onDragEnd(). + mCurrentAnimation.getTarget().setInterpolator(currentInterpolator); onUserControlledAnimationCreated(mCurrentAnimation); mCurrentAnimation.getTarget().addListener(this); mCurrentAnimation.dispatchOnStart();