Extract logic from PhoneCallDetailsViews.

Instead of having the logic in the views object, use a helper class. The
advantage is that we can have a single instance of this class and I will
do some optimizations in a follow-up changelist.

Change-Id: I6258e947aa33a2a3b6e72d7273a3b7e080c5d7e5
diff --git a/src/com/android/contacts/PhoneCallDetailsViews.java b/src/com/android/contacts/PhoneCallDetailsViews.java
index 713a667..f9f8572 100644
--- a/src/com/android/contacts/PhoneCallDetailsViews.java
+++ b/src/com/android/contacts/PhoneCallDetailsViews.java
@@ -16,16 +16,6 @@
 
 package com.android.contacts;
 
-import com.android.contacts.format.FormatUtils;
-
-import android.content.res.Resources;
-import android.graphics.Typeface;
-import android.provider.CallLog.Calls;
-import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.telephony.PhoneNumberUtils;
-import android.text.Spanned;
-import android.text.TextUtils;
-import android.text.format.DateUtils;
 import android.view.View;
 import android.widget.TextView;
 
@@ -47,78 +37,4 @@
         mCallTypeAndDateView = (TextView) view.findViewById(R.id.call_type);
         mNumberView = (TextView) view.findViewById(R.id.number);
     }
-
-    /**
-     * Fills the call details views with content.
-     *
-     * @param resources used to look up strings
-     * @param date the date of the call, in milliseconds since the epoch
-     * @param callType the type of call, as defined in the call log table
-     * @param name the name of the contact, if available
-     * @param number the number of the other party involved in the call
-     * @param numberType the type of phone, e.g., {@link Phone#TYPE_HOME}, 0 if not available
-     * @param numberLabel the custom label associated with the phone number in the contact
-     */
-    public void setPhoneCallDetails(Resources resources, long date, int callType,
-            CharSequence name, CharSequence number, int numberType, CharSequence numberLabel) {
-        CharSequence callTypeText = "";
-        switch (callType) {
-            case Calls.INCOMING_TYPE:
-                callTypeText = resources.getString(R.string.type_incoming);
-                break;
-
-            case Calls.OUTGOING_TYPE:
-                callTypeText = resources.getString(R.string.type_outgoing);
-                break;
-
-            case Calls.MISSED_TYPE:
-                callTypeText = resources.getString(R.string.type_missed);
-                break;
-        }
-
-        CharSequence shortDateText =
-            DateUtils.getRelativeTimeSpanString(date,
-                    System.currentTimeMillis(),
-                    DateUtils.MINUTE_IN_MILLIS,
-                    DateUtils.FORMAT_ABBREV_RELATIVE);
-
-        CharSequence callTypeAndDateText = FormatUtils.applyStyleToSpan(Typeface.BOLD,
-                callTypeText + " " + shortDateText, 0, callTypeText.length(),
-                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
-
-        CharSequence numberFormattedLabel = null;
-        // Only show a label if the number is shown and it is not a SIP address.
-        if (!TextUtils.isEmpty(number) && !PhoneNumberUtils.isUriNumber(number.toString())) {
-            numberFormattedLabel = Phone.getTypeLabel(resources, numberType, numberLabel);
-        }
-
-        CharSequence nameText;
-        CharSequence numberText;
-        if (TextUtils.isEmpty(name)) {
-            nameText = number;
-            numberText = "";
-        } else {
-            nameText = name;
-            numberText = number;
-            if (callType != 0 && numberFormattedLabel != null) {
-                numberText = FormatUtils.applyStyleToSpan(Typeface.BOLD,
-                        numberFormattedLabel + " " + number, 0,
-                        numberFormattedLabel.length(),
-                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
-            }
-        }
-
-        mCallTypeAndDateView.setText(callTypeAndDateText);
-        mCallTypeAndDateView.setVisibility(View.VISIBLE);
-        mNameView.setText(nameText);
-        mNameView.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)) {
-            mNumberView.setText(numberText);
-            mNumberView.setVisibility(View.VISIBLE);
-        } else {
-            mNumberView.setVisibility(View.GONE);
-        }
-    }
-}
\ No newline at end of file
+}