Add more swipe up to home/spring variables as dynamic resources.

Bug: 147302669
Change-Id: I7a13f1eac8324d963302f5f42793478896f10097
diff --git a/quickstep/recents_ui_overrides/res/values/dimens.xml b/quickstep/recents_ui_overrides/res/values/dimens.xml
index de97d08..61c576e 100644
--- a/quickstep/recents_ui_overrides/res/values/dimens.xml
+++ b/quickstep/recents_ui_overrides/res/values/dimens.xml
@@ -23,10 +23,4 @@
 
     <!-- Minimum distance to swipe to trigger accessibility gesture -->
     <dimen name="accessibility_gesture_min_swipe_distance">80dp</dimen>
-
-    <!-- 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">-60dp</dimen>
-
 </resources>
\ No newline at end of file
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
index 1d1c7bb..a17476e 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
@@ -448,7 +448,7 @@
             RotationHelper.mapInverseRectFromNormalOrientation(startRect,
                 mDp.widthPx, mDp.heightPx, mOrientedState.getDisplayRotation());
         }
-        RectFSpringAnim anim = new RectFSpringAnim(startRect, targetRect, mContext.getResources());
+        RectFSpringAnim anim = new RectFSpringAnim(startRect, targetRect, mContext);
         if (isFloatingIconView) {
             FloatingIconView fiv = (FloatingIconView) floatingView;
             anim.addAnimatorListener(fiv);
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java
index 682c92c..dde7605 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java
@@ -17,7 +17,6 @@
 
 import android.animation.Animator;
 import android.content.Context;
-import android.content.res.Resources;
 import android.graphics.PointF;
 import android.graphics.RectF;
 
@@ -106,7 +105,7 @@
     private float mMinVisChange;
     private float mYOvershoot;
 
-    public RectFSpringAnim(RectF startRect, RectF targetRect, Resources resources) {
+    public RectFSpringAnim(RectF startRect, RectF targetRect, Context context) {
         mStartRect = startRect;
         mTargetRect = targetRect;
         mCurrentCenterX = mStartRect.centerX();
@@ -114,8 +113,9 @@
         mTrackingBottomY = startRect.bottom < targetRect.bottom;
         mCurrentY = mTrackingBottomY ? mStartRect.bottom : mStartRect.top;
 
-        mMinVisChange = resources.getDimensionPixelSize(R.dimen.swipe_up_fling_min_visible_change);
-        mYOvershoot = resources.getDimensionPixelSize(R.dimen.swipe_up_y_overshoot);
+        ResourceProvider rp = DynamicResource.provider(context);
+        mMinVisChange = rp.getDimension(R.dimen.swipe_up_fling_min_visible_change);
+        mYOvershoot = rp.getDimension(R.dimen.swipe_up_y_overshoot);
     }
 
     public void onTargetPositionChanged() {
@@ -160,7 +160,7 @@
         float endX = mTargetRect.centerX();
         float minXValue = Math.min(startX, endX);
         float maxXValue = Math.max(startX, endX);
-        mRectXAnim = new FlingSpringAnim(this, RECT_CENTER_X, startX, endX,
+        mRectXAnim = new FlingSpringAnim(this, context, RECT_CENTER_X, startX, endX,
                 velocityPxPerMs.x * 1000, mMinVisChange, minXValue, maxXValue, 1f, onXEndListener);
 
         float startVelocityY = velocityPxPerMs.y * 1000;
@@ -170,13 +170,13 @@
         float endY = mTrackingBottomY ? mTargetRect.bottom : mTargetRect.top;
         float minYValue = Math.min(startY, endY - mYOvershoot);
         float maxYValue = Math.max(startY, endY);
-        mRectYAnim = new FlingSpringAnim(this, RECT_Y, startY, endY, startVelocityY,
+        mRectYAnim = new FlingSpringAnim(this, context, RECT_Y, startY, endY, startVelocityY,
                 mMinVisChange, minYValue, maxYValue, springVelocityFactor, onYEndListener);
 
         float minVisibleChange = Math.abs(1f / mStartRect.height());
         ResourceProvider rp = DynamicResource.provider(context);
-        float damping = rp.getFloat(R.dimen.swipe_up_rect_damping_ratio);
-        float stiffness = rp.getFloat(R.dimen.swipe_up_rect_stiffness);
+        float damping = rp.getFloat(R.dimen.swipe_up_rect_scale_damping_ratio);
+        float stiffness = rp.getFloat(R.dimen.swipe_up_rect_scale_stiffness);
 
         mRectScaleAnim = new SpringAnimation(this, RECT_SCALE_PROGRESS)
                 .setSpring(new SpringForce(1f)
diff --git a/res/values/config.xml b/res/values/config.xml
index 35e5e6d..df0f233 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -133,12 +133,21 @@
     <item name="horizontal_spring_damping_ratio" type="dimen" format="float">0.75</item>
     <item name="horizontal_spring_stiffness" type="dimen" format="float">200</item>
 
-    <item name="swipe_up_rect_damping_ratio" type="dimen" format="float">0.75</item>
-    <item name="swipe_up_rect_stiffness" type="dimen" format="float">200</item>
+    <item name="swipe_up_rect_scale_damping_ratio" type="dimen" format="float">0.75</item>
+    <item name="swipe_up_rect_scale_stiffness" type="dimen" format="float">200</item>
+
+    <item name="swipe_up_rect_xy_fling_friction" type="dimen" format="float">1.5</item>
+    <item name="swipe_up_rect_xy_damping_ratio" type="dimen" format="float">0.8</item>
+    <item name="swipe_up_rect_xy_stiffness" type="dimen" format="float">200</item>
 
     <item name="staggered_damping_ratio" type="dimen" format="float">0.7</item>
     <item name="staggered_stiffness" type="dimen" format="float">150</item>
 
+    <!-- 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">-60dp</dimen>
+
     <array name="dynamic_resources">
         <item>@dimen/all_apps_spring_damping_ratio</item>
         <item>@dimen/all_apps_spring_stiffness</item>
@@ -152,10 +161,17 @@
         <item>@dimen/horizontal_spring_damping_ratio</item>
         <item>@dimen/horizontal_spring_stiffness</item>
 
-        <item>@dimen/swipe_up_rect_damping_ratio</item>
-        <item>@dimen/swipe_up_rect_stiffness</item>
+        <item>@dimen/swipe_up_rect_scale_damping_ratio</item>
+        <item>@dimen/swipe_up_rect_scale_stiffness</item>
+
+        <item>@dimen/swipe_up_rect_xy_fling_friction</item>
+        <item>@dimen/swipe_up_rect_xy_damping_ratio</item>
+        <item>@dimen/swipe_up_rect_xy_stiffness</item>
 
         <item>@dimen/staggered_damping_ratio</item>
         <item>@dimen/staggered_stiffness</item>
+
+        <item>@dimen/swipe_up_fling_min_visible_change</item>
+        <item>@dimen/swipe_up_y_overshoot</item>
     </array>
 </resources>
diff --git a/src/com/android/launcher3/anim/FlingSpringAnim.java b/src/com/android/launcher3/anim/FlingSpringAnim.java
index eaf3b1c..06d0f1c 100644
--- a/src/com/android/launcher3/anim/FlingSpringAnim.java
+++ b/src/com/android/launcher3/anim/FlingSpringAnim.java
@@ -15,32 +15,40 @@
  */
 package com.android.launcher3.anim;
 
+import android.content.Context;
+
 import androidx.dynamicanimation.animation.DynamicAnimation.OnAnimationEndListener;
 import androidx.dynamicanimation.animation.FlingAnimation;
 import androidx.dynamicanimation.animation.FloatPropertyCompat;
 import androidx.dynamicanimation.animation.SpringAnimation;
 import androidx.dynamicanimation.animation.SpringForce;
 
+import com.android.launcher3.R;
+import com.android.launcher3.util.DynamicResource;
+import com.android.systemui.plugins.ResourceProvider;
+
 /**
  * Given a property to animate and a target value and starting velocity, first apply friction to
  * the fling until we pass the target, then apply a spring force to pull towards the target.
  */
 public class FlingSpringAnim {
 
-    private static final float FLING_FRICTION = 1.5f;
-    private static final float SPRING_STIFFNESS = 200;
-    private static final float SPRING_DAMPING = 0.8f;
-
     private final FlingAnimation mFlingAnim;
     private SpringAnimation mSpringAnim;
 
     private float mTargetPosition;
 
-    public <K> FlingSpringAnim(K object, FloatPropertyCompat<K> property, float startPosition,
-            float targetPosition, float startVelocity, float minVisChange, float minValue,
-            float maxValue, float springVelocityFactor, OnAnimationEndListener onEndListener) {
+    public <K> FlingSpringAnim(K object, Context context, FloatPropertyCompat<K> property,
+            float startPosition, float targetPosition, float startVelocity, float minVisChange,
+            float minValue, float maxValue, float springVelocityFactor,
+            OnAnimationEndListener onEndListener) {
+        ResourceProvider rp = DynamicResource.provider(context);
+        float damping = rp.getFloat(R.dimen.swipe_up_rect_xy_damping_ratio);
+        float stiffness = rp.getFloat(R.dimen.swipe_up_rect_xy_stiffness);
+        float friction = rp.getFloat(R.dimen.swipe_up_rect_xy_fling_friction);
+
         mFlingAnim = new FlingAnimation(object, property)
-                .setFriction(FLING_FRICTION)
+                .setFriction(friction)
                 // Have the spring pull towards the target if we've slowed down too much before
                 // reaching it.
                 .setMinimumVisibleChange(minVisChange)
@@ -54,8 +62,8 @@
                     .setStartValue(value)
                     .setStartVelocity(velocity * springVelocityFactor)
                     .setSpring(new SpringForce(mTargetPosition)
-                            .setStiffness(SPRING_STIFFNESS)
-                            .setDampingRatio(SPRING_DAMPING));
+                            .setStiffness(stiffness)
+                            .setDampingRatio(damping));
             mSpringAnim.addEndListener(onEndListener);
             mSpringAnim.animateToFinalPosition(mTargetPosition);
         }));