Animate PiP away on inset changes.

This specifically refers to the taskbar that can be expanded or
minimized, which changes the bottom inset, but PiP remained in it's
original position. This change will move it down if it was already by
the bottom edge, or move it up just enough to be within the movement
bounds.

Bug: 256560961
Test: manually
Test: http://recall/-/ekEuGtt9d9HWqkUtAzpHx8/dSTq2oAg1k85bpIZRBDLIH

Change-Id: I487be6f54b2f9afae8d18df8cf6456858704c703
This commit is contained in:
Mateusz Cicheński
2022-11-02 03:40:21 +00:00
parent 625756bee7
commit 9621f52c01

View File

@@ -612,9 +612,24 @@ public class PipController implements PipTransitionController.PipTransitionCallb
new DisplayInsetsController.OnInsetsChangedListener() {
@Override
public void insetsChanged(InsetsState insetsState) {
int oldMaxMovementBound = mPipBoundsState.getMovementBounds().bottom;
onDisplayChanged(
mDisplayController.getDisplayLayout(mPipBoundsState.getDisplayId()),
false /* saveRestoreSnapFraction */);
int newMaxMovementBound = mPipBoundsState.getMovementBounds().bottom;
if (!mEnablePipKeepClearAlgorithm) {
int pipTop = mPipBoundsState.getBounds().top;
int diff = newMaxMovementBound - oldMaxMovementBound;
if (diff < 0 && pipTop > newMaxMovementBound) {
// bottom inset has increased, move PiP up if it is too low
mPipMotionHelper.animateToOffset(mPipBoundsState.getBounds(),
newMaxMovementBound - pipTop);
}
if (diff > 0 && oldMaxMovementBound == pipTop) {
// bottom inset has decreased, move PiP down if it was by the edge
mPipMotionHelper.animateToOffset(mPipBoundsState.getBounds(), diff);
}
}
}
});