Show a count for more than 3 calls in a group.

The count represents the total count.

The icons for the call types of the 3 most recent calls are shown.

Change-Id: I1e7a4d2421b5fafa222793c3a4732b134633b828
diff --git a/res/layout/call_log_phone_call_details.xml b/res/layout/call_log_phone_call_details.xml
index aebda9d..b46a8ed 100644
--- a/res/layout/call_log_phone_call_details.xml
+++ b/res/layout/call_log_phone_call_details.xml
@@ -27,6 +27,7 @@
             android:id="@+id/call_type_icons"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_marginRight="?attr/call_log_date_margin"
         />
         <TextView
             android:id="@+id/call_type_name"
@@ -34,12 +35,13 @@
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceSmall"
             android:textColor="?attr/call_log_primary_text_color"
+            android:layout_marginRight="?attr/call_log_date_margin"
         />
         <TextView
             android:id="@+id/call_type_separator"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginLeft="?attr/call_log_date_margin"
+            android:layout_marginRight="?attr/call_log_date_margin"
             android:textAppearance="?android:attr/textAppearanceSmall"
             android:textColor="?attr/call_log_primary_text_color"
             android:text="@string/call_log_type_date_separator"
@@ -51,7 +53,6 @@
             android:textAppearance="?android:attr/textAppearanceSmall"
             android:textColor="?attr/call_log_primary_text_color"
             android:layout_toRightOf="@id/call_type"
-            android:layout_marginLeft="?attr/call_log_date_margin"
             android:layout_alignParentBottom="true"
         />
     </LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 547f3e7..52f8394 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1641,4 +1641,7 @@
    <!--  User action prompt shown next to a voicemail status message to let the user call voicemail
    server directly to listen to the voicemails. [CHAR LIMIT=20] -->
     <string name="voicemail_status_action_call_server">Call voicemail</string>
+
+    <!-- The counter for calls in a group in the call log [CHAR LIMIT=5] -->
+    <string name="call_log_item_count">(%1$d)</string>
 </resources>
diff --git a/src/com/android/contacts/PhoneCallDetailsHelper.java b/src/com/android/contacts/PhoneCallDetailsHelper.java
index e115d21..8369a0c 100644
--- a/src/com/android/contacts/PhoneCallDetailsHelper.java
+++ b/src/com/android/contacts/PhoneCallDetailsHelper.java
@@ -35,6 +35,9 @@
  * Helper class to fill in the views in {@link PhoneCallDetailsViews}.
  */
 public class PhoneCallDetailsHelper {
+    /** The maximum number of icons will be shown to represent the call types in a group. */
+    private static final int MAX_CALL_TYPE_ICONS = 3;
+
     private final Context mContext;
     private final Resources mResources;
     /** The injected current time in milliseconds since the epoch. Used only by tests. */
@@ -64,14 +67,22 @@
         if (useIcons) {
             views.callTypeIcons.removeAllViews();
             int count = details.callTypes.length;
-            for (int callType : details.callTypes) {
+            for (int index = 0; index < count && index < MAX_CALL_TYPE_ICONS; ++index) {
+                int callType = details.callTypes[index];
                 ImageView callTypeImage = new ImageView(mContext);
                 callTypeImage.setImageDrawable(mCallTypeHelper.getCallTypeDrawable(callType));
                 views.callTypeIcons.addView(callTypeImage);
             }
             views.callTypeIcons.setVisibility(View.VISIBLE);
-            views.callTypeText.setVisibility(View.GONE);
-            views.callTypeSeparator.setVisibility(View.GONE);
+            if (count > MAX_CALL_TYPE_ICONS) {
+                views.callTypeText.setVisibility(View.VISIBLE);
+                views.callTypeSeparator.setVisibility(View.VISIBLE);
+                views.callTypeText.setText(
+                        mResources.getString(R.string.call_log_item_count, count));
+            } else {
+                views.callTypeText.setVisibility(View.GONE);
+                views.callTypeSeparator.setVisibility(View.GONE);
+            }
         } else {
             String callTypeName;
             // Use the name of the first call type.