Don't announce changes for A11y within the same keyboard mode.
Bug: 8439108 Change-Id: If9f14bb65625468dcd399df47ad0d2123be30be7main
parent
19a7008728
commit
a7b4398c35
|
@ -64,6 +64,9 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
|
||||||
*/
|
*/
|
||||||
private int mEdgeSlop;
|
private int mEdgeSlop;
|
||||||
|
|
||||||
|
/** The most recently set keyboard mode. */
|
||||||
|
private int mLastKeyboardMode;
|
||||||
|
|
||||||
public static void init(final InputMethodService inputMethod) {
|
public static void init(final InputMethodService inputMethod) {
|
||||||
sInstance.initInternal(inputMethod);
|
sInstance.initInternal(inputMethod);
|
||||||
}
|
}
|
||||||
|
@ -113,16 +116,19 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
|
||||||
if (mView == null) {
|
if (mView == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAccessibilityNodeProvider != null) {
|
if (mAccessibilityNodeProvider != null) {
|
||||||
mAccessibilityNodeProvider.setKeyboard();
|
mAccessibilityNodeProvider.setKeyboard();
|
||||||
}
|
}
|
||||||
|
final int keyboardMode = mView.getKeyboard().mId.mMode;
|
||||||
|
|
||||||
// Since this method is called even when accessibility is off, make sure
|
// Since this method is called even when accessibility is off, make sure
|
||||||
// to check the state before announcing anything.
|
// to check the state before announcing anything. Also, don't announce
|
||||||
if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) {
|
// changes within the same mode.
|
||||||
announceKeyboardMode();
|
if (AccessibilityUtils.getInstance().isAccessibilityEnabled()
|
||||||
|
&& (mLastKeyboardMode != keyboardMode)) {
|
||||||
|
announceKeyboardMode(keyboardMode);
|
||||||
}
|
}
|
||||||
|
mLastKeyboardMode = keyboardMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,25 +138,24 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
|
||||||
if (mView == null) {
|
if (mView == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
announceKeyboardHidden();
|
announceKeyboardHidden();
|
||||||
|
mLastKeyboardMode = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Announces which type of keyboard is being displayed. If the keyboard type
|
* Announces which type of keyboard is being displayed. If the keyboard type
|
||||||
* is unknown, no announcement is made.
|
* is unknown, no announcement is made.
|
||||||
|
*
|
||||||
|
* @param mode The new keyboard mode.
|
||||||
*/
|
*/
|
||||||
private void announceKeyboardMode() {
|
private void announceKeyboardMode(int mode) {
|
||||||
final Keyboard keyboard = mView.getKeyboard();
|
final int resId = KEYBOARD_MODE_RES_IDS.get(mode);
|
||||||
final int resId = KEYBOARD_MODE_RES_IDS.get(keyboard.mId.mMode);
|
|
||||||
if (resId == 0) {
|
if (resId == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Context context = mView.getContext();
|
final Context context = mView.getContext();
|
||||||
final String keyboardMode = context.getString(resId);
|
final String keyboardMode = context.getString(resId);
|
||||||
final String text = context.getString(R.string.announce_keyboard_mode, keyboardMode);
|
final String text = context.getString(R.string.announce_keyboard_mode, keyboardMode);
|
||||||
|
|
||||||
sendWindowStateChanged(text);
|
sendWindowStateChanged(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +172,7 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
|
||||||
/**
|
/**
|
||||||
* Sends a window state change event with the specified text.
|
* Sends a window state change event with the specified text.
|
||||||
*
|
*
|
||||||
* @param text
|
* @param text The text to send with the event.
|
||||||
*/
|
*/
|
||||||
private void sendWindowStateChanged(final String text) {
|
private void sendWindowStateChanged(final String text) {
|
||||||
final AccessibilityEvent stateChange = AccessibilityEvent.obtain(
|
final AccessibilityEvent stateChange = AccessibilityEvent.obtain(
|
||||||
|
@ -195,7 +200,6 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
|
||||||
if (mView == null) {
|
if (mView == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getAccessibilityNodeProvider();
|
return getAccessibilityNodeProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,11 +252,9 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
|
||||||
case MotionEvent.ACTION_HOVER_MOVE:
|
case MotionEvent.ACTION_HOVER_MOVE:
|
||||||
if (key != previousKey) {
|
if (key != previousKey) {
|
||||||
return onTransitionKey(key, previousKey, event);
|
return onTransitionKey(key, previousKey, event);
|
||||||
} else {
|
}
|
||||||
return onHoverKey(key, event);
|
return onHoverKey(key, event);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,18 +296,13 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
|
||||||
private boolean onTransitionKey(final Key currentKey, final Key previousKey,
|
private boolean onTransitionKey(final Key currentKey, final Key previousKey,
|
||||||
final MotionEvent event) {
|
final MotionEvent event) {
|
||||||
final int savedAction = event.getAction();
|
final int savedAction = event.getAction();
|
||||||
|
|
||||||
event.setAction(MotionEvent.ACTION_HOVER_EXIT);
|
event.setAction(MotionEvent.ACTION_HOVER_EXIT);
|
||||||
onHoverKey(previousKey, event);
|
onHoverKey(previousKey, event);
|
||||||
|
|
||||||
event.setAction(MotionEvent.ACTION_HOVER_ENTER);
|
event.setAction(MotionEvent.ACTION_HOVER_ENTER);
|
||||||
onHoverKey(currentKey, event);
|
onHoverKey(currentKey, event);
|
||||||
|
|
||||||
event.setAction(MotionEvent.ACTION_HOVER_MOVE);
|
event.setAction(MotionEvent.ACTION_HOVER_MOVE);
|
||||||
final boolean handled = onHoverKey(currentKey, event);
|
final boolean handled = onHoverKey(currentKey, event);
|
||||||
|
|
||||||
event.setAction(savedAction);
|
event.setAction(savedAction);
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue