Always run animateClose when closing TaskMenuView

- This avoid diverging code path when animation is off
- Also made sure menuTranslationX and Y always reset when not needed
- Also remove AnimatedVectorDrawable in favour of scale animation in code, as AnimatedVectorDrawable doesn't work well when animation is off

Bug: 319086207
Test: OverviewMenuImageTest
Flag: ACONFIG com.android.launcher3.enable_overview_icon_menu TEAMFOOD
Change-Id: I4a18cf4aac3237031095c2600c777b6c4c3e518f
diff --git a/quickstep/res/drawable/ic_chevron_down.xml b/quickstep/res/drawable/ic_chevron_down.xml
index 77a8295..f246cbc 100644
--- a/quickstep/res/drawable/ic_chevron_down.xml
+++ b/quickstep/res/drawable/ic_chevron_down.xml
@@ -13,35 +13,22 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:aapt="http://schemas.android.com/aapt"
-    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
-    <target android:name="scaleGroup">
-        <aapt:attr name="android:animation">
-            <objectAnimator
-                android:duration="150"
-                android:propertyName="scaleX"
-                android:valueFrom="1"
-                android:valueTo="-1" />
-        </aapt:attr>
-    </target>
-    <aapt:attr name="android:drawable">
-        <vector
-            android:width="48dp"
-            android:height="48dp"
-            android:autoMirrored="true"
-            android:tint="?androidprv:attr/materialColorOnSurface"
-            android:viewportHeight="48"
-            android:viewportWidth="48">
-            <group
-                android:name="scaleGroup"
-                android:pivotX="24"
-                android:pivotY="24"
-                android:rotation="90">
-                <path
-                    android:fillColor="@android:color/white"
-                    android:pathData="M18.75,36 L16.6,33.85 26.5,23.95 16.6,14.05 18.75,11.9 30.8,23.95Z" />
-            </group>
-        </vector>
-    </aapt:attr>
-</animated-vector>
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+    android:width="48dp"
+    android:height="48dp"
+    android:autoMirrored="true"
+    android:tint="?androidprv:attr/materialColorOnSurface"
+    android:viewportHeight="48"
+    android:viewportWidth="48">
+    <group
+        android:name="scaleGroup"
+        android:pivotX="24"
+        android:pivotY="24"
+        android:rotation="90">
+        <path
+            android:fillColor="@android:color/white"
+            android:pathData="M18.75,36 L16.6,33.85 26.5,23.95 16.6,14.05 18.75,11.9 30.8,23.95Z" />
+    </group>
+</vector>
diff --git a/quickstep/src/com/android/quickstep/views/IconAppChipView.java b/quickstep/src/com/android/quickstep/views/IconAppChipView.java
index cb3566e..6bb98e1 100644
--- a/quickstep/src/com/android/quickstep/views/IconAppChipView.java
+++ b/quickstep/src/com/android/quickstep/views/IconAppChipView.java
@@ -30,7 +30,6 @@
 import android.content.res.Resources;
 import android.graphics.Outline;
 import android.graphics.Rect;
-import android.graphics.drawable.AnimatedVectorDrawable;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.view.View;
@@ -121,36 +120,12 @@
     }
 
     /**
-     * Translate the View on the X-axis without overriding the raw translation.
-     * This function is used for the menu split animation. It allows external animations to
-     * translate this view without affecting the value of the original translation. Thus,
-     * it is possible to restore the initial translation value.
-     *
-     * @param translationX Animated translation to be aggregated to the raw translation.
-     */
-    public void setMenuTranslationX(float translationX) {
-        mViewTranslationX.get(INDEX_MENU_TRANSLATION).setValue(translationX);
-    }
-
-    /**
      * Gets the menu y-axis translation for split task
      */
     public MultiPropertyFactory<View>.MultiProperty getMenuTranslationY() {
         return mViewTranslationY.get(INDEX_MENU_TRANSLATION);
     }
 
-    /**
-     * Translate the View on the Y-axis without overriding the raw translation.
-     * This function is used for the menu split animation. It allows external animations to
-     * translate this view without affecting the value of the original translation. Thus,
-     * it is possible to restore the initial translation value.
-     *
-     * @param translationY Animated translation to be aggregated to the raw translation.
-     */
-    public void setMenuTranslationY(float translationY) {
-        mViewTranslationY.get(INDEX_MENU_TRANSLATION).setValue(translationY);
-    }
-
     public IconAppChipView(Context context) {
         this(context, null);
     }
