Tuning app open/close animation.

* Mostly value changes.
* Added a way to round the corners during swipe up to home animation.

Bug: 123900446
Change-Id: Id61d241d919ba51ced0633585e36b7d93efe30b0
diff --git a/quickstep/recents_ui_overrides/res/values/dimens.xml b/quickstep/recents_ui_overrides/res/values/dimens.xml
index c80e531..863a8ba 100644
--- a/quickstep/recents_ui_overrides/res/values/dimens.xml
+++ b/quickstep/recents_ui_overrides/res/values/dimens.xml
@@ -27,5 +27,5 @@
     <!-- Swipe up to home related -->
     <dimen name="swipe_up_fling_min_visible_change">18dp</dimen>
     <dimen name="swipe_up_y_overshoot">10dp</dimen>
-    <dimen name="swipe_up_max_workspace_trans_y">-80dp</dimen>
+    <dimen name="swipe_up_max_workspace_trans_y">-60dp</dimen>
 </resources>
\ No newline at end of file
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 0d0478a..9f446c8 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -19,6 +19,7 @@
 import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS;
 import static com.android.launcher3.Utilities.SINGLE_FRAME_MS;
 import static com.android.launcher3.Utilities.postAsyncCallback;
+import static com.android.launcher3.anim.Interpolators.ACCEL_1_5;
 import static com.android.launcher3.anim.Interpolators.DEACCEL;
 import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
 import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -1131,16 +1132,25 @@
 
         AnimatorPlaybackController homeAnim = homeAnimationFactory.createActivityAnimationToHome();
 
+        // End on a "round-enough" radius so that the shape reveal doesn't have to do too much
+        // rounding at the end of the animation.
+        float startRadius = mClipAnimationHelper.getCurrentCornerRadius();
+        float endRadius = startRect.width() / 6f;
         // We want the window alpha to be 0 once this threshold is met, so that the
         // FolderIconView can be seen morphing into the icon shape.
         final float windowAlphaThreshold = isFloatingIconView ? 1f - SHAPE_PROGRESS_DURATION : 1f;
         anim.addOnUpdateListener((currentRect, progress) -> {
             homeAnim.setPlayFraction(progress);
 
-            float windowAlpha = Math.max(0, Utilities.mapToRange(progress, 0,
-                    windowAlphaThreshold, 1f, 0f, Interpolators.LINEAR));
+            float alphaProgress = ACCEL_1_5.getInterpolation(progress);
+            float windowAlpha = Utilities.boundToRange(Utilities.mapToRange(alphaProgress, 0,
+                    windowAlphaThreshold, 1.5f, 0f, Interpolators.LINEAR), 0, 1);
             mTransformParams.setProgress(progress)
                     .setCurrentRectAndTargetAlpha(currentRect, windowAlpha);
+            if (isFloatingIconView) {
+                mTransformParams.setCornerRadius(endRadius * progress + startRadius
+                        * (1f - progress));
+            }
             mClipAnimationHelper.applyTransform(targetSet, mTransformParams,
                     false /* launcherOnTop */);
 
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/ClipAnimationHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/ClipAnimationHelper.java
index e2fb602..aca23e4 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/ClipAnimationHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/ClipAnimationHelper.java
@@ -197,10 +197,15 @@
                     mTmpMatrix.postTranslate(app.position.x, app.position.y);
                     mClipRectF.roundOut(crop);
                     if (mSupportsRoundedCornersOnWindows) {
-                        float windowCornerRadius = mUseRoundedCornersOnWindows
-                                ? mWindowCornerRadius : 0;
-                        cornerRadius = Utilities.mapRange(progress, windowCornerRadius,
-                                mTaskCornerRadius);
+                        if (params.cornerRadius > -1) {
+                            cornerRadius = params.cornerRadius;
+                            scale = params.currentRect.width() / crop.width();
+                        } else {
+                            float windowCornerRadius = mUseRoundedCornersOnWindows
+                                    ? mWindowCornerRadius : 0;
+                            cornerRadius = Utilities.mapRange(progress, windowCornerRadius,
+                                    mTaskCornerRadius);
+                        }
                         mCurrentCornerRadius = cornerRadius;
                     }
                 }
@@ -355,6 +360,7 @@
         @Nullable RectF currentRect;
         float targetAlpha;
         boolean forLiveTile;
+        float cornerRadius;
 
         SyncRtSurfaceTransactionApplierCompat syncTransactionApplier;
 
@@ -365,6 +371,7 @@
             currentRect = null;
             targetAlpha = 0;
             forLiveTile = false;
+            cornerRadius = -1;
         }
 
         public TransformParams setProgress(float progress) {
@@ -373,6 +380,11 @@
             return this;
         }
 
