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

Commit e33543ff authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Refactor how we calculate offset for PIP animation" into pi-dev

parents 5fa492f9 4be72d22
Loading
Loading
Loading
Loading
+18 −23
Original line number Original line Diff line number Diff line
@@ -284,14 +284,19 @@ public class PipTouchHandler {
                // Defer the update of the current movement bounds until after the user finishes
                // Defer the update of the current movement bounds until after the user finishes
                // touching the screen
                // touching the screen
            } else {
            } else {
                final Rect toMovementBounds = mMenuState == MENU_STATE_FULL
                final int adjustedOffset = Math.max(mIsImeShowing ? mImeHeight + mImeOffset : 0,
                        ? expandedMovementBounds
                        mIsShelfShowing ? mShelfHeight : 0);
                        : normalMovementBounds;
                Rect normalAdjustedBounds = new Rect();
                animateToOffset(animatingBounds, toMovementBounds,
                mSnapAlgorithm.getMovementBounds(mNormalBounds, insetBounds, normalAdjustedBounds,
                        fromImeAdjustment,
                        adjustedOffset);
                        fromImeAdjustment ? mIsImeShowing : mIsShelfShowing,
                Rect expandedAdjustedBounds = new Rect();
                        // Shelf height serves as an offset, but does not change movement bounds.
                mSnapAlgorithm.getMovementBounds(mExpandedBounds, insetBounds,
                        fromImeAdjustment ? mImeOffset : mShelfHeight);
                        expandedAdjustedBounds, adjustedOffset);
                final Rect toAdjustedBounds = mMenuState == MENU_STATE_FULL
                        ? expandedAdjustedBounds
                        : normalAdjustedBounds;

                animateToOffset(animatingBounds, toAdjustedBounds);
            }
            }
        }
        }


@@ -313,23 +318,13 @@ public class PipTouchHandler {
        }
        }
    }
    }


    private void animateToOffset(Rect animatingBounds, Rect toMovementBounds,
    private void animateToOffset(Rect animatingBounds, Rect toAdjustedBounds) {
            boolean fromImeAdjustment, boolean showing, int offset) {
        final Rect bounds = new Rect(animatingBounds);
        final Rect bounds = new Rect(animatingBounds);
        if (showing) {
        if (toAdjustedBounds.bottom < mMovementBounds.bottom
            // IME/shelf visible, apply the IME/shelf offset if the space allows for it
                && bounds.top < toAdjustedBounds.bottom) {
            final int calculatedOffset = toMovementBounds.bottom - Math.max(toMovementBounds.top,
            return;
                    toMovementBounds.bottom - offset);
            bounds.offset(0,
                    Math.min(0, toMovementBounds.bottom - calculatedOffset - bounds.top));
        } else {
            // IME/shelf hidden
            if (bounds.top >= (mMovementBounds.bottom - offset)) {
                bounds.offset(0, toMovementBounds.bottom - bounds.top -
                        // Counter going back home from search where keyboard is up.
                        (fromImeAdjustment ? mShelfHeight : 0));
            }
        }
        }
        bounds.offset(0, toAdjustedBounds.bottom - bounds.top);
        mMotionHelper.animateToOffset(bounds);
        mMotionHelper.animateToOffset(bounds);
    }
    }