diff options
author | 2014-05-27 10:40:36 +0900 | |
---|---|---|
committer | 2014-05-27 10:48:03 +0900 | |
commit | 7b5bccc06625b8693f5b0e849b99ca7502a9e5f4 (patch) | |
tree | 980ad88b614790c31ddf650cf2efcd2833243dce /java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java | |
parent | 71c795d00b7bc22a000b1cca50c53a365614a8eb (diff) | |
download | latinime-7b5bccc06625b8693f5b0e849b99ca7502a9e5f4.tar.gz latinime-7b5bccc06625b8693f5b0e849b99ca7502a9e5f4.tar.xz latinime-7b5bccc06625b8693f5b0e849b99ca7502a9e5f4.zip |
Use "unknown emoji" or emoji that has an empty translation
Because the number of emoji description spoken string resources is
rather huge (~800), some locales may chose an empty description as a
translation. If that is the case, we will announce "unknown emoji" as
a fallback.
Bug: 11452158
Change-Id: Ibb65e5bec93030c40bd33ac2be2115c3bbc8bd11
Diffstat (limited to 'java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java')
-rw-r--r-- | java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java index 2c87fc1e9..58672ace7 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java +++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java @@ -285,15 +285,14 @@ public final class KeyCodeDescriptionMapper { if (index >= 0) { return context.getString(mKeyCodeMap.valueAt(index)); } - final String accentedLetter = getSpokenAccentedLetterDescriptionId(context, code); + final String accentedLetter = getSpokenAccentedLetterDescription(context, code); if (accentedLetter != null) { return accentedLetter; } - // Here, <code>code</code> may be a base letter. - final int spokenEmojiId = getSpokenDescriptionId( - context, code, SPOKEN_EMOJI_RESOURCE_NAME_FORMAT); - if (spokenEmojiId != 0) { - return context.getString(spokenEmojiId); + // Here, <code>code</code> may be a base (non-accented) letter. + final String emojiDescription = getSpokenEmojiDescription(context, code); + if (emojiDescription != null) { + return emojiDescription; } if (isDefinedNonCtrl) { return Character.toString((char) code); @@ -304,7 +303,7 @@ public final class KeyCodeDescriptionMapper { return context.getString(R.string.spoken_description_unknown, code); } - private String getSpokenAccentedLetterDescriptionId(final Context context, final int code) { + private String getSpokenAccentedLetterDescription(final Context context, final int code) { final boolean isUpperCase = Character.isUpperCase(code); final int baseCode = isUpperCase ? Character.toLowerCase(code) : code; final int baseIndex = mKeyCodeMap.indexOfKey(baseCode); @@ -314,7 +313,17 @@ public final class KeyCodeDescriptionMapper { return null; } final String spokenText = context.getString(resId); - return isUpperCase ? context.getString(R.string.spoke_description_upper_case, spokenText) + return isUpperCase ? context.getString(R.string.spoken_description_upper_case, spokenText) + : spokenText; + } + + 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; } |