@@ -330,6 +305,7 @@
         LayoutParams iconArrowParams = (LayoutParams) mIconArrowView.getLayoutParams();
         int arrowMarginStart = collapsedBackgroundBounds.right - mArrowMarginEnd - mArrowSize;
         orientationHandler.setIconAppChipChildrenParams(iconArrowParams, arrowMarginStart);
+        mIconArrowView.setPivotY(iconArrowParams.height / 2f);
         mIconArrowView.setLayoutParams(iconArrowParams);
 
         // This method is called twice sometimes (like when rotating split tasks). It is called
@@ -378,7 +354,6 @@
         if (isRevealing) {
             boolean isRtl = isLayoutRtl();
             bringToFront();
-            ((AnimatedVectorDrawable) mIconArrowView.getDrawable()).start();
             // Clip expanded text with reveal animation so it doesn't go beyond the edge of the menu
             Animator expandedTextRevealAnim = ViewAnimationUtils.createCircularReveal(
                     mIconTextExpandedView, 0, mIconTextExpandedView.getHeight() / 2,
@@ -412,10 +387,10 @@
                             textTranslationXWithRtl),
                     ObjectAnimator.ofFloat(mIconTextCollapsedView, ALPHA, 0),
                     ObjectAnimator.ofFloat(mIconTextExpandedView, ALPHA, 1),
-                    ObjectAnimator.ofFloat(mIconArrowView, TRANSLATION_X, arrowTranslationWithRtl));
+                    ObjectAnimator.ofFloat(mIconArrowView, TRANSLATION_X, arrowTranslationWithRtl),
+                    ObjectAnimator.ofFloat(mIconArrowView, SCALE_Y, -1));
             mAnimator.setDuration(MENU_BACKGROUND_REVEAL_DURATION);
         } else {
-            ((AnimatedVectorDrawable) mIconArrowView.getDrawable()).reverse();
             // Clip expanded text with reveal animation so it doesn't go beyond the edge of the menu
             Animator expandedTextClipAnim = ViewAnimationUtils.createCircularReveal(
                     mIconTextExpandedView, 0, mIconTextExpandedView.getHeight() / 2,
@@ -436,7 +411,8 @@
                     ObjectAnimator.ofFloat(mIconTextExpandedView, TRANSLATION_X, 0),
                     ObjectAnimator.ofFloat(mIconTextCollapsedView, ALPHA, 1),
                     ObjectAnimator.ofFloat(mIconTextExpandedView, ALPHA, 0),
-                    ObjectAnimator.ofFloat(mIconArrowView, TRANSLATION_X, 0));
+                    ObjectAnimator.ofFloat(mIconArrowView, TRANSLATION_X, 0),
+                    ObjectAnimator.ofFloat(mIconArrowView, SCALE_Y, 1));
             mAnimator.setDuration(MENU_BACKGROUND_HIDE_DURATION);
         }
 
@@ -458,19 +434,6 @@
         return new Rect(0, 0, mExpandedMenuDefaultWidth, mExpandedMenuDefaultHeight);
     }
 