+        public TransformParams setCornerRadius(float cornerRadius) {
+            this.cornerRadius = cornerRadius;
+            return this;
+        }
+
         public TransformParams setCurrentRectAndTargetAlpha(RectF currentRect, float targetAlpha) {
             this.currentRect = currentRect;
             this.targetAlpha = targetAlpha;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
index 93b6e4b..837c2dc 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
@@ -44,14 +44,13 @@
  */
 public class StaggeredWorkspaceAnim {
 
-    private static final int APP_CLOSE_ROW_START_DELAY_MS = 16;
-    private static final int ALPHA_DURATION_MS = 200;
+    private static final int APP_CLOSE_ROW_START_DELAY_MS = 10;
+    private static final int ALPHA_DURATION_MS = 250;
 
     private static final float MAX_VELOCITY_PX_PER_S = 22f;
 
-    private static final float DAMPING_RATIO =
-            (SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY + SpringForce.DAMPING_RATIO_LOW_BOUNCY) / 2f;
-    private static final float STIFFNESS = SpringForce.STIFFNESS_LOW;
+    private static final float DAMPING_RATIO = 0.7f;
+    private static final float STIFFNESS = 150f;
 
     private final float mVelocity;
     private final float mSpringTransY;
@@ -71,9 +70,9 @@
 
         // Scale the translationY based on the initial velocity to better sync the workspace items
         // with the floating view.
-        float transFactor = 0.1f + 0.9f * Math.abs(velocity) / MAX_VELOCITY_PX_PER_S;
+        float transFactor = 0.2f + 0.9f * Math.abs(velocity) / MAX_VELOCITY_PX_PER_S;
         mSpringTransY = transFactor * launcher.getResources()
-                .getDimensionPixelSize(R.dimen.swipe_up_max_workspace_trans_y);;
+                .getDimensionPixelSize(R.dimen.swipe_up_max_workspace_trans_y);
 
         DeviceProfile grid = launcher.getDeviceProfile();
         ShortcutAndWidgetContainer currentPage = ((CellLayout) launcher.getWorkspace()
diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
index 79540c1..dcf2e3c 100644
--- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
@@ -119,6 +119,9 @@
     private static final long APP_LAUNCH_ALPHA_DOWN_DURATION =
             (long) (APP_LAUNCH_ALPHA_DURATION * APP_LAUNCH_DOWN_DUR_SCALE_FACTOR);
 
+    private static final long CROP_DURATION = 375;
+    private static final long RADIUS_DURATION = 375;
+
     public static final int RECENTS_LAUNCH_DURATION = 336;
     private static final int LAUNCHER_RESUME_START_DELAY = 100;
     private static final int CLOSING_TRANSITION_DURATION_MS = 250;
@@ -494,10 +497,10 @@
                     EXAGGERATED_EASE);
             FloatProp mIconAlpha = new FloatProp(1f, 0f, APP_LAUNCH_ALPHA_START_DELAY,
                     alphaDuration, LINEAR);
-            FloatProp mCroppedSize = new FloatProp(startCrop, endCrop, 0, APP_LAUNCH_DURATION,
+            FloatProp mCroppedSize = new FloatProp(startCrop, endCrop, 0, CROP_DURATION,
                     EXAGGERATED_EASE);
             FloatProp mWindowRadius = new FloatProp(startCrop / 2f, windowRadius, 0,
-                    APP_LAUNCH_DURATION, EXAGGERATED_EASE);
+                    RADIUS_DURATION, EXAGGERATED_EASE);
 
             @Override
             public void onUpdate(float percent) {
diff --git a/src/com/android/launcher3/anim/FlingSpringAnim.java b/src/com/android/launcher3/anim/FlingSpringAnim.java
index f53ea51..eaf3b1c 100644
--- a/src/com/android/launcher3/anim/FlingSpringAnim.java
+++ b/src/com/android/launcher3/anim/FlingSpringAnim.java
@@ -29,7 +29,7 @@
 
     private static final float FLING_FRICTION = 1.5f;
     private static final float SPRING_STIFFNESS = 200;
-    private static final float SPRING_DAMPING = 0.85f;
+    private static final float SPRING_DAMPING = 0.8f;
 
     private final FlingAnimation mFlingAnim;
     private SpringAnimation mSpringAnim;
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index 7a6da3e..e4591b6 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -77,7 +77,7 @@
 public class FloatingIconView extends View implements
         Animator.AnimatorListener, ClipPathView, OnGlobalLayoutListener {
 
-    public static final float SHAPE_PROGRESS_DURATION = 0.15f;
+    public static final float SHAPE_PROGRESS_DURATION = 0.10f;
     private static final int FADE_DURATION_MS = 200;
     private static final Rect sTmpRect = new Rect();
     private static final RectF sTmpRectF = new RectF();
@@ -85,8 +85,8 @@
 
     // We spring the foreground drawable relative to the icon's movement in the DragLayer.
     // We then use these two factor values to scale the movement of the fg within this view.
-    private static final int FG_TRANS_X_FACTOR = 80;
-    private static final int FG_TRANS_Y_FACTOR = 100;
+    private static final int FG_TRANS_X_FACTOR = 60;
+    private static final int FG_TRANS_Y_FACTOR = 75;
 
     private static final FloatPropertyCompat<FloatingIconView> mFgTransYProperty
             = new FloatPropertyCompat<FloatingIconView>("FloatingViewFgTransY") {