Use last user-resized size when re-entering PIP
Bug: 160799929 Test: enter PIP, resize it, restore to fullscreen then re-enter. The re-entry size should be the same as when exiting. Change-Id: Idb36b5ec51c2d76b9df5f311518652109fa57b37
This commit is contained in:
@@ -394,12 +394,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
* Update the bounds used to save the re-entry size and snap fraction when exiting PIP.
|
||||
*/
|
||||
public void updateReentryBounds(Rect bounds) {
|
||||
// On phones, the expansion animation that happens on pip tap before restoring
|
||||
// to fullscreen makes it so that the last reported bounds are the expanded
|
||||
// bounds. We want to restore to the unexpanded bounds when re-entering pip,
|
||||
// so we use the bounds before expansion (normal) instead of the reported
|
||||
// bounds.
|
||||
Rect reentryBounds = mTouchHandler.getNormalBounds();
|
||||
final Rect reentryBounds = mTouchHandler.getUserResizeBounds();
|
||||
float snapFraction = mPipBoundsHandler.getSnapFraction(bounds);
|
||||
mPipBoundsHandler.applySnapFraction(reentryBounds, snapFraction);
|
||||
mReentryBounds.set(reentryBounds);
|
||||
|
||||
@@ -88,6 +88,7 @@ public class PipResizeGestureHandler {
|
||||
private final Point mMaxSize = new Point();
|
||||
private final Point mMinSize = new Point();
|
||||
private final Rect mLastResizeBounds = new Rect();
|
||||
private final Rect mUserResizeBounds = new Rect();
|
||||
private final Rect mLastDownBounds = new Rect();
|
||||
private final Rect mDragCornerSize = new Rect();
|
||||
private final Rect mTmpTopLeftCorner = new Rect();
|
||||
@@ -181,6 +182,7 @@ public class PipResizeGestureHandler {
|
||||
|
||||
void onActivityUnpinned() {
|
||||
mIsAttached = false;
|
||||
mUserResizeBounds.setEmpty();
|
||||
updateIsEnabled();
|
||||
}
|
||||
|
||||
@@ -329,6 +331,7 @@ public class PipResizeGestureHandler {
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
if (!mLastResizeBounds.isEmpty()) {
|
||||
mUserResizeBounds.set(mLastResizeBounds);
|
||||
mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds,
|
||||
(Rect bounds) -> {
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
@@ -351,6 +354,14 @@ public class PipResizeGestureHandler {
|
||||
mThresholdCrossed = false;
|
||||
}
|
||||
|
||||
void setUserResizeBounds(Rect bounds) {
|
||||
mUserResizeBounds.set(bounds);
|
||||
}
|
||||
|
||||
Rect getUserResizeBounds() {
|
||||
return mUserResizeBounds;
|
||||
}
|
||||
|
||||
void updateMaxSize(int maxX, int maxY) {
|
||||
mMaxSize.set(maxX, maxY);
|
||||
}
|
||||
|
||||
@@ -132,9 +132,6 @@ public class PipTouchHandler {
|
||||
|
||||
// The current movement bounds
|
||||
private Rect mMovementBounds = new Rect();
|
||||
// The current resized bounds, changed by user resize.
|
||||
// This is used during expand/un-expand to save/restore the user's resized size.
|
||||
@VisibleForTesting Rect mResizedBounds = new Rect();
|
||||
|
||||
// The reference inset bounds, used to determine the dismiss fraction
|
||||
private Rect mInsetBounds = new Rect();
|
||||
@@ -383,7 +380,6 @@ public class PipTouchHandler {
|
||||
|
||||
mFloatingContentCoordinator.onContentRemoved(mMotionHelper);
|
||||
}
|
||||
mResizedBounds.setEmpty();
|
||||
mPipResizeGestureHandler.onActivityUnpinned();
|
||||
}
|
||||
|
||||
@@ -393,9 +389,8 @@ public class PipTouchHandler {
|
||||
mMotionHelper.synchronizePinnedStackBounds();
|
||||
updateMovementBounds();
|
||||
if (direction == TRANSITION_DIRECTION_TO_PIP) {
|
||||
// updates mResizedBounds only if it's an entering PiP animation
|
||||
// mResized should be otherwise updated in setMenuState.
|
||||
mResizedBounds.set(mMotionHelper.getBounds());
|
||||
// Set the initial bounds as the user resize bounds.
|
||||
mPipResizeGestureHandler.setUserResizeBounds(mMotionHelper.getBounds());
|
||||
}
|
||||
|
||||
if (mShowPipMenuOnAnimationEnd) {
|
||||
@@ -808,9 +803,7 @@ public class PipTouchHandler {
|
||||
// Save the current snap fraction and if we do not drag or move the PiP, then
|
||||
// we store back to this snap fraction. Otherwise, we'll reset the snap
|
||||
// fraction and snap to the closest edge.
|
||||
// Also save the current resized bounds so when the menu disappears, we can restore it.
|
||||
if (resize) {
|
||||
mResizedBounds.set(mMotionHelper.getBounds());
|
||||
Rect expandedBounds = new Rect(mExpandedBounds);
|
||||
mSavedSnapFraction = mMotionHelper.animateToExpandedState(expandedBounds,
|
||||
mMovementBounds, mExpandedMovementBounds, callback);
|
||||
@@ -839,7 +832,7 @@ public class PipTouchHandler {
|
||||
}
|
||||
|
||||
if (mDeferResizeToNormalBoundsUntilRotation == -1) {
|
||||
Rect restoreBounds = new Rect(mResizedBounds);
|
||||
Rect restoreBounds = new Rect(getUserResizeBounds());
|
||||
Rect restoredMovementBounds = new Rect();
|
||||
mSnapAlgorithm.getMovementBounds(restoreBounds, mInsetBounds,
|
||||
restoredMovementBounds, mIsImeShowing ? mImeHeight : 0);
|
||||
@@ -890,6 +883,10 @@ public class PipTouchHandler {
|
||||
return mNormalBounds;
|
||||
}
|
||||
|
||||
Rect getUserResizeBounds() {
|
||||
return mPipResizeGestureHandler.getUserResizeBounds();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gesture controlling normal movement of the PIP.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user