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

Commit baa7b721 authored by Winson Chung's avatar Winson Chung
Browse files

Small fixes and tweaks to PiP transition.

- Fixing case where default bounds did not account for ime height
- Ensuring that we using the animating/target bounds when calculating
  the new ime-offset bounds
- Tweaking transition interpolators and durations

Bug: 35396882
Test: android.server.cts.ActivityManagerPinnedStackTests
Change-Id: Ia22ea0008d834c47a3f26bf2e1f484c72fae8736
parent a7f69740
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line 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
     * 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
     * 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
     * {@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);
            boolean fromImeAdjustement);


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


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


+12 −15
Original line number Original line 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 DEFAULT_MOVE_STACK_DURATION = 225;
    private static final int SNAP_STACK_DURATION = 225;
    private static final int SNAP_STACK_DURATION = 225;
    private static final int DISMISS_STACK_DURATION = 375;
    private static final int DISMISS_STACK_DURATION = 375;
    private static final int SHRINK_STACK_FROM_MENU_DURATION = 150;
    private static final int SHRINK_STACK_FROM_MENU_DURATION = 250;
    private static final int EXPAND_STACK_TO_MENU_DURATION = 150;
    private static final int EXPAND_STACK_TO_MENU_DURATION = 250;
    private static final int EXPAND_STACK_TO_FULLSCREEN_DURATION = 225;
    private static final int EXPAND_STACK_TO_FULLSCREEN_DURATION = 300;
    private static final int MINIMIZE_STACK_MAX_DURATION = 200;
    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
    // 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;
    private static final float MINIMIZE_OFFSCREEN_FRACTION = 0.2f;
@@ -288,6 +289,14 @@ public class PipMotionHelper {
        resizeAndAnimatePipUnchecked(normalBounds, SHRINK_STACK_FROM_MENU_DURATION);
        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.
     * Animates the dismissal of the PiP over the dismiss target bounds.
     */
     */
@@ -309,18 +318,6 @@ public class PipMotionHelper {
        return toBounds;
        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.
     * Cancels all existing animations.
     */
     */
+3 −3
Original line number Original line Diff line number Diff line
@@ -180,7 +180,7 @@ public class PipTouchHandler {
        mImeHeight = imeHeight;
        mImeHeight = imeHeight;
    }
    }


    public void onMovementBoundsChanged(Rect insetBounds, Rect normalBounds,
    public void onMovementBoundsChanged(Rect insetBounds, Rect normalBounds, Rect animatingBounds,
            boolean fromImeAdjustement) {
            boolean fromImeAdjustement) {
        // Re-calculate the expanded bounds
        // Re-calculate the expanded bounds
        mNormalBounds = normalBounds;
        mNormalBounds = normalBounds;
@@ -207,7 +207,7 @@ 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 bounds = new Rect(mMotionHelper.getBounds());
                final Rect bounds = new Rect(animatingBounds);
                final Rect toMovementBounds = mIsMenuVisible
                final Rect toMovementBounds = mIsMenuVisible
                        ? expandedMovementBounds
                        ? expandedMovementBounds
                        : normalMovementBounds;
                        : normalMovementBounds;
@@ -227,7 +227,7 @@ public class PipTouchHandler {
                        bounds.offsetTo(bounds.left, toMovementBounds.bottom);
                        bounds.offsetTo(bounds.left, toMovementBounds.bottom);
                    }
                    }
                }
                }
                mMotionHelper.animateToBounds(bounds);
                mMotionHelper.animateToIMEOffset(bounds);
            }
            }
        }
        }


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


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