Show text or icons for call log items.

The current code uses the small icons to show the type of call. The
design we want to implement allows for both icons and text to be
present, depending on the context.

This change adds a boolean flag to determine which one to use.

Change-Id: Ia3ec8bba44f46a4b4857654ffc0256e1af909741
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index 1200cdf..5a795e2 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -305,7 +305,7 @@
                 }
                 mPhoneCallDetailsHelper.setPhoneCallDetails(mPhoneCallDetailsViews,
                         new PhoneCallDetails(numberText, callType, date, nameText, numberType,
-                                numberLabel));
+                                numberLabel), false);
 
                 loadContactPhotos(photoId);
             } else {
diff --git a/src/com/android/contacts/PhoneCallDetailsHelper.java b/src/com/android/contacts/PhoneCallDetailsHelper.java
index f884df7..b52dacb 100644
--- a/src/com/android/contacts/PhoneCallDetailsHelper.java
+++ b/src/com/android/contacts/PhoneCallDetailsHelper.java
@@ -47,6 +47,14 @@
     private final Drawable mMissedDrawable;
     /** Icon for voicemails. */
     private final Drawable mVoicemailDrawable;
+    /** Name used to identify incoming calls. */
+    private final String mIncomingName;
+    /** Name used to identify outgoing calls. */
+    private final String mOutgoingName;
+    /** Name used to identify missed calls. */
+    private final String mMissedName;
+    /** Name used to identify voicemail calls. */
+    private final String mVoicemailName;
     /** The injected current time in milliseconds since the epoch. Used only by tests. */
     private Long mCurrentTimeMillisForTest;
 
@@ -67,28 +75,76 @@
         mOutgoingDrawable = outgoingDrawable;
         mMissedDrawable = missedDrawable;
         mVoicemailDrawable = voicemailDrawable;
+        // Cache these values so that we do not need to look them up each time.
+        mIncomingName = mResources.getString(R.string.type_incoming);
+        mOutgoingName = mResources.getString(R.string.type_outgoing);
+        mMissedName = mResources.getString(R.string.type_missed);
+        mVoicemailName = mResources.getString(R.string.type_voicemail);
     }
 
     /** Fills the call details views with content. */
