aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/accessibility
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-04-25 16:56:45 -0700
committerTadashi G. Takaoka <takaoka@google.com>2014-04-30 18:46:46 +0900
commit24536580bf3d8976b91c73c1d81147762c0ca066 (patch)
treec2b63b632752311f5ce4d762c8f312a16d6a44b7 /java/src/com/android/inputmethod/accessibility
parent879629af3c375608464a6cc8f4c18e08f5e2d7b3 (diff)
downloadlatinime-24536580bf3d8976b91c73c1d81147762c0ca066.tar.gz
latinime-24536580bf3d8976b91c73c1d81147762c0ca066.tar.xz
latinime-24536580bf3d8976b91c73c1d81147762c0ca066.zip
TalkBack correct shift state
Change-Id: I3097805c6c8b4a4ac19fbe062f763e2639eb5cbf
Diffstat (limited to 'java/src/com/android/inputmethod/accessibility')
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java130
1 files changed, 56 insertions, 74 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
index 322127a12..15f79f3de 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
@@ -136,12 +136,19 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
return;
}
// Announce the language name only when the language is changed.
- if (lastKeyboard == null || !lastKeyboard.mId.mSubtype.equals(keyboard.mId.mSubtype)) {
+ if (lastKeyboard == null || !keyboard.mId.mSubtype.equals(lastKeyboard.mId.mSubtype)) {
announceKeyboardLanguage(keyboard);
+ return;
}
// Announce the mode only when the mode is changed.
- if (lastKeyboardMode != keyboard.mId.mMode) {
+ if (keyboard.mId.mMode != lastKeyboardMode) {
announceKeyboardMode(keyboard);
+ return;
+ }
+ // Announce the keyboard type only when the type is changed.
+ if (keyboard.mId.mElementId != lastKeyboard.mId.mElementId) {
+ announceKeyboardType(keyboard, lastKeyboard);
+ return;
}
}
@@ -174,9 +181,8 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
* @param keyboard The new keyboard.
*/
private void announceKeyboardMode(final Keyboard keyboard) {
- final int mode = keyboard.mId.mMode;
final Context context = mView.getContext();
- final int modeTextResId = KEYBOARD_MODE_RES_IDS.get(mode);
+ final int modeTextResId = KEYBOARD_MODE_RES_IDS.get(keyboard.mId.mMode);
if (modeTextResId == 0) {
return;
}
@@ -186,6 +192,50 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
}
/**
+ * Announces which type of keyboard is being displayed.
+ *
+ * @param keyboard The new keyboard.
+ * @param lastKeyboard The last keyboard.
+ */
+ private void announceKeyboardType(final Keyboard keyboard, final Keyboard lastKeyboard) {
+ final int lastElementId = lastKeyboard.mId.mElementId;
+ final int resId;
+ switch (keyboard.mId.mElementId) {
+ case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED:
+ case KeyboardId.ELEMENT_ALPHABET:
+ if (lastElementId == KeyboardId.ELEMENT_ALPHABET
+ || lastElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) {
+ return;
+ }
+ resId = R.string.spoken_description_mode_alpha;
+ break;
+ case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED:
+ resId = R.string.spoken_description_shiftmode_on;
+ break;
+ case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED:
+ case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED:
+ resId = R.string.spoken_description_shiftmode_locked;
+ break;
+ case KeyboardId.ELEMENT_SYMBOLS:
+ resId = R.string.spoken_description_mode_symbol;
+ break;
+ case KeyboardId.ELEMENT_SYMBOLS_SHIFTED:
+ resId = R.string.spoken_description_mode_symbol_shift;
+ break;
+ case KeyboardId.ELEMENT_PHONE:
+ resId = R.string.spoken_description_mode_phone;
+ break;
+ case KeyboardId.ELEMENT_PHONE_SYMBOLS:
+ resId = R.string.spoken_description_mode_phone_shift;
+ break;
+ default:
+ return;
+ }
+ final String text = mView.getContext().getString(resId);
+ sendWindowStateChanged(text);
+ }
+
+ /**
* Announces that the keyboard has been hidden.
*/
private void announceKeyboardHidden() {
@@ -301,7 +351,7 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
}
/**
- * Simulates a key press by injecting touch event into the keyboard view.
+ * Simulates a key press by injecting touch an event into the keyboard view.
* This avoids the complexity of trackers and listeners within the keyboard.
*
* @param key The key to press.
@@ -318,7 +368,7 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
}
/**
- * Simulates a key release by injecting touch event into the keyboard view.
+ * Simulates a key release by injecting touch an event into the keyboard view.
* This avoids the complexity of trackers and listeners within the keyboard.
*
* @param key The key to release.
@@ -383,72 +433,4 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
}
return true;
}
-
- /**
- * Notifies the user of changes in the keyboard shift state.
- */
- public void notifyShiftState() {
- if (mView == null || mKeyboard == null) {
- return;
- }
-
- final KeyboardId keyboardId = mKeyboard.mId;
- final int elementId = keyboardId.mElementId;
- final Context context = mView.getContext();
- final CharSequence text;
-
- switch (elementId) {
- case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED:
- case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED:
- text = context.getText(R.string.spoken_description_shiftmode_locked);
- break;
- case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED:
- case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED:
- case KeyboardId.ELEMENT_SYMBOLS_SHIFTED:
- text = context.getText(R.string.spoken_description_shiftmode_on);
- break;
- default:
- text = context.getText(R.string.spoken_description_shiftmode_off);
- }
- AccessibilityUtils.getInstance().announceForAccessibility(mView, text);
- }
-
- /**
- * Notifies the user of changes in the keyboard symbols state.
- */
- public void notifySymbolsState() {
- if (mView == null || mKeyboard == null) {
- return;
- }
-
- final KeyboardId keyboardId = mKeyboard.mId;
- final int elementId = keyboardId.mElementId;
- final Context context = mView.getContext();
- final int resId;
-
- switch (elementId) {
- case KeyboardId.ELEMENT_ALPHABET:
- case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED:
- case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED:
- case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED:
- case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED:
- resId = R.string.spoken_description_mode_alpha;
- break;
- case KeyboardId.ELEMENT_SYMBOLS:
- case KeyboardId.ELEMENT_SYMBOLS_SHIFTED:
- resId = R.string.spoken_description_mode_symbol;
- break;
- case KeyboardId.ELEMENT_PHONE:
- resId = R.string.spoken_description_mode_phone;
- break;
- case KeyboardId.ELEMENT_PHONE_SYMBOLS:
- resId = R.string.spoken_description_mode_phone_shift;
- break;
- default:
- return;
- }
-
- final String text = context.getString(resId);
- AccessibilityUtils.getInstance().announceForAccessibility(mView, text);
- }
}