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

Commit 3edcd3ed authored by Hongwei Wang's avatar Hongwei Wang Committed by Android (Google) Code Review
Browse files

Merge "Apply round corner when expand PiP" into main

parents ce7f4789 c5971125
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -86,6 +86,11 @@ public class PipExpandAnimator extends ValueAnimator {
            super.onAnimationEnd(animation);
            if (mFinishTransaction != null) {
                onExpandAnimationUpdate(mFinishTransaction, 1f);
                // Reset the corner radius at the end, if not in desktop windowing mode.
                if (!mIsPipInDesktopMode) {
                    mPipSurfaceTransactionHelper.round(mFinishTransaction, mLeash,
                            false /* applyCornerRadius */);
                }
            }
            if (mAnimationEndCallback != null) {
                mAnimationEndCallback.run();
@@ -183,7 +188,9 @@ public class PipExpandAnimator extends ValueAnimator {
                    mAnimatedRect, insets, degrees, x, y,
                    true /* isExpanding */, mRotation == ROTATION_90);
        }
        mPipSurfaceTransactionHelper.round(tx, mLeash, mIsPipInDesktopMode /* applyCornerRadius */)
        // Apply round corner during the animation, it will be reset at the end if not in desktop
        // windowing mode.
        mPipSurfaceTransactionHelper.round(tx, mLeash, true /* applyCornerRadius */)
                .shadow(tx, mLeash, false /* applyShadowRadius */);
    }

+31 −2
Original line number Diff line number Diff line
@@ -173,6 +173,31 @@ public class PipExpandAnimatorTest {
        verify(mMockEndCallback).run();
    }

    @Test
    public void onAnimationUpdate_expand_setRoundCornersWithoutShadow() {
        mRotation = Surface.ROTATION_0;
        mBaseBounds = new Rect(0, 0, 1_000, 2_000);
        mStartBounds = new Rect(500, 1_000, 1_000, 2_000);
        mEndBounds = new Rect(mBaseBounds);
        mPipExpandAnimator = new PipExpandAnimator(mMockContext,
                new PipSurfaceTransactionHelper(mMockContext), mTestLeash,
                mMockStartTransaction, mMockFinishTransaction,
                mBaseBounds, mStartBounds, mEndBounds, mSourceRectHint,
                mRotation, false /* isPipInDesktopMode */);
        mPipExpandAnimator.setSurfaceControlTransactionFactory(mMockFactory);

        mPipExpandAnimator.setAnimationStartCallback(mMockStartCallback);
        mPipExpandAnimator.setAnimationEndCallback(mMockEndCallback);
        InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
            mPipExpandAnimator.start();
            clearInvocations(mMockTransaction);
            mPipExpandAnimator.setCurrentFraction(0.5f);
        });

        verify(mMockTransaction).setCornerRadius(mTestLeash, CORNER_RADIUS);
        verify(mMockTransaction).setShadowRadius(mTestLeash, 0f);
    }

    @Test
    public void onAnimationEnd_expand_leashIsFullscreen() {
        mRotation = Surface.ROTATION_0;
@@ -191,16 +216,18 @@ public class PipExpandAnimatorTest {
        InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
            mPipExpandAnimator.start();
            clearInvocations(mMockTransaction);
            clearInvocations(mMockFinishTransaction);
            mPipExpandAnimator.end();
        });

        verify(mMockTransaction).setCrop(mTestLeash, mEndBounds);
        verify(mMockTransaction).setCornerRadius(mTestLeash, 0f);
        verify(mMockTransaction).setCornerRadius(mTestLeash, CORNER_RADIUS);
        verify(mMockTransaction).setShadowRadius(mTestLeash, 0f);
        verify(mMockFinishTransaction).setCornerRadius(mTestLeash, 0f);
    }

    @Test
    public void onAnimationEnd_expand_isInDesktopMode_setRoundedCorners() {
    public void onAnimationEnd_expandInDesktopMode_setRoundedCorners() {
        mRotation = Surface.ROTATION_0;
        mBaseBounds = new Rect(0, 0, 1_000, 2_000);
        mStartBounds = new Rect(500, 1_000, 1_000, 2_000);
@@ -217,11 +244,13 @@ public class PipExpandAnimatorTest {
        InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
            mPipExpandAnimator.start();
            clearInvocations(mMockTransaction);
            clearInvocations(mMockFinishTransaction);
            mPipExpandAnimator.end();
        });

        verify(mMockTransaction).setCrop(mTestLeash, mEndBounds);
        verify(mMockTransaction).setCornerRadius(mTestLeash, CORNER_RADIUS);
        verify(mMockTransaction).setShadowRadius(mTestLeash, 0f);
        verify(mMockFinishTransaction).setCornerRadius(mTestLeash, CORNER_RADIUS);
    }
}