summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewGroup.java
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2012-05-15 11:31:28 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-15 11:31:28 -0700
commitd83a0800679583ccc99a90a128f8d6c11afbeca4 (patch)
treefb94a29f1450a20e089a53a54978f915f4fb8a51 /core/java/android/view/ViewGroup.java
parent1bcd6b8ce8f7769e0b61dd630c98d56116d43595 (diff)
parent8ce2d78aa89e89e9a5607d8809bf6d248508a531 (diff)
am 8ce2d78a: Merge "Improving accessibility focus traversal." into jb-dev
* commit '8ce2d78aa89e89e9a5607d8809bf6d248508a531': Improving accessibility focus traversal.
Diffstat (limited to 'core/java/android/view/ViewGroup.java')
-rw-r--r--core/java/android/view/ViewGroup.java38
1 files changed, 25 insertions, 13 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index f55b7acca9a0..b95ca5e3614f 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);
}
}
@@ -1659,6 +1657,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>