diff options
author | Ihab Awad <ihab@google.com> | 2014-12-08 19:35:32 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-12-08 19:35:32 +0000 |
commit | f70a7d304e72e8dbdcaedea21eb1cb8af63783e3 (patch) | |
tree | a939177fbfb10e7475ab824b745cc600aae2950b /src | |
parent | 0804b537ed01ab767d18c2c80c0d69a5869ff5ee (diff) | |
parent | 61a4143777480b61523b992339c68f184613ce57 (diff) |
am 61a41437: am 1e5325f4: Add Text-to-Speech annotations for phone number displays (3/3)
* commit '61a4143777480b61523b992339c68f184613ce57':
Add Text-to-Speech annotations for phone number displays (3/3)
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAdapter.java | 5 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogListItemHelper.java | 39 | ||||
-rw-r--r-- | src/com/android/dialer/list/ShortcutCardsAdapter.java | 8 |
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); |