summaryrefslogtreecommitdiff
path: root/core/java/android/view/MotionEvent.java
diff options
context:
space:
mode:
authorMady Mellor <madym@google.com>2015-04-30 09:58:35 -0700
committerMady Mellor <madym@google.com>2015-04-30 09:58:35 -0700
commite82067b57595a2bce656e5ba3a9bcf19048f2f25 (patch)
tree7f6a5fe7e2a1f0df9502269a41cf120b78fed7b4 /core/java/android/view/MotionEvent.java
parent8f72b4037022c4f860caafa296e2ac309bde177f (diff)
Add onStylusButtonPress listener to View
The gesture is: stylus touching screen + button pressed, the event is recognized when the button is pressed, not when it's released. It can be pressed during DOWN or MOVE. If the stylus touch + press button is occurring longpress cannot occur and vice versa. Also adds the haptic feedback and accessibility bits specific to the new gesture. Bug: 19620479 Change-Id: Ibc4654978ef39e7b4251d17636453d90f3bf622d
Diffstat (limited to 'core/java/android/view/MotionEvent.java')
-rw-r--r--core/java/android/view/MotionEvent.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index 5e45c8fe10dd..5df596a1fce0 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -3180,6 +3180,18 @@ public final class MotionEvent extends InputEvent implements Parcelable {
return (getButtonState() & button) == button;
}
+ /**
+ * Checks if a stylus is being used and if the first stylus button is
+ * pressed.
+ *
+ * @return True if the tool is a stylus and if the first stylus button is
+ * pressed.
+ * @see #BUTTON_SECONDARY
+ */
+ public final boolean isStylusButtonPressed() {
+ return (isButtonPressed(BUTTON_SECONDARY) && getToolType(0) == TOOL_TYPE_STYLUS);
+ }
+
public static final Parcelable.Creator<MotionEvent> CREATOR
= new Parcelable.Creator<MotionEvent>() {
public MotionEvent createFromParcel(Parcel in) {