From f75fffdc20cbe1bca14dbfac6f31322b21bac770 Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Fri, 2 Apr 2021 17:20:36 -0700 Subject: [PATCH] PiP: Allow customization of PiP minimum size. Bug: 171596717 Test: None. Change-Id: I9bb6f2740d25fce99a436f938e7b3cca819ffa98 --- libs/WindowManager/Shell/res/values/config.xml | 3 +++ .../com/android/wm/shell/pip/phone/PipTouchHandler.java | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/WindowManager/Shell/res/values/config.xml b/libs/WindowManager/Shell/res/values/config.xml index 8cea869aea349..d0e4f7a02ffcf 100644 --- a/libs/WindowManager/Shell/res/values/config.xml +++ b/libs/WindowManager/Shell/res/values/config.xml @@ -36,6 +36,9 @@ false + + 40% + 250 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 0bcd1a363eb63..7867f933de4fa 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 @@ -63,7 +63,6 @@ import java.io.PrintWriter; * the PIP. */ public class PipTouchHandler { - @VisibleForTesting static final float MINIMUM_SIZE_PERCENT = 0.4f; private static final String TAG = "PipTouchHandler"; private static final float DEFAULT_STASH_VELOCITY_THRESHOLD = 18000.f; @@ -115,6 +114,7 @@ public class PipTouchHandler { private float mSavedSnapFraction = -1f; private boolean mSendingHoverAccessibilityEvents; private boolean mMovementWithinDismiss; + private float mMinimumSizePercent; // Touch state private final PipTouchState mTouchState; @@ -252,6 +252,7 @@ public class PipTouchHandler { mExpandedShortestEdgeSize = res.getDimensionPixelSize( R.dimen.pip_expanded_shortest_edge_size); mImeOffset = res.getDimensionPixelSize(R.dimen.pip_ime_offset); + mMinimumSizePercent = res.getFraction(R.fraction.config_pipShortestEdgePercent, 1, 1); mPipDismissTargetHandler.updateMagneticTargetSize(); } @@ -481,12 +482,12 @@ public class PipTouchHandler { + (mPipBoundsState.getDisplayBounds().height() - insetBounds.bottom); final int minWidth, minHeight, maxWidth, maxHeight; if (aspectRatio > 1f) { - minWidth = (int) Math.min(normalBounds.width(), shorterLength * MINIMUM_SIZE_PERCENT); + minWidth = (int) Math.min(normalBounds.width(), shorterLength * mMinimumSizePercent); minHeight = (int) (minWidth / aspectRatio); maxWidth = (int) Math.max(normalBounds.width(), shorterLength - totalHorizontalPadding); maxHeight = (int) (maxWidth / aspectRatio); } else { - minHeight = (int) Math.min(normalBounds.height(), shorterLength * MINIMUM_SIZE_PERCENT); + minHeight = (int) Math.min(normalBounds.height(), shorterLength * mMinimumSizePercent); minWidth = (int) (minHeight * aspectRatio); maxHeight = (int) Math.max(normalBounds.height(), shorterLength - totalVerticalPadding); maxWidth = (int) (maxHeight * aspectRatio);