Add contentDescription to Emoji palette

This CL adds content descriptions of:
- Emoji Category icon/label.
- Delete key
- Space key

Bug: 11452158
Change-Id: Ic00592c560b6265c880cd25f2e18cfd349b4620b
diff --git a/java/res/layout/emoji_keyboard_tab_icon.xml b/java/res/layout/emoji_keyboard_tab_icon.xml
index 1609f6a..13bb41c 100644
--- a/java/res/layout/emoji_keyboard_tab_icon.xml
+++ b/java/res/layout/emoji_keyboard_tab_icon.xml
@@ -18,10 +18,12 @@
 */
 -->
 
+<!-- Note: contentDescription will be added programatically in {@link EmojiPalettesView}. -->
 <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="0dip"
     android:layout_weight="1.0"
     android:layout_height="wrap_content"
     android:gravity="center"
     android:scaleType="center"
+    android:contentDescription="@null"
 />
diff --git a/java/res/layout/emoji_palettes_view.xml b/java/res/layout/emoji_palettes_view.xml
index ef565a4..552a474 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" />
     </LinearLayout>
     <android.support.v4.view.ViewPager
         android:id="@+id/emoji_keyboard_pager"
@@ -99,7 +100,8 @@
             android:id="@+id/emoji_keyboard_space"
             android:layout_width="0dip"
             android:layout_weight="0.70"
-            android:layout_height="match_parent" />
+            android:layout_height="match_parent"
+            android:contentDescription="@string/spoken_description_space"/>
         <TextView
             android:id="@+id/emoji_keyboard_alphabet_right"
             android:layout_width="0dip"
diff --git a/java/res/layout/suggestion_divider.xml b/java/res/layout/suggestion_divider.xml
index a8b78c0..1490951 100644
--- a/java/res/layout/suggestion_divider.xml
+++ b/java/res/layout/suggestion_divider.xml
@@ -23,5 +23,6 @@
     android:layout_width="wrap_content"
     android:layout_height="match_parent"
     android:src="@drawable/suggestions_strip_divider"
+    android:contentDescription="@null"
     android:padding="0dp"
     android:gravity="center" />
diff --git a/java/res/values/strings-talkback-descriptions.xml b/java/res/values/strings-talkback-descriptions.xml
index 03b191e..9c1e652 100644
--- a/java/res/values/strings-talkback-descriptions.xml
+++ b/java/res/values/strings-talkback-descriptions.xml
@@ -108,4 +108,19 @@
     <string name="keyboard_mode_time">time</string>
     <!-- Description of the keyboard mode for entering URLs. -->
     <string name="keyboard_mode_url">URL</string>
+
+    <!-- Description of the emoji category icon of Recents. -->
+    <string name="spoken_descrption_emoji_category_recents">Recents</string>
+    <!-- Description of the emoji category icon of People. -->
+    <string name="spoken_descrption_emoji_category_people">People</string>
+    <!-- Description of the emoji category icon of Objects. -->
+    <string name="spoken_descrption_emoji_category_objects">Objects</string>
+    <!-- Description of the emoji category icon of Nature. -->
+    <string name="spoken_descrption_emoji_category_nature">Nature</string>
+    <!-- Description of the emoji category icon of Places. -->
+    <string name="spoken_descrption_emoji_category_places">Places</string>
+    <!-- Description of the emoji category icon of Symbols. -->
+    <string name="spoken_descrption_emoji_category_symbols">Symbols</string>
+    <!-- Description of the emoji category icon of Emoticons. -->
+    <string name="spoken_descrption_emoji_category_emoticons">Emoticons</string>
 </resources>
diff --git a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
index 8822cce..ad99697 100644
--- a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
+++ b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
@@ -123,7 +123,7 @@
                 "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 @@
                 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 @@
                 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<String, Integer> mCategoryNameToIdMap = CollectionUtils.newHashMap();
@@ -156,6 +165,7 @@
         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 @@
             return sCategoryLabel[categoryId];
         }
 
+        public String getAccessibilityDescription(final int categoryId) {
+            return mRes.getString(sAccessibilityDescriptionResourceIdsForCategories[categoryId]);
+        }
+
         public ArrayList<CategoryProperties> getShownCategories() {
             return mShownCategories;
         }
@@ -447,12 +461,14 @@
             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);
         }