summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIhab Awad <ihab@google.com>2014-12-01 14:47:38 -0800
committerIhab Awad <ihab@google.com>2014-12-05 15:29:06 -0800
commit1e5325f43c98a92f8bfec1dbd9db3d32a91835e9 (patch)
tree1a5ccbe60a79d3415d424a8aa1ce37c6fce3e579 /src
parent1513fec51cbb557685f1976ee2050c73ccdbe036 (diff)
Add Text-to-Speech annotations for phone number displays (3/3)
Bug: 17321294 Change-Id: Icc712da80e25e5a5294986ece055fcffaa558f1e
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java5
-rw-r--r--src/com/android/dialer/calllog/CallLogListItemHelper.java39
-rw-r--r--src/com/android/dialer/list/ShortcutCardsAdapter.java8
3 files changed, 37 insertions, 15 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index e799b00cc..aba00b036 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -29,6 +29,7 @@ import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
import android.provider.ContactsContract.PhoneLookup;
import android.telecom.PhoneAccountHandle;
+import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -45,6 +46,7 @@ import com.android.common.widget.GroupingListAdapter;
import com.android.contacts.common.CallUtil;
import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
+import com.android.contacts.common.util.PhoneNumberHelper;
import com.android.contacts.common.model.Contact;
import com.android.contacts.common.model.ContactLoader;
import com.android.contacts.common.util.UriUtils;
@@ -754,7 +756,8 @@ public class CallLogAdapter extends GroupingListAdapter
final String label = info.label;
final long photoId = info.photoId;
final Uri photoUri = info.photoUri;
- CharSequence formattedNumber = info.formattedNumber;
+ CharSequence formattedNumber = info.formattedNumber == null
+ ? null : PhoneNumberUtils.ttsSpanAsPhoneNumber(info.formattedNumber);
final int[] callTypes = getCallTypes(c, count);
final String geocode = c.getString(CallLogQuery.GEOCODED_LOCATION);
final int sourceType = info.sourceType;
diff --git a/src/com/android/dialer/calllog/CallLogListItemHelper.java b/src/com/android/dialer/calllog/CallLogListItemHelper.java
index 4ebfb4b88..793a1755c 100644
--- a/src/com/android/dialer/calllog/CallLogListItemHelper.java
+++ b/src/com/android/dialer/calllog/CallLogListItemHelper.java
@@ -19,6 +19,7 @@ package com.android.dialer.calllog;
import android.content.Context;
import android.content.res.Resources;
import android.provider.CallLog.Calls;
+import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import com.android.contacts.common.CallUtil;
@@ -79,16 +80,24 @@ import com.android.dialer.R;
*/
public void setActionContentDescriptions(CallLogListItemViews views) {
views.callBackButtonView.setContentDescription(
- mResources.getString(R.string.description_call_back_action, views.nameOrNumber));
+ TextUtils.expandTemplate(
+ mResources.getString(R.string.description_call_back_action),
+ views.nameOrNumber));
views.videoCallButtonView.setContentDescription(
- mResources.getString(R.string.description_video_call_action, views.nameOrNumber));
+ TextUtils.expandTemplate(
+ mResources.getString(R.string.description_video_call_action),
+ views.nameOrNumber));
views.voicemailButtonView.setContentDescription(
- mResources.getString(R.string.description_voicemail_action, views.nameOrNumber));
+ TextUtils.expandTemplate(
+ mResources.getString(R.string.description_voicemail_action),
+ views.nameOrNumber));
views.detailsButtonView.setContentDescription(
- mResources.getString(R.string.description_details_action, views.nameOrNumber));
+ TextUtils.expandTemplate(
+ mResources.getString(R.string.description_details_action),
+ views.nameOrNumber));
}
/**
@@ -149,7 +158,7 @@ import com.android.dialer.R;
// Get the time/date of the call
final CharSequence timeOfCall = mPhoneCallDetailsHelper.getCallDate(details);
- StringBuilder callDescription = new StringBuilder();
+ SpannableStringBuilder callDescription = new SpannableStringBuilder();
// Prepend the voicemail indication.
if (isVoiceMail) {
@@ -172,13 +181,19 @@ import com.android.dialer.R;
String accountLabel = PhoneAccountUtils.getAccountLabel(context, details.accountHandle);
// Use chosen string resource to build up the message.
- callDescription.append(mResources.getString(stringID,
- nameOrNumber,
- // If no type or location can be determined, sub in empty string.
- typeOrLocation == null ? "" : typeOrLocation,
- timeOfCall,
- accountLabel == null ? "" :
- mResources.getString(R.string.description_phone_account, accountLabel)));
+ CharSequence onAccountLabel = accountLabel == null
+ ? ""
+ : TextUtils.expandTemplate(
+ mResources.getString(R.string.description_phone_account),
+ accountLabel);
+ callDescription.append(
+ TextUtils.expandTemplate(
+ mResources.getString(stringID),
+ nameOrNumber,
+ // If no type or location can be determined, sub in empty string.
+ typeOrLocation == null ? "" : typeOrLocation,
+ timeOfCall,
+ onAccountLabel));
return callDescription;
}
diff --git a/src/com/android/dialer/list/ShortcutCardsAdapter.java b/src/com/android/dialer/list/ShortcutCardsAdapter.java
index 78b774b02..78647882c 100644
--- a/src/com/android/dialer/list/ShortcutCardsAdapter.java
+++ b/src/com/android/dialer/list/ShortcutCardsAdapter.java
@@ -21,6 +21,7 @@ import android.content.res.Resources;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.graphics.Rect;
+import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
@@ -258,8 +259,11 @@ public class ShortcutCardsAdapter extends BaseAdapter {
// TODO: Set content description including type/location and time information.
TextView nameView = (TextView) actionView.findViewById(R.id.name);
- actionView.setContentDescription(getResources().getString(
- R.string.description_call_back_action, nameView.getText()));
+
+ actionView.setContentDescription(
+ TextUtils.expandTemplate(
+ getResources().getString(R.string.description_call_back_action),
+ nameView.getText()));
mPreviousTranslationZ = getResources().getDimensionPixelSize(
R.dimen.recent_call_log_item_translation_z);