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

Commit dc2fe53e authored by Jorge Gil's avatar Jorge Gil Committed by Android (Google) Code Review
Browse files

Merge "Use PipBoundsState to access current bounds"

parents 87b1ff6c 5b9f045c
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -105,8 +105,8 @@ public class PipAccessibilityInteractionConnection

            // R constants are not final so this cannot be put in the switch-case.
            if (action == R.id.action_pip_resize) {
                if (mMotionHelper.getBounds().width() == mNormalBounds.width()
                        && mMotionHelper.getBounds().height() == mNormalBounds.height()) {
                if (mPipBoundsState.getBounds().width() == mNormalBounds.width()
                        && mPipBoundsState.getBounds().height() == mNormalBounds.height()) {
                    setToExpandedBounds();
                } else {
                    setToNormalBounds();
@@ -130,7 +130,7 @@ public class PipAccessibilityInteractionConnection
                        int newY = arguments.getInt(
                                AccessibilityNodeInfo.ACTION_ARGUMENT_MOVE_WINDOW_Y);
                        Rect pipBounds = new Rect();
                        pipBounds.set(mMotionHelper.getBounds());
                        pipBounds.set(mPipBoundsState.getBounds());
                        mTmpBounds.offsetTo(newX, newY);
                        mMotionHelper.movePip(mTmpBounds);
                        result = true;
+1 −3
Original line number Diff line number Diff line
@@ -348,10 +348,8 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,

    /**
     * @return the PiP bounds.
     *
     * TODO(b/169373982): can be private, outside callers can use PipBoundsState directly.
     */
    Rect getBounds() {
    private Rect getBounds() {
        return mPipBoundsState.getBounds();
    }

+7 −7
Original line number Diff line number Diff line
@@ -296,7 +296,7 @@ public class PipResizeGestureHandler {
     * |_|_|         |_|_|
     */
    public boolean isWithinTouchRegion(int x, int y) {
        final Rect currentPipBounds = mMotionHelper.getBounds();
        final Rect currentPipBounds = mPipBoundsState.getBounds();
        if (currentPipBounds == null) {
            return false;
        }
@@ -349,8 +349,8 @@ public class PipResizeGestureHandler {
    }

    private void setCtrlTypeForPinchToZoom() {
        final Rect currentPipBounds = mMotionHelper.getBounds();
        mLastDownBounds.set(mMotionHelper.getBounds());
        final Rect currentPipBounds = mPipBoundsState.getBounds();
        mLastDownBounds.set(mPipBoundsState.getBounds());

        Rect movementBounds = mMovementBoundsSupplier.apply(currentPipBounds);
        mDisplayBounds.set(movementBounds.left,
@@ -372,7 +372,7 @@ public class PipResizeGestureHandler {
    }

    private void setCtrlType(int x, int y) {
        final Rect currentPipBounds = mMotionHelper.getBounds();
        final Rect currentPipBounds = mPipBoundsState.getBounds();

        Rect movementBounds = mMovementBoundsSupplier.apply(currentPipBounds);
        mDisplayBounds.set(movementBounds.left,
@@ -413,13 +413,13 @@ public class PipResizeGestureHandler {
        float x = ev.getX();
        float y = ev.getY();
        if (action == MotionEvent.ACTION_DOWN) {
            final Rect currentPipBounds = mMotionHelper.getBounds();
            final Rect currentPipBounds = mPipBoundsState.getBounds();
            mLastResizeBounds.setEmpty();
            mAllowGesture = isInValidSysUiState() && isWithinTouchRegion((int) x, (int) y);
            if (mAllowGesture) {
                setCtrlType((int) x, (int) y);
                mDownPoint.set(x, y);
                mLastDownBounds.set(mMotionHelper.getBounds());
                mLastDownBounds.set(mPipBoundsState.getBounds());
            }
            if (!currentPipBounds.contains((int) ev.getX(), (int) ev.getY())
                    && mPipMenuActivityController.isMenuVisible()) {
@@ -446,7 +446,7 @@ public class PipResizeGestureHandler {
                            mPipMenuActivityController.hideMenuWithoutResize();
                            mPipMenuActivityController.hideMenu();
                        }
                        final Rect currentPipBounds = mMotionHelper.getBounds();
                        final Rect currentPipBounds = mPipBoundsState.getBounds();
                        mLastResizeBounds.set(TaskResizingAlgorithm.resizeDrag(x, y,
                                mDownPoint.x, mDownPoint.y, currentPipBounds, mCtrlType, mMinSize.x,
                                mMinSize.y, mMaxSize, true,
+14 −13
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ public class PipTouchHandler {

        @Override
        public void onPipShowMenu() {
            mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
            mMenuController.showMenu(MENU_STATE_FULL, mPipBoundsState.getBounds(),
                    true /* allowMenuTimeout */, willResizeMenu(), shouldShowResizeHandle());
        }
    }
@@ -176,8 +176,9 @@ public class PipTouchHandler {
        mPipDismissTargetHandler = new PipDismissTargetHandler(context, pipUiEventLogger,
                mMotionHelper, mHandler);
        mTouchState = new PipTouchState(ViewConfiguration.get(context), mHandler,
                () -> mMenuController.showMenuWithDelay(MENU_STATE_FULL, mMotionHelper.getBounds(),
                        true /* allowMenuTimeout */, willResizeMenu(), shouldShowResizeHandle()),
                () -> mMenuController.showMenuWithDelay(MENU_STATE_FULL,
                        mPipBoundsState.getBounds(), true /* allowMenuTimeout */, willResizeMenu(),
                        shouldShowResizeHandle()),
                menuController::hideMenu);

        Resources res = context.getResources();
@@ -229,7 +230,7 @@ public class PipTouchHandler {
    public void showPictureInPictureMenu() {
        // Only show the menu if the user isn't currently interacting with the PiP
        if (!mTouchState.isUserInteracting()) {
            mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
            mMenuController.showMenu(MENU_STATE_FULL, mPipBoundsState.getBounds(),
                    false /* allowMenuTimeout */, willResizeMenu(),
                    shouldShowResizeHandle());
        }
@@ -265,11 +266,11 @@ public class PipTouchHandler {
        updateMovementBounds();
        if (direction == TRANSITION_DIRECTION_TO_PIP) {
            // Set the initial bounds as the user resize bounds.
            mPipResizeGestureHandler.setUserResizeBounds(mMotionHelper.getBounds());
            mPipResizeGestureHandler.setUserResizeBounds(mPipBoundsState.getBounds());
        }

        if (mShowPipMenuOnAnimationEnd) {
            mMenuController.showMenu(MENU_STATE_CLOSE, mMotionHelper.getBounds(),
            mMenuController.showMenu(MENU_STATE_CLOSE, mPipBoundsState.getBounds(),
                    true /* allowMenuTimeout */, false /* willResizeMenu */,
                    shouldShowResizeHandle());
            mShowPipMenuOnAnimationEnd = false;
@@ -446,7 +447,7 @@ public class PipTouchHandler {
    }

    private void onAccessibilityShowMenu() {
        mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
        mMenuController.showMenu(MENU_STATE_FULL, mPipBoundsState.getBounds(),
                true /* allowMenuTimeout */, willResizeMenu(),
                shouldShowResizeHandle());
    }
@@ -529,7 +530,7 @@ public class PipTouchHandler {
                // Let's not enable menu show/hide for a11y services.
                if (!mAccessibilityManager.isTouchExplorationEnabled()) {
                    mTouchState.removeHoverExitTimeoutCallback();
                    mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
                    mMenuController.showMenu(MENU_STATE_FULL, mPipBoundsState.getBounds(),
                            false /* allowMenuTimeout */, false /* willResizeMenu */,
                            shouldShowResizeHandle());
                }
@@ -773,7 +774,7 @@ public class PipTouchHandler {
                if (mMenuState != MENU_STATE_NONE) {
                    // If the menu is still visible, then just poke the menu so that
                    // it will timeout after the user stops touching it
                    mMenuController.showMenu(mMenuState, mMotionHelper.getBounds(),
                    mMenuController.showMenu(mMenuState, mPipBoundsState.getBounds(),
                            true /* allowMenuTimeout */, willResizeMenu(),
                            shouldShowResizeHandle());
                }
@@ -797,9 +798,9 @@ public class PipTouchHandler {
            } else if (mTouchState.isDoubleTap() && !mPipBoundsState.isStashed()) {
                // If using pinch to zoom, double-tap functions as resizing between max/min size
                if (mPipResizeGestureHandler.isUsingPinchToZoom()) {
                    final boolean toExpand = mMotionHelper.getBounds().width()
                    final boolean toExpand = mPipBoundsState.getBounds().width()
                            < mPipBoundsState.getExpandedBounds().width()
                            && mMotionHelper.getBounds().height()
                            && mPipBoundsState.getBounds().height()
                            < mPipBoundsState.getExpandedBounds().height();
                    mPipResizeGestureHandler.setUserResizeBounds(toExpand
                            ? mPipBoundsState.getExpandedBounds()
@@ -819,7 +820,7 @@ public class PipTouchHandler {
                if (!mTouchState.isWaitingForDoubleTap()) {
                    // User has stalled long enough for this not to be a drag or a double tap, just
                    // expand the menu
                    mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
                    mMenuController.showMenu(MENU_STATE_FULL, mPipBoundsState.getBounds(),
                            true /* allowMenuTimeout */, willResizeMenu(),
                            shouldShowResizeHandle());
                } else {
@@ -864,7 +865,7 @@ public class PipTouchHandler {
     * resized.
     */
    private void updateMovementBounds() {
        mPipBoundsAlgorithm.getSnapAlgorithm().getMovementBounds(mMotionHelper.getBounds(),
        mPipBoundsAlgorithm.getSnapAlgorithm().getMovementBounds(mPipBoundsState.getBounds(),
                mInsetBounds, mPipBoundsState.getMovementBounds(), mIsImeShowing ? mImeHeight : 0);
        mMotionHelper.onMovementBoundsChanged();