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

Commit a3f96997 authored by Mateusz Cicheński's avatar Mateusz Cicheński
Browse files

Enter PiP with fixed rotation restore reentry state correctly

Previously the maxSize was calculated on the previous orientation (e.g.
landscape), and thus lead to incorrect destination bounds.
This change makes sure that the maxSize used is for the correct
rotation and that PipTransition also applies the scaling correctly.

Also refactoring some of the PipTouchHandler to avoid duplicate
calculations.

Bug: 326490788
Test: after fix http://recall/-/ekEuGtt9d9HWqkUtAzpHx8/bngzAYINo6LsYv8Tdt9y31
Flag: none

Change-Id: I1e10b7d67f49399d9b869d02cff923b7ec104d88
parent bb859135
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -228,6 +228,14 @@ public class PipBoundsState {
        mExpandedMovementBounds.set(bounds);
    }

    /** Updates the min and max sizes based on the size spec and aspect ratio. */
    public void updateMinMaxSize(float aspectRatio) {
        final Size minSize = mSizeSpecSource.getMinSize(aspectRatio);
        mMinSize.set(minSize.getWidth(), minSize.getHeight());
        final Size maxSize = mSizeSpecSource.getMaxSize(aspectRatio);
        mMaxSize.set(maxSize.getWidth(), maxSize.getHeight());
    }

    /** Sets the max possible size for resize. */
    public void setMaxSize(int width, int height) {
        mMaxSize.set(width, height);
+1 −0
Original line number Diff line number Diff line
@@ -1037,6 +1037,7 @@ public class PipTransition extends PipTransitionController {
    private void computeEnterPipRotatedBounds(int rotationDelta, int startRotation, int endRotation,
            TaskInfo taskInfo, Rect outDestinationBounds, @Nullable Rect outSourceHintRect) {
        mPipDisplayLayoutState.rotateTo(endRotation);
        mPipBoundsState.updateMinMaxSize(mPipBoundsState.getAspectRatio());

        final Rect displayBounds = mPipDisplayLayoutState.getDisplayBounds();
        outDestinationBounds.set(mPipBoundsAlgorithm.getEntryDestinationBounds());
+8 −0
Original line number Diff line number Diff line
@@ -976,8 +976,16 @@ public class PipController implements PipTransitionController.PipTransitionCallb
        mPipBoundsState.addNamedUnrestrictedKeepClearArea(LAUNCHER_KEEP_CLEAR_AREA_TAG,
                hotseatKeepClearArea);
        onDisplayRotationChangedNotInPip(mContext, launcherRotation);
        // cache current min/max size
        Point minSize = mPipBoundsState.getMinSize();
        Point maxSize = mPipBoundsState.getMaxSize();
        mPipBoundsState.updateMinMaxSize(pictureInPictureParams.getAspectRatioFloat());
        final Rect entryBounds = mPipTaskOrganizer.startSwipePipToHome(componentName, activityInfo,
                pictureInPictureParams);
        // restore min/max size, as this is referenced later in OnDisplayChangingListener and needs
        // to reflect the pre-rotation state for it to work
        mPipBoundsState.setMinSize(minSize.x, minSize.y);
        mPipBoundsState.setMaxSize(maxSize.x, maxSize.y);
        // sync mPipBoundsState with the newly calculated bounds.
        mPipBoundsState.setNormalBounds(entryBounds);
        return entryBounds;
+5 −11
Original line number Diff line number Diff line
@@ -467,17 +467,11 @@ public class PipTouchHandler {
    }

    private void updatePinchResizeSizeConstraints(float aspectRatio) {
        final int minWidth, minHeight, maxWidth, maxHeight;

        minWidth = mSizeSpecSource.getMinSize(aspectRatio).getWidth();
        minHeight = mSizeSpecSource.getMinSize(aspectRatio).getHeight();
        maxWidth = mSizeSpecSource.getMaxSize(aspectRatio).getWidth();
        maxHeight = mSizeSpecSource.getMaxSize(aspectRatio).getHeight();

        mPipResizeGestureHandler.updateMinSize(minWidth, minHeight);
        mPipResizeGestureHandler.updateMaxSize(maxWidth, maxHeight);
        mPipBoundsState.setMaxSize(maxWidth, maxHeight);
        mPipBoundsState.setMinSize(minWidth, minHeight);
        mPipBoundsState.updateMinMaxSize(aspectRatio);
        mPipResizeGestureHandler.updateMinSize(mPipBoundsState.getMinSize().x,
                mPipBoundsState.getMinSize().y);
        mPipResizeGestureHandler.updateMaxSize(mPipBoundsState.getMaxSize().x,
                mPipBoundsState.getMaxSize().y);
    }

    /**