Open groups of calls in the CallDetailActivity.

This change allow showing the details of a group of calls in the
CallDetailActivity.

First of all, it adds a way to pass to the activity a list of calls,
namely by using an extra containing a list of ids of rows in the call
log. It preserves the existing mean to open the call details using a URI
for backward compatibility.

In turns, the activity will get the details of each call, assuming they
all come from the same number and therefore the same person, and show a
single contact header at the top, while placing the detail of each of
the calls in the list at the bottom of the activity.

With that done, we no longer allow opening up groups of calls in the
call log: they are no longer necessary, as the details of the calls
within a group are now accessible in the details page.

In the process, extract a utility class that encapsulates operations on
phone number, like whether calls can be placed to a phone number, and
how to display the number to the user. There might be a few more places
where this helper can be used, but I will look at those in a follow-up.

A few optimizations still need to be pursued, for instance the lookup of
the details of the phone calls in a group can be optimized.

Another candidate for a follow-up is using a common ContactInfo class
between the call log and the call details, maybe with shared functions
to extra the information from a cursor.

A further improvement would be to have a shared cache of the contact
info and call log details, so that looking up the information when
opening the call details can be done more efficiently (it is currently a
strict mode violation) since the call details will generally require
information which had already been looked up by the call log beforehand.

Change-Id: I408650d7485afe4c132dd9cc376e6ba0e3388c1e
diff --git a/src/com/android/contacts/PhoneCallDetailsHelper.java b/src/com/android/contacts/PhoneCallDetailsHelper.java
index cbf3c5c..6bdfbaa 100644
--- a/src/com/android/contacts/PhoneCallDetailsHelper.java
+++ b/src/com/android/contacts/PhoneCallDetailsHelper.java
@@ -17,8 +17,8 @@
 package com.android.contacts;
 
 import com.android.contacts.calllog.CallTypeHelper;
+import com.android.contacts.calllog.PhoneNumberHelper;
 import com.android.contacts.format.FormatUtils;
-import com.android.internal.telephony.CallerInfo;
 
 import android.content.Context;
 import android.content.res.Resources;
@@ -37,10 +37,11 @@
 public class PhoneCallDetailsHelper {
     private final Context mContext;
     private final Resources mResources;
-    private final String mVoicemailNumber;
     /** The injected current time in milliseconds since the epoch. Used only by tests. */
     private Long mCurrentTimeMillisForTest;
+    // Helper classes.
     private final CallTypeHelper mCallTypeHelper;
+    private final PhoneNumberHelper mPhoneNumberHelper;
 
     /**
      * Creates a new instance of the helper.
@@ -49,12 +50,12 @@
      *
      * @param resources used to look up strings
      */
-    public PhoneCallDetailsHelper(Context context, Resources resources, String voicemailNumber,
-            CallTypeHelper callTypeHelper) {
+    public PhoneCallDetailsHelper(Context context, Resources resources,
+            CallTypeHelper callTypeHelper, PhoneNumberHelper phoneNumberHelper) {
         mContext = context;
         mResources = resources;
-        mVoicemailNumber = voicemailNumber;
         mCallTypeHelper = callTypeHelper;
+        mPhoneNumberHelper = phoneNumberHelper;
     }
 
     /** Fills the call details views with content. */
@@ -100,12 +101,13 @@
 
         final CharSequence nameText;
         final CharSequence numberText;
+        final CharSequence displayNumber =
+            mPhoneNumberHelper.getDisplayNumber(details.number, details.formattedNumber);
         if (TextUtils.isEmpty(details.name)) {
-            nameText = getDisplayNumber(details.number, details.formattedNumber);
+            nameText = displayNumber;
             numberText = "";
         } else {
             nameText = details.name;
-            CharSequence displayNumber = getDisplayNumber(details.number, details.formattedNumber);
             if (numberFormattedLabel != null) {
                 numberText = FormatUtils.applyStyleToSpan(Typeface.BOLD,
                         numberFormattedLabel + " " + displayNumber, 0,
@@ -130,29 +132,6 @@
         }
     }
 
-    private CharSequence getDisplayNumber(CharSequence number, CharSequence formattedNumber) {
-        if (TextUtils.isEmpty(number)) {
-            return "";
-        }
-        if (number.equals(CallerInfo.UNKNOWN_NUMBER)) {
-            return mResources.getString(R.string.unknown);
-        }
-        if (number.equals(CallerInfo.PRIVATE_NUMBER)) {
-            return mResources.getString(R.string.private_num);
-        }
-        if (number.equals(CallerInfo.PAYPHONE_NUMBER)) {
-            return mResources.getString(R.string.payphone);
-        }
-        if (PhoneNumberUtils.extractNetworkPortion(number.toString()).equals(mVoicemailNumber)) {
-            return mResources.getString(R.string.voicemail);
-        }
-        if (TextUtils.isEmpty(formattedNumber)) {
-            return number;
-        } else {
-            return formattedNumber;
-        }
-    }
-
     public void setCurrentTimeForTest(long currentTimeMillis) {
         mCurrentTimeMillisForTest = currentTimeMillis;
     }