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

Commit 9ec4199d authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Implement auto-enter PiP2 in gesture nav [3/N]

Implement auto-enter PiP in PiP2 while in gesture
navigation mode.

Set config at end to true for the PiP task token
when requesting to handle enter PiP transition.

Make sure, we apply the correct startTransaction
in swipe PiP to Home when source-rect-hint is valid.

Bug: 325481148
Test: swipe up to enter PiP w/ auto-enter + valid src-rect-hint
Change-Id: Id6bdbd1951cb40b73a4f48b06dfa49f53c447205
parent 91e0ba18
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -226,7 +226,26 @@ public class PipTransition extends PipTransitionController {

        // cache the PiP task token and leash
        mPipScheduler.setPipTaskToken(mPipTaskToken);
        SurfaceControl pipLeash = pipChange.getLeash();

        PictureInPictureParams params = pipChange.getTaskInfo().pictureInPictureParams;
        Rect srcRectHint = params.getSourceRectHint();
        Rect destinationBounds = pipChange.getEndAbsBounds();

        if (PipBoundsAlgorithm.isSourceRectHintValidForEnterPip(srcRectHint, destinationBounds)) {
            float scale = (float) destinationBounds.width() / srcRectHint.width();
            startTransaction.setWindowCrop(pipLeash, srcRectHint);
            startTransaction.setPosition(pipLeash,
                    destinationBounds.left - srcRectHint.left * scale,
                    destinationBounds.top - srcRectHint.top * scale);

            // Reset the scale in case we are in the multi-activity case.
            // TO_FRONT transition already scales down the task in single-activity case, but
            // in multi-activity case, reparenting yields new reset scales coming from pinned task.
            startTransaction.setScale(pipLeash, scale, scale);
        } else {
            // TODO(b/325481148): handle the case with invalid srcRectHint (using overlay).
        }
        startTransaction.apply();
        finishCallback.onTransitionFinished(null);
        return true;
@@ -303,6 +322,7 @@ public class PipTransition extends PipTransitionController {

        WindowContainerTransaction wct = new WindowContainerTransaction();
        wct.movePipActivityToPinnedRootTask(pipTask.token, entryBounds);
        wct.deferConfigToTransitionEnd(pipTask.token);
        return wct;
    }