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

Commit 6e68af5e authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Update bounds on shelf/ime adjustment during transition

setShelfHeight can be called during the transition from fullscreen to
PiP, in which case, we simply update the destination bounds on the
animator.

Bug: 135529229
Test: manually enter/exit PiP
Change-Id: Id7ca6a1ed136765361305ee2832f204d9e594fd4
parent 0b74287b
Loading
Loading
Loading
Loading
+20 −14
Original line number Diff line number Diff line
@@ -319,24 +319,30 @@ public class PipTaskOrganizer extends TaskOrganizer {
     * TODO(b/152809058): consolidate the display info handling logic in SysUI
     */
    @SuppressWarnings("unchecked")
    public void mayUpdateCurrentAnimationOnRotationChange() {
    public void onMovementBoundsChanged(boolean fromImeAdjustment, boolean fromShelfAdjustment) {
        final PipAnimationController.PipTransitionAnimator animator =
                mPipAnimationController.getCurrentAnimator();
        if (animator != null && animator.isRunning()
                && animator.getTransitionDirection() == TRANSITION_DIRECTION_TO_PIP) {
        if (animator == null || !animator.isRunning()
                || animator.getTransitionDirection() != TRANSITION_DIRECTION_TO_PIP) {
            return;
        }

        final Rect currentDestinationBounds = animator.getDestinationBounds();
            if (mPipBoundsHandler.getDisplayBounds().contains(currentDestinationBounds)) {
        if (!fromImeAdjustment && !fromShelfAdjustment
                && mPipBoundsHandler.getDisplayBounds().contains(currentDestinationBounds)) {
            // no need to update the destination bounds, bail early
            return;
        }

        final Rect newDestinationBounds = mPipBoundsHandler.getDestinationBounds(
                getAspectRatioOrDefault(mTaskInfo.pictureInPictureParams),
                null /* bounds */, getMinimalSize(mTaskInfo.topActivityInfo));
        if (newDestinationBounds.equals(currentDestinationBounds)) return;
        if (animator.getAnimationType() == ANIM_TYPE_BOUNDS) {
            animator.updateEndValue(newDestinationBounds);
        }
        animator.setDestinationBounds(newDestinationBounds);
    }
    }

    /**
     * @return {@code true} if the aspect ratio is changed since no other parameters within
+1 −1
Original line number Diff line number Diff line
@@ -362,7 +362,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
        mTouchHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
                animatingBounds, fromImeAdjustment, fromShelfAdjustment,
                mTmpDisplayInfo.rotation);
        mPipTaskOrganizer.mayUpdateCurrentAnimationOnRotationChange();
        mPipTaskOrganizer.onMovementBoundsChanged(fromImeAdjustment, fromShelfAdjustment);
    }

    public void dump(PrintWriter pw) {