diff --git a/core/java/android/view/IPinnedStackController.aidl b/core/java/android/view/IPinnedStackController.aidl index 830591d5b503f..a81eef831f4ec 100644 --- a/core/java/android/view/IPinnedStackController.aidl +++ b/core/java/android/view/IPinnedStackController.aidl @@ -30,4 +30,9 @@ interface IPinnedStackController { * Notifies the controller that the user is currently interacting with the PIP. */ oneway void setInInteractiveMode(boolean inInteractiveMode); + + /** + * Notifies the controller that the desired snap mode is to the closest edge. + */ + oneway void setSnapToEdge(boolean snapToEdge); } diff --git a/core/java/com/android/internal/policy/PipSnapAlgorithm.java b/core/java/com/android/internal/policy/PipSnapAlgorithm.java index 45b7b0183fd8d..cbacf269a0f09 100644 --- a/core/java/com/android/internal/policy/PipSnapAlgorithm.java +++ b/core/java/com/android/internal/policy/PipSnapAlgorithm.java @@ -46,7 +46,8 @@ public class PipSnapAlgorithm { private final Context mContext; private final ArrayList mSnapGravities = new ArrayList<>(); - private final int mSnapMode = SNAP_MODE_CORNERS_ONLY; + private final int mDefaultSnapMode = SNAP_MODE_CORNERS_ONLY; + private int mSnapMode = mDefaultSnapMode; private Scroller mScroller; private int mOrientation = Configuration.ORIENTATION_UNDEFINED; @@ -64,6 +65,13 @@ public class PipSnapAlgorithm { calculateSnapTargets(); } + /** + * Enables snapping to the closest edge. + */ + public void setSnapToEdge(boolean snapToEdge) { + mSnapMode = snapToEdge ? SNAP_MODE_EDGE : mDefaultSnapMode; + } + /** * @return the closest absolute snap stack bounds for the given {@param stackBounds} moving at * the given {@param velocityX} and {@param velocityY}. The {@param movementBounds} should be diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 1ca5a36ed91f9..37a7e38eb4f93 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1706,4 +1706,12 @@ not appear on production builds ever. --> Tap once to interact with the activity + + Snap to closest edge + + + Snap to the closest edge + diff --git a/packages/SystemUI/res/xml/tuner_prefs.xml b/packages/SystemUI/res/xml/tuner_prefs.xml index 9c71b4f813f64..f09d6e9fe052c 100644 --- a/packages/SystemUI/res/xml/tuner_prefs.xml +++ b/packages/SystemUI/res/xml/tuner_prefs.xml @@ -143,6 +143,12 @@ android:summary="@string/pip_tap_through_summary" sysui:defValue="false" /> + + { + mSnapAlgorithm.setSnapToEdge(snapToEdge); + }); + } } /**