diff options
| author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-05-08 15:58:32 -0700 |
|---|---|---|
| committer | Svetoslav Ganov <svetoslavganov@google.com> | 2012-05-14 16:21:29 -0700 |
| commit | e5dfa47d84668376b84074c04570fb961870adeb (patch) | |
| tree | 3be9fe55e6170d33bbfb7fe57af3a1cc05c05266 /core/java/android/view/ViewGroup.java | |
| parent | 0d607fbe546ac943de38dad33ae681b09efec6ea (diff) | |
Improving accessibility focus traversal.
1. Now the views considered during the accessibility focus search
are the ones that would get accessibility focus when thovered
over. This way the user will get the same items i.e. feedback
if he touch explores the screen and uses focus traversal. This
is imperative for a good user experience.
2. Updated which focusables are considered when searching for access
focus in ViewGroup. Generally accessibility focus ignores focus
before/after descendants.
3. Implemented focus search strategy in AbsListView that will traverse
the items of the current list (and the stuff withing one item
before moving to the next) before continuing the search if
forward and backward accessibility focus direction.
4. View focus search stops at root namespace. This is not the right
way to prevent some stuff that is not supposed to get a focus in
a container for a specific state. Actually the addFocusables
for that container has to be overriden. Further this approach
leads to focus getting stuck. The accessibility focus ignores
root names space since we want to traverse the entire screen.
5. Fixed an bug in AccessibilityInteractionController which was not
starting to search from the root of a virtual node tree.
6. Fixed a couple of bugs in FocusFinder where it was possible to
get index out of bounds exception if the focusables list is empty.
bug:5932640
Change-Id: Ic3bdd11767a7d40fbb21f35dcd79a4746af784d4
Diffstat (limited to 'core/java/android/view/ViewGroup.java')
| -rw-r--r-- | core/java/android/view/ViewGroup.java | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index b3c8895a9f9e..a4c0258accee 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -628,7 +628,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * FOCUS_RIGHT, or 0 for not applicable. */ public View focusSearch(View focused, int direction) { - if (isRootNamespace()) { + // If we are moving accessibility focus we want to consider all + // views no matter if they are on the screen. It is responsibility + // of the accessibility service to check whether the result is in + // the screen. + if (isRootNamespace() && (direction & FOCUS_ACCESSIBILITY) == 0) { // root namespace means we should consider ourselves the top of the // tree for focus searching; otherwise we could be focus searching // into other tabs. see LocalActivityManager and TabHost for more info @@ -857,20 +861,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * {@inheritDoc} */ @Override - public void addFocusables(ArrayList<View> views, int direction) { - addFocusables(views, direction, FOCUSABLES_TOUCH_MODE); - } - - /** - * {@inheritDoc} - */ - @Override public void addFocusables(ArrayList<View> views, int direction, int focusableMode) { final int focusableCount = views.size(); final int descendantFocusability = getDescendantFocusability(); - if (descendantFocusability != FOCUS_BLOCK_DESCENDANTS) { + if (descendantFocusability != FOCUS_BLOCK_DESCENDANTS + || (focusableMode & FOCUSABLES_ACCESSIBILITY) == FOCUSABLES_ACCESSIBILITY) { final int count = mChildrenCount; final View[] children = mChildren; @@ -886,10 +883,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // FOCUS_AFTER_DESCENDANTS and there are some descendants focusable. this is // to avoid the focus search finding layouts when a more precise search // among the focusable children would be more interesting. - if ( - descendantFocusability != FOCUS_AFTER_DESCENDANTS || + if (descendantFocusability != FOCUS_AFTER_DESCENDANTS // No focusable descendants - (focusableCount == views.size())) { + || (focusableCount == views.size()) + // We are collecting accessibility focusables. + || (focusableMode & FOCUSABLES_ACCESSIBILITY) == FOCUSABLES_ACCESSIBILITY) { super.addFocusables(views, direction, focusableMode); } } @@ -1660,6 +1658,20 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } /** + * @hide + */ + @Override + public View findViewToTakeAccessibilityFocusFromHover(View child, View descendant) { + if (includeForAccessibility() && isActionableForAccessibility()) { + return this; + } + if (mParent != null) { + return mParent.findViewToTakeAccessibilityFocusFromHover(this, descendant); + } + return null; + } + + /** * Implement this method to intercept hover events before they are handled * by child views. * <p> |
