summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/View.java
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2013-10-02 17:41:15 -0700
committerAlan Viverette <alanv@google.com>2013-10-02 17:41:15 -0700
commit23be199171bedb05e81864f8941492af066fa667 (patch)
tree77e353eae03a2d5e419f669c4653642a5adf5806 /core/java/android/view/View.java
parent4c6b29006f2e6605da18ff8ad9acba2594ec78a2 (diff)
downloadframeworks_base-23be199171bedb05e81864f8941492af066fa667.zip
frameworks_base-23be199171bedb05e81864f8941492af066fa667.tar.gz
frameworks_base-23be199171bedb05e81864f8941492af066fa667.tar.bz2
Add importantForAccessibility mode to block entire hierarchy
Since older versions of the platform will crash if the mode is set to 3, this CL adds an extra bit and uses 4 as the mode. This will also cleanly default the mode to AUTO on unsupported platforms. BUG: 11031947 Change-Id: I48035abbf35523d65cead6f27be10f8087973ceb
Diffstat (limited to 'core/java/android/view/View.java')
-rw-r--r--core/java/android/view/View.java44
1 files changed, 30 insertions, 14 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 06f00f7..f763d19 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2121,6 +2121,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = 0x00000002;
/**
+ * The view is not important for accessibility, nor are any of its
+ * descendant views.
+ */
+ public static final int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS = 0x00000004;
+
+ /**
* The default whether the view is important for accessibility.
*/
static final int IMPORTANT_FOR_ACCESSIBILITY_DEFAULT = IMPORTANT_FOR_ACCESSIBILITY_AUTO;
@@ -2130,14 +2136,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* whether a view is important for accessibility.
*/
static final int PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK = (IMPORTANT_FOR_ACCESSIBILITY_AUTO
- | IMPORTANT_FOR_ACCESSIBILITY_YES | IMPORTANT_FOR_ACCESSIBILITY_NO)
+ | IMPORTANT_FOR_ACCESSIBILITY_YES | IMPORTANT_FOR_ACCESSIBILITY_NO
+ | IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS)
<< PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT;
/**
* Shift for the bits in {@link #mPrivateFlags2} related to the
* "accessibilityLiveRegion" attribute.
*/
- static final int PFLAG2_ACCESSIBILITY_LIVE_REGION_SHIFT = 22;
+ static final int PFLAG2_ACCESSIBILITY_LIVE_REGION_SHIFT = 23;
/**
* Live region mode specifying that accessibility services should not
@@ -6999,12 +7006,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @see #IMPORTANT_FOR_ACCESSIBILITY_YES
* @see #IMPORTANT_FOR_ACCESSIBILITY_NO
+ * @see #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
* @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
*/
@ViewDebug.ExportedProperty(category = "accessibility", mapping = {
@ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_AUTO, to = "auto"),
@ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_YES, to = "yes"),
- @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_NO, to = "no")
+ @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_NO, to = "no"),
+ @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS,
+ to = "noHideDescendants")
})
public int getImportantForAccessibility() {
return (mPrivateFlags2 & PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK)
@@ -7074,6 +7084,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @see #IMPORTANT_FOR_ACCESSIBILITY_YES
* @see #IMPORTANT_FOR_ACCESSIBILITY_NO
+ * @see #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
* @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
*/
public void setImportantForAccessibility(int mode) {
@@ -7101,19 +7112,24 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
public boolean isImportantForAccessibility() {
final int mode = (mPrivateFlags2 & PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK)
>> PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT;
- switch (mode) {
- case IMPORTANT_FOR_ACCESSIBILITY_YES:
- return true;
- case IMPORTANT_FOR_ACCESSIBILITY_NO:
+ if (mode == IMPORTANT_FOR_ACCESSIBILITY_NO
+ || mode == IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
+ return false;
+ }
+
+ // Check parent mode to ensure we're not hidden.
+ ViewParent parent = mParent;
+ while (parent instanceof View) {
+ if (((View) parent).getImportantForAccessibility()
+ == IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
return false;
- case IMPORTANT_FOR_ACCESSIBILITY_AUTO:
- return isActionableForAccessibility() || hasListenersForAccessibility()
- || getAccessibilityNodeProvider() != null
- || getAccessibilityLiveRegion() != ACCESSIBILITY_LIVE_REGION_NONE;
- default:
- throw new IllegalArgumentException("Unknow important for accessibility mode: "
- + mode);
+ }
+ parent = parent.getParent();
}
+
+ return mode == IMPORTANT_FOR_ACCESSIBILITY_YES || isActionableForAccessibility()
+ || hasListenersForAccessibility() || getAccessibilityNodeProvider() != null
+ || getAccessibilityLiveRegion() != ACCESSIBILITY_LIVE_REGION_NONE;
}
/**