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

Commit 20dc060d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Animate when removing PiP" into rvc-qpr-dev

parents df15ada5 925a102e
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.animation.Animator;
import android.animation.RectEvaluator;
import android.animation.ValueAnimator;
import android.annotation.IntDef;
import android.content.Context;
import android.graphics.Rect;
import android.view.SurfaceControl;

@@ -56,13 +55,15 @@ public class PipAnimationController {
    public static final int TRANSITION_DIRECTION_TO_PIP = 2;
    public static final int TRANSITION_DIRECTION_TO_FULLSCREEN = 3;
    public static final int TRANSITION_DIRECTION_TO_SPLIT_SCREEN = 4;
    public static final int TRANSITION_DIRECTION_REMOVE_STACK = 5;

    @IntDef(prefix = { "TRANSITION_DIRECTION_" }, value = {
            TRANSITION_DIRECTION_NONE,
            TRANSITION_DIRECTION_SAME,
            TRANSITION_DIRECTION_TO_PIP,
            TRANSITION_DIRECTION_TO_FULLSCREEN,
            TRANSITION_DIRECTION_TO_SPLIT_SCREEN
            TRANSITION_DIRECTION_TO_SPLIT_SCREEN,
            TRANSITION_DIRECTION_REMOVE_STACK
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface TransitionDirection {}
@@ -88,7 +89,7 @@ public class PipAnimationController {
            });

    @Inject
    PipAnimationController(Context context, PipSurfaceTransactionHelper helper) {
    PipAnimationController(PipSurfaceTransactionHelper helper) {
        mSurfaceTransactionHelper = helper;
    }

@@ -338,6 +339,10 @@ public class PipAnimationController {

                @Override
                void onStartTransaction(SurfaceControl leash, SurfaceControl.Transaction tx) {
                    if (getTransitionDirection() == TRANSITION_DIRECTION_REMOVE_STACK) {
                        // while removing the pip stack, no extra work needs to be done here.
                        return;
                    }
                    getSurfaceTransactionHelper()
                            .resetScale(tx, leash, getDestinationBounds())
                            .crop(tx, leash, getDestinationBounds())
+27 −14
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_ALPHA;
import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_NONE;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_REMOVE_STACK;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_SAME;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_FULLSCREEN;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
@@ -337,7 +338,19 @@ public class PipTaskOrganizer extends TaskOrganizer implements
                    + " mInPip=" + mInPip + " mExitingPip=" + mExitingPip + " mToken=" + mToken);
            return;
        }
        getUpdateHandler().post(() -> {

        // removePipImmediately is expected when the following animation finishes.
        mUpdateHandler.post(() -> mPipAnimationController
                .getAnimator(mLeash, mLastReportedBounds, 1f, 0f)
                .setTransitionDirection(TRANSITION_DIRECTION_REMOVE_STACK)
                .setPipAnimationCallback(mPipAnimationCallback)
                .setDuration(mEnterExitAnimationDuration)
                .start());
        mInitialState.remove(mToken.asBinder());
        mExitingPip = true;
    }

    private void removePipImmediately() {
        try {
            // Reset the task bounds first to ensure the activity configuration is reset as well
            final WindowContainerTransaction wct = new WindowContainerTransaction();
@@ -349,9 +362,6 @@ public class PipTaskOrganizer extends TaskOrganizer implements
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to remove PiP", e);
        }
        });
        mInitialState.remove(mToken.asBinder());
        mExitingPip = true;
    }

    @Override
@@ -803,7 +813,10 @@ public class PipTaskOrganizer extends TaskOrganizer implements
                    + "directly");
        }
        mLastReportedBounds.set(destinationBounds);
        if (isInPipDirection(direction) && type == ANIM_TYPE_ALPHA) {
        if (direction == TRANSITION_DIRECTION_REMOVE_STACK) {
            removePipImmediately();
            return;
        } else if (isInPipDirection(direction) && type == ANIM_TYPE_ALPHA) {
            return;
        }

+1 −2
Original line number Diff line number Diff line
@@ -61,8 +61,7 @@ public class PipAnimationControllerTest extends SysuiTestCase {
    @Before
    public void setUp() throws Exception {
        mPipAnimationController = new PipAnimationController(
                mContext, new PipSurfaceTransactionHelper(mContext,
                mock(ConfigurationController.class)));
                new PipSurfaceTransactionHelper(mContext, mock(ConfigurationController.class)));
        mLeash = new SurfaceControl.Builder()
                .setContainerLayer()
                .setName("FakeLeash")