Merge "Stylus support: creating and setting listeners for stylus button press" into ub-launcher3-burnaby

This commit is contained in:
Mady Mellor authored and Android (Google) Code Review committed 2015-06-03 16:26:35 +00:00
commit 19b1bad239
6 files changed
+144 -1

No files matched your search

+12 -1
View File
@@ -61,6 +61,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;
@@ -123,6 +124,7 @@ public class BubbleTextView extends TextView {
}
mLongPressHelper = new CheckLongPressHelper(this);
mStylusEventHelper = new StylusEventHelper(this);
mOutlineHelper = HolographicOutlineHelper.obtain(getContext());
if (mCustomShadowsEnabled) {
@@ -234,6 +236,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(),
@@ -243,7 +251,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: