Use simple TextView for call details header.

Instead of the using the more complex call_log_phone_call_details
layout, use just a text view, since all we want to show is the name (or
number) of the person who called.

Bug: 5099652
Change-Id: I408b5ffaeea09c0efe2631bd317d1ea640be294f
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index d093453..cd5ba14 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -77,11 +77,10 @@
     /** If we should immediately start playback of the voicemail, this extra will be set to true. */
     public static final String EXTRA_VOICEMAIL_START_PLAYBACK = "EXTRA_VOICEMAIL_START_PLAYBACK";
 
-    /** The views representing the details of a phone call. */
-    private PhoneCallDetailsViews mPhoneCallDetailsViews;
     private CallTypeHelper mCallTypeHelper;
     private PhoneNumberHelper mPhoneNumberHelper;
     private PhoneCallDetailsHelper mPhoneCallDetailsHelper;
+    private TextView mHeaderTextView;
     private ImageView mMainActionView;
     private ImageButton mMainActionPushLayerView;
     private ImageView mContactBackgroundView;
@@ -145,13 +144,13 @@
         mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
         mResources = getResources();
 
-        mPhoneCallDetailsViews = PhoneCallDetailsViews.fromView(getWindow().getDecorView());
         mCallTypeHelper = new CallTypeHelper(getResources());
         mPhoneNumberHelper = new PhoneNumberHelper(mResources, getVoicemailNumber());
         mPhoneCallDetailsHelper = new PhoneCallDetailsHelper(mResources, mCallTypeHelper,
                 mPhoneNumberHelper);
         mVoicemailStatusHelper = new VoicemailStatusHelperImpl();
         mAsyncQueryHandler = new CallDetailActivityQueryHandler(this);
+        mHeaderTextView = (TextView) findViewById(R.id.header_text);
         mStatusMessageView = findViewById(R.id.voicemail_status);
         mStatusMessageText = (TextView) findViewById(R.id.voicemail_status_message);
         mStatusMessageAction = (TextView) findViewById(R.id.voicemail_status_action);
@@ -276,8 +275,7 @@
         final Uri photoUri = details[0].photoUri;
 
         // Set the details header, based on the first phone call.
-        mPhoneCallDetailsHelper.setPhoneCallDetails(mPhoneCallDetailsViews,
-                details[0], false, false, true);
+        mPhoneCallDetailsHelper.setPhoneCallName(mHeaderTextView, details[0]);
 
         // Cache the details about the phone number.
         final Uri numberCallUri = mPhoneNumberHelper.getCallUri(mNumber);
diff --git a/src/com/android/contacts/PhoneCallDetailsHelper.java b/src/com/android/contacts/PhoneCallDetailsHelper.java
index 8cdd0d0..08e6a56 100644
--- a/src/com/android/contacts/PhoneCallDetailsHelper.java
+++ b/src/com/android/contacts/PhoneCallDetailsHelper.java
@@ -28,6 +28,7 @@
 import android.text.TextUtils;
 import android.text.format.DateUtils;
 import android.view.View;
+import android.widget.TextView;
 
 /**
  * Helper class to fill in the views in {@link PhoneCallDetailsViews}.
@@ -59,7 +60,7 @@
 
     /** Fills the call details views with content. */
     public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details,
-            boolean useIcons, boolean isHighlighted, boolean nameOnly) {
+            boolean useIcons, boolean isHighlighted) {
         if (useIcons) {
             views.callTypeIcons.clear();
             int count = details.callTypes.length;
@@ -130,21 +131,22 @@
         }
 
         views.dateView.setText(shortDateText);
-        views.dateView.setVisibility(View.VISIBLE);
         views.nameView.setText(nameText);
-        views.nameView.setVisibility(View.VISIBLE);
-        // Do not show the number if it is not available. This happens if we have only the number,
-        // in which case the number is shown in the name field instead.
-        if (!TextUtils.isEmpty(numberText)) {
-            views.numberView.setText(numberText);
-            views.numberView.setVisibility(View.VISIBLE);
+        views.numberView.setText(numberText);
+    }
+
+    /** Sets the name in the text view for the given phone call. */
+    public void setPhoneCallName(TextView nameView, PhoneCallDetails details) {
+        final CharSequence nameText;
+        final CharSequence displayNumber =
+            mPhoneNumberHelper.getDisplayNumber(details.number, details.formattedNumber);
+        if (TextUtils.isEmpty(details.name)) {
+            nameText = displayNumber;
         } else {
-            views.numberView.setVisibility(View.GONE);
+            nameText = details.name;
         }
 
-        // Hide the rest if not visible.
-        views.callTypeView.setVisibility(nameOnly ? View.GONE : View.VISIBLE);
-        views.numberView.setVisibility(nameOnly ? View.GONE : View.VISIBLE);
+        nameView.setText(nameText);
     }
 
     public void setCurrentTimeForTest(long currentTimeMillis) {
diff --git a/src/com/android/contacts/calllog/CallLogListItemHelper.java b/src/com/android/contacts/calllog/CallLogListItemHelper.java
index d8184d2..a448399 100644
--- a/src/com/android/contacts/calllog/CallLogListItemHelper.java
+++ b/src/com/android/contacts/calllog/CallLogListItemHelper.java
@@ -54,7 +54,7 @@
     public void setPhoneCallDetails(CallLogListItemViews views, PhoneCallDetails details,
             boolean useIcons, boolean isHighlighted) {
         mPhoneCallDetailsHelper.setPhoneCallDetails(views.phoneCallDetailsViews, details, useIcons,
-                isHighlighted, false);
+                isHighlighted);
         boolean canCall = mPhoneNumberHelper.canPlaceCallsTo(details.number);
         boolean canPlay = details.callTypes[0] == Calls.VOICEMAIL_TYPE;