Add contentDescription to Emoji palette

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

Bug: 11452158
Change-Id: Ic00592c560b6265c880cd25f2e18cfd349b4620b
main
Tadashi G. Takaoka 2014-04-17 12:06:55 +09:00
parent 1c1d37caf9
commit bfc998096b
5 changed files with 39 additions and 3 deletions

View File

@ -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"
/>

View File

@ -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"

View File

@ -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" />

View File

@ -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>

View File

@ -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<String, Integer> 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<CategoryProperties> 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);
}