summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/BubbleTextView.java
diff options
context:
space:
mode:
authorMady Mellor <madym@google.com>2015-06-02 15:35:07 -0700
committerMady Mellor <madym@google.com>2015-06-02 15:35:07 -0700
commitef044dd380ac3abf354027750efdc16d5d48ac70 (patch)
tree4e1e94f011c84d407395617315504b6ae3d67c7e /src/com/android/launcher3/BubbleTextView.java
parent585b764ae24c7869704c428d1739e151e989674d (diff)
downloadandroid_packages_apps_Trebuchet-ef044dd380ac3abf354027750efdc16d5d48ac70.tar.gz
android_packages_apps_Trebuchet-ef044dd380ac3abf354027750efdc16d5d48ac70.tar.bz2
android_packages_apps_Trebuchet-ef044dd380ac3abf354027750efdc16d5d48ac70.zip
Stylus support: creating and setting listeners for stylus button press
This updates almost(*) all locations that use a long press listener to also set a custom touch listener that recognizes the stylus button press action. The stylus button press action is: when a stylus touches a view while the primary stylus button is pressed which may occur on a DOWN or MOVE event. *The location this is *not* enabled for is: Longpress to enter "overview" mode -- this isn't really a selection or drag n drop action; it is also easy to accidentally do this while using the stylus gesture to drag n drop items which is not an ideal interaction. Also not set for the "cling" that demonstrates this. Bug: 20430722 Change-Id: I9343f143261a7b4fada9afca28b8a11a60dbecca
Diffstat (limited to 'src/com/android/launcher3/BubbleTextView.java')
-rw-r--r--src/com/android/launcher3/BubbleTextView.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index edf502112..798eec8e7 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -63,6 +63,7 @@ public class BubbleTextView extends TextView {
private final Drawable mBackground;
private final CheckLongPressHelper mLongPressHelper;
private final HolographicOutlineHelper mOutlineHelper;
+ private final StylusEventHelper mStylusEventHelper;
private boolean mBackgroundSizeChanged;
@@ -125,6 +126,7 @@ public class BubbleTextView extends TextView {
}
mLongPressHelper = new CheckLongPressHelper(this);
+ mStylusEventHelper = new StylusEventHelper(this);
mOutlineHelper = HolographicOutlineHelper.obtain(getContext());
if (mCustomShadowsEnabled) {
@@ -236,6 +238,12 @@ public class BubbleTextView extends TextView {
// isPressed() on an ACTION_UP
boolean result = super.onTouchEvent(event);
+ // Check for a stylus button press, if it occurs cancel any long press checks.
+ if (mStylusEventHelper.checkAndPerformStylusEvent(event)) {
+ mLongPressHelper.cancelLongPress();
+ result = true;
+ }
+
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// So that the pressed outline is visible immediately on setStayPressed(),
@@ -245,7 +253,10 @@ public class BubbleTextView extends TextView {
mPressedBackground = mOutlineHelper.createMediumDropShadow(this);
}
- mLongPressHelper.postCheckForLongPress();
+ // If we're in a stylus button press, don't check for long press.
+ if (!mStylusEventHelper.inStylusButtonPressed()) {
+ mLongPressHelper.postCheckForLongPress();
+ }
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: