am d801b6ee: Populate accessibility root node info of keyboard

* commit 'd801b6ee668f6ed4ef1926fd2cdb928fd36ace3a':
  Populate accessibility root node info of keyboard
main
Tadashi G. Takaoka 2014-06-20 23:12:05 +00:00 committed by Android Git Automerger
commit ef19c71a26
2 changed files with 23 additions and 4 deletions

View File

@ -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);

View File

@ -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}
*/ */