diff options
author | Tony <twickham@google.com> | 2018-11-16 16:42:07 -0600 |
---|---|---|
committer | Tony <twickham@google.com> | 2018-11-29 11:35:16 -0800 |
commit | 6cfb0edb41f155acf49667ce954a017616d07526 (patch) | |
tree | 3847108420afd8b2345d637c9cf475f438ea5a0f | |
parent | 6478d4f41bb5055116b97b55ba7ce08bd18fcd97 (diff) | |
download | android_packages_apps_Trebuchet-6cfb0edb41f155acf49667ce954a017616d07526.tar.gz android_packages_apps_Trebuchet-6cfb0edb41f155acf49667ce954a017616d07526.tar.bz2 android_packages_apps_Trebuchet-6cfb0edb41f155acf49667ce954a017616d07526.zip |
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
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 54269f09f..753f73a16 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<T extends BaseDraggingActivity> 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 02af0d65c..b96f9f067 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<T extends BaseDraggingActivity> { 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 b0d7ff37e..fe3300d36 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -825,6 +825,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> { 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 164728ae6..819c8439b 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 ce1cc89dd..a7bd243a6 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 |