From 9b9c7d019b55a00c50964307a037620de225bbce Mon Sep 17 00:00:00 2001 From: "jorgegil@google.com" Date: Fri, 14 Aug 2020 17:33:28 -0700 Subject: Invalidate resized bounds on aspect ratio changes When the aspect ratio is changed on the pinned window, the previously saved user-resize bounds are used as the restore bounds when unexpanding, which have the previous aspect ratio still. This change invalidates the user resized bounds on aspect ratio changes, which then forces it to be re-set to the new normal bounds. Bug: 163420655 Test: PIP portrait Youtube video, touch to expand menu, click 'next' icon to switch to a landscape video. The landscape video should restore to its unexpanded bounds with the correct aspect ratio. Change-Id: I808993a921e3dc3858fad2c131e6a86bf45955e0 --- .../src/com/android/systemui/pip/phone/PipManager.java | 5 ++++- .../android/systemui/pip/phone/PipResizeGestureHandler.java | 4 ++++ .../src/com/android/systemui/pip/phone/PipTouchHandler.java | 13 +++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) (limited to 'packages/SystemUI') diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java index 9dfa864e2ee7..d96f7dde0dff 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java @@ -233,7 +233,10 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio @Override public void onAspectRatioChanged(float aspectRatio) { - mHandler.post(() -> mPipBoundsHandler.onAspectRatioChanged(aspectRatio)); + mHandler.post(() -> { + mPipBoundsHandler.onAspectRatioChanged(aspectRatio); + mTouchHandler.onAspectRatioChanged(); + }); } } diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java index 9c42f8bff378..2800bb938149 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java @@ -364,6 +364,10 @@ public class PipResizeGestureHandler { mUserResizeBounds.set(bounds); } + void invalidateUserResizeBounds() { + mUserResizeBounds.setEmpty(); + } + Rect getUserResizeBounds() { return mUserResizeBounds; } diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java index b20ea4e5c836..ecd315b336f2 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java @@ -426,8 +426,21 @@ public class PipTouchHandler { } } + /** + * Responds to IPinnedStackListener on resetting aspect ratio for the pinned window. + */ + public void onAspectRatioChanged() { + mPipResizeGestureHandler.invalidateUserResizeBounds(); + } + public void onMovementBoundsChanged(Rect insetBounds, Rect normalBounds, Rect curBounds, boolean fromImeAdjustment, boolean fromShelfAdjustment, int displayRotation) { + // Set the user resized bounds equal to the new normal bounds in case they were + // invalidated (e.g. by an aspect ratio change). + if (mPipResizeGestureHandler.getUserResizeBounds().isEmpty()) { + mPipResizeGestureHandler.setUserResizeBounds(normalBounds); + } + final int bottomOffset = mIsImeShowing ? mImeHeight : 0; final boolean fromDisplayRotationChanged = (mDisplayRotation != displayRotation); if (fromDisplayRotationChanged) { -- cgit v1.2.3-59-g8ed1b