Return an empty accessibility node info for a keyboard
Because a keyboard handling hover events and determining a virtual node by itself, there is no need to supply whole virtual nodes info for the keyboard. Just returning an empty accessibility node info supresses annoucements of all keys. This CL also fixes the undefined virtual id value. Bug: 15582251 Change-Id: Ie033d21ef878d272417cf2b20f8eec1e516587f6
parent
03eba0927d
commit
9934740a5f
|
@ -49,7 +49,9 @@ import java.util.List;
|
|||
*/
|
||||
final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderCompat {
|
||||
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 AccessibilityUtils mAccessibilityUtils;
|
||||
|
@ -167,22 +169,10 @@ final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderC
|
|||
}
|
||||
if (virtualViewId == View.NO_ID) {
|
||||
// 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 =
|
||||
AccessibilityNodeInfoCompat.obtain(mKeyboardView);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue