summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mady Mellor <madym@google.com> 2018-12-10 16:57:35 -0800
committer Mady Mellor <madym@google.com> 2018-12-11 08:52:36 -0800
commit6dfef9756e8616c98989eceb7fe491c3409cbbc0 (patch)
treef25509ae2976327778ccac599127a40958e38499
parent06353c6eb589fcecd7f161ee7b29261d82993242 (diff)
Increase the size of the 'target' that bubble is dragged to for dismiss
* The text target is pretty small, this CL increases the area around it when checking if the views are intersecting for an easier dismiss action * Also includes a different haptic effect when you drag away / out of the target. Bug: 111236845 Test: manual - enable bubbles and drag to target, note that it's easier and you feel the haptic effect Change-Id: I77d5e796162a5b107f964c038e11b58b448b6d4b
-rw-r--r--packages/SystemUI/res/values/dimens.xml2
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipDismissViewController.java28
2 files changed, 22 insertions, 8 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 879b02f89701..3851190fdeec 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -998,4 +998,6 @@
<dimen name="bubble_pointer_height">4dp</dimen>
<!-- Width of the triangle that points to the expanded bubble -->
<dimen name="bubble_pointer_width">6dp</dimen>
+ <!-- Extra padding around the dismiss target for bubbles -->
+ <dimen name="bubble_dismiss_slop">16dp</dimen>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipDismissViewController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipDismissViewController.java
index 8262b54f3cd6..8224365e7b96 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipDismissViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipDismissViewController.java
@@ -51,6 +51,8 @@ public class PipDismissViewController {
// Used for dismissing a bubble -- bubble should be in the target to be considered a dismiss
private View mTargetView;
+ private int mTargetSlop;
+ private Point mWindowSize;
private int[] mLoc = new int[2];
private boolean mIntersecting;
private Vibrator mVibe;
@@ -69,12 +71,14 @@ public class PipDismissViewController {
// Determine sizes for the view
final Rect stableInsets = new Rect();
WindowManagerWrapper.getInstance().getStableInsets(stableInsets);
- final Point windowSize = new Point();
- mWindowManager.getDefaultDisplay().getRealSize(windowSize);
+ mWindowSize = new Point();
+ mWindowManager.getDefaultDisplay().getRealSize(mWindowSize);
final int gradientHeight = mContext.getResources().getDimensionPixelSize(
R.dimen.pip_dismiss_gradient_height);
final int bottomMargin = mContext.getResources().getDimensionPixelSize(
R.dimen.pip_dismiss_text_bottom_margin);
+ mTargetSlop = mContext.getResources().getDimensionPixelSize(
+ R.dimen.bubble_dismiss_slop);
// Create a new view for the dismiss target
LayoutInflater inflater = LayoutInflater.from(mContext);
@@ -96,7 +100,7 @@ public class PipDismissViewController {
// Add the target to the window
LayoutParams lp = new LayoutParams(
LayoutParams.MATCH_PARENT, gradientHeight,
- 0, windowSize.y - gradientHeight,
+ 0, mWindowSize.y - gradientHeight,
LayoutParams.TYPE_NAVIGATION_BAR_PANEL,
LayoutParams.FLAG_LAYOUT_IN_SCREEN
| LayoutParams.FLAG_NOT_TOUCHABLE
@@ -112,7 +116,7 @@ public class PipDismissViewController {
/**
- * Updates the dismiss target based on location of the view.
+ * Updates the dismiss target based on location of the view, only used for bubbles not for PIP.
*
* @return whether the view is within the dismiss target.
*/
@@ -127,11 +131,13 @@ public class PipDismissViewController {
mTargetView.getLocationOnScreen(mLoc);
Rect targetRect = new Rect(mLoc[0], mLoc[1], mLoc[0] + mTargetView.getWidth(),
mLoc[1] + mTargetView.getHeight());
+ expandRect(targetRect, mTargetSlop);
boolean intersecting = targetRect.intersect(viewRect);
- if (intersecting && !mIntersecting) {
+ if (intersecting != mIntersecting) {
// TODO: is this the right effect?
- mVibe.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_CLICK));
- mIntersecting = true;
+ mVibe.vibrate(VibrationEffect.get(intersecting
+ ? VibrationEffect.EFFECT_CLICK
+ : VibrationEffect.EFFECT_TICK));
}
mIntersecting = intersecting;
return intersecting;
@@ -139,7 +145,6 @@ public class PipDismissViewController {
return false;
}
-
/**
* Shows the dismiss target.
*/
@@ -172,4 +177,11 @@ public class PipDismissViewController {
.start();
}
}
+
+ private void expandRect(Rect outRect, int expandAmount) {
+ outRect.left = Math.max(0, outRect.left - expandAmount);
+ outRect.top = Math.max(0, outRect.top - expandAmount);
+ outRect.right = Math.min(mWindowSize.x, outRect.right + expandAmount);
+ outRect.bottom = Math.min(mWindowSize.y, outRect.bottom + expandAmount);
+ }
}