diff options
| author | Mady Mellor <madym@google.com> | 2015-04-30 09:58:35 -0700 |
|---|---|---|
| committer | Mady Mellor <madym@google.com> | 2015-04-30 09:58:35 -0700 |
| commit | e82067b57595a2bce656e5ba3a9bcf19048f2f25 (patch) | |
| tree | 7f6a5fe7e2a1f0df9502269a41cf120b78fed7b4 /core/java/android/view/accessibility | |
| parent | 8f72b4037022c4f860caafa296e2ac309bde177f (diff) | |
| download | frameworks_base-e82067b57595a2bce656e5ba3a9bcf19048f2f25.zip frameworks_base-e82067b57595a2bce656e5ba3a9bcf19048f2f25.tar.gz frameworks_base-e82067b57595a2bce656e5ba3a9bcf19048f2f25.tar.bz2 | |
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/accessibility')
| -rw-r--r-- | core/java/android/view/accessibility/AccessibilityEvent.java | 14 | ||||
| -rw-r--r-- | core/java/android/view/accessibility/AccessibilityNodeInfo.java | 34 |
2 files changed, 48 insertions, 0 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java index 417e22c..b0dbeca 100644 --- a/core/java/android/view/accessibility/AccessibilityEvent.java +++ b/core/java/android/view/accessibility/AccessibilityEvent.java @@ -684,6 +684,11 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par public static final int TYPE_WINDOWS_CHANGED = 0x00400000; /** + * Represents the event of a stylus button press on a {@link android.view.View}. + */ + public static final int TYPE_VIEW_STYLUS_BUTTON_PRESSED = 0x00800000; + + /** * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: * The type of change is not defined. */ @@ -731,6 +736,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par * @see #TYPE_TOUCH_INTERACTION_START * @see #TYPE_TOUCH_INTERACTION_END * @see #TYPE_WINDOWS_CHANGED + * @see #TYPE_VIEW_STYLUS_BUTTON_PRESSED */ public static final int TYPES_ALL_MASK = 0xFFFFFFFF; @@ -1396,6 +1402,14 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par builder.append("TYPE_WINDOWS_CHANGED"); eventTypeCount++; } break; + case TYPE_VIEW_STYLUS_BUTTON_PRESSED: { + if (eventTypeCount > 0) { + builder.append(", "); + } + builder.append("TYPE_VIEW_STYLUS_BUTTON_PRESSED"); + eventTypeCount++; + } + break; } } if (eventTypeCount > 1) { diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index 0736ed8..bf4b7ae 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -520,6 +520,8 @@ public class AccessibilityNodeInfo implements Parcelable { private static final int BOOLEAN_PROPERTY_CONTENT_INVALID = 0x00010000; + private static final int BOOLEAN_PROPERTY_STYLUS_BUTTON_PRESSABLE = 0x00020000; + /** * Bits that provide the id of a virtual descendant of a view. */ @@ -1930,6 +1932,30 @@ public class AccessibilityNodeInfo implements Parcelable { } /** + * Gets whether this node is stylus button pressable. + * + * @return True if the node is stylus button pressable. + */ + public boolean isStylusButtonPressable() { + return getBooleanProperty(BOOLEAN_PROPERTY_STYLUS_BUTTON_PRESSABLE); + } + + /** + * Sets whether this node is stylus button pressable. + * <p> + * <strong>Note:</strong> Cannot be called from an + * {@link android.accessibilityservice.AccessibilityService}. This class is made immutable + * before being delivered to an AccessibilityService. + * </p> + * + * @param stylusButtonPressable True if the node is stylus button pressable. + * @throws IllegalStateException If called from an AccessibilityService. + */ + public void setStylusButtonPressable(boolean stylusButtonPressable) { + setBooleanProperty(BOOLEAN_PROPERTY_STYLUS_BUTTON_PRESSABLE, stylusButtonPressable); + } + + /** * Gets the node's live region mode. * <p> * A live region is a node that contains information that is important for @@ -3117,6 +3143,7 @@ public class AccessibilityNodeInfo implements Parcelable { builder.append("; selected: ").append(isSelected()); builder.append("; clickable: ").append(isClickable()); builder.append("; longClickable: ").append(isLongClickable()); + builder.append("; stylusButtonPressable: ").append(isStylusButtonPressable()); builder.append("; enabled: ").append(isEnabled()); builder.append("; password: ").append(isPassword()); builder.append("; scrollable: ").append(isScrollable()); @@ -3472,6 +3499,12 @@ public class AccessibilityNodeInfo implements Parcelable { public static final AccessibilityAction ACTION_SCROLL_TO_POSITION = new AccessibilityAction(R.id.accessibilityActionScrollToPosition, null); + /** + * Action that stylus button presses the node. + */ + public static final AccessibilityAction ACTION_STYLUS_BUTTON_PRESS = + new AccessibilityAction(R.id.accessibilityActionStylusButtonPress, null); + private static final ArraySet<AccessibilityAction> sStandardActions = new ArraySet<>(); static { sStandardActions.add(ACTION_FOCUS); @@ -3498,6 +3531,7 @@ public class AccessibilityNodeInfo implements Parcelable { sStandardActions.add(ACTION_SET_TEXT); sStandardActions.add(ACTION_SHOW_ON_SCREEN); sStandardActions.add(ACTION_SCROLL_TO_POSITION); + sStandardActions.add(ACTION_STYLUS_BUTTON_PRESS); } private final int mActionId; |