-    protected void reset() {
-        mBackgroundRelativeLtrLocation.set(getCollapsedBackgroundLtrBounds());
-        mIconView.setScaleX(1);
-        mIconView.setScaleY(1);
-        mIconTextCollapsedView.setTranslationX(0);
-        mIconTextExpandedView.setTranslationX(0);
-        mIconTextCollapsedView.setAlpha(1);
-        mIconTextExpandedView.setAlpha(0);
-        mIconArrowView.setTranslationX(0);
-        ((AnimatedVectorDrawable) mIconArrowView.getDrawable()).reset();
-        mAnimator = null;
-    }
-
     private void cancelInProgressAnimations() {
         // We null the `AnimatorSet` because it holds references to the `Animators` which aren't
         // expecting to be mutable and will cause a crash if they are re-used.
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
index 39f1e46..a5e8989 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
@@ -113,7 +113,7 @@
 
     @Override
     protected void handleClose(boolean animate) {
-        if (animate) {
+        if (animate || enableOverviewIconMenu()) {
             animateClose();
         } else {
             closeComplete();
@@ -305,6 +305,8 @@
                 : Interpolators.DECELERATE);
 
         if (enableOverviewIconMenu()) {
+            IconAppChipView iconAppChip = (IconAppChipView) mTaskContainer.getIconView().asView();
+
             float additionalTranslationY = 0;
             if (((RecentsView) mActivity.getOverviewPanel()).isOnGridBottomRow(mTaskView)) {
                 // Animate menu up for enough room to display full menu when task on bottom row.
@@ -320,34 +322,33 @@
                             : mMenuTranslationYBeforeOpen + additionalTranslationY);
             translationYAnim.setInterpolator(EMPHASIZED);
 
-            IconAppChipView iconAppChip = (IconAppChipView) mTaskContainer.getIconView().asView();
             ObjectAnimator menuTranslationYAnim = ObjectAnimator.ofFloat(
                     iconAppChip.getMenuTranslationY(),
                     MULTI_PROPERTY_VALUE, closing ? 0 : additionalTranslationY);
             menuTranslationYAnim.setInterpolator(EMPHASIZED);
 
-            mOpenCloseAnimator.playTogether(translationYAnim, menuTranslationYAnim);
-        }
-        // Animate menu and icon when split task would display off the side of the screen.
-        if (enableOverviewIconMenu() && mActivity.getDeviceProfile().isLandscape
-                && mTaskContainer.getStagePosition() == STAGE_POSITION_BOTTOM_OR_RIGHT) {
-            float additionalTranslationX = Math.max(
-                    getTranslationX() + getWidth() - (mActivity.getDeviceProfile().widthPx
-                            - getResources().getDimensionPixelSize(
-                            R.dimen.task_menu_edge_padding) * 2), 0);
+            float additionalTranslationX = 0;
+            if (mActivity.getDeviceProfile().isLandscape
+                    && mTaskContainer.getStagePosition() == STAGE_POSITION_BOTTOM_OR_RIGHT) {
+                // Animate menu and icon when split task would display off the side of the screen.
+                additionalTranslationX = Math.max(
+                        getTranslationX() + getWidth() - (mActivity.getDeviceProfile().widthPx
+                                - getResources().getDimensionPixelSize(
+                                R.dimen.task_menu_edge_padding) * 2), 0);
+            }
 
             ObjectAnimator translationXAnim = ObjectAnimator.ofFloat(this, TRANSLATION_X,
                     closing ? mMenuTranslationXBeforeOpen
                             : mMenuTranslationXBeforeOpen - additionalTranslationX);
             translationXAnim.setInterpolator(EMPHASIZED);
 
-            IconAppChipView iconAppChip = (IconAppChipView) mTaskContainer.getIconView().asView();
             ObjectAnimator menuTranslationXAnim = ObjectAnimator.ofFloat(
                     iconAppChip.getMenuTranslationX(),
                     MULTI_PROPERTY_VALUE, closing ? 0 : -additionalTranslationX);
             menuTranslationXAnim.setInterpolator(EMPHASIZED);
 
-            mOpenCloseAnimator.playTogether(translationXAnim, menuTranslationXAnim);
+            mOpenCloseAnimator.playTogether(translationYAnim, translationXAnim,
+                    menuTranslationXAnim);
         }
 
         mOpenCloseAnimator.playTogether(mRevealAnimator,
@@ -377,21 +378,10 @@
 
     private void closeComplete() {
         mIsOpen = false;
-        resetOverviewIconMenu();
         mActivity.getDragLayer().removeView(this);
         mRevealAnimator = null;
     }
 
-    private void resetOverviewIconMenu() {
-        if (enableOverviewIconMenu()) {
-            IconAppChipView iconAppChipView = (IconAppChipView) mTaskContainer.getIconView();
-            iconAppChipView.reset();
-            iconAppChipView.setMenuTranslationX(0);
-            iconAppChipView.setMenuTranslationY(0);
-            setTranslationY(mMenuTranslationYBeforeOpen);
-        }
-    }
-
     private RoundedRectRevealOutlineProvider createOpenCloseOutlineProvider() {
         float radius = TaskCornerRadius.get(mContext);
         Rect fromRect = new Rect(