summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ikram Gabiyev <gabiyev@google.com> 2024-12-04 13:26:15 -0800
committer Ikram Gabiyev <gabiyev@google.com> 2024-12-04 13:26:15 -0800
commitbb55a7f10b136a12ad5e0fb3670eca3389963038 (patch)
treecf4f04b472a9fc43db8f6efbc2ff20e150d8e563
parent27d12132f097274645fc1e0ae997ccf92e9028c6 (diff)
Update userResizeBounds onMovementBoundsChange
When exiting PiP, onActivityUnpinned() clears PipResizeGestureHandler#mUserResizeBounds. So we need to make sure they are updated to normal bounds whenever movement bounds are updated. Movement bounds will also be updated upon entering PiP and upon aspect ratio changes. Bug: 381350374 Flag: com.android.wm.shell.enable_pip2 Test: enter PiP, double-tap, tap expand menu icon, enter PiP, double-tap Change-Id: Ib2064f2b8d6a05c45aaac76071d0e1946ee097f3
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTouchHandler.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTouchHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTouchHandler.java
index 44cc563eadf4..fc3fbe299605 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTouchHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTouchHandler.java
@@ -222,7 +222,10 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha
pipBoundsState, mTouchState, mPipScheduler, mPipTransitionState, pipUiEventLogger,
menuController, mainExecutor,
mPipPerfHintController);
- mPipBoundsState.addOnAspectRatioChangedCallback(this::updateMinMaxSize);
+ mPipBoundsState.addOnAspectRatioChangedCallback(aspectRatio -> {
+ updateMinMaxSize(aspectRatio);
+ onAspectRatioChanged();
+ });
mMoveOnShelVisibilityChanged = () -> {
if (mIsImeShowing && mImeHeight > mShelfHeight) {
@@ -768,16 +771,17 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha
private void animateToNormalSize(Runnable callback) {
// Save the current bounds as the user-resize bounds.
mPipResizeGestureHandler.setUserResizeBounds(mPipBoundsState.getBounds());
+ final Rect adjustedNormalBounds = getAdjustedNormalBounds();
+ mSavedSnapFraction = mMotionHelper.animateToExpandedState(adjustedNormalBounds,
+ getMovementBounds(mPipBoundsState.getBounds()),
+ getMovementBounds(adjustedNormalBounds), callback /* callback */);
+ }
+ private Rect getAdjustedNormalBounds() {
final Size minMenuSize = mMenuController.getEstimatedMinMenuSize();
final Size defaultSize = mSizeSpecSource.getDefaultSize(mPipBoundsState.getAspectRatio());
final Rect normalBounds = new Rect(0, 0, defaultSize.getWidth(), defaultSize.getHeight());
- final Rect adjustedNormalBounds = mPipBoundsAlgorithm.adjustNormalBoundsToFitMenu(
- normalBounds, minMenuSize);
-
- mSavedSnapFraction = mMotionHelper.animateToExpandedState(adjustedNormalBounds,
- getMovementBounds(mPipBoundsState.getBounds()),
- getMovementBounds(adjustedNormalBounds), callback /* callback */);
+ return mPipBoundsAlgorithm.adjustNormalBoundsToFitMenu(normalBounds, minMenuSize);
}
private void animateToUnexpandedState(Rect restoreBounds) {
@@ -1065,6 +1069,10 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha
mPipBoundsAlgorithm.getMovementBounds(mPipBoundsState.getBounds(),
insetBounds, mPipBoundsState.getMovementBounds(), mIsImeShowing ? mImeHeight : 0);
mMotionHelper.onMovementBoundsChanged();
+
+ if (mPipResizeGestureHandler.getUserResizeBounds().isEmpty()) {
+ mPipResizeGestureHandler.setUserResizeBounds(getAdjustedNormalBounds());
+ }
}
private Rect getMovementBounds(Rect curBounds) {