From 47ba140cbf9faa8c391fc85f4254ade0b4d23357 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Tue, 4 Apr 2017 17:25:43 -0700 Subject: [PATCH] Add ability to fling to dismiss PIP from anywhere This is by default turned off and is behind a tuner flag. Allows the PIP to be dismissed if it is flung towards the bottom center of the screen and the finger is released within the bottom area of the screen. Test: Manual - enable tuner setting, have a PIP, position it at top of screen, long- fling it towards bottom center of screen, it dismisses. Bug: 35358628 Change-Id: I2d3d50093f6523c7bb321e0486dab360095a398e --- packages/SystemUI/res/values/strings.xml | 6 +++++ packages/SystemUI/res/xml/tuner_prefs.xml | 6 +++++ .../systemui/pip/phone/PipMotionHelper.java | 20 +++++++++++++++++ .../systemui/pip/phone/PipTouchHandler.java | 22 ++++++++++++------- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 9fb884e958afc..afc570f0ae438 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1902,6 +1902,12 @@ Drag or fling the PIP to the edges of the screen to minimize it. + + Fling to dismiss + + + Fling from anywhere on the screen to the bottom of the screen to dismiss the PIP. + Play diff --git a/packages/SystemUI/res/xml/tuner_prefs.xml b/packages/SystemUI/res/xml/tuner_prefs.xml index a685c794c5d6e..523dd9f2e8bb2 100644 --- a/packages/SystemUI/res/xml/tuner_prefs.xml +++ b/packages/SystemUI/res/xml/tuner_prefs.xml @@ -131,6 +131,12 @@ android:summary="@string/pip_minimize_description" sysui:defValue="false" /> + + Math.abs(vel.y); final float velocity = PointF.length(vel.x, vel.y); final boolean isFling = velocity > mFlingAnimationUtils.getMinVelocityPxPerSecond(); - final boolean isFlingToBot = isFling - && !isHorizontal && mMovementWithinDismiss && vel.y > 0; + final boolean isUpWithinDimiss = mEnableFlingToDismiss + && touchState.getLastTouchPosition().y >= mMovementBounds.bottom + && mMotionHelper.isGestureToDismissArea(mMotionHelper.getBounds(), vel.x, + vel.y, isFling); + final boolean isFlingToBot = isFling && vel.y > 0 && !isHorizontal + && (mMovementWithinDismiss || isUpWithinDimiss); if (ENABLE_DISMISS_DRAG_TO_EDGE) { try { mHandler.removeCallbacks(mShowDismissAffordance);