From d0b79cc12a7ea064bbd6bae51ed61bda13d938bd Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 2 Jun 2014 14:37:42 +0900 Subject: [PATCH] Add verbalization of symbols that are unsupported by TTS/TalkBack Bug: 13336905 Change-Id: Iefd117fa7b30b8ba240590b13b03d7044fd37ede --- .../res/values/strings-emoji-descriptions.xml | 4 ++ .../values/strings-letter-descriptions.xml | 64 ++++++++++++++++++- .../values/strings-talkback-descriptions.xml | 4 +- .../KeyCodeDescriptionMapper.java | 28 +++++++- 4 files changed, 96 insertions(+), 4 deletions(-) diff --git a/java/res/values/strings-emoji-descriptions.xml b/java/res/values/strings-emoji-descriptions.xml index 7952a7f33..8cbde264c 100644 --- a/java/res/values/strings-emoji-descriptions.xml +++ b/java/res/values/strings-emoji-descriptions.xml @@ -17,6 +17,10 @@ ** limitations under the License. */ --> + Copyright sign diff --git a/java/res/values/strings-letter-descriptions.xml b/java/res/values/strings-letter-descriptions.xml index fbf4671cb..297b6bed2 100644 --- a/java/res/values/strings-letter-descriptions.xml +++ b/java/res/values/strings-letter-descriptions.xml @@ -17,7 +17,11 @@ ** limitations under the License. */ --> - + Feminine ordinal indicator @@ -319,4 +323,62 @@ Y, hook above Y, tilde + + Inverted exclamation mark + + Left-pointing double angle quotation mark + + Middle dot + + Superscript one + + Right-pointing double angle quotation mark + + Inverted question mark + + Left single quotation mark + + Right single quotation mark + + Single low-9 quotation mark + + Left double quotation mark + + Right double quotation mark + + Dagger + + Double dagger + + Per mille sign + + Prime + + Double prime + + Single left-pointing angle quotation mark + + Single right-pointing angle quotation mark + + Superscript four + + Superscript latin small letter n + + Peso sign + + Care of + + Rightwards arrow + + Downwards arrow + + Empty set + + Increment + + Less-than or equal to + + Greater-than or equal to + + Black star diff --git a/java/res/values/strings-talkback-descriptions.xml b/java/res/values/strings-talkback-descriptions.xml index d7978b0c8..fa06362d8 100644 --- a/java/res/values/strings-talkback-descriptions.xml +++ b/java/res/values/strings-talkback-descriptions.xml @@ -32,7 +32,7 @@ %1$s performs auto-correction - Key code %d + Unknown character Shift @@ -135,6 +135,8 @@ Capital I, dot above + + Unknown symbol Unknown emoji 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 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,