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
diff --git a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
index 54269f09..753f73a 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
@@ -243,7 +243,7 @@
             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 02af0d6..b96f9f0 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.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.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.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 @@
                     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 b0d7ff3..fe3300d 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -825,6 +825,7 @@
                 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 164728a..819c843 100644
--- a/src/com/android/launcher3/anim/AnimatorPlaybackController.java
+++ b/src/com/android/launcher3/anim/AnimatorPlaybackController.java
@@ -154,6 +154,10 @@
         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 ce1cc89..a7bd243 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -372,8 +372,7 @@
 
         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