Populate accessibility root node info of keyboard
Partially reverting Ie033d21ef8 to populate root node info. This CL also fixes the bounds in screen of virtual node info. Bug: 15746768 Bug: 15582251 Change-Id: I3a82f904270adf138036ef462fd70b349a3cd33e
This commit is contained in:
parent
d2e566f999
commit
d801b6ee66
2 changed files with 23 additions and 4 deletions
|
@ -76,7 +76,6 @@ final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderC
|
||||||
mKeyCodeDescriptionMapper = KeyCodeDescriptionMapper.getInstance();
|
mKeyCodeDescriptionMapper = KeyCodeDescriptionMapper.getInstance();
|
||||||
mAccessibilityUtils = AccessibilityUtils.getInstance();
|
mAccessibilityUtils = AccessibilityUtils.getInstance();
|
||||||
mKeyboardView = keyboardView;
|
mKeyboardView = keyboardView;
|
||||||
updateParentLocation();
|
|
||||||
|
|
||||||
// Since this class is constructed lazily, we might not get a subsequent
|
// Since this class is constructed lazily, we might not get a subsequent
|
||||||
// call to setKeyboard() and therefore need to call it now.
|
// call to setKeyboard() and therefore need to call it now.
|
||||||
|
@ -169,10 +168,23 @@ 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. Returning an empty info is sufficient for a keyboard.
|
// this View, i.e. the root of the virtual sub-tree.
|
||||||
final AccessibilityNodeInfoCompat rootInfo =
|
final AccessibilityNodeInfoCompat rootInfo =
|
||||||
AccessibilityNodeInfoCompat.obtain(mKeyboardView);
|
AccessibilityNodeInfoCompat.obtain(mKeyboardView);
|
||||||
ViewCompat.onInitializeAccessibilityNodeInfo(mKeyboardView, rootInfo);
|
ViewCompat.onInitializeAccessibilityNodeInfo(mKeyboardView, rootInfo);
|
||||||
|
updateParentLocation();
|
||||||
|
|
||||||
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,9 +212,9 @@ final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderC
|
||||||
info.setBoundsInScreen(boundsInScreen);
|
info.setBoundsInScreen(boundsInScreen);
|
||||||
info.setParent(mKeyboardView);
|
info.setParent(mKeyboardView);
|
||||||
info.setSource(mKeyboardView, virtualViewId);
|
info.setSource(mKeyboardView, virtualViewId);
|
||||||
info.setBoundsInScreen(boundsInScreen);
|
info.setEnabled(key.isEnabled());
|
||||||
info.setEnabled(true);
|
|
||||||
info.setVisibleToUser(true);
|
info.setVisibleToUser(true);
|
||||||
|
// TODO: Add ACTION_CLICK and ACTION_LONG_CLICK.
|
||||||
|
|
||||||
if (mAccessibilityFocusedView == virtualViewId) {
|
if (mAccessibilityFocusedView == virtualViewId) {
|
||||||
info.addAction(AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
info.addAction(AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.os.Handler;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
|
|
||||||
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
||||||
import com.android.inputmethod.accessibility.KeyboardAccessibilityDelegate;
|
import com.android.inputmethod.accessibility.KeyboardAccessibilityDelegate;
|
||||||
|
@ -106,6 +107,12 @@ final class EmojiPageKeyboardView extends KeyboardView implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dispatchPopulateAccessibilityEvent(final AccessibilityEvent event) {
|
||||||
|
// Don't populate accessibility event with all Emoji keys.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue