Merge "PiP: Recalculate size if too big/small on display change." into sc-v2-dev am: 984af19cf9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16177568 Change-Id: I036b34aa7ddf3bfe83ff20cc36956d3c913be2f0
This commit is contained in:
@@ -490,12 +490,25 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
|||||||
if (mPipTaskOrganizer.isInPip() && saveRestoreSnapFraction) {
|
if (mPipTaskOrganizer.isInPip() && saveRestoreSnapFraction) {
|
||||||
// Calculate the snap fraction of the current stack along the old movement bounds
|
// Calculate the snap fraction of the current stack along the old movement bounds
|
||||||
final PipSnapAlgorithm pipSnapAlgorithm = mPipBoundsAlgorithm.getSnapAlgorithm();
|
final PipSnapAlgorithm pipSnapAlgorithm = mPipBoundsAlgorithm.getSnapAlgorithm();
|
||||||
final Rect postChangeStackBounds = new Rect(mPipBoundsState.getBounds());
|
final float snapFraction = pipSnapAlgorithm.getSnapFraction(mPipBoundsState.getBounds(),
|
||||||
final float snapFraction = pipSnapAlgorithm.getSnapFraction(postChangeStackBounds,
|
mPipBoundsAlgorithm.getMovementBounds(mPipBoundsState.getBounds()),
|
||||||
mPipBoundsAlgorithm.getMovementBounds(postChangeStackBounds),
|
|
||||||
mPipBoundsState.getStashedState());
|
mPipBoundsState.getStashedState());
|
||||||
|
|
||||||
updateDisplayLayout.run();
|
updateDisplayLayout.run();
|
||||||
|
final Rect postChangeStackBounds;
|
||||||
|
if (mPipBoundsState.getBounds() != null
|
||||||
|
&& (mPipBoundsState.getBounds().width() > mPipBoundsState.getMaxSize().x
|
||||||
|
|| mPipBoundsState.getBounds().height() > mPipBoundsState.getMaxSize().y)) {
|
||||||
|
postChangeStackBounds = new Rect(0, 0, mPipBoundsState.getMaxSize().x,
|
||||||
|
mPipBoundsState.getMaxSize().y);
|
||||||
|
} else if (mPipBoundsState.getBounds() != null
|
||||||
|
&& (mPipBoundsState.getBounds().width() < mPipBoundsState.getMinSize().x
|
||||||
|
|| mPipBoundsState.getBounds().height() < mPipBoundsState.getMinSize().y)) {
|
||||||
|
postChangeStackBounds = new Rect(0, 0, mPipBoundsState.getMinSize().x,
|
||||||
|
mPipBoundsState.getMinSize().y);
|
||||||
|
} else {
|
||||||
|
postChangeStackBounds = new Rect(mPipBoundsState.getBounds());
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate the stack bounds in the new orientation based on same fraction along the
|
// Calculate the stack bounds in the new orientation based on same fraction along the
|
||||||
// rotated movement bounds.
|
// rotated movement bounds.
|
||||||
@@ -507,7 +520,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
|||||||
mPipBoundsState.getDisplayBounds(),
|
mPipBoundsState.getDisplayBounds(),
|
||||||
mPipBoundsState.getDisplayLayout().stableInsets());
|
mPipBoundsState.getDisplayLayout().stableInsets());
|
||||||
|
|
||||||
mTouchHandler.getMotionHelper().movePip(postChangeStackBounds);
|
mTouchHandler.getMotionHelper().animateResizedBounds(postChangeStackBounds);
|
||||||
} else {
|
} else {
|
||||||
updateDisplayLayout.run();
|
updateDisplayLayout.run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
|
|||||||
private static final int UNSTASH_DURATION = 250;
|
private static final int UNSTASH_DURATION = 250;
|
||||||
private static final int LEAVE_PIP_DURATION = 300;
|
private static final int LEAVE_PIP_DURATION = 300;
|
||||||
private static final int SHIFT_DURATION = 300;
|
private static final int SHIFT_DURATION = 300;
|
||||||
|
private static final int ANIMATE_PIP_RESIZE_ANIMATION = 250;
|
||||||
|
|
||||||
/** Friction to use for PIP when it moves via physics fling animations. */
|
/** Friction to use for PIP when it moves via physics fling animations. */
|
||||||
private static final float DEFAULT_FRICTION = 1.9f;
|
private static final float DEFAULT_FRICTION = 1.9f;
|
||||||
@@ -547,6 +548,14 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
|
|||||||
resizeAndAnimatePipUnchecked(unstashedBounds, UNSTASH_DURATION);
|
resizeAndAnimatePipUnchecked(unstashedBounds, UNSTASH_DURATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Animates the PiP from an old bound to a new bound. This is mostly used when display
|
||||||
|
* has changed and PiP bounds needs to be changed.
|
||||||
|
*/
|
||||||
|
void animateResizedBounds(Rect newBounds) {
|
||||||
|
resizeAndAnimatePipUnchecked(newBounds, ANIMATE_PIP_RESIZE_ANIMATION);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animates the PiP to offset it from the IME or shelf.
|
* Animates the PiP to offset it from the IME or shelf.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ public class PipControllerTest extends ShellTestCase {
|
|||||||
mPipController.mDisplaysChangedListener.onDisplayConfigurationChanged(
|
mPipController.mDisplaysChangedListener.onDisplayConfigurationChanged(
|
||||||
displayId, new Configuration());
|
displayId, new Configuration());
|
||||||
|
|
||||||
verify(mMockPipMotionHelper).movePip(any(Rect.class));
|
verify(mMockPipMotionHelper).animateResizedBounds(any(Rect.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user