Add EmojiPageKeyboardAccessibilityDelegate

Because EmojiPageKeyboardView doesn't use PointerTracker to handle
MotionEvent, a dedicated accessibility delegate is needed. Then the
recent tab can be updated even with accessibility mode on.

Bug: 15582599
Change-Id: I63d75b9aca21ec44f1f77d2eaaf2ba7813992183
This commit is contained in:
Tadashi G. Takaoka 2014-06-13 13:33:19 +09:00
parent c1cb930dde
commit e9d9b37b5a
2 changed files with 21 additions and 5 deletions

View file

@ -55,7 +55,22 @@ final class EmojiPageKeyboardView extends KeyboardView implements
private OnKeyEventListener mListener = EMPTY_LISTENER; private OnKeyEventListener mListener = EMPTY_LISTENER;
private final KeyDetector mKeyDetector = new KeyDetector(); private final KeyDetector mKeyDetector = new KeyDetector();
private final GestureDetector mGestureDetector; private final GestureDetector mGestureDetector;
private KeyboardAccessibilityDelegate<EmojiPageKeyboardView> mAccessibilityDelegate; private EmojiPageKeyboardAccessibilityDelegate mAccessibilityDelegate;
private static final class EmojiPageKeyboardAccessibilityDelegate
extends KeyboardAccessibilityDelegate<EmojiPageKeyboardView> {
public EmojiPageKeyboardAccessibilityDelegate(final EmojiPageKeyboardView keyboardView,
final KeyDetector keyDetector) {
super(keyboardView, keyDetector);
}
@Override
protected void simulateTouchEvent(int touchAction, MotionEvent hoverEvent) {
final MotionEvent touchEvent = synthesizeTouchEvent(touchAction, hoverEvent);
mKeyboardView.onTouchEvent(touchEvent);
touchEvent.recycle();
}
}
public EmojiPageKeyboardView(final Context context, final AttributeSet attrs) { public EmojiPageKeyboardView(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.keyboardViewStyle); this(context, attrs, R.attr.keyboardViewStyle);
@ -82,7 +97,8 @@ final class EmojiPageKeyboardView extends KeyboardView implements
mKeyDetector.setKeyboard(keyboard, 0 /* correctionX */, 0 /* correctionY */); mKeyDetector.setKeyboard(keyboard, 0 /* correctionX */, 0 /* correctionY */);
if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) { if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) {
if (mAccessibilityDelegate == null) { if (mAccessibilityDelegate == null) {
mAccessibilityDelegate = new KeyboardAccessibilityDelegate<>(this, mKeyDetector); mAccessibilityDelegate = new EmojiPageKeyboardAccessibilityDelegate(
this, mKeyDetector);
} }
mAccessibilityDelegate.setKeyboard(keyboard); mAccessibilityDelegate.setKeyboard(keyboard);
} else { } else {

View file

@ -263,10 +263,10 @@ public final class Constants {
case CODE_ENTER: return "enter"; case CODE_ENTER: return "enter";
case CODE_SPACE: return "space"; case CODE_SPACE: return "space";
default: default:
if (code < CODE_SPACE) return String.format("\\u%02x", code); if (code < CODE_SPACE) return String.format("\\u%02X", code);
if (code < 0x100) return String.format("%c", code); if (code < 0x100) return String.format("%c", code);
if (code < 0x10000) return String.format("\\u04x", code); if (code < 0x10000) return String.format("\\u%04X", code);
return String.format("\\U%05x", code); return String.format("\\U%05X", code);
} }
} }