-    public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details) {
-        Drawable callTypeDrawable = null;
-        switch (details.callType) {
-            case Calls.INCOMING_TYPE:
-                callTypeDrawable = mIncomingDrawable;
-                break;
+    public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details,
+            boolean useIcons) {
+        if (useIcons) {
+            final Drawable callTypeDrawable;
+            switch (details.callType) {
+                case Calls.INCOMING_TYPE:
+                    callTypeDrawable = mIncomingDrawable;
+                    break;
 
-            case Calls.OUTGOING_TYPE:
-                callTypeDrawable = mOutgoingDrawable;
-                break;
+                case Calls.OUTGOING_TYPE:
+                    callTypeDrawable = mOutgoingDrawable;
+                    break;
 
-            case Calls.MISSED_TYPE:
-                callTypeDrawable = mMissedDrawable;
-                break;
+                case Calls.MISSED_TYPE:
+                    callTypeDrawable = mMissedDrawable;
+                    break;
 
-            case Calls.VOICEMAIL_TYPE:
-                callTypeDrawable = mVoicemailDrawable;
-                break;
+                case Calls.VOICEMAIL_TYPE:
+                    callTypeDrawable = mVoicemailDrawable;
+                    break;
+
+                default:
+                    throw new IllegalArgumentException("invalid call type: " + details.callType);
+            }
+            ImageView callTypeImage = new ImageView(mContext);
+            callTypeImage.setImageDrawable(callTypeDrawable);
+            views.callTypeIcons.removeAllViews();
+            views.callTypeIcons.addView(callTypeImage);
+
+            views.callTypeIcons.setVisibility(View.VISIBLE);
+            views.callTypeText.setVisibility(View.GONE);
+            views.callTypeSeparator.setVisibility(View.GONE);
+        } else {
+            String callTypeName;
+            switch (details.callType) {
+                case Calls.INCOMING_TYPE:
+                    callTypeName = mIncomingName;
+                    break;
+
+                case Calls.OUTGOING_TYPE:
+                    callTypeName = mOutgoingName;
+                    break;
+
+                case Calls.MISSED_TYPE:
+                    callTypeName = mMissedName;
+                    break;
+
+                case Calls.VOICEMAIL_TYPE:
+                    callTypeName = mVoicemailName;
+                    break;
+
+                default:
+                    throw new IllegalArgumentException("invalid call type: " + details.callType);
+            }
+            views.callTypeText.setText(callTypeName);
+            views.callTypeIcons.removeAllViews();
+
+            views.callTypeText.setVisibility(View.VISIBLE);
+            views.callTypeSeparator.setVisibility(View.VISIBLE);
+            views.callTypeIcons.setVisibility(View.GONE);
         }
+
         CharSequence shortDateText =
             DateUtils.getRelativeTimeSpanString(details.date,
                     getCurrentTimeMillis(),
@@ -121,11 +177,6 @@
             }
         }
 
-        ImageView callTypeImage = new ImageView(mContext);
-        callTypeImage.setImageDrawable(callTypeDrawable);
-        views.callTypesLayout.removeAllViews();
-        views.callTypesLayout.addView(callTypeImage);
-
         views.dateView.setText(shortDateText);
         views.dateView.setVisibility(View.VISIBLE);
         views.nameView.setText(nameText);
diff --git a/src/com/android/contacts/PhoneCallDetailsViews.java b/src/com/android/contacts/PhoneCallDetailsViews.java
index 483ec65..7453af0 100644
--- a/src/com/android/contacts/PhoneCallDetailsViews.java
+++ b/src/com/android/contacts/PhoneCallDetailsViews.java
@@ -25,14 +25,18 @@
  */
 public final class PhoneCallDetailsViews {
     public final TextView nameView;
-    public final LinearLayout callTypesLayout;
+    public final LinearLayout callTypeIcons;
+    public final TextView callTypeText;
+    public final View callTypeSeparator;
     public final TextView dateView;
     public final TextView numberView;
 
-    private PhoneCallDetailsViews(TextView nameView, LinearLayout callTypesLayout,
-            TextView dateView, TextView numberView) {
+    private PhoneCallDetailsViews(TextView nameView, LinearLayout callTypeIcons,
+            TextView callTypeText, View callTypeSeparator, TextView dateView, TextView numberView) {
         this.nameView = nameView;
-        this.callTypesLayout = callTypesLayout;
+        this.callTypeIcons = callTypeIcons;
+        this.callTypeText = callTypeText;
+        this.callTypeSeparator = callTypeSeparator;
         this.dateView = dateView;
         this.numberView = numberView;
     }
@@ -46,13 +50,17 @@
      */
     public static PhoneCallDetailsViews fromView(View view) {
         return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name),
-                (LinearLayout) view.findViewById(R.id.call_types),
+                (LinearLayout) view.findViewById(R.id.call_type_icons),
+                (TextView) view.findViewById(R.id.call_type_name),
+                view.findViewById(R.id.call_type_separator),
                 (TextView) view.findViewById(R.id.date),
                 (TextView) view.findViewById(R.id.number));
     }
 
     public static PhoneCallDetailsViews createForTest(TextView nameView,
-            LinearLayout callTypesLayout, TextView dateView, TextView numberView) {
-        return new PhoneCallDetailsViews(nameView, callTypesLayout, dateView, numberView);
+            LinearLayout callTypeIcons, TextView callTypeText, View callTypeSeparator,
+            TextView dateView, TextView numberView) {
+        return new PhoneCallDetailsViews(nameView, callTypeIcons, callTypeText, callTypeSeparator,
+                dateView, numberView);
     }
 }