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

Commit c95ff843 authored by Winson Chung's avatar Winson Chung
Browse files

Prevent updating aspect ratio unless it is different.

- The old check of the bounds assumed there was no expanded state, so when
  a PiP activity tries to set the aspect ratio from a a menu action, it
  will cause an animation to the normal bounds again.

Bug: 36462497
Test: Set aspect ratio in pip action handler
Change-Id: Iba5e9571a3024c8369c2a24d32c2d8f34831ede4
parent 914c4ab1
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -298,6 +298,13 @@ class PinnedStackController {
        }
    }

    /**
     * @return the current aspect ratio.
     */
    float getAspectRatio() {
        return mAspectRatio;
    }

    /**
     * Sets the current set of actions.
     */
+9 −11
Original line number Diff line number Diff line
@@ -79,21 +79,19 @@ public class PinnedStackWindowController extends StackWindowController {
                return;
            }

            final PinnedStackController pinnedStackController =
                    mContainer.getDisplayContent().getPinnedStackController();

            if (Float.compare(aspectRatio, pinnedStackController.getAspectRatio()) != 0) {
                final int displayId = mContainer.getDisplayContent().getDisplayId();
                final Rect toBounds = mService.getPictureInPictureBounds(displayId, aspectRatio);
            final Rect targetBounds = new Rect();
            mContainer.getAnimatingBounds(targetBounds);
            if (!toBounds.equals(targetBounds)) {
                animateResizePinnedStack(toBounds, -1 /* duration */);
            }

            final PinnedStackController pinnedStackController =
                    mContainer.getDisplayContent().getPinnedStackController();
                pinnedStackController.setAspectRatio(
                        pinnedStackController.isValidPictureInPictureAspectRatio(aspectRatio)
                                ? aspectRatio : -1f);
            }
        }
    }

    /**
     * Sets the current picture-in-picture actions.