From 9621f52c010fc882abae89ddf0c70612241adb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ciche=C5=84ski?= Date: Wed, 2 Nov 2022 03:40:21 +0000 Subject: [PATCH] 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 --- .../android/wm/shell/pip/phone/PipController.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java index 616d447247de3..d28a9f3cf8ff2 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java @@ -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); + } + } } });