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

Commit eb02bd46 authored by Tracy Zhou's avatar Tracy Zhou Committed by android-build-merger
Browse files

Merge "Only move PIP window if PIP is not way above shelf/IME." into pi-dev

am: 0c97d089

Change-Id: I32ca69f9ad41c756b774a62d9afdcbc8edb19316
parents 5b9df55b 0c97d089
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -295,6 +295,26 @@ public class PipTouchHandler {
                final Rect toAdjustedBounds = mMenuState == MENU_STATE_FULL
                        ? expandedAdjustedBounds
                        : normalAdjustedBounds;
                final Rect toMovementBounds = mMenuState == MENU_STATE_FULL
                        ? expandedMovementBounds
                        : normalMovementBounds;

                // If the PIP window needs to shift to right above shelf/IME and it's already above
                // that, don't move the PIP window.
                if (toAdjustedBounds.bottom < mMovementBounds.bottom
                        && animatingBounds.top < toAdjustedBounds.bottom) {
                    return;
                }

                // If the PIP window needs to shift down due to dismissal of shelf/IME but it's way
                // above the position as if shelf/IME shows, don't move the PIP window.
                int movementBoundsAdjustment = toMovementBounds.bottom - mMovementBounds.bottom;
                int offsetAdjustment = fromImeAdjustment ? mImeOffset : mShelfHeight;
                if (toAdjustedBounds.bottom >= mMovementBounds.bottom
                        && animatingBounds.top
                        < toAdjustedBounds.bottom - movementBoundsAdjustment - offsetAdjustment) {
                    return;
                }

                animateToOffset(animatingBounds, toAdjustedBounds);
            }
@@ -320,10 +340,6 @@ public class PipTouchHandler {

    private void animateToOffset(Rect animatingBounds, Rect toAdjustedBounds) {
        final Rect bounds = new Rect(animatingBounds);
        if (toAdjustedBounds.bottom < mMovementBounds.bottom
                && bounds.top < toAdjustedBounds.bottom) {
            return;
        }
        bounds.offset(0, toAdjustedBounds.bottom - bounds.top);
        // In landscape mode, PIP window can go offset while launching IME. We want to align the
        // the top of the PIP window with the top of the movement bounds in that case.