From 6c3f99e2e9f0f1ada622c7ab25876b69fa82b146 Mon Sep 17 00:00:00 2001 From: Jin Cao Date: Thu, 22 Jan 2015 11:35:29 -0800 Subject: Add content description to the chips delete icon b/19102218 Change-Id: I94f6cc642a12793dc7ee38afad6589d52f262d1a --- res/values/strings.xml | 12 +++++------- src/com/android/ex/chips/DropdownChipLayouter.java | 13 ++++++++++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 878cdaa..ecff60f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -16,16 +16,14 @@ \u002B%1$d - - + Copy email address - + Copy phone number - + Return Contact suggestions opened + + Remove %s from recipients diff --git a/src/com/android/ex/chips/DropdownChipLayouter.java b/src/com/android/ex/chips/DropdownChipLayouter.java index a3b809c..b9738dd 100644 --- a/src/com/android/ex/chips/DropdownChipLayouter.java +++ b/src/com/android/ex/chips/DropdownChipLayouter.java @@ -1,6 +1,7 @@ package com.android.ex.chips; import android.content.Context; +import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.StateListDrawable; @@ -75,7 +76,9 @@ public class DropdownChipLayouter { /** * See {@link #bindView(View, ViewGroup, RecipientEntry, int, AdapterType, String)} - * @param deleteDrawable + * @param deleteDrawable a {@link android.graphics.drawable.StateListDrawable} representing + * the delete icon. android.R.attr.state_activated should map to the delete icon, and the + * default state can map to a drawable of your choice (or null for no drawable). */ public View bindView(View convertView, ViewGroup parent, RecipientEntry entry, int position, AdapterType type, String constraint, StateListDrawable deleteDrawable) { @@ -128,7 +131,7 @@ public class DropdownChipLayouter { bindTextToView(destination, viewHolder.destinationView); bindTextToView(destinationType, viewHolder.destinationTypeView); bindIconToView(showImage, entry, viewHolder.imageView, type); - bindDrawableToDeleteView(deleteDrawable, viewHolder.deleteView); + bindDrawableToDeleteView(deleteDrawable, entry.getDisplayName(), viewHolder.deleteView); return itemView; } @@ -214,14 +217,18 @@ public class DropdownChipLayouter { } } - protected void bindDrawableToDeleteView(final StateListDrawable drawable, ImageView view) { + protected void bindDrawableToDeleteView(final StateListDrawable drawable, String recipient, + ImageView view) { if (view == null) { return; } if (drawable == null) { view.setVisibility(View.GONE); } else { + final Resources res = mContext.getResources(); view.setImageDrawable(drawable); + view.setContentDescription( + res.getString(R.string.dropdown_delete_button_desc, recipient)); if (mDeleteListener != null) { view.setOnClickListener(new View.OnClickListener() { @Override -- cgit v1.2.3