Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipBoundsState.java +15 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,8 @@ public class PipBoundsState { private int mShelfHeight; /** Whether the user has resized the PIP manually. */ private boolean mHasUserResizedPip; /** Whether the user has moved the PIP manually. */ private boolean mHasUserMovedPip; /** * Areas defined by currently visible apps that they prefer to keep clear from overlays such as * the PiP. Restricted areas may only move the PiP a limited amount from its anchor position. Loading Loading @@ -279,6 +281,7 @@ public class PipBoundsState { if (changed) { clearReentryState(); setHasUserResizedPip(false); setHasUserMovedPip(false); } } Loading Loading @@ -442,6 +445,16 @@ public class PipBoundsState { mHasUserResizedPip = hasUserResizedPip; } /** Returns whether the user has moved the PIP. */ public boolean hasUserMovedPip() { return mHasUserMovedPip; } /** Set whether the user has moved the PIP. */ public void setHasUserMovedPip(boolean hasUserMovedPip) { mHasUserMovedPip = hasUserMovedPip; } /** * Registers a callback when the minimal size of PIP that is set by the app changes. */ Loading Loading @@ -577,6 +590,8 @@ public class PipBoundsState { pw.println(innerPrefix + "mImeHeight=" + mImeHeight); pw.println(innerPrefix + "mIsShelfShowing=" + mIsShelfShowing); pw.println(innerPrefix + "mShelfHeight=" + mShelfHeight); pw.println(innerPrefix + "mHasUserMovedPip=" + mHasUserMovedPip); pw.println(innerPrefix + "mHasUserResizedPip=" + mHasUserResizedPip); if (mPipReentryState == null) { pw.println(innerPrefix + "mPipReentryState=null"); } else { Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipKeepClearAlgorithm.java +29 −19 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.pip.phone; import android.content.Context; import android.content.res.Resources; import android.graphics.Rect; import android.os.SystemProperties; import android.util.ArraySet; import android.view.Gravity; Loading @@ -34,6 +35,10 @@ import java.util.Set; */ public class PhonePipKeepClearAlgorithm implements PipKeepClearAlgorithm { private boolean mKeepClearAreaGravityEnabled = SystemProperties.getBoolean( "persist.wm.debug.enable_pip_keep_clear_algorithm_gravity", false); protected int mKeepClearAreasPadding; public PhonePipKeepClearAlgorithm(Context context) { Loading @@ -53,6 +58,16 @@ public class PhonePipKeepClearAlgorithm implements PipKeepClearAlgorithm { Rect startingBounds = pipBoundsState.getBounds().isEmpty() ? pipBoundsAlgorithm.getEntryDestinationBoundsIgnoringKeepClearAreas() : pipBoundsState.getBounds(); Rect insets = new Rect(); pipBoundsAlgorithm.getInsetBounds(insets); if (pipBoundsState.isImeShowing()) { insets.bottom -= pipBoundsState.getImeHeight(); } Rect pipBounds = new Rect(startingBounds); // move PiP towards corner if user hasn't moved it manually or the flag is on if (mKeepClearAreaGravityEnabled || (!pipBoundsState.hasUserMovedPip() && !pipBoundsState.hasUserResizedPip())) { float snapFraction = pipBoundsAlgorithm.getSnapFraction(startingBounds); int verticalGravity = Gravity.BOTTOM; int horizontalGravity; Loading @@ -61,23 +76,18 @@ public class PhonePipKeepClearAlgorithm implements PipKeepClearAlgorithm { } else { horizontalGravity = Gravity.LEFT; } // push the bounds based on the gravity Rect insets = new Rect(); pipBoundsAlgorithm.getInsetBounds(insets); if (pipBoundsState.isImeShowing()) { insets.bottom -= pipBoundsState.getImeHeight(); } Rect pushedBounds = new Rect(startingBounds); if (verticalGravity == Gravity.BOTTOM) { pushedBounds.offsetTo(pushedBounds.left, insets.bottom - pushedBounds.height()); pipBounds.offsetTo(pipBounds.left, insets.bottom - pipBounds.height()); } if (horizontalGravity == Gravity.RIGHT) { pushedBounds.offsetTo(insets.right - pushedBounds.width(), pushedBounds.top); pipBounds.offsetTo(insets.right - pipBounds.width(), pipBounds.top); } else { pushedBounds.offsetTo(insets.left, pushedBounds.top); pipBounds.offsetTo(insets.left, pipBounds.top); } } return findUnoccludedPosition(pushedBounds, pipBoundsState.getRestrictedKeepClearAreas(), return findUnoccludedPosition(pipBounds, pipBoundsState.getRestrictedKeepClearAreas(), pipBoundsState.getUnrestrictedKeepClearAreas(), insets); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +2 −0 Original line number Diff line number Diff line Loading @@ -875,6 +875,8 @@ public class PipTouchHandler { } if (touchState.isDragging()) { mPipBoundsState.setHasUserMovedPip(true); // Move the pinned stack freely final PointF lastDelta = touchState.getLastTouchDelta(); float lastX = mStartPosition.x + mDelta.x; Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipBoundsState.java +15 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,8 @@ public class PipBoundsState { private int mShelfHeight; /** Whether the user has resized the PIP manually. */ private boolean mHasUserResizedPip; /** Whether the user has moved the PIP manually. */ private boolean mHasUserMovedPip; /** * Areas defined by currently visible apps that they prefer to keep clear from overlays such as * the PiP. Restricted areas may only move the PiP a limited amount from its anchor position. Loading Loading @@ -279,6 +281,7 @@ public class PipBoundsState { if (changed) { clearReentryState(); setHasUserResizedPip(false); setHasUserMovedPip(false); } } Loading Loading @@ -442,6 +445,16 @@ public class PipBoundsState { mHasUserResizedPip = hasUserResizedPip; } /** Returns whether the user has moved the PIP. */ public boolean hasUserMovedPip() { return mHasUserMovedPip; } /** Set whether the user has moved the PIP. */ public void setHasUserMovedPip(boolean hasUserMovedPip) { mHasUserMovedPip = hasUserMovedPip; } /** * Registers a callback when the minimal size of PIP that is set by the app changes. */ Loading Loading @@ -577,6 +590,8 @@ public class PipBoundsState { pw.println(innerPrefix + "mImeHeight=" + mImeHeight); pw.println(innerPrefix + "mIsShelfShowing=" + mIsShelfShowing); pw.println(innerPrefix + "mShelfHeight=" + mShelfHeight); pw.println(innerPrefix + "mHasUserMovedPip=" + mHasUserMovedPip); pw.println(innerPrefix + "mHasUserResizedPip=" + mHasUserResizedPip); if (mPipReentryState == null) { pw.println(innerPrefix + "mPipReentryState=null"); } else { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipKeepClearAlgorithm.java +29 −19 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.pip.phone; import android.content.Context; import android.content.res.Resources; import android.graphics.Rect; import android.os.SystemProperties; import android.util.ArraySet; import android.view.Gravity; Loading @@ -34,6 +35,10 @@ import java.util.Set; */ public class PhonePipKeepClearAlgorithm implements PipKeepClearAlgorithm { private boolean mKeepClearAreaGravityEnabled = SystemProperties.getBoolean( "persist.wm.debug.enable_pip_keep_clear_algorithm_gravity", false); protected int mKeepClearAreasPadding; public PhonePipKeepClearAlgorithm(Context context) { Loading @@ -53,6 +58,16 @@ public class PhonePipKeepClearAlgorithm implements PipKeepClearAlgorithm { Rect startingBounds = pipBoundsState.getBounds().isEmpty() ? pipBoundsAlgorithm.getEntryDestinationBoundsIgnoringKeepClearAreas() : pipBoundsState.getBounds(); Rect insets = new Rect(); pipBoundsAlgorithm.getInsetBounds(insets); if (pipBoundsState.isImeShowing()) { insets.bottom -= pipBoundsState.getImeHeight(); } Rect pipBounds = new Rect(startingBounds); // move PiP towards corner if user hasn't moved it manually or the flag is on if (mKeepClearAreaGravityEnabled || (!pipBoundsState.hasUserMovedPip() && !pipBoundsState.hasUserResizedPip())) { float snapFraction = pipBoundsAlgorithm.getSnapFraction(startingBounds); int verticalGravity = Gravity.BOTTOM; int horizontalGravity; Loading @@ -61,23 +76,18 @@ public class PhonePipKeepClearAlgorithm implements PipKeepClearAlgorithm { } else { horizontalGravity = Gravity.LEFT; } // push the bounds based on the gravity Rect insets = new Rect(); pipBoundsAlgorithm.getInsetBounds(insets); if (pipBoundsState.isImeShowing()) { insets.bottom -= pipBoundsState.getImeHeight(); } Rect pushedBounds = new Rect(startingBounds); if (verticalGravity == Gravity.BOTTOM) { pushedBounds.offsetTo(pushedBounds.left, insets.bottom - pushedBounds.height()); pipBounds.offsetTo(pipBounds.left, insets.bottom - pipBounds.height()); } if (horizontalGravity == Gravity.RIGHT) { pushedBounds.offsetTo(insets.right - pushedBounds.width(), pushedBounds.top); pipBounds.offsetTo(insets.right - pipBounds.width(), pipBounds.top); } else { pushedBounds.offsetTo(insets.left, pushedBounds.top); pipBounds.offsetTo(insets.left, pipBounds.top); } } return findUnoccludedPosition(pushedBounds, pipBoundsState.getRestrictedKeepClearAreas(), return findUnoccludedPosition(pipBounds, pipBoundsState.getRestrictedKeepClearAreas(), pipBoundsState.getUnrestrictedKeepClearAreas(), insets); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +2 −0 Original line number Diff line number Diff line Loading @@ -875,6 +875,8 @@ public class PipTouchHandler { } if (touchState.isDragging()) { mPipBoundsState.setHasUserMovedPip(true); // Move the pinned stack freely final PointF lastDelta = touchState.getLastTouchDelta(); float lastX = mStartPosition.x + mDelta.x; Loading