Format phone number before setting it on ContactListItemView.

Get the country ISO from the context in the PhoneNumberListAdapter.
Then, in ContactListItemView, use PhoneNumberUtils to format the
given phone number before setting it. Also, deprecates/deletes
showPhoneNumber() method.

Bug: 11734577

Change-Id: I890f1b090acb1814814396da654f75b23d9ef8de
diff --git a/src/com/android/contacts/common/list/ContactListItemView.java b/src/com/android/contacts/common/list/ContactListItemView.java
index 8b0594b..0217620 100644
--- a/src/com/android/contacts/common/list/ContactListItemView.java
+++ b/src/com/android/contacts/common/list/ContactListItemView.java
@@ -29,6 +29,7 @@
 import android.os.Bundle;
 import android.provider.ContactsContract;
 import android.provider.ContactsContract.Contacts;
+import android.telephony.PhoneNumberUtils;
 import android.text.Spannable;
 import android.text.SpannableString;
 import android.text.TextUtils;
@@ -1018,15 +1019,20 @@
      * Sets phone number for a list item. This takes care of number highlighting if the highlight
      * mask exists.
      */
-    public void setPhoneNumber(String text) {
+    public void setPhoneNumber(String text, String countryIso) {
         if (text == null) {
             if (mDataView != null) {
                 mDataView.setVisibility(View.GONE);
             }
         } else {
             getDataView();
+
+            if (countryIso != null) {
+                text = PhoneNumberUtils.formatNumber(text, countryIso);
+            }
+
             // Sets phone number texts for display after highlighting it, if applicable.
-            //CharSequence textToSet = text;
+            // CharSequence textToSet = text;
             final SpannableString textToSet = new SpannableString(text);
 
             if (mNumberHighlightSequence.size() != 0) {
@@ -1483,11 +1489,6 @@
         setData(mDataBuffer.data, mDataBuffer.sizeCopied);
     }
 
-    public void showPhoneNumber(Cursor cursor, int dataColumnIndex) {
-        // Highlights the number and aligns text before showing.
-        setPhoneNumber(cursor.getString(dataColumnIndex));
-    }
-
     public void setActivatedStateSupported(boolean flag) {
         this.mActivatedStateSupported = flag;
     }
diff --git a/src/com/android/contacts/common/list/PhoneNumberListAdapter.java b/src/com/android/contacts/common/list/PhoneNumberListAdapter.java
index 88cc2b8..a6d67ce 100644
--- a/src/com/android/contacts/common/list/PhoneNumberListAdapter.java
+++ b/src/com/android/contacts/common/list/PhoneNumberListAdapter.java
@@ -29,6 +29,7 @@
 import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.Directory;
+import android.telephony.PhoneNumberUtils;
 import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
@@ -100,6 +101,7 @@
     }
 
     private final CharSequence mUnknownNameText;
+    private final String mCountryIso;
 
     private ContactListItemView.PhotoPosition mPhotoPosition;
 
@@ -109,6 +111,7 @@
         super(context);
         setDefaultFilterHeaderText(R.string.list_filter_phones);
         mUnknownNameText = context.getText(android.R.string.unknownName);
+        mCountryIso = GeoUtil.getCurrentCountryIso(context);
 
         final ExtendedPhoneDirectoriesManager manager
                 = ExtensionsFactory.getExtendedPhoneDirectoriesManager();
@@ -386,7 +389,7 @@
                 text = GeoUtil.getGeocodedLocationFor(mContext, phoneNumber);
             }
         }
-        view.setPhoneNumber(text);
+        view.setPhoneNumber(text, mCountryIso);
     }
 
     protected void bindSectionHeaderAndDivider(final ContactListItemView view, int position) {