From d4173126b3fac228451cbd6b2e42059de7f3fde1 Mon Sep 17 00:00:00 2001 From: "jorgegil@google.com" Date: Fri, 10 Jul 2020 10:20:12 -0700 Subject: [PATCH] Allow reentry bounds to be overriden before saving Allows subclasses to use something other than the normal bounds as the reentry bounds when re-entering PIP mode. Bug: 160799929 Test: atest SystemUITests Change-Id: I050403ca3a5c2dc44c04cca741ac71bdc4f12b8a Merged-In: I050403ca3a5c2dc44c04cca741ac71bdc4f12b8a (cherry picked from commit 5679a841b75cb69e5e57da20ab1c91b5963fb280) --- .../systemui/pip/phone/PipManager.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java index 7d35416a8d1df..3febc1619b818 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java @@ -355,17 +355,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio @Override public void onPipTransitionStarted(ComponentName activity, int direction) { if (isOutPipDirection(direction)) { - // On phones, the expansion animation that happens on pip tap before restoring - // to fullscreen makes it so that the bounds received here are the expanded - // bounds. We want to restore to the unexpanded bounds when re-entering pip, - // so we save the bounds before expansion (normal) instead of the current - // bounds. - mReentryBounds.set(mTouchHandler.getNormalBounds()); - // Apply the snap fraction of the current bounds to the normal bounds. - final Rect bounds = mPipTaskOrganizer.getLastReportedBounds(); - float snapFraction = mPipBoundsHandler.getSnapFraction(bounds); - mPipBoundsHandler.applySnapFraction(mReentryBounds, snapFraction); - // Save reentry bounds (normal non-expand bounds with current position applied). + // Exiting PIP, save the reentry bounds to restore to when re-entering. + updateReentryBounds(); mPipBoundsHandler.onSaveReentryBounds(activity, mReentryBounds); } // Disable touches while the animation is running @@ -379,6 +370,23 @@ 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() { + // 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(); + // Apply the snap fraction of the current bounds to the normal bounds. + final Rect bounds = mPipTaskOrganizer.getLastReportedBounds(); + float snapFraction = mPipBoundsHandler.getSnapFraction(bounds); + mPipBoundsHandler.applySnapFraction(reentryBounds, snapFraction); + mReentryBounds.set(reentryBounds); + } + @Override public void onPipTransitionFinished(ComponentName activity, int direction) { onPipTransitionFinishedOrCanceled(direction);