Added ACTION_SCROLL_IN_DIRECTION

Also added TYPE_VIEW_TARGETED_BY_SCROLL event.

Test: see AccessibilityEndToEndTest.java

Bug: 249770245
Change-Id: I6ce4e0d881209dfcb33762437c04d52bce0235fb
This commit is contained in:
Shailen Tuli
2022-11-21 19:16:32 +00:00
parent 818be438cd
commit 3a1d16d741
5 changed files with 79 additions and 1 deletions

View File

@@ -2115,6 +2115,7 @@ package android {
field public static final int accessibilityActionPageUp = 16908358; // 0x1020046
field public static final int accessibilityActionPressAndHold = 16908362; // 0x102004a
field public static final int accessibilityActionScrollDown = 16908346; // 0x102003a
field public static final int accessibilityActionScrollInDirection;
field public static final int accessibilityActionScrollLeft = 16908345; // 0x1020039
field public static final int accessibilityActionScrollRight = 16908347; // 0x102003b
field public static final int accessibilityActionScrollToPosition = 16908343; // 0x1020037
@@ -52771,6 +52772,7 @@ package android.view.accessibility {
field public static final int TYPE_VIEW_LONG_CLICKED = 2; // 0x2
field public static final int TYPE_VIEW_SCROLLED = 4096; // 0x1000
field public static final int TYPE_VIEW_SELECTED = 4; // 0x4
field public static final int TYPE_VIEW_TARGETED_BY_SCROLL = 67108864; // 0x4000000
field public static final int TYPE_VIEW_TEXT_CHANGED = 16; // 0x10
field public static final int TYPE_VIEW_TEXT_SELECTION_CHANGED = 8192; // 0x2000
field public static final int TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY = 131072; // 0x20000
@@ -53011,6 +53013,7 @@ package android.view.accessibility {
method public void writeToParcel(android.os.Parcel, int);
field public static final int ACTION_ACCESSIBILITY_FOCUS = 64; // 0x40
field public static final String ACTION_ARGUMENT_COLUMN_INT = "android.view.accessibility.action.ARGUMENT_COLUMN_INT";
field public static final String ACTION_ARGUMENT_DIRECTION_INT = "android.view.accessibility.action.ARGUMENT_DIRECTION_INT";
field public static final String ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN = "ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN";
field public static final String ACTION_ARGUMENT_HTML_ELEMENT_STRING = "ACTION_ARGUMENT_HTML_ELEMENT_STRING";
field public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT = "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT";
@@ -53103,6 +53106,7 @@ package android.view.accessibility {
field public static final android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_BACKWARD;
field public static final android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_DOWN;
field public static final android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_FORWARD;
field @NonNull public static final android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_IN_DIRECTION;
field public static final android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_LEFT;
field public static final android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_RIGHT;
field public static final android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_TO_POSITION;

View File

@@ -304,6 +304,20 @@ import java.util.List;
* </ul>
* </p>
* <p>
* <b>View scrolled to</b> - represents the event of a target node brought on screen by
* ACTION_SCROLL_IN_DIRECTION.
* <em>Type:</em> {@link #TYPE_VIEW_TARGETED_BY_SCROLL}</br>
* <em>Properties:</em></br>
* <ul>
* <li>{@link #getEventType()} - The type of the event.</li>
* <li>{@link #getSource()} - The source info (for registered clients). This represents the node
* that is brought on screen as a result of the scroll.</li>
* <li>{@link #getClassName()} - The class name of the source.</li>
* <li>{@link #getPackageName()} - The package name of the source.</li>
* <li>{@link #getEventTime()} - The event time.</li>
* </ul>
* </p>
* <p>
* <b>Touch interaction start</b> - represents the event of starting a touch
* interaction, which is the user starts touching the screen.</br>
* <em>Type:</em> {@link #TYPE_TOUCH_INTERACTION_START}</br>
@@ -595,6 +609,11 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
*/
public static final int TYPE_SPEECH_STATE_CHANGE = 0x02000000;
/**
* Represents the event of a scroll having completed and brought the target node on screen.
*/
public static final int TYPE_VIEW_TARGETED_BY_SCROLL = 0x04000000;
/**
* Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: The type of change is not
* defined.
@@ -899,7 +918,8 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
TYPE_WINDOWS_CHANGED,
TYPE_VIEW_CONTEXT_CLICKED,
TYPE_ASSIST_READING_CONTEXT,
TYPE_SPEECH_STATE_CHANGE
TYPE_SPEECH_STATE_CHANGE,
TYPE_VIEW_TARGETED_BY_SCROLL
})
@Retention(RetentionPolicy.SOURCE)
public @interface EventType {}
@@ -929,6 +949,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
* @see #TYPE_TOUCH_INTERACTION_END
* @see #TYPE_WINDOWS_CHANGED
* @see #TYPE_VIEW_CONTEXT_CLICKED
* @see #TYPE_VIEW_TARGETED_BY_SCROLL
*/
public static final int TYPES_ALL_MASK = 0xFFFFFFFF;
@@ -1729,6 +1750,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
case TYPE_VIEW_CONTEXT_CLICKED: return "TYPE_VIEW_CONTEXT_CLICKED";
case TYPE_ASSIST_READING_CONTEXT: return "TYPE_ASSIST_READING_CONTEXT";
case TYPE_SPEECH_STATE_CHANGE: return "TYPE_SPEECH_STATE_CHANGE";
case TYPE_VIEW_TARGETED_BY_SCROLL: return "TYPE_VIEW_TARGETED_BY_SCROLL";
default: return Integer.toHexString(eventType);
}
}

View File

@@ -659,6 +659,25 @@ public class AccessibilityNodeInfo implements Parcelable {
public static final String ACTION_ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT =
"android.view.accessibility.action.ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT";
/**
* <p>Argument to represent the direction when using
* {@link AccessibilityAction#ACTION_SCROLL_IN_DIRECTION}.</p>
*
* <p>
* The value of this argument can be one of:
* <ul>
* <li>{@link View#FOCUS_DOWN}</li>
* <li>{@link View#FOCUS_UP}</li>
* <li>{@link View#FOCUS_LEFT}</li>
* <li>{@link View#FOCUS_RIGHT}</li>
* <li>{@link View#FOCUS_FORWARD}</li>
* <li>{@link View#FOCUS_BACKWARD}</li>
* </ul>
* </p>
*/
public static final String ACTION_ARGUMENT_DIRECTION_INT =
"android.view.accessibility.action.ARGUMENT_DIRECTION_INT";
// Focus types
/**
@@ -4682,6 +4701,9 @@ public class AccessibilityNodeInfo implements Parcelable {
if (action == R.id.accessibilityActionShowTextSuggestions) {
return "ACTION_SHOW_TEXT_SUGGESTIONS";
}
if (action == R.id.accessibilityActionScrollInDirection) {
return "ACTION_SCROLL_IN_DIRECTION";
}
return "ACTION_UNKNOWN";
}
}
@@ -5217,6 +5239,32 @@ public class AccessibilityNodeInfo implements Parcelable {
public static final AccessibilityAction ACTION_SCROLL_TO_POSITION =
new AccessibilityAction(R.id.accessibilityActionScrollToPosition);
/**
* Action that brings fully on screen the next node in the specified direction.
*
* <p>
* This should include wrapping around to the next/previous row, column, etc. in a
* collection if one is available. If there is no node in that direction, the action
* should fail and return false.
* </p>
* <p>
* This action should be used instead of
* {@link AccessibilityAction#ACTION_SCROLL_TO_POSITION} when a widget does not have
* clear row and column semantics or if a directional search is needed to find a node in
* a complex ViewGroup where individual nodes may span multiple rows or columns. The
* implementing widget must send a
* {@link AccessibilityEvent#TYPE_VIEW_TARGETED_BY_SCROLL} accessibility event with the
* scroll target as the source. An accessibility service can listen for this event,
* inspect its source, and use the result when determining where to place accessibility
* focus.
* <p>
* <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_DIRECTION_INT}. This is a
* required argument.<br>
* </p>
*/
@NonNull public static final AccessibilityAction ACTION_SCROLL_IN_DIRECTION =
new AccessibilityAction(R.id.accessibilityActionScrollInDirection);
/**
* Action to scroll the node content up.
*/

View File

@@ -279,6 +279,9 @@
<!-- Accessibility action identifier for {@link android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction#ACTION_SHOW_TEXT_SUGGESTIONS}. -->
<item type="id" name="accessibilityActionShowTextSuggestions" />
<!-- Accessibility action identifier for {@link android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction#ACTION_SCROLL_IN_DIRECTION}. -->
<item type="id" name="accessibilityActionScrollInDirection" />
<!-- View tag for remote views to store the index of the next child when adding nested remote views dynamically. -->
<item type="id" name="remote_views_next_child" />

View File

@@ -124,6 +124,7 @@
<public name="bold" />
<public name="italic" />
<public name="underline" />
<public name="accessibilityActionScrollInDirection" />
</staging-public-group>
<staging-public-group type="style" first-id="0x01cc0000">