Improve accessibility of call log's call button.
Use the contact name or phone number is the content description for the
call button, so that it is clear which person or number will be dialed.
Bug: 5276039
Change-Id: Icb63d4a26a978b008af470dde12e5e7e93a242b6
diff --git a/res/values/strings.xml b/res/values/strings.xml
index aa99d21..fde7b87 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1676,13 +1676,6 @@
<!-- Used to display as default status when the contact is busy or Do not disturb for chat [CHAR LIMIT=19] -->
<string name="status_busy">Busy</string>
- <!-- String describing the icon in the call log used to place a call.
-
- 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_call_log_call_button">Call number</string>
-
<!-- String describing the icon in the call log used to play a voicemail.
Note: AccessibilityServices use this attribute to announce what the view represents.
diff --git a/src/com/android/contacts/calllog/CallLogListItemHelper.java b/src/com/android/contacts/calllog/CallLogListItemHelper.java
index 602c283..9997c40 100644
--- a/src/com/android/contacts/calllog/CallLogListItemHelper.java
+++ b/src/com/android/contacts/calllog/CallLogListItemHelper.java
@@ -22,6 +22,7 @@
import android.content.res.Resources;
import android.provider.CallLog.Calls;
+import android.text.TextUtils;
import android.view.View;
/**
@@ -68,7 +69,7 @@
views.dividerView.setVisibility(View.VISIBLE);
} else if (canCall) {
// Call is the secondary action.
- configureCallSecondaryAction(views);
+ configureCallSecondaryAction(views, details);
views.dividerView.setVisibility(View.VISIBLE);
} else {
// No action available.
@@ -78,11 +79,23 @@
}
/** Sets the secondary action to correspond to the call button. */
- private void configureCallSecondaryAction(CallLogListItemViews views) {
+ private void configureCallSecondaryAction(CallLogListItemViews views,
+ PhoneCallDetails details) {
views.secondaryActionView.setVisibility(View.VISIBLE);
views.secondaryActionView.setImageResource(R.drawable.ic_ab_dialer_holo_dark);
- views.secondaryActionView.setContentDescription(
- mResources.getString(R.string.description_call_log_call_button));
+ views.secondaryActionView.setContentDescription(getCallActionDescription(details));
+ }
+
+ /** Returns the description used by the call action for this phone call. */
+ private CharSequence getCallActionDescription(PhoneCallDetails details) {
+ final CharSequence recipient;
+ if (!TextUtils.isEmpty(details.name)) {
+ recipient = details.name;
+ } else {
+ recipient = mPhoneNumberHelper.getDisplayNumber(
+ details.number, details.formattedNumber);
+ }
+ return mResources.getString(R.string.description_call, recipient);
}
/** Sets the secondary action to correspond to the play button. */