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

Commit 192b50d5 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Small fixes and tweaks to PiP transition."

parents f4284638 baa7b721
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -38,9 +38,11 @@ oneway interface IPinnedStackListener {
     * to be changed (ie. after configuration change, aspect ratio change, etc). It then provides
     * the components that allow the listener to calculate the movement bounds itself. The
     * {@param normalBounds} are also the default bounds that the PiP would be entered in its
     * current state with the aspect ratio applied.
     * current state with the aspect ratio applied.  The {@param animatingBounds} are provided
     * to indicate the current target bounds of the pinned stack (the final bounds if animating,
     * the current bounds if not), which may be helpful in calculating dependent animation bounds.
     */
    void onMovementBoundsChanged(in Rect insetBounds, in Rect normalBounds,
    void onMovementBoundsChanged(in Rect insetBounds, in Rect normalBounds, in Rect animatingBounds,
            boolean fromImeAdjustement);

    /**
+3 −2
Original line number Diff line number Diff line
@@ -122,9 +122,10 @@ public class PipManager implements BasePipManager {

        @Override
        public void onMovementBoundsChanged(Rect insetBounds, Rect normalBounds,
                boolean fromImeAdjustement) {
                Rect animatingBounds, boolean fromImeAdjustement) {
            mHandler.post(() -> {
                mTouchHandler.onMovementBoundsChanged(insetBounds, normalBounds, fromImeAdjustement);
                mTouchHandler.onMovementBoundsChanged(insetBounds, normalBounds, animatingBounds,
                        fromImeAdjustement);
            });
        }

+12 −15
Original line number Diff line number Diff line
@@ -57,10 +57,11 @@ public class PipMotionHelper {
    private static final int DEFAULT_MOVE_STACK_DURATION = 225;
    private static final int SNAP_STACK_DURATION = 225;
    private static final int DISMISS_STACK_DURATION = 375;
    private static final int SHRINK_STACK_FROM_MENU_DURATION = 150;
    private static final int EXPAND_STACK_TO_MENU_DURATION = 150;
    private static final int EXPAND_STACK_TO_FULLSCREEN_DURATION = 225;
    private static final int SHRINK_STACK_FROM_MENU_DURATION = 250;
    private static final int EXPAND_STACK_TO_MENU_DURATION = 250;
    private static final int EXPAND_STACK_TO_FULLSCREEN_DURATION = 300;
    private static final int MINIMIZE_STACK_MAX_DURATION = 200;
    private static final int IME_SHIFT_DURATION = 300;

    // The fraction of the stack width that the user has to drag offscreen to minimize the PiP
    private static final float MINIMIZE_OFFSCREEN_FRACTION = 0.2f;
@@ -288,6 +289,14 @@ public class PipMotionHelper {
        resizeAndAnimatePipUnchecked(normalBounds, SHRINK_STACK_FROM_MENU_DURATION);
    }

    /**
     * Animates the PiP to offset it from the IME.
     */
    void animateToIMEOffset(Rect toBounds) {
        cancelAnimations();
        resizeAndAnimatePipUnchecked(toBounds, IME_SHIFT_DURATION);
    }

    /**
     * Animates the dismissal of the PiP over the dismiss target bounds.
     */
@@ -309,18 +318,6 @@ public class PipMotionHelper {
        return toBounds;
    }

    /**
     * Animates the PiP to some given bounds.
     */
    void animateToBounds(Rect toBounds) {
        cancelAnimations();
        if (!mBounds.equals(toBounds)) {
            mBoundsAnimator = createAnimationToBounds(mBounds, toBounds,
                    DEFAULT_MOVE_STACK_DURATION, FAST_OUT_LINEAR_IN, mUpdateBoundsListener);
            mBoundsAnimator.start();
        }
    }

    /**
     * Cancels all existing animations.
     */
+3 −3
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ public class PipTouchHandler {
        mImeHeight = imeHeight;
    }

    public void onMovementBoundsChanged(Rect insetBounds, Rect normalBounds,
    public void onMovementBoundsChanged(Rect insetBounds, Rect normalBounds, Rect animatingBounds,
            boolean fromImeAdjustement) {
        // Re-calculate the expanded bounds
        mNormalBounds = normalBounds;
@@ -207,7 +207,7 @@ public class PipTouchHandler {
                // Defer the update of the current movement bounds until after the user finishes
                // touching the screen
            } else {
                final Rect bounds = new Rect(mMotionHelper.getBounds());
                final Rect bounds = new Rect(animatingBounds);
                final Rect toMovementBounds = mIsMenuVisible
                        ? expandedMovementBounds
                        : normalMovementBounds;
@@ -227,7 +227,7 @@ public class PipTouchHandler {
                        bounds.offsetTo(bounds.left, toMovementBounds.bottom);
                    }
                }
                mMotionHelper.animateToBounds(bounds);
                mMotionHelper.animateToIMEOffset(bounds);
            }
        }

+1 −1
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ public class PipManager implements BasePipManager {

        @Override
        public void onMovementBoundsChanged(Rect insetBounds, Rect normalBounds,
                boolean fromImeAdjustement) {
                Rect animatingBounds, boolean fromImeAdjustement) {
            mHandler.post(() -> {
                mDefaultPipBounds.set(normalBounds);
            });
Loading