From bfc998096b506ab4813267bc47ff312a37fcef84 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 17 Apr 2014 12:06:55 +0900 Subject: [PATCH] Add contentDescription to Emoji palette This CL adds content descriptions of: - Emoji Category icon/label. - Delete key - Space key Bug: 11452158 Change-Id: Ic00592c560b6265c880cd25f2e18cfd349b4620b --- java/res/layout/emoji_keyboard_tab_icon.xml | 2 ++ java/res/layout/emoji_palettes_view.xml | 6 ++++-- java/res/layout/suggestion_divider.xml | 1 + .../values/strings-talkback-descriptions.xml | 15 +++++++++++++++ .../keyboard/EmojiPalettesView.java | 18 +++++++++++++++++- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/java/res/layout/emoji_keyboard_tab_icon.xml b/java/res/layout/emoji_keyboard_tab_icon.xml index 1609f6a26..13bb41ca2 100644 --- a/java/res/layout/emoji_keyboard_tab_icon.xml +++ b/java/res/layout/emoji_keyboard_tab_icon.xml @@ -18,10 +18,12 @@ */ --> + diff --git a/java/res/layout/emoji_palettes_view.xml b/java/res/layout/emoji_palettes_view.xml index ef565a4f8..552a474b4 100644 --- a/java/res/layout/emoji_palettes_view.xml +++ b/java/res/layout/emoji_palettes_view.xml @@ -71,7 +71,8 @@ android:layout_weight="12.5" android:layout_height="match_parent" android:background="@color/emoji_key_background_color" - android:src="@drawable/sym_keyboard_delete_holo_dark" /> + android:src="@drawable/sym_keyboard_delete_holo_dark" + android:contentDescription="@string/spoken_description_delete" /> + android:layout_height="match_parent" + android:contentDescription="@string/spoken_description_space"/> diff --git a/java/res/values/strings-talkback-descriptions.xml b/java/res/values/strings-talkback-descriptions.xml index 03b191e59..9c1e652b0 100644 --- a/java/res/values/strings-talkback-descriptions.xml +++ b/java/res/values/strings-talkback-descriptions.xml @@ -108,4 +108,19 @@ time URL + + + Recents + + People + + Objects + + Nature + + Places + + Symbols + + Emoticons diff --git a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java index 8822ccec9..ad996971f 100644 --- a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java +++ b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java @@ -123,7 +123,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange "places", "symbols", "emoticons" }; - private static final int[] sCategoryIcon = new int[] { + private static final int[] sCategoryIcon = { R.drawable.ic_emoji_recent_light, R.drawable.ic_emoji_people_light, R.drawable.ic_emoji_objects_light, @@ -133,6 +133,14 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange 0 }; private static final String[] sCategoryLabel = { null, null, null, null, null, null, ":-)" }; + private static final int[] sAccessibilityDescriptionResourceIdsForCategories = { + R.string.spoken_descrption_emoji_category_recents, + R.string.spoken_descrption_emoji_category_people, + R.string.spoken_descrption_emoji_category_objects, + R.string.spoken_descrption_emoji_category_nature, + R.string.spoken_descrption_emoji_category_places, + R.string.spoken_descrption_emoji_category_symbols, + R.string.spoken_descrption_emoji_category_emoticons }; private static final int[] sCategoryElementId = { KeyboardId.ELEMENT_EMOJI_RECENTS, KeyboardId.ELEMENT_EMOJI_CATEGORY1, @@ -142,6 +150,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange KeyboardId.ELEMENT_EMOJI_CATEGORY5, KeyboardId.ELEMENT_EMOJI_CATEGORY6 }; private final SharedPreferences mPrefs; + private final Resources mRes; private final int mMaxPageKeyCount; private final KeyboardLayoutSet mLayoutSet; private final HashMap mCategoryNameToIdMap = CollectionUtils.newHashMap(); @@ -156,6 +165,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange public EmojiCategory(final SharedPreferences prefs, final Resources res, final KeyboardLayoutSet layoutSet) { mPrefs = prefs; + mRes = res; mMaxPageKeyCount = res.getInteger(R.integer.config_emoji_keyboard_max_page_key_count); mLayoutSet = layoutSet; for (int i = 0; i < sCategoryName.length; ++i) { @@ -206,6 +216,10 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange return sCategoryLabel[categoryId]; } + public String getAccessibilityDescription(final int categoryId) { + return mRes.getString(sAccessibilityDescriptionResourceIdsForCategories[categoryId]); + } + public ArrayList getShownCategories() { return mShownCategories; } @@ -447,12 +461,14 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange final ImageView iconView = (ImageView)LayoutInflater.from(getContext()).inflate( R.layout.emoji_keyboard_tab_icon, null); iconView.setImageResource(mEmojiCategory.getCategoryIcon(categoryId)); + iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId)); tspec.setIndicator(iconView); } if (mEmojiCategory.getCategoryLabel(categoryId) != null) { final TextView textView = (TextView)LayoutInflater.from(getContext()).inflate( R.layout.emoji_keyboard_tab_label, null); textView.setText(mEmojiCategory.getCategoryLabel(categoryId)); + textView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId)); textView.setTextColor(mTabLabelColor); tspec.setIndicator(textView); }