Added scale animation for taskbar pinning transition.

Animate the bubble bar icons size and padding for taskbar change mode
animation.

Bug: 345698412
Test: TaskbarPinningControllerTest
Flag: com.android.wm.shell.enable_bubble_bar
Change-Id: Ibdecabd1310203dc956f69673dc446a0e7e556a6
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt
index caf8dd8..bcfc718 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt
@@ -123,10 +123,7 @@
         controllers.bubbleControllers.getOrNull()?.bubbleBarViewController?.let {
             // if bubble bar is not visible no need to add it`s animations
             if (!it.isBubbleBarVisible) return@let
-            // TODO(b/345698412): add scale animation
-            animatorSet.playTogether(
-                it.bubbleBarTranslationYForPinning.animateToValue(animateToValue)
-            )
+            animatorSet.playTogether(it.bubbleBarPinning.animateToValue(animateToValue))
         }
         animatorSet.interpolator = Interpolators.EMPHASIZED
         return animatorSet
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
index c5d649e..996d645 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
@@ -332,6 +332,17 @@
     }
 
     /**
+     * Set the bubble icons size and spacing between the bubbles and the borders of the bubble
+     * bar.
+     */
+    public void setIconSizeAndPaddingForPinning(float newIconSize, float newBubbleBarPadding) {
+        mBubbleBarPadding = newBubbleBarPadding;
+        mIconScale = newIconSize / mIconSize;
+        updateBubblesLayoutProperties(mBubbleBarLocation);
+        invalidate();
+    }
+
+    /**
      * Sets new icon sizes and newBubbleBarPadding between icons and bubble bar borders.
      *
      * @param newIconSize         new icon size
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
index 7e57238..74546d8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
@@ -107,9 +107,10 @@
             this::updateTranslationY);
     private final AnimatedFloat mBubbleOffsetY = new AnimatedFloat(
             this::updateBubbleOffsetY);
-    private final AnimatedFloat mBubbleBarTranslationYForPinning = new AnimatedFloat(
-            this::updateTranslationY);
-
+    private final AnimatedFloat mBubbleBarPinning = new AnimatedFloat(pinningProgress -> {
+        updateTranslationY();
+        setBubbleBarScaleAndPadding(pinningProgress);
+    });
 
     // Modified when swipe up is happening on the bubble bar or task bar.
     private float mBubbleBarSwipeUpTranslationY;
@@ -182,7 +183,7 @@
         float pinningValue = DisplayController.isTransientTaskbar(mActivity)
                 ? PINNING_TRANSIENT
                 : PINNING_PERSISTENT;
-        mBubbleBarTranslationYForPinning.updateValue(pinningValue);
+        mBubbleBarPinning.updateValue(pinningValue);
         mBarView.setController(new BubbleBarView.Controller() {
             @Override
             public float getBubbleBarTranslationY() {
@@ -236,9 +237,9 @@
         };
     }
 
-    /** Returns animated float property for controlling pining Y position. */
-    public AnimatedFloat getBubbleBarTranslationYForPinning() {
-        return mBubbleBarTranslationYForPinning;
+    /** Returns animated float property responsible for pinning transition animation. */
+    public AnimatedFloat getBubbleBarPinning() {
+        return mBubbleBarPinning;
     }
 
     private BubbleBarFlyoutPositioner createFlyoutPositioner() {
@@ -609,9 +610,11 @@
         updateBubbleBarIconSizeAndPadding(newIconSize, newPadding, animate);
     }
 
-
     private int getBubbleBarIconSizeFromDeviceProfile(Resources res) {
-        DeviceProfile deviceProfile = mActivity.getDeviceProfile();
+        return getBubbleBarIconSizeFromDeviceProfile(res, mActivity.getDeviceProfile());
+    }
+
+    private int getBubbleBarIconSizeFromDeviceProfile(Resources res, DeviceProfile deviceProfile) {
         DisplayMetrics dm = res.getDisplayMetrics();
         float smallIconSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                 APP_ICON_SMALL_DP, dm);
@@ -626,7 +629,10 @@
     }
 
     private int getBubbleBarPaddingFromDeviceProfile(Resources res) {
-        DeviceProfile deviceProfile = mActivity.getDeviceProfile();
+        return getBubbleBarPaddingFromDeviceProfile(res, mActivity.getDeviceProfile());
+    }
+
+    private int getBubbleBarPaddingFromDeviceProfile(Resources res, DeviceProfile deviceProfile) {
         DisplayMetrics dm = res.getDisplayMetrics();
         float mediumIconSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                 APP_ICON_MEDIUM_DP, dm);
@@ -673,14 +679,32 @@
     /** Computes translation y for taskbar pinning. */
     private float getBubbleBarTranslationYForTaskbarPinning() {
         if (mTaskbarSharedState == null) return 0f;
-        float animationProgress = mBubbleBarTranslationYForPinning.value;
+        float pinningProgress = mBubbleBarPinning.value;
         if (mTaskbarSharedState.startTaskbarVariantIsTransient) {
-            return mapRange(animationProgress, /* min = */ 0f, mTaskbarTranslationDelta);
+            return mapRange(pinningProgress, /* min = */ 0f, mTaskbarTranslationDelta);
         } else {
-            return mapRange(animationProgress, -mTaskbarTranslationDelta, /* max = */ 0f);
+            return mapRange(pinningProgress, -mTaskbarTranslationDelta, /* max = */ 0f);
         }
     }
 
+    private void setBubbleBarScaleAndPadding(float pinningProgress) {
+        Resources res = mActivity.getResources();
+        // determine icon scale for pinning
+        int persistentIconSize = res.getDimensionPixelSize(
+                R.dimen.bubblebar_icon_size_persistent_taskbar);
+        int transientIconSize = getBubbleBarIconSizeFromDeviceProfile(res,
+                mActivity.getTransientTaskbarDeviceProfile());
+        float pinningIconSize = mapRange(pinningProgress, transientIconSize, persistentIconSize);
+
+        // determine bubble bar padding for pinning
+        int persistentPadding = res.getDimensionPixelSize(
+                R.dimen.bubblebar_icon_spacing_persistent_taskbar);
+        int transientPadding = getBubbleBarPaddingFromDeviceProfile(res,
+                mActivity.getTransientTaskbarDeviceProfile());
+        float pinningPadding = mapRange(pinningProgress, transientPadding, persistentPadding);
+        mBarView.setIconSizeAndPaddingForPinning(pinningIconSize, pinningPadding);
+    }
+
     /**
      * Calculates the vertical difference in the bubble bar positions for pinned and transient
      * taskbar modes.