From 6cfb0edb41f155acf49667ce954a017616d07526 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 16 Nov 2018 16:42:07 -0600 Subject: [PATCH] Fix end state when animating launcher after swipe up from an app Previously we were comparing the controller's progress at the time of the end of the animation... which is always 1. Instead, we should be comparing the effective final progress based on the interpolator. Change-Id: I18110b5a3b914839860931187f39cfa11182b3e2 --- .../uioverrides/TaskViewTouchController.java | 2 +- .../com/android/quickstep/ActivityControlHelper.java | 12 ++++++++---- .../quickstep/WindowTransformSwipeHandler.java | 1 + .../launcher3/anim/AnimatorPlaybackController.java | 4 ++++ .../touch/AbstractStateChangeTouchController.java | 3 +-- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java index 54269f09fa..753f73a167 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java @@ -243,7 +243,7 @@ public abstract class TaskViewTouchController fling = false; } float progress = mCurrentAnimation.getProgressFraction(); - float interpolatedProgress = mCurrentAnimation.getInterpolator().getInterpolation(progress); + float interpolatedProgress = mCurrentAnimation.getInterpolatedProgress(); if (fling) { logAction = Touch.FLING; boolean goingUp = velocity < 0; diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java index 02af0d65cf..b96f9f0672 100644 --- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java +++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java @@ -29,6 +29,7 @@ import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB; import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_BACK; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_ROTATION; + import android.animation.Animator; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; @@ -43,8 +44,7 @@ import android.os.Build; import android.os.Handler; import android.os.Looper; import android.view.View; -import androidx.annotation.Nullable; -import androidx.annotation.UiThread; + import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; @@ -77,6 +77,9 @@ import java.util.Objects; import java.util.function.BiPredicate; import java.util.function.Consumer; +import androidx.annotation.Nullable; +import androidx.annotation.UiThread; + /** * Utility class which abstracts out the logical differences between Launcher and RecentsActivity. */ @@ -305,9 +308,10 @@ public interface ActivityControlHelper { AnimatorPlaybackController.wrap(anim, transitionLength * 2); // Since we are changing the start position of the UI, reapply the state, at the end - controller.setEndAction(() -> + controller.setEndAction(() -> { activity.getStateManager().goToState( - controller.getProgressFraction() > 0.5 ? endState : fromState, false)); + controller.getInterpolatedProgress() > 0.5 ? endState : fromState, false); + }); callback.accept(controller); } diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index b0d7ff37ed..fe3300d36f 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -825,6 +825,7 @@ public class WindowTransformSwipeHandler { return; } if (start == end || duration <= 0) { + mLauncherTransitionController.dispatchSetInterpolator(t -> end); mLauncherTransitionController.getAnimationPlayer().end(); } else { // Adjust start progress and duration in case we are on a different thread. diff --git a/src/com/android/launcher3/anim/AnimatorPlaybackController.java b/src/com/android/launcher3/anim/AnimatorPlaybackController.java index 164728ae67..819c8439b4 100644 --- a/src/com/android/launcher3/anim/AnimatorPlaybackController.java +++ b/src/com/android/launcher3/anim/AnimatorPlaybackController.java @@ -154,6 +154,10 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat return mCurrentFraction; } + public float getInterpolatedProgress() { + return getInterpolator().getInterpolation(mCurrentFraction); + } + /** * Sets the action to be called when the animation is completed. Also clears any * previously set action. diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index ce1cc89dd1..a7bd243a6f 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -372,8 +372,7 @@ public abstract class AbstractStateChangeTouchController final LauncherState targetState; final float progress = mCurrentAnimation.getProgressFraction(); - final float interpolatedProgress = mCurrentAnimation.getInterpolator() - .getInterpolation(progress); + final float interpolatedProgress = mCurrentAnimation.getInterpolatedProgress(); if (fling) { targetState = Float.compare(Math.signum(velocity), Math.signum(mProgressMultiplier)) == 0