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
This commit is contained in:
1 parent
585b764ae2
commit
ef044dd380
6 files changed
+144
-1
No files matched your search
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user