Merge "Exposes accessibility importance on AccessibilityNodeInfo"
This commit is contained in:
committed by
Android (Google) Code Review
commit
cbfd71c66d
@@ -6770,6 +6770,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
|
||||
info.setVisibleToUser(isVisibleToUser());
|
||||
|
||||
if ((mAttachInfo != null) && ((mAttachInfo.mAccessibilityFetchFlags
|
||||
& AccessibilityNodeInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) != 0)) {
|
||||
info.setImportantForAccessibility(isImportantForAccessibility());
|
||||
} else {
|
||||
info.setImportantForAccessibility(true);
|
||||
}
|
||||
|
||||
info.setPackageName(mContext.getPackageName());
|
||||
info.setClassName(getAccessibilityClassName());
|
||||
info.setContentDescription(getContentDescription());
|
||||
|
||||
@@ -569,6 +569,8 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
|
||||
private static final int BOOLEAN_PROPERTY_CONTEXT_CLICKABLE = 0x00020000;
|
||||
|
||||
private static final int BOOLEAN_PROPERTY_IMPORTANCE = 0x0040000;
|
||||
|
||||
/**
|
||||
* Bits that provide the id of a virtual descendant of a view.
|
||||
*/
|
||||
@@ -2156,6 +2158,33 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
setBooleanProperty(BOOLEAN_PROPERTY_DISMISSABLE, dismissable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the node originates from a view considered important for accessibility.
|
||||
*
|
||||
* @return {@code true} if the node originates from a view considered important for
|
||||
* accessibility, {@code false} otherwise
|
||||
*
|
||||
* @see View#isImportantForAccessibility()
|
||||
*/
|
||||
public boolean isImportantForAccessibility() {
|
||||
return getBooleanProperty(BOOLEAN_PROPERTY_IMPORTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node is considered important for accessibility.
|
||||
* <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 important {@code true} if the node is considered important for accessibility,
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
public void setImportantForAccessibility(boolean important) {
|
||||
setBooleanProperty(BOOLEAN_PROPERTY_IMPORTANCE, important);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the package this node comes from.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user