From 4ecee5c2a6a350860b19d2bc7fab740afaa02621 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Wed, 27 Nov 2013 18:00:50 -0800 Subject: [PATCH] Unhide accessibility focus and importance getter APIs BUG: 11421928 Change-Id: Ica5cf80fc7e4c1cb0900d4d0d2e7b0d02ff13c87 --- api/current.txt | 2 ++ core/java/android/view/View.java | 34 ++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/api/current.txt b/api/current.txt index 0a88f87a8d216..26d1292ac7694 100644 --- a/api/current.txt +++ b/api/current.txt @@ -28421,6 +28421,7 @@ package android.view { method public void invalidate(int, int, int, int); method public void invalidate(); method public void invalidateDrawable(android.graphics.drawable.Drawable); + method public boolean isAccessibilityFocused(); method public boolean isActivated(); method public boolean isAttachedToWindow(); method public boolean isClickable(); @@ -28436,6 +28437,7 @@ package android.view { method public boolean isHorizontalFadingEdgeEnabled(); method public boolean isHorizontalScrollBarEnabled(); method public boolean isHovered(); + method public boolean isImportantForAccessibility(); method public boolean isInEditMode(); method public boolean isInLayout(); method public boolean isInTouchMode(); diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 2734abc3edc53..26ac995e059d3 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -6941,7 +6941,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * Returns whether this View is accessibility focused. * * @return True if this View is accessibility focused. - * @hide */ public boolean isAccessibilityFocused() { return (mPrivateFlags2 & PFLAG2_ACCESSIBILITY_FOCUSED) != 0; @@ -7289,11 +7288,38 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** - * Gets whether this view should be exposed for accessibility. + * Computes whether this view should be exposed for accessibility. In + * general, views that are interactive or provide information are exposed + * while views that serve only as containers are hidden. + *

+ * If an ancestor of this view has importance + * {@link #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS}, this method + * returns false. + *

+ * Otherwise, the value is computed according to the view's + * {@link #getImportantForAccessibility()} value: + *

    + *
  1. {@link #IMPORTANT_FOR_ACCESSIBILITY_NO} or + * {@link #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS}, return false + * + *
  2. {@link #IMPORTANT_FOR_ACCESSIBILITY_YES}, return true + *
  3. {@link #IMPORTANT_FOR_ACCESSIBILITY_AUTO}, return true if + * view satisfies any of the following: + *
      + *
    • Is actionable, e.g. {@link #isClickable()}, + * {@link #isLongClickable()}, or {@link #isFocusable()} + *
    • Has an {@link AccessibilityDelegate} + *
    • Has an interaction listener, e.g. {@link OnTouchListener}, + * {@link OnKeyListener}, etc. + *
    • Is an accessibility live region, e.g. + * {@link #getAccessibilityLiveRegion()} is not + * {@link #ACCESSIBILITY_LIVE_REGION_NONE}. + *
    + *
* * @return Whether the view is exposed for accessibility. - * - * @hide + * @see #setImportantForAccessibility(int) + * @see #getImportantForAccessibility() */ public boolean isImportantForAccessibility() { final int mode = (mPrivateFlags2 & PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK)