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

Commit bae6c26f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Ensure we account for insets in minimized state."

parents 00269391 114aeea5
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -128,11 +128,14 @@ public class PipSnapAlgorithm {
    /**
     * Applies the offset to the {@param stackBounds} to adjust it to a minimized state.
     */
    public void applyMinimizedOffset(Rect stackBounds, Rect movementBounds, Point displaySize) {
    public void applyMinimizedOffset(Rect stackBounds, Rect movementBounds, Point displaySize,
            Rect stableInsets) {
        if (stackBounds.left <= movementBounds.centerX()) {
            stackBounds.offsetTo(-stackBounds.width() + mMinimizedVisibleSize, stackBounds.top);
            stackBounds.offsetTo(stableInsets.left + mMinimizedVisibleSize - stackBounds.width(),
                    stackBounds.top);
        } else {
            stackBounds.offsetTo(displaySize.x - mMinimizedVisibleSize, stackBounds.top);
            stackBounds.offsetTo(displaySize.x - stableInsets.right - mMinimizedVisibleSize,
                    stackBounds.top);
        }
    }

+4 −1
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ public class PipTouchHandler implements TunerService.Tunable {
    // Allow the PIP to be "docked" slightly offscreen
    private boolean mEnableMinimizing = true;

    private final Rect mStableInsets = new Rect();
    private final Rect mPinnedStackBounds = new Rect();
    private final Rect mBoundedPinnedStackBounds = new Rect();
    private ValueAnimator mPinnedStackBoundsAnimator = null;
@@ -421,7 +422,8 @@ public class PipTouchHandler implements TunerService.Tunable {
        mContext.getDisplay().getRealSize(displaySize);
        Rect toBounds = mSnapAlgorithm.findClosestSnapBounds(mBoundedPinnedStackBounds,
                mPinnedStackBounds);
        mSnapAlgorithm.applyMinimizedOffset(toBounds, mBoundedPinnedStackBounds, displaySize);
        mSnapAlgorithm.applyMinimizedOffset(toBounds, mBoundedPinnedStackBounds, displaySize,
                mStableInsets);
        mPinnedStackBoundsAnimator = mMotionHelper.createAnimationToBounds(mPinnedStackBounds,
                toBounds, MINIMIZE_STACK_MAX_DURATION, LINEAR_OUT_SLOW_IN,
                mUpdatePinnedStackBoundsListener);
@@ -528,6 +530,7 @@ public class PipTouchHandler implements TunerService.Tunable {
                if (updatePinnedStackBounds) {
                    mPinnedStackBounds.set(info.bounds);
                }
                mWindowManager.getStableInsets(info.displayId, mStableInsets);
                mBoundedPinnedStackBounds.set(mWindowManager.getPictureInPictureMovementBounds(
                        info.displayId));
            }
+7 −3
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ class PinnedStackController {

    // Used to calculate stack bounds across rotations
    private final DisplayInfo mDisplayInfo = new DisplayInfo();
    private final Rect mStableInsets = new Rect();

    // The size and position information that describes where the pinned stack will go by default.
    private int mDefaultStackGravity;
@@ -250,10 +251,12 @@ class PinnedStackController {
    }

    /**
     * @return the repositioned PIP bounds given it's pre-change bounds, and the new display info.
     * @return the repositioned PIP bounds given it's pre-change bounds, and the new display
     *         content.
     */
    Rect onDisplayChanged(Rect preChangeStackBounds, DisplayInfo displayInfo) {
    Rect onDisplayChanged(Rect preChangeStackBounds, DisplayContent displayContent) {
        final Rect postChangeStackBounds = new Rect(preChangeStackBounds);
        final DisplayInfo displayInfo = displayContent.getDisplayInfo();
        if (!mDisplayInfo.equals(displayInfo)) {
            // Calculate the snap fraction of the current stack along the old movement bounds, and
            // then update the stack bounds to the same fraction along the rotated movement bounds.
@@ -269,8 +272,9 @@ class PinnedStackController {
            if (mIsMinimized) {
                final Point displaySize = new Point(mDisplayInfo.logicalWidth,
                        mDisplayInfo.logicalHeight);
                mService.getStableInsetsLocked(displayContent.getDisplayId(), mStableInsets);
                mSnapAlgorithm.applyMinimizedOffset(postChangeStackBounds, postChangeMovementBounds,
                        displaySize);
                        displaySize, mStableInsets);
            }
        }
        return postChangeStackBounds;
+2 −2
Original line number Diff line number Diff line
@@ -413,7 +413,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
        switch (mStackId) {
            case PINNED_STACK_ID:
                mTmpRect2 = mDisplayContent.getPinnedStackController().onDisplayChanged(mBounds,
                        getDisplayInfo());
                        mDisplayContent);
                break;
            case DOCKED_STACK_ID:
                repositionDockedStackAfterRotation(mTmpRect2);
@@ -684,7 +684,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
        // Update the pinned stack controller after the display info is updated
        if (mStackId == PINNED_STACK_ID) {
            mDisplayContent.getPinnedStackController().onDisplayChanged(oldBounds,
                    getDisplayInfo());
                    mDisplayContent);
        }

        super.onDisplayChanged(dc);