am 163f3185: Merge "Return an empty accessibility node info for a keyboard"

* commit '163f318545f6c4c568e96cc1e379afed41159d31':
  Return an empty accessibility node info for a keyboard
This commit is contained in:
Tadashi G. Takaoka 2014-06-13 07:52:21 +00:00 committed by Android Git Automerger
commit 0658d88e6a

View file

@ -49,7 +49,9 @@ import java.util.List;
*/ */
final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderCompat { final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderCompat {
private static final String TAG = KeyboardAccessibilityNodeProvider.class.getSimpleName(); private static final String TAG = KeyboardAccessibilityNodeProvider.class.getSimpleName();
private static final int UNDEFINED = Integer.MIN_VALUE;
// From {@link android.view.accessibility.AccessibilityNodeInfo#UNDEFINED_ITEM_ID}.
private static final int UNDEFINED = Integer.MAX_VALUE;
private final KeyCodeDescriptionMapper mKeyCodeDescriptionMapper; private final KeyCodeDescriptionMapper mKeyCodeDescriptionMapper;
private final AccessibilityUtils mAccessibilityUtils; private final AccessibilityUtils mAccessibilityUtils;
@ -167,22 +169,10 @@ final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderC
} }
if (virtualViewId == View.NO_ID) { if (virtualViewId == View.NO_ID) {
// We are requested to create an AccessibilityNodeInfo describing // We are requested to create an AccessibilityNodeInfo describing
// this View, i.e. the root of the virtual sub-tree. // this View. Returning an empty info is sufficient for a keyboard.
final AccessibilityNodeInfoCompat rootInfo = final AccessibilityNodeInfoCompat rootInfo =
AccessibilityNodeInfoCompat.obtain(mKeyboardView); AccessibilityNodeInfoCompat.obtain(mKeyboardView);
ViewCompat.onInitializeAccessibilityNodeInfo(mKeyboardView, rootInfo); ViewCompat.onInitializeAccessibilityNodeInfo(mKeyboardView, rootInfo);
// Add the virtual children of the root View.
final List<Key> sortedKeys = mKeyboard.getSortedKeys();
final int size = sortedKeys.size();
for (int index = 0; index < size; index++) {
final Key key = sortedKeys.get(index);
if (key.isSpacer()) {
continue;
}
// Use an index of the sorted keys list as a virtual view id.
rootInfo.addChild(mKeyboardView, index);
}
return rootInfo; return rootInfo;
} }