Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ff4c1f5 authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

Merge "Always run animateClose when closing TaskMenuView" into main

parents 5fbbbcef 60ad90e5
Loading
Loading
Loading
Loading
+19 −32
Original line number Diff line number Diff line
@@ -13,20 +13,9 @@
     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
    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"
@@ -43,5 +32,3 @@
            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>
+5 −42
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import android.content.Context;
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;
@@ -120,18 +119,6 @@ public class IconAppChipView extends FrameLayout implements TaskViewIcon {
        return mViewTranslationX.get(INDEX_MENU_TRANSLATION);
    }

    /**
     * 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
     */
@@ -139,18 +126,6 @@ public class IconAppChipView extends FrameLayout implements TaskViewIcon {
        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 @@ public class IconAppChipView extends FrameLayout implements TaskViewIcon {
        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 @@ public class IconAppChipView extends FrameLayout implements TaskViewIcon {
        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 @@ public class IconAppChipView extends FrameLayout implements TaskViewIcon {
                            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 @@ public class IconAppChipView extends FrameLayout implements TaskViewIcon {
                    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 @@ public class IconAppChipView extends FrameLayout implements TaskViewIcon {
        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.
+14 −24
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ public class TaskMenuView extends AbstractFloatingView {

    @Override
    protected void handleClose(boolean animate) {
        if (animate) {
        if (animate || enableOverviewIconMenu()) {
            animateClose();
        } else {
            closeComplete();
@@ -305,6 +305,8 @@ public class TaskMenuView extends AbstractFloatingView {
                : 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 @@ public class TaskMenuView extends AbstractFloatingView {
                            : 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
            float additionalTranslationX = 0;
            if (mActivity.getDeviceProfile().isLandscape
                    && mTaskContainer.getStagePosition() == STAGE_POSITION_BOTTOM_OR_RIGHT) {
            float additionalTranslationX = Math.max(
                // 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 @@ public class TaskMenuView extends AbstractFloatingView {

    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(