Enhance QuickContact accessibility description

Change QuickContact accessibility descriptions for the icon row from
'Phone' and 'Gmail' to 'Phone Bob Home' or 'Gmail Bob Work' when display
name and labels are present, otherwise 'Phone 123-345-5678' or
'Gmail bob@gmail.com'.

Bug:5057309
Change-Id: Iacbf10a2a6118c037f5f5af96af8e199b5bf5837
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index adf58bc..7bab1cd 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -431,7 +431,7 @@
         // Add buttons for each mimetype
         mTrack.removeAllViews();
         for (String mimeType : mSortedActionMimeTypes) {
-            final View actionView = inflateAction(mimeType, cache, mTrack);
+            final View actionView = inflateAction(mimeType, cache, mTrack, data.getDisplayName());
             mTrack.addView(actionView);
         }
 
@@ -465,7 +465,8 @@
      * Inflate the in-track view for the action of the given MIME-type, collapsing duplicate values.
      * Will use the icon provided by the {@link DataKind}.
      */
-    private View inflateAction(String mimeType, ResolveCache resolveCache, ViewGroup root) {
+    private View inflateAction(String mimeType, ResolveCache resolveCache,
+                               ViewGroup root, String name) {
         final CheckableImageView typeView = (CheckableImageView) getLayoutInflater().inflate(
                 R.layout.quickcontact_track_button, root, false);
 
@@ -474,7 +475,7 @@
         final Action firstInfo = children.get(0);
 
         // Set icon and listen for clicks
-        final CharSequence descrip = resolveCache.getDescription(firstInfo);
+        final CharSequence descrip = resolveCache.getDescription(firstInfo, name);
         final Drawable icon = resolveCache.getIcon(firstInfo);
         typeView.setChecked(false);
         typeView.setContentDescription(descrip);
diff --git a/src/com/android/contacts/quickcontact/ResolveCache.java b/src/com/android/contacts/quickcontact/ResolveCache.java
index ec59b94..af5d160 100644
--- a/src/com/android/contacts/quickcontact/ResolveCache.java
+++ b/src/com/android/contacts/quickcontact/ResolveCache.java
@@ -206,16 +206,18 @@
      * Find the best description for the given {@link Action}, usually used
      * for accessibility purposes.
      */
-    public CharSequence getDescription(Action action) {
-        final CharSequence actionSubtitle = action.getSubtitle();
+    public CharSequence getDescription(Action action, String name) {
         final ResolveInfo info = getEntry(action).bestResolve;
-        if (info != null) {
-            return info.loadLabel(mPackageManager);
-        } else if (!TextUtils.isEmpty(actionSubtitle)) {
-            return actionSubtitle;
+        final CharSequence infoStr = info != null ? info.loadLabel(mPackageManager) : null;
+        CharSequence actionDesc = action.getSubtitle();
+        CharSequence strs[];
+        if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(actionDesc)) {
+            strs = new CharSequence[]{infoStr, name, actionDesc};
         } else {
-            return null;
+            strs = new CharSequence[]{infoStr, action.getBody()};
         }
+        CharSequence desc = TextUtils.join(" ", strs);
+        return !TextUtils.isEmpty(desc) ? desc : null;
     }
 
     /**