From 76f287e416ded85734b610f316e38d243d2ddb09 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Mon, 23 Apr 2012 11:02:36 -0700 Subject: Removing hierarchical accessibility focus directions. 1. The accessibility focus directions are not needed since an accessibility service just get the root, first child, next sibling, previous sibling and call execute the action to give it accessibility focus. Now the accessibility node info tree is properly ordered taking into account layout manager directions for both layout manager that we report and ones that we have determined as not important for accessibility. Also the position of a node info are ordered properly based on their coordinates after all transformations as opposed to child index. bug:5932640 Change-Id: I994a8297cb1e57c829ecbac73a937c2bcbe0bac7 --- .../view/AccessibilityInteractionController.java | 86 +++++++++++----------- 1 file changed, 45 insertions(+), 41 deletions(-) (limited to 'core/java/android/view/AccessibilityInteractionController.java') diff --git a/core/java/android/view/AccessibilityInteractionController.java b/core/java/android/view/AccessibilityInteractionController.java index 7d569adda0f8..63871486ade6 100644 --- a/core/java/android/view/AccessibilityInteractionController.java +++ b/core/java/android/view/AccessibilityInteractionController.java @@ -662,29 +662,31 @@ final class AccessibilityInteractionController { ViewGroup parentGroup = (ViewGroup) parent; ChildListForAccessibility children = ChildListForAccessibility.obtain(parentGroup, false); - final int childCount = children.getChildCount(); - for (int i = 0; i < childCount; i++) { - if (outInfos.size() >= MAX_ACCESSIBILITY_NODE_INFO_BATCH_SIZE) { - children.recycle(); - return; - } - View child = children.getChildAt(i); - if (child.getAccessibilityViewId() != current.getAccessibilityViewId() - && child.isDisplayedOnScreen()) { - AccessibilityNodeInfo info = null; - AccessibilityNodeProvider provider = child.getAccessibilityNodeProvider(); - if (provider == null) { - info = child.createAccessibilityNodeInfo(); - } else { - info = provider.createAccessibilityNodeInfo( - AccessibilityNodeInfo.UNDEFINED); + try { + final int childCount = children.getChildCount(); + for (int i = 0; i < childCount; i++) { + if (outInfos.size() >= MAX_ACCESSIBILITY_NODE_INFO_BATCH_SIZE) { + return; } - if (info != null) { - outInfos.add(info); + View child = children.getChildAt(i); + if (child.getAccessibilityViewId() != current.getAccessibilityViewId() + && child.isDisplayedOnScreen()) { + AccessibilityNodeInfo info = null; + AccessibilityNodeProvider provider = child.getAccessibilityNodeProvider(); + if (provider == null) { + info = child.createAccessibilityNodeInfo(); + } else { + info = provider.createAccessibilityNodeInfo( + AccessibilityNodeInfo.UNDEFINED); + } + if (info != null) { + outInfos.add(info); + } } } + } finally { + children.recycle(); } - children.recycle(); } } @@ -697,32 +699,34 @@ final class AccessibilityInteractionController { HashMap addedChildren = new HashMap(); ChildListForAccessibility children = ChildListForAccessibility.obtain(rootGroup, false); - final int childCount = children.getChildCount(); - for (int i = 0; i < childCount; i++) { - if (outInfos.size() >= MAX_ACCESSIBILITY_NODE_INFO_BATCH_SIZE) { - children.recycle(); - return; - } - View child = children.getChildAt(i); - if (child.isDisplayedOnScreen()) { - AccessibilityNodeProvider provider = child.getAccessibilityNodeProvider(); - if (provider == null) { - AccessibilityNodeInfo info = child.createAccessibilityNodeInfo(); - if (info != null) { - outInfos.add(info); - addedChildren.put(child, null); - } - } else { - AccessibilityNodeInfo info = provider.createAccessibilityNodeInfo( - AccessibilityNodeInfo.UNDEFINED); - if (info != null) { - outInfos.add(info); - addedChildren.put(child, info); + try { + final int childCount = children.getChildCount(); + for (int i = 0; i < childCount; i++) { + if (outInfos.size() >= MAX_ACCESSIBILITY_NODE_INFO_BATCH_SIZE) { + return; + } + View child = children.getChildAt(i); + if (child.isDisplayedOnScreen()) { + AccessibilityNodeProvider provider = child.getAccessibilityNodeProvider(); + if (provider == null) { + AccessibilityNodeInfo info = child.createAccessibilityNodeInfo(); + if (info != null) { + outInfos.add(info); + addedChildren.put(child, null); + } + } else { + AccessibilityNodeInfo info = provider.createAccessibilityNodeInfo( + AccessibilityNodeInfo.UNDEFINED); + if (info != null) { + outInfos.add(info); + addedChildren.put(child, info); + } } } } + } finally { + children.recycle(); } - children.recycle(); if (outInfos.size() < MAX_ACCESSIBILITY_NODE_INFO_BATCH_SIZE) { for (Map.Entry entry : addedChildren.entrySet()) { View addedChild = entry.getKey(); -- cgit v1.2.3