Correct Talkback announcement of SMS shortcut on Quick Contact

Bug: 25794705
Change-Id: Ifd39d3cb88c1b27710fb307ca95949df17ee5d91
diff --git a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
index 10887cb..762ff6c 100644
--- a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
+++ b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
@@ -108,7 +108,7 @@
         private final Intent mIntent;
         private final Drawable mAlternateIcon;
         private final Intent mAlternateIntent;
-        private final String mAlternateContentDescription;
+        private Spannable mAlternateContentDescription;
         private final boolean mShouldApplyColor;
         private final boolean mIsEditable;
         private final EntryContextMenuInfo mEntryContextMenuInfo;
@@ -122,8 +122,8 @@
         public Entry(int id, Drawable mainIcon, String header, String subHeader,
                 Drawable subHeaderIcon, String text, Drawable textIcon,
                 Spannable primaryContentDescription, Intent intent,
-                Drawable alternateIcon, Intent alternateIntent, String alternateContentDescription,
-                boolean shouldApplyColor, boolean isEditable,
+                Drawable alternateIcon, Intent alternateIntent,
+                Spannable alternateContentDescription, boolean shouldApplyColor, boolean isEditable,
                 EntryContextMenuInfo entryContextMenuInfo, Drawable thirdIcon, Intent thirdIntent,
                 String thirdContentDescription, int thirdAction, Bundle thirdExtras,
                 int iconResourceId) {
@@ -190,7 +190,7 @@
             return mAlternateIntent;
         }
 
-        String getAlternateContentDescription() {
+        Spannable getAlternateContentDescription() {
             return mAlternateContentDescription;
         }
 
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 0f5b3b0..a3d92d4 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -1700,6 +1700,7 @@
         Drawable textIcon = null;
         StringBuilder primaryContentDescription = new StringBuilder();
         Spannable phoneContentDescription = null;
+        Spannable smsContentDescription = null;
         Intent intent = null;
         boolean shouldApplyColor = true;
         Drawable alternateIcon = null;
@@ -1857,6 +1858,8 @@
 
                 alternateIcon = res.getDrawable(R.drawable.ic_message_24dp);
                 alternateContentDescription.append(res.getString(R.string.sms_custom, header));
+                smsContentDescription = com.android.contacts.common.util.ContactDisplayUtils
+                        .getTelephoneTtsSpannable(alternateContentDescription.toString(), header);
 
                 if (CallUtil.isCallWithSubjectSupported(context)) {
                     thirdIcon = res.getDrawable(R.drawable.ic_call_note_white_24dp);
@@ -2082,7 +2085,10 @@
                         ? new SpannableString(primaryContentDescription.toString())
                         : phoneContentDescription,
                 intent, alternateIcon, alternateIntent,
-                alternateContentDescription.toString(), shouldApplyColor, isEditable,
+                smsContentDescription == null
+                        ? new SpannableString(alternateContentDescription.toString())
+                        : smsContentDescription,
+                shouldApplyColor, isEditable,
                 entryContextMenuInfo, thirdIcon, thirdIntent, thirdContentDescription, thirdAction,
                 thirdExtras, iconResourceId);
     }