diff options
author | Walter Jang <wjang@google.com> | 2014-10-29 13:26:43 -0700 |
---|---|---|
committer | Walter Jang <wjang@google.com> | 2014-10-29 13:26:43 -0700 |
commit | 7ce5352a70e8aaf120bf4f7bd05d595f46abb080 (patch) | |
tree | 13765863614b9271152cd1ecda95cc98f7c0568f /src | |
parent | 8a3fe52802135be2402a5b216325615fb796a509 (diff) | |
download | packages_apps_Contacts-7ce5352a70e8aaf120bf4f7bd05d595f46abb080.tar.gz packages_apps_Contacts-7ce5352a70e8aaf120bf4f7bd05d595f46abb080.tar.bz2 packages_apps_Contacts-7ce5352a70e8aaf120bf4f7bd05d595f46abb080.zip |
Apply TtsSpan to known phone numbers in contact interactions
The primary content description in ContactInteraction must be
made a Spannable so that the TtsSpan can be progated from the
Loader (where the ContactInteraction is constructed) up to the
ExpandingEntryCardView.
Bug 17322140
Change-Id: If668f27cab20822f3c80aab606089e6b6f2a96c0
Diffstat (limited to 'src')
6 files changed, 27 insertions, 12 deletions
diff --git a/src/com/android/contacts/interactions/CalendarInteraction.java b/src/com/android/contacts/interactions/CalendarInteraction.java index efd724a19..e249e4f93 100644 --- a/src/com/android/contacts/interactions/CalendarInteraction.java +++ b/src/com/android/contacts/interactions/CalendarInteraction.java @@ -11,6 +11,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.provider.CalendarContract.Attendees; import android.provider.CalendarContract.Events; +import android.text.Spannable; import android.text.TextUtils; import android.text.format.Time; import android.util.Log; @@ -278,7 +279,7 @@ public class CalendarInteraction implements ContactInteraction { } @Override - public String getContentDescription(Context context) { + public Spannable getContentDescription(Context context) { // The default TalkBack is good return null; } diff --git a/src/com/android/contacts/interactions/CallLogInteraction.java b/src/com/android/contacts/interactions/CallLogInteraction.java index a03f6a49f..3464c0f95 100644 --- a/src/com/android/contacts/interactions/CallLogInteraction.java +++ b/src/com/android/contacts/interactions/CallLogInteraction.java @@ -17,6 +17,7 @@ package com.android.contacts.interactions; import com.android.contacts.R; import com.android.contacts.common.util.BitmapUtil; +import com.android.contacts.common.util.ContactDisplayUtils; import android.content.ContentValues; import android.content.Context; @@ -28,6 +29,7 @@ import android.net.Uri; import android.provider.CallLog.Calls; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.text.BidiFormatter; +import android.text.Spannable; import android.text.TextDirectionHeuristics; /** @@ -179,9 +181,12 @@ public class CallLogInteraction implements ContactInteraction { } @Override - public String getContentDescription(Context context) { - return context.getResources().getString(R.string.content_description_recent_call, - getCallTypeString(context), getViewHeader(context), getViewFooter(context)); + public Spannable getContentDescription(Context context) { + final String phoneNumber = getViewHeader(context); + final String contentDescription = context.getResources().getString( + R.string.content_description_recent_call, + getCallTypeString(context), phoneNumber, getViewFooter(context)); + return ContactDisplayUtils.getTelephoneTtsSpannable(contentDescription, phoneNumber); } private String getCallTypeString(Context context) { diff --git a/src/com/android/contacts/interactions/ContactInteraction.java b/src/com/android/contacts/interactions/ContactInteraction.java index 11bbb493c..bf001328b 100644 --- a/src/com/android/contacts/interactions/ContactInteraction.java +++ b/src/com/android/contacts/interactions/ContactInteraction.java @@ -19,6 +19,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.text.Spannable; /** * Represents a default interaction between the phone's owner and a contact @@ -32,7 +33,7 @@ public interface ContactInteraction { Drawable getIcon(Context context); Drawable getBodyIcon(Context context); Drawable getFooterIcon(Context context); - String getContentDescription(Context context); + Spannable getContentDescription(Context context); /** The resource id for the icon, if available. May be 0 if one is not available. */ int getIconResourceId(); } diff --git a/src/com/android/contacts/interactions/SmsInteraction.java b/src/com/android/contacts/interactions/SmsInteraction.java index 3bba0bcf7..7d26401ee 100644 --- a/src/com/android/contacts/interactions/SmsInteraction.java +++ b/src/com/android/contacts/interactions/SmsInteraction.java @@ -16,6 +16,7 @@ package com.android.contacts.interactions; import com.android.contacts.R; +import com.android.contacts.common.util.ContactDisplayUtils; import android.content.ContentValues; import android.content.Context; @@ -24,6 +25,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.provider.Telephony.Sms; import android.text.BidiFormatter; +import android.text.Spannable; import android.text.TextDirectionHeuristics; /** @@ -159,9 +161,12 @@ public class SmsInteraction implements ContactInteraction { } @Override - public String getContentDescription(Context context) { - return context.getResources().getString(R.string.content_description_recent_sms, - getViewHeader(context), getViewBody(context), getViewFooter(context)); + public Spannable getContentDescription(Context context) { + final String phoneNumber = getViewBody(context); + final String contentDescription = context.getResources().getString( + R.string.content_description_recent_sms, + getViewHeader(context), phoneNumber, getViewFooter(context)); + return ContactDisplayUtils.getTelephoneTtsSpannable(contentDescription, phoneNumber); } @Override diff --git a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java index 68698d614..dc8970b83 100644 --- a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java +++ b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java @@ -23,6 +23,7 @@ import android.graphics.ColorFilter; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.support.v7.widget.CardView; +import android.text.Spannable; import android.text.TextUtils; import android.transition.ChangeBounds; import android.transition.ChangeScroll; @@ -73,7 +74,7 @@ public class ExpandingEntryCardView extends CardView { private final Drawable mSubHeaderIcon; private final String mText; private final Drawable mTextIcon; - private final String mPrimaryContentDescription; + private Spannable mPrimaryContentDescription; private final Intent mIntent; private final Drawable mAlternateIcon; private final Intent mAlternateIntent; @@ -88,7 +89,7 @@ public class ExpandingEntryCardView extends CardView { public Entry(int id, Drawable mainIcon, String header, String subHeader, Drawable subHeaderIcon, String text, Drawable textIcon, - String primaryContentDescription, Intent intent, + Spannable primaryContentDescription, Intent intent, Drawable alternateIcon, Intent alternateIntent, String alternateContentDescription, boolean shouldApplyColor, boolean isEditable, EntryContextMenuInfo entryContextMenuInfo, Drawable thirdIcon, Intent thirdIntent, @@ -138,7 +139,7 @@ public class ExpandingEntryCardView extends CardView { return mTextIcon; } - String getPrimaryContentDescription() { + Spannable getPrimaryContentDescription() { return mPrimaryContentDescription; } diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java index 4d543a4a4..dbd449419 100644 --- a/src/com/android/contacts/quickcontact/QuickContactActivity.java +++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java @@ -73,6 +73,7 @@ import android.support.v7.graphics.Palette; import android.telecom.PhoneAccount; import android.telecom.TelecomManager; import android.text.BidiFormatter; +import android.text.SpannableString; import android.text.TextDirectionHeuristics; import android.text.TextUtils; import android.util.Log; @@ -1606,7 +1607,8 @@ public class QuickContactActivity extends ContactsActivity { -1 : (int) dataItem.getId(); return new Entry(dataId, icon, header, subHeader, subHeaderIcon, text, textIcon, - primaryContentDescription.toString(), intent, alternateIcon, alternateIntent, + new SpannableString(primaryContentDescription.toString()), + intent, alternateIcon, alternateIntent, alternateContentDescription.toString(), shouldApplyColor, isEditable, entryContextMenuInfo, thirdIcon, thirdIntent, thirdContentDescription, iconResourceId); |