aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-06-02 14:37:42 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-06-02 17:02:38 +0900
commitd0b79cc12a7ea064bbd6bae51ed61bda13d938bd (patch)
tree77a34bcd78468577433db49d410e265c53e26072 /java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
parent82674ca81c40acbba4fb9b7113a9a8fe13afccc6 (diff)
downloadlatinime-d0b79cc12a7ea064bbd6bae51ed61bda13d938bd.tar.gz
latinime-d0b79cc12a7ea064bbd6bae51ed61bda13d938bd.tar.xz
latinime-d0b79cc12a7ea064bbd6bae51ed61bda13d938bd.zip
Add verbalization of symbols that are unsupported by TTS/TalkBack
Bug: 13336905 Change-Id: Iefd117fa7b30b8ba240590b13b03d7044fd37ede
Diffstat (limited to 'java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java')
-rw-r--r--java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
index 58672ace7..27c4732ca 100644
--- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
+++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
@@ -34,6 +34,7 @@ import java.util.Locale;
public final class KeyCodeDescriptionMapper {
private static final String TAG = KeyCodeDescriptionMapper.class.getSimpleName();
private static final String SPOKEN_LETTER_RESOURCE_NAME_FORMAT = "spoken_accented_letter_%04X";
+ private static final String SPOKEN_SYMBOL_RESOURCE_NAME_FORMAT = "spoken_symbol_%04X";
private static final String SPOKEN_EMOJI_RESOURCE_NAME_FORMAT = "spoken_emoji_%04X";
// The resource ID of the string spoken for obscured keys
@@ -290,6 +291,10 @@ public final class KeyCodeDescriptionMapper {
return accentedLetter;
}
// Here, <code>code</code> may be a base (non-accented) letter.
+ final String unsupportedSymbol = getSpokenSymbolDescription(context, code);
+ if (unsupportedSymbol != null) {
+ return unsupportedSymbol;
+ }
final String emojiDescription = getSpokenEmojiDescription(context, code);
if (emojiDescription != null) {
return emojiDescription;
@@ -303,6 +308,7 @@ public final class KeyCodeDescriptionMapper {
return context.getString(R.string.spoken_description_unknown, code);
}
+ // TODO: Remove this method once TTS supports those accented letters' verbalization.
private String getSpokenAccentedLetterDescription(final Context context, final int code) {
final boolean isUpperCase = Character.isUpperCase(code);
final int baseCode = isUpperCase ? Character.toLowerCase(code) : code;
@@ -317,14 +323,32 @@ public final class KeyCodeDescriptionMapper {
: spokenText;
}
+ // TODO: Remove this method once TTS supports those symbols' verbalization.
+ private String getSpokenSymbolDescription(final Context context, final int code) {
+ final int resId = getSpokenDescriptionId(context, code, SPOKEN_SYMBOL_RESOURCE_NAME_FORMAT);
+ if (resId == 0) {
+ return null;
+ }
+ final String spokenText = context.getString(resId);
+ if (!TextUtils.isEmpty(spokenText)) {
+ return spokenText;
+ }
+ // If a translated description is empty, fall back to unknown symbol description.
+ return context.getString(R.string.spoken_symbol_unknown);
+ }
+
+ // TODO: Remove this method once TTS supports emoji verbalization.
private String getSpokenEmojiDescription(final Context context, final int code) {
final int resId = getSpokenDescriptionId(context, code, SPOKEN_EMOJI_RESOURCE_NAME_FORMAT);
if (resId == 0) {
return null;
}
final String spokenText = context.getString(resId);
- return TextUtils.isEmpty(spokenText) ? context.getString(R.string.spoken_emoji_unknown)
- : spokenText;
+ if (!TextUtils.isEmpty(spokenText)) {
+ return spokenText;
+ }
+ // If a translated description is empty, fall back to unknown emoji description.
+ return context.getString(R.string.spoken_emoji_unknown);
}
private int getSpokenDescriptionId(final Context context, final int code,