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

Commit 824407da authored by Mateusz Cicheński's avatar Mateusz Cicheński
Browse files

Merge mSwipePipToHomeOverlay with mPipOverlay and remove unused code

Test: n/a
Bug: 315544436
Flag: none, refactoring
Change-Id: I332a30fefbd90a7cbd6ec5791d5360dd11a18e6b
parent 65395db5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -769,7 +769,6 @@ public class PipAnimationController {
                        getSurfaceTransactionHelper().crop(tx, leash, destBounds);
                    }
                    if (mContentOverlay != null) {
                        mContentOverlay.onAnimationEnd(tx, destBounds);
                        clearContentOverlay();
                    }
                }
+0 −24
Original line number Diff line number Diff line
@@ -67,15 +67,6 @@ public abstract class PipContentOverlay {
    public abstract void onAnimationUpdate(SurfaceControl.Transaction atomicTx,
            Rect currentBounds, float fraction);

    /**
     * Callback when reaches the end of animation on the internal {@link #mLeash}.
     * @param atomicTx {@link SurfaceControl.Transaction} to operate, you should not explicitly
     *                 call apply on this transaction, it should be applied on the caller side.
     * @param destinationBounds {@link Rect} of the final bounds.
     */
    public abstract void onAnimationEnd(SurfaceControl.Transaction atomicTx,
            Rect destinationBounds);

    /** A {@link PipContentOverlay} uses solid color. */
    public static final class PipColorOverlay extends PipContentOverlay {
        private static final String TAG = PipColorOverlay.class.getSimpleName();
@@ -107,11 +98,6 @@ public abstract class PipContentOverlay {
            atomicTx.setAlpha(mLeash, fraction < 0.5f ? 0 : (fraction - 0.5f) * 2);
        }

        @Override
        public void onAnimationEnd(SurfaceControl.Transaction atomicTx, Rect destinationBounds) {
            // Do nothing. Color overlay should be fully opaque by now, ready for fade out.
        }

        private float[] getContentOverlayColor(Context context) {
            final TypedArray ta = context.obtainStyledAttributes(new int[] {
                    android.R.attr.colorBackground });
@@ -164,11 +150,6 @@ public abstract class PipContentOverlay {
                Rect currentBounds, float fraction) {
            // Do nothing. Keep the snapshot till animation ends.
        }

        @Override
        public void onAnimationEnd(SurfaceControl.Transaction atomicTx, Rect destinationBounds) {
            // Do nothing. Snapshot overlay should be fully opaque by now, ready for fade out.
        }
    }

    /** A {@link PipContentOverlay} shows app icon on solid color background. */
@@ -254,11 +235,6 @@ public abstract class PipContentOverlay {
                    .setAlpha(mLeash, fraction < 0.5f ? 0 : (fraction - 0.5f) * 2);
        }

        @Override
        public void onAnimationEnd(SurfaceControl.Transaction atomicTx, Rect destinationBounds) {
            // Do nothing. Icon overlay should be fully opaque by now, ready for fade out.
        }

        @Override
        public void detach(SurfaceControl.Transaction tx) {
            super.detach(tx);
+7 −15
Original line number Diff line number Diff line
@@ -329,15 +329,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
    private @Surface.Rotation int mCurrentRotation;

    /**
     * An optional overlay used to mask content changing between an app in/out of PiP, only set if
     * {@link PipTransitionState#getInSwipePipToHomeTransition()} is true, only in gesture nav.
     */
    @Nullable
    SurfaceControl mSwipePipToHomeOverlay;

    /**
     * An optional overlay used to mask content changing between an app in/out of PiP, only set if
     * {@link PipTransitionState#getInSwipePipToHomeTransition()} is false.
     * An optional overlay used to mask content changing between an app in/out of PiP.
     */
    @Nullable
    SurfaceControl mPipOverlay;
@@ -480,7 +472,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
            return;
        }
        mPipBoundsState.setBounds(destinationBounds);
        mSwipePipToHomeOverlay = overlay;
        mPipOverlay = overlay;
        if (ENABLE_SHELL_TRANSITIONS && overlay != null) {
            // With Shell transition, the overlay was attached to the remote transition leash, which
            // will be removed when the current transition is finished, so we need to reparent it
@@ -892,7 +884,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        }

        final Rect destinationBounds = mPipBoundsState.getBounds();
        final SurfaceControl swipeToHomeOverlay = mSwipePipToHomeOverlay;
        final SurfaceControl swipeToHomeOverlay = mPipOverlay;
        final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction();
        mSurfaceTransactionHelper
                .resetScale(tx, mLeash, destinationBounds)
@@ -911,7 +903,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
            }
        }, tx);
        mPipTransitionState.setInSwipePipToHomeTransition(false);
        mSwipePipToHomeOverlay = null;
        mPipOverlay = null;
    }

    private void applyEnterPipSyncTransaction(Rect destinationBounds, Runnable runnable,
@@ -1126,9 +1118,9 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        }

        clearWaitForFixedRotation();
        if (mSwipePipToHomeOverlay != null) {
            removeContentOverlay(mSwipePipToHomeOverlay, null /* callback */);
            mSwipePipToHomeOverlay = null;
        if (mPipOverlay != null) {
            removeContentOverlay(mPipOverlay, null /* callback */);
            mPipOverlay = null;
        }
        resetShadowRadius();
        mPipTransitionState.setInSwipePipToHomeTransition(false);
+9 −9
Original line number Diff line number Diff line
@@ -465,7 +465,7 @@ public class PipTransition extends PipTransitionController {
                    mSurfaceTransactionHelper.crop(tx, leash, destinationBounds)
                            .resetScale(tx, leash, destinationBounds)
                            .round(tx, leash, true /* applyCornerRadius */);
                    if (mPipOrganizer.mSwipePipToHomeOverlay != null && !mInitBounds.isEmpty()) {
                    if (mPipOrganizer.mPipOverlay != null && !mInitBounds.isEmpty()) {
                        // Resetting the scale for pinned task while re-adjusting its crop,
                        // also scales the overlay. So we need to update the overlay leash too.
                        Rect overlayBounds = new Rect(destinationBounds);
@@ -476,7 +476,7 @@ public class PipTransition extends PipTransitionController {
                                (destinationBounds.width() - overlaySize) / 2,
                                (destinationBounds.height() - overlaySize) / 2);
                        mSurfaceTransactionHelper.resetScale(tx,
                                mPipOrganizer.mSwipePipToHomeOverlay, overlayBounds);
                                mPipOrganizer.mPipOverlay, overlayBounds);
                    }
                }
                mInitBounds.setEmpty();
@@ -615,9 +615,9 @@ public class PipTransition extends PipTransitionController {
            }
        }
        // if overlay is present remove it immediately, as exit transition came before it faded out
        if (mPipOrganizer.mSwipePipToHomeOverlay != null) {
            startTransaction.remove(mPipOrganizer.mSwipePipToHomeOverlay);
            clearSwipePipToHomeOverlay();
        if (mPipOrganizer.mPipOverlay != null) {
            startTransaction.remove(mPipOrganizer.mPipOverlay);
            clearPipOverlay();
        }
        if (pipChange == null) {
            ProtoLog.w(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
@@ -1077,7 +1077,7 @@ public class PipTransition extends PipTransitionController {
        if (mFixedRotationState == FIXED_ROTATION_CALLBACK && appBounds != null) {
            mInitBounds.set(appBounds);
        }
        final SurfaceControl swipePipToHomeOverlay = mPipOrganizer.mSwipePipToHomeOverlay;
        final SurfaceControl swipePipToHomeOverlay = mPipOrganizer.mPipOverlay;
        if (swipePipToHomeOverlay != null) {
            // Launcher fade in the overlay on top of the fullscreen Task. It is possible we
            // reparent the PIP activity to a new PIP task (in case there are other activities
@@ -1106,7 +1106,7 @@ public class PipTransition extends PipTransitionController {
        sendOnPipTransitionFinished(TRANSITION_DIRECTION_TO_PIP);
        if (swipePipToHomeOverlay != null) {
            mPipOrganizer.fadeOutAndRemoveOverlay(swipePipToHomeOverlay,
                    this::clearSwipePipToHomeOverlay /* callback */, false /* withStartDelay */);
                    this::clearPipOverlay /* callback */, false /* withStartDelay */);
        }
        mPipTransitionState.setInSwipePipToHomeTransition(false);
    }
@@ -1250,8 +1250,8 @@ public class PipTransition extends PipTransitionController {
        mPipMenuController.updateMenuBounds(destinationBounds);
    }

    private void clearSwipePipToHomeOverlay() {
        mPipOrganizer.mSwipePipToHomeOverlay = null;
    private void clearPipOverlay() {
        mPipOrganizer.mPipOverlay = null;
    }

    @Override