am 7b5bccc0: Use "unknown emoji" or emoji that has an empty translation

* commit '7b5bccc06625b8693f5b0e849b99ca7502a9e5f4':
  Use "unknown emoji" or emoji that has an empty translation
This commit is contained in:
Tadashi G. Takaoka 2014-05-27 02:12:29 +00:00 committed by Android Git Automerger
commit 369a16c8c2
2 changed files with 20 additions and 9 deletions

View file

@ -128,11 +128,13 @@
<string name="spoken_descrption_emoji_category_emoticons">Emoticons</string> <string name="spoken_descrption_emoji_category_emoticons">Emoticons</string>
<!-- Description of an upper case letter of LOWER_LETTER. --> <!-- Description of an upper case letter of LOWER_LETTER. -->
<string name="spoke_description_upper_case">Capital <xliff:g id="LOWER_LETTER" example="A, E, ligature">%s</xliff:g></string> <string name="spoken_description_upper_case">Capital <xliff:g id="LOWER_LETTER" example="A, E, ligature">%s</xliff:g></string>
<!-- Spoken description for Unicode code point U+0049: "I" LATIN CAPITAL LETTER I <!-- Spoken description for Unicode code point U+0049: "I" LATIN CAPITAL LETTER I
Note that depending on locale, the lower-case of this letter is U+0069 or U+0131. --> Note that depending on locale, the lower-case of this letter is U+0069 or U+0131. -->
<string name="spoken_letter_0049">Capital I</string> <string name="spoken_letter_0049">Capital I</string>
<!-- Spoken description for Unicode code point U+0130: "İ" LATIN CAPITAL LETTER I WITH DOT ABOVE <!-- Spoken description for Unicode code point U+0130: "İ" LATIN CAPITAL LETTER I WITH DOT ABOVE
Note that depending on locale, the lower-case of this letter is U+0069 or U+0131. --> Note that depending on locale, the lower-case of this letter is U+0069 or U+0131. -->
<string name="spoken_letter_0130">Capital I, dot above</string> <string name="spoken_letter_0130">Capital I, dot above</string>
<!-- Spoken description for unknown emoji code point. -->
<string name="spoken_emoji_unknown">Unknown emoji</string>
</resources> </resources>

View file

@ -285,15 +285,14 @@ public final class KeyCodeDescriptionMapper {
if (index >= 0) { if (index >= 0) {
return context.getString(mKeyCodeMap.valueAt(index)); return context.getString(mKeyCodeMap.valueAt(index));
} }
final String accentedLetter = getSpokenAccentedLetterDescriptionId(context, code); final String accentedLetter = getSpokenAccentedLetterDescription(context, code);
if (accentedLetter != null) { if (accentedLetter != null) {
return accentedLetter; return accentedLetter;
} }
// Here, <code>code</code> may be a base letter. // Here, <code>code</code> may be a base (non-accented) letter.
final int spokenEmojiId = getSpokenDescriptionId( final String emojiDescription = getSpokenEmojiDescription(context, code);
context, code, SPOKEN_EMOJI_RESOURCE_NAME_FORMAT); if (emojiDescription != null) {
if (spokenEmojiId != 0) { return emojiDescription;
return context.getString(spokenEmojiId);
} }
if (isDefinedNonCtrl) { if (isDefinedNonCtrl) {
return Character.toString((char) code); return Character.toString((char) code);
@ -304,7 +303,7 @@ public final class KeyCodeDescriptionMapper {
return context.getString(R.string.spoken_description_unknown, code); 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 boolean isUpperCase = Character.isUpperCase(code);
final int baseCode = isUpperCase ? Character.toLowerCase(code) : code; final int baseCode = isUpperCase ? Character.toLowerCase(code) : code;
final int baseIndex = mKeyCodeMap.indexOfKey(baseCode); final int baseIndex = mKeyCodeMap.indexOfKey(baseCode);
@ -314,7 +313,17 @@ public final class KeyCodeDescriptionMapper {
return null; return null;
} }
final String spokenText = context.getString(resId); 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; : spokenText;
} }