From b0748625e635d49834dbf08337074297ca761477 Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Mon, 10 May 2021 12:57:07 -0700 Subject: [PATCH] PiP: Use vertical/horizontal padding base on PiP orientation. Since not all paddings are created the same, let's respect the correct top/bottom or left/right pair based on PIP orientation. Bug: 187525862 Test: Open vertical PIP, rotate to landscape, maximize PIP - respects maximum space now Change-Id: Ib04ac72328e246302b45fe6630dc01d0c081cfcc --- .../com/android/wm/shell/pip/phone/PipTouchHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java index 0a0798ef24c12..1d35378149887 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java @@ -467,17 +467,20 @@ public class PipTouchHandler { float aspectRatio) { final int shorterLength = Math.min(mPipBoundsState.getDisplayBounds().width(), mPipBoundsState.getDisplayBounds().height()); - final int totalPadding = insetBounds.left * 2; + final int totalHorizontalPadding = insetBounds.left + + (mPipBoundsState.getDisplayBounds().width() - insetBounds.right); + final int totalVerticalPadding = insetBounds.top + + (mPipBoundsState.getDisplayBounds().height() - insetBounds.bottom); final int minWidth, minHeight, maxWidth, maxHeight; if (aspectRatio > 1f) { minWidth = (int) Math.min(normalBounds.width(), shorterLength * MINIMUM_SIZE_PERCENT); minHeight = (int) (minWidth / aspectRatio); - maxWidth = (int) Math.max(normalBounds.width(), shorterLength - totalPadding); + maxWidth = (int) Math.max(normalBounds.width(), shorterLength - totalHorizontalPadding); maxHeight = (int) (maxWidth / aspectRatio); } else { minHeight = (int) Math.min(normalBounds.height(), shorterLength * MINIMUM_SIZE_PERCENT); minWidth = (int) (minHeight * aspectRatio); - maxHeight = (int) Math.max(normalBounds.height(), shorterLength - totalPadding); + maxHeight = (int) Math.max(normalBounds.height(), shorterLength - totalVerticalPadding); maxWidth = (int) (maxHeight * aspectRatio); }