Fix accesibility text in quick contact and itemview
Bug: 5275688 accessibility: phone and messaging icon
both are read as 'image-number' in quick-contact card/contact card.
5320265 Accessibility: content description for quick contact
image is the image id number
Added code in quick contact to add specific content description for phone numbers.
Added a specific content description for the quick contact bagde in the ContactListItemView.
Change-Id: Iad57b7bf8e563ac77b121bb15cd8096616fb1d9e
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 06a461d..075cbea 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1745,6 +1745,7 @@
Note: AccessibilityServices use this attribute to announce what the view represents.
This is especially valuable for views without textual representation like ImageView.
+ [CHAR LIMIT=NONE]
-->
<string name="description_send_text_message">Send text message to <xliff:g id="name">%1$s</xliff:g></string>
@@ -1753,9 +1754,32 @@
Note: AccessibilityServices use this attribute to announce what the view represents.
This is especially valuable for views without textual representation like ImageView.
+ [CHAR LIMIT=NONE]
-->
<string name="description_call_log_unheard_voicemail">Unheard voicemail</string>
+ <!-- String describing the button to send a text message on quick contact.
+
+ Note: AccessibilityServices use this attribute to announce what the view represents.
+ This is especially valuable for views without textual representation like ImageView.
+ [CHAR LIMIT=NONE]
+ -->
+ <string name="description_send_message">Send message to <xliff:g id="name">%1$s</xliff:g></string>
+
+ <!-- String describing the text for a phone number in quick contact.
+
+ Note: AccessibilityServices use this attribute to announce what the view represents.
+ This is especially valuable for views without textual representation like ImageView.
+ -->
+ <string name="description_dial_phone_number">Dial phone <xliff:g id="name">%1$s</xliff:g></string>
+
+ <!-- String describing the text for photo of a contact in a contacts list.
+
+ Note: AccessibilityServices use this attribute to announce what the view represents.
+ This is especially valuable for views without textual representation like ImageView.
+ -->
+ <string name="description_quick_contact_for">Quick contact for <xliff:g id="name">%1$s</xliff:g></string>
+
<!-- The string used to represent an unknown location for a phone number in the call log [CHAR LIMIT=3] -->
<string name="call_log_empty_gecode">-</string>
diff --git a/src/com/android/contacts/list/ContactListItemView.java b/src/com/android/contacts/list/ContactListItemView.java
index a6e241f..f47560b 100644
--- a/src/com/android/contacts/list/ContactListItemView.java
+++ b/src/com/android/contacts/list/ContactListItemView.java
@@ -698,6 +698,11 @@
}
if (mQuickContact == null) {
mQuickContact = new QuickContactBadge(mContext, null, QUICK_CONTACT_BADGE_STYLE);
+ if (mNameTextView != null) {
+ mQuickContact.setContentDescription(mContext.getString(
+ R.string.description_quick_contact_for, mNameTextView.getText()));
+ }
+
addView(mQuickContact);
mPhotoViewWidthAndHeightAreReady = false;
}
@@ -1038,6 +1043,13 @@
mDisplayNameFormatter.setDisplayName(
getNameTextView(), displayOrder, highlightingEnabled, mHighlightedPrefix);
+ // Since the quick contact content description is derived from the display name and there is
+ // no guarantee that when the quick contact is initialized the display name is already set,
+ // do it here too.
+ if (mQuickContact != null) {
+ mQuickContact.setContentDescription(mContext.getString(
+ R.string.description_quick_contact_for, mNameTextView.getText()));
+ }
}
public void hideDisplayName() {
diff --git a/src/com/android/contacts/quickcontact/QuickContactListFragment.java b/src/com/android/contacts/quickcontact/QuickContactListFragment.java
index 7cbc7c8..cd899fa 100644
--- a/src/com/android/contacts/quickcontact/QuickContactListFragment.java
+++ b/src/com/android/contacts/quickcontact/QuickContactListFragment.java
@@ -20,6 +20,7 @@
import android.app.Fragment;
import android.os.Bundle;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -115,6 +116,16 @@
alternateActionButton.setImageDrawable(action.getAlternateIcon());
alternateActionButton.setVisibility(hasAlternateAction ? View.VISIBLE : View.GONE);
+ // Special case for phone numbers in accessibility mode
+ if (action.getMimeType().equals(Phone.CONTENT_ITEM_TYPE)) {
+ text1.setContentDescription(getActivity().getString(
+ R.string.description_dial_phone_number, action.getBody()));
+ if (hasAlternateAction) {
+ alternateActionButton.setContentDescription(getActivity()
+ .getString(R.string.description_send_message, action.getBody()));
+ }
+ }
+
text1.setText(action.getBody());
text2.setText(action.getSubtitle());