aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/res/values/strings-talkback-descriptions.xml5
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java130
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java12
-rw-r--r--native/jni/src/defines.h7
-rw-r--r--native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.cpp11
-rw-r--r--native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.h1
6 files changed, 68 insertions, 98 deletions
diff --git a/java/res/values/strings-talkback-descriptions.xml b/java/res/values/strings-talkback-descriptions.xml
index 9c1e652b0..4ffca10c8 100644
--- a/java/res/values/strings-talkback-descriptions.xml
+++ b/java/res/values/strings-talkback-descriptions.xml
@@ -74,11 +74,10 @@
<string name="spoken_description_shiftmode_on">Shift enabled</string>
<!-- Spoken feedback after turning "Caps lock" mode on. -->
<string name="spoken_description_shiftmode_locked">Caps lock enabled</string>
- <!-- Spoken feedback after turning "Shift" mode off. -->
- <string name="spoken_description_shiftmode_off">Shift disabled</string>
-
<!-- Spoken feedback after changing to the symbols keyboard. -->
<string name="spoken_description_mode_symbol">Symbols mode</string>
+ <!-- Spoken feedback after changing to the symbols shift keyboard. -->
+ <string name="spoken_description_mode_symbol_shift">Symbols shift mode</string>
<!-- Spoken feedback after changing to the alphanumeric keyboard. -->
<string name="spoken_description_mode_alpha">Letters mode</string>
<!-- Spoken feedback after changing to the phone dialer keyboard. -->
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);
- }
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index f1b1b8db2..78867f153 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1596,18 +1596,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void onReleaseKey(final int primaryCode, final boolean withSliding) {
mKeyboardSwitcher.onReleaseKey(primaryCode, withSliding, getCurrentAutoCapsState(),
getCurrentRecapitalizeState());
-
- // If accessibility is on, ensure the user receives keyboard state updates.
- if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
- switch (primaryCode) {
- case Constants.CODE_SHIFT:
- AccessibleKeyboardViewProxy.getInstance().notifyShiftState();
- break;
- case Constants.CODE_SWITCH_ALPHA_SYMBOL:
- AccessibleKeyboardViewProxy.getInstance().notifySymbolsState();
- break;
- }
- }
}
private HardwareEventDecoder getHardwareKeyEventDecoder(final int deviceId) {
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index 2fe2bd8fa..cd095c91d 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -293,13 +293,6 @@ static inline void prof_out(void) {
#define M_PI_F 3.14159265f
#define MAX_PERCENTILE 100
-// Number of base-10 digits in the largest integer + 1 to leave room for a zero terminator.
-// As such, this is the maximum number of characters will be needed to represent an int as a
-// string, including the terminator; this is used as the size of a string buffer large enough to
-// hold any value that is intended to fit in an integer, e.g. in the code that reads the header
-// of the binary dictionary where a {key,value} string pair scheme is used.
-#define LARGEST_INT_DIGIT_COUNT 11
-
#define NOT_A_CODE_POINT (-1)
#define NOT_A_DISTANCE (-1)
#define NOT_A_COORDINATE (-1)
diff --git a/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.cpp b/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.cpp
index d20accfbc..5608e27d4 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.cpp
+++ b/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.cpp
@@ -26,6 +26,13 @@
namespace latinime {
+// Number of base-10 digits in the largest integer + 1 to leave room for a zero terminator.
+// As such, this is the maximum number of characters will be needed to represent an int as a
+// string, including the terminator; this is used as the size of a string buffer large enough to
+// hold any value that is intended to fit in an integer, e.g. in the code that reads the header
+// of the binary dictionary where a {key,value} string pair scheme is used.
+const int HeaderReadWriteUtils::LARGEST_INT_DIGIT_COUNT = 11;
+
const int HeaderReadWriteUtils::MAX_ATTRIBUTE_KEY_LENGTH = 256;
const int HeaderReadWriteUtils::MAX_ATTRIBUTE_VALUE_LENGTH = 256;
@@ -154,8 +161,8 @@ typedef DictionaryHeaderStructurePolicy::AttributeMap AttributeMap;
/* static */ void HeaderReadWriteUtils::setIntAttributeInner(AttributeMap *const headerAttributes,
const AttributeMap::key_type *const key, const int value) {
AttributeMap::mapped_type valueVector;
- char charBuf[LARGEST_INT_DIGIT_COUNT + 1];
- snprintf(charBuf, LARGEST_INT_DIGIT_COUNT + 1, "%d", value);
+ char charBuf[LARGEST_INT_DIGIT_COUNT];
+ snprintf(charBuf, sizeof(charBuf), "%d", value);
insertCharactersIntoVector(charBuf, &valueVector);
(*headerAttributes)[*key] = valueVector;
}
diff --git a/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.h b/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.h
index a6b4c4e14..9b90488fc 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.h
+++ b/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.h
@@ -92,6 +92,7 @@ class HeaderReadWriteUtils {
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(HeaderReadWriteUtils);
+ static const int LARGEST_INT_DIGIT_COUNT;
static const int MAX_ATTRIBUTE_KEY_LENGTH;
static const int MAX_ATTRIBUTE_VALUE_LENGTH;