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

Commit 92ee38e0 authored by Simon (Qiong) Sun's avatar Simon (Qiong) Sun Committed by Android (Google) Code Review
Browse files

Merge "Check and move the the PiP window bounds after a fling transition." into main

parents 2b10d206 d5d37746
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -773,6 +773,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
                if (mWaitingForFlingTransition) {
                    mWaitingForFlingTransition = false;
                    handleFlingTransition(startTx, finishTx, destinationBounds);
                    settlePipBoundsAfterFling();
                } else if (mWaitingToPlayBoundsChangeTransition) {
                    mWaitingToPlayBoundsChangeTransition = false;
                    startResizeAnimation(startTx, finishTx, destinationBounds, duration);
@@ -813,6 +814,17 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
        mPipScheduler.scheduleFinishPipBoundsChange(destinationBounds);
    }

    private void settlePipBoundsAfterFling() {
        mPipTransitionState.setOnIdlePipTransitionStateRunnable(() -> {
            final int delta =
                    mPipBoundsState.getMovementBounds().bottom - mPipBoundsState.getBounds().top;
            if (delta < 0) {
                // Move the PiP window to the movementBounds.
                animateToOffset(mPipBoundsState.getBounds(), delta);
            }
        });
    }

    private void startResizeAnimation(SurfaceControl.Transaction startTx,
            SurfaceControl.Transaction finishTx, Rect destinationBounds, int duration) {
        SurfaceControl pipLeash = mPipTransitionState.getPinnedTaskLeash();
+6 −1
Original line number Diff line number Diff line
@@ -386,8 +386,12 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha

        // Cache new movement bounds using the new potential IME height.
        updateMovementBounds();

        mPipTransitionState.setOnIdlePipTransitionStateRunnable(() -> {
            if (imeVisible && mPipBoundsState.getMotionBoundsState().isInMotion()) {
                // Skip updating bounds now as it will be done after the animation settles
                return;
            }

            int delta = mPipBoundsState.getMovementBounds().bottom
                    - mPipBoundsState.getBounds().top;
            boolean hasUserInteracted = (mPipBoundsState.hasUserMovedPip()
@@ -1044,6 +1048,7 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha
     */
    void updateMovementBounds() {
        Rect insetBounds = new Rect();
        mPipBoundsState.setImeVisibility(mIsImeShowing, mIsImeShowing ? mImeHeight : 0);
        mPipBoundsAlgorithm.getInsetBounds(insetBounds);
        mPipBoundsAlgorithm.getMovementBounds(mPipBoundsState.getBounds(),
                insetBounds, mPipBoundsState.getMovementBounds(), mIsImeShowing ? mImeHeight : 0);