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

Commit d5d37746 authored by Simon (Qiong) Sun's avatar Simon (Qiong) Sun
Browse files

Check and move the the PiP window bounds after a fling transition.

- Ignore PiP window bounds check when IME becomes visible and PiP is already in motion (eg: fling)
- Check and move PiP window bounds after fling transition

Bug: 373717506
Flag: com.android.wm.shell.enable_pip2
Video: http://recall/-/enO6UfsUvbbP010y4Er8TK/djheyKZFEByF037Nr7KBhF
Test: Fling PiP window when entering IME.

Change-Id: I4da70bcf0de45ca880c554fe44cd1548d77d8d31
parent bd599322
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);