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

Commit a86cdec6 authored by Ikram Gabiyev's avatar Ikram Gabiyev Committed by Android (Google) Code Review
Browse files

Merge "Update userResizeBounds onMovementBoundsChange" into main

parents 2bba79b7 bb55a7f1
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -222,7 +222,10 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha
                pipBoundsState, mTouchState, mPipScheduler, mPipTransitionState, pipUiEventLogger,
                menuController, mainExecutor,
                mPipPerfHintController);
        mPipBoundsState.addOnAspectRatioChangedCallback(this::updateMinMaxSize);
        mPipBoundsState.addOnAspectRatioChangedCallback(aspectRatio -> {
            updateMinMaxSize(aspectRatio);
            onAspectRatioChanged();
        });

        mMoveOnShelVisibilityChanged = () -> {
            if (mIsImeShowing && mImeHeight > mShelfHeight) {
@@ -768,16 +771,17 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha
    private void animateToNormalSize(Runnable callback) {
        // Save the current bounds as the user-resize bounds.
        mPipResizeGestureHandler.setUserResizeBounds(mPipBoundsState.getBounds());
        final Rect adjustedNormalBounds = getAdjustedNormalBounds();
        mSavedSnapFraction = mMotionHelper.animateToExpandedState(adjustedNormalBounds,
                getMovementBounds(mPipBoundsState.getBounds()),
                getMovementBounds(adjustedNormalBounds), callback /* callback */);
    }

    private Rect getAdjustedNormalBounds() {
        final Size minMenuSize = mMenuController.getEstimatedMinMenuSize();
        final Size defaultSize = mSizeSpecSource.getDefaultSize(mPipBoundsState.getAspectRatio());
        final Rect normalBounds = new Rect(0, 0, defaultSize.getWidth(), defaultSize.getHeight());
        final Rect adjustedNormalBounds = mPipBoundsAlgorithm.adjustNormalBoundsToFitMenu(
                normalBounds, minMenuSize);

        mSavedSnapFraction = mMotionHelper.animateToExpandedState(adjustedNormalBounds,
                getMovementBounds(mPipBoundsState.getBounds()),
                getMovementBounds(adjustedNormalBounds), callback /* callback */);
        return mPipBoundsAlgorithm.adjustNormalBoundsToFitMenu(normalBounds, minMenuSize);
    }

    private void animateToUnexpandedState(Rect restoreBounds) {
@@ -1065,6 +1069,10 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha
        mPipBoundsAlgorithm.getMovementBounds(mPipBoundsState.getBounds(),
                insetBounds, mPipBoundsState.getMovementBounds(), mIsImeShowing ? mImeHeight : 0);
        mMotionHelper.onMovementBoundsChanged();

        if (mPipResizeGestureHandler.getUserResizeBounds().isEmpty()) {
            mPipResizeGestureHandler.setUserResizeBounds(getAdjustedNormalBounds());
        }
    }

    private Rect getMovementBounds(Rect curBounds) {