From 23f4432437b2ab742971055b7eb79b346894f24b Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Mon, 6 Apr 2015 16:04:56 -0700 Subject: Add accessibility action for scrolling to a collection position Cleans up verbose R package in GridView, accessibility action docs, and some lint warnings in AccessibilityNodeInfo. Makes the action IDs for SHOW_ON_SCREEN and SCROLL_TO_POSITION public so that we can guarantee they won't change (and thus reference them in support lib). Change-Id: Ica53b7be7a68b84054b9bac1fc7958a21a42e089 --- .../view/accessibility/AccessibilityNodeInfo.java | 122 +++++++++++++++------ 1 file changed, 91 insertions(+), 31 deletions(-) (limited to 'core/java/android/view/accessibility') diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index ec527d5..0736ed8 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -266,7 +266,8 @@ public class AccessibilityNodeInfo implements Parcelable { * Action to set the selection. Performing this action with no arguments * clears the selection. *

- * Arguments: {@link #ACTION_ARGUMENT_SELECTION_START_INT}, + * Arguments: + * {@link #ACTION_ARGUMENT_SELECTION_START_INT}, * {@link #ACTION_ARGUMENT_SELECTION_END_INT}
* Example: *

@@ -302,7 +303,8 @@ public class AccessibilityNodeInfo implements Parcelable { * null or empty {@link CharSequence} will clear the text. This action will also put the * cursor at the end of text. *

- * Arguments: {@link #ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE}
+ * Arguments: + * {@link #ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE}
* Example: *

* Bundle arguments = new Bundle(); @@ -326,12 +328,15 @@ public class AccessibilityNodeInfo implements Parcelable { * Argument for which movement granularity to be used when traversing the node text. *

* Type: int
- * Actions: {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY}, - * {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY} + * Actions: + *

    + *
  • {@link AccessibilityAction#ACTION_NEXT_AT_MOVEMENT_GRANULARITY}
  • + *
  • {@link AccessibilityAction#ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY}
  • + *
*

* - * @see #ACTION_NEXT_AT_MOVEMENT_GRANULARITY - * @see #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY + * @see AccessibilityAction#ACTION_NEXT_AT_MOVEMENT_GRANULARITY + * @see AccessibilityAction#ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY */ public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT = "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT"; @@ -340,12 +345,15 @@ public class AccessibilityNodeInfo implements Parcelable { * Argument for which HTML element to get moving to the next/previous HTML element. *

* Type: String
- * Actions: {@link #ACTION_NEXT_HTML_ELEMENT}, - * {@link #ACTION_PREVIOUS_HTML_ELEMENT} + * Actions: + *

    + *
  • {@link AccessibilityAction#ACTION_NEXT_HTML_ELEMENT}
  • + *
  • {@link AccessibilityAction#ACTION_PREVIOUS_HTML_ELEMENT}
  • + *
*

* - * @see #ACTION_NEXT_HTML_ELEMENT - * @see #ACTION_PREVIOUS_HTML_ELEMENT + * @see AccessibilityAction#ACTION_NEXT_HTML_ELEMENT + * @see AccessibilityAction#ACTION_PREVIOUS_HTML_ELEMENT */ public static final String ACTION_ARGUMENT_HTML_ELEMENT_STRING = "ACTION_ARGUMENT_HTML_ELEMENT_STRING"; @@ -355,12 +363,14 @@ public class AccessibilityNodeInfo implements Parcelable { * or to move it otherwise. *

* Type: boolean
- * Actions: {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY}, - * {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY} - *

+ * Actions: + *
    + *
  • {@link AccessibilityAction#ACTION_NEXT_AT_MOVEMENT_GRANULARITY}
  • + *
  • {@link AccessibilityAction#ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY}
  • + *
* - * @see #ACTION_NEXT_AT_MOVEMENT_GRANULARITY - * @see #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY + * @see AccessibilityAction#ACTION_NEXT_AT_MOVEMENT_GRANULARITY + * @see AccessibilityAction#ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY */ public static final String ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN = "ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN"; @@ -369,10 +379,12 @@ public class AccessibilityNodeInfo implements Parcelable { * Argument for specifying the selection start. *

* Type: int
- * Actions: {@link #ACTION_SET_SELECTION} - *

+ * Actions: + *
    + *
  • {@link AccessibilityAction#ACTION_SET_SELECTION}
  • + *
* - * @see #ACTION_SET_SELECTION + * @see AccessibilityAction#ACTION_SET_SELECTION */ public static final String ACTION_ARGUMENT_SELECTION_START_INT = "ACTION_ARGUMENT_SELECTION_START_INT"; @@ -381,26 +393,58 @@ public class AccessibilityNodeInfo implements Parcelable { * Argument for specifying the selection end. *

* Type: int
- * Actions: {@link #ACTION_SET_SELECTION} - *

+ * Actions: + *
    + *
  • {@link AccessibilityAction#ACTION_SET_SELECTION}
  • + *
* - * @see #ACTION_SET_SELECTION + * @see AccessibilityAction#ACTION_SET_SELECTION */ public static final String ACTION_ARGUMENT_SELECTION_END_INT = "ACTION_ARGUMENT_SELECTION_END_INT"; /** - * Argument for specifying the text content to set + * Argument for specifying the text content to set. *

* Type: CharSequence
- * Actions: {@link #ACTION_SET_TEXT} - *

+ * Actions: + *
    + *
  • {@link AccessibilityAction#ACTION_SET_TEXT}
  • + *
* - * @see #ACTION_SET_TEXT + * @see AccessibilityAction#ACTION_SET_TEXT */ public static final String ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE = "ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE"; + /** + * Argument for specifying the collection row to make visible on screen. + *

+ * Type: int
+ * Actions: + *

    + *
  • {@link AccessibilityAction#ACTION_SCROLL_TO_POSITION}
  • + *
+ * + * @see AccessibilityAction#ACTION_SCROLL_TO_POSITION + */ + public static final String ACTION_ARGUMENT_ROW_INT = + "android.view.accessibility.action.ARGUMENT_ROW_INT"; + + /** + * Argument for specifying the collection column to make visible on screen. + *

+ * Type: int
+ * Actions: + *

    + *
  • {@link AccessibilityAction#ACTION_SCROLL_TO_POSITION}
  • + *
+ * + * @see AccessibilityAction#ACTION_SCROLL_TO_POSITION + */ + public static final String ACTION_ARGUMENT_COLUMN_INT = + "android.view.accessibility.action.ARGUMENT_COLUMN_INT"; + // Focus types /** @@ -539,7 +583,7 @@ public class AccessibilityNodeInfo implements Parcelable { // Housekeeping. private static final int MAX_POOL_SIZE = 50; private static final SynchronizedPool sPool = - new SynchronizedPool(MAX_POOL_SIZE); + new SynchronizedPool<>(MAX_POOL_SIZE); private boolean mSealed; @@ -970,7 +1014,7 @@ public class AccessibilityNodeInfo implements Parcelable { } if (mActions == null) { - mActions = new ArrayList(); + mActions = new ArrayList<>(); } mActions.remove(action); @@ -3411,9 +3455,24 @@ public class AccessibilityNodeInfo implements Parcelable { * @see View#requestRectangleOnScreen(Rect) */ public static final AccessibilityAction ACTION_SHOW_ON_SCREEN = - new AccessibilityAction(R.id.accessibility_action_show_on_screen, null); + new AccessibilityAction(R.id.accessibilityActionShowOnScreen, null); + + /** + * Action that scrolls the node to make the specified collection + * position visible on screen. + *

+ * Arguments: + *

    + *
  • {@link AccessibilityNodeInfo#ACTION_ARGUMENT_ROW_INT}
  • + *
  • {@link AccessibilityNodeInfo#ACTION_ARGUMENT_COLUMN_INT}
  • + *
      + * + * @see AccessibilityNodeInfo#getCollectionInfo() + */ + public static final AccessibilityAction ACTION_SCROLL_TO_POSITION = + new AccessibilityAction(R.id.accessibilityActionScrollToPosition, null); - private static final ArraySet sStandardActions = new ArraySet(); + private static final ArraySet sStandardActions = new ArraySet<>(); static { sStandardActions.add(ACTION_FOCUS); sStandardActions.add(ACTION_CLEAR_FOCUS); @@ -3438,6 +3497,7 @@ public class AccessibilityNodeInfo implements Parcelable { sStandardActions.add(ACTION_DISMISS); sStandardActions.add(ACTION_SET_TEXT); sStandardActions.add(ACTION_SHOW_ON_SCREEN); + sStandardActions.add(ACTION_SCROLL_TO_POSITION); } private final int mActionId; @@ -3658,7 +3718,7 @@ public class AccessibilityNodeInfo implements Parcelable { private static final int MAX_POOL_SIZE = 20; private static final SynchronizedPool sPool = - new SynchronizedPool(MAX_POOL_SIZE); + new SynchronizedPool<>(MAX_POOL_SIZE); private int mRowCount; private int mColumnCount; @@ -3804,7 +3864,7 @@ public class AccessibilityNodeInfo implements Parcelable { private static final int MAX_POOL_SIZE = 20; private static final SynchronizedPool sPool = - new SynchronizedPool(MAX_POOL_SIZE); + new SynchronizedPool<>(MAX_POOL_SIZE); /** * Obtains a pooled instance that is a clone of another one. -- cgit v1.1