aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-06-02 08:46:27 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-06-02 08:46:27 +0000
commit909ee65bea3917b6166c73c1165dc009c3e2df13 (patch)
tree12d0838c9d5ff733e6eeca79ace2f38db55a73c4 /java/src
parent81a7089012f7cd2a8b6f2867c902a128dec2b64f (diff)
parentd0b79cc12a7ea064bbd6bae51ed61bda13d938bd (diff)
downloadlatinime-909ee65bea3917b6166c73c1165dc009c3e2df13.tar.gz
latinime-909ee65bea3917b6166c73c1165dc009c3e2df13.tar.xz
latinime-909ee65bea3917b6166c73c1165dc009c3e2df13.zip
am d0b79cc1: Add verbalization of symbols that are unsupported by TTS/TalkBack
* commit 'd0b79cc12a7ea064bbd6bae51ed61bda13d938bd': Add verbalization of symbols that are unsupported by TTS/TalkBack
Diffstat (limited to 'java/src')
-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,