Merge "Import revised translations.  DO NOT MERGE" into ics-mr1
diff --git a/res/layout-sw580dp-w1000dp/people_activity.xml b/res/layout-sw580dp-w1000dp/people_activity.xml
index 9d066df..a288ff0 100644
--- a/res/layout-sw580dp-w1000dp/people_activity.xml
+++ b/res/layout-sw580dp-w1000dp/people_activity.xml
@@ -137,7 +137,7 @@
                 <!-- Most Frequent -->
                 <fragment
                     android:id="@+id/frequent_fragment"
-                    class="com.android.contacts.list.ContactTileListFragment"
+                    class="com.android.contacts.list.ContactTileFrequentFragment"
                     android:layout_width="0dip"
                     android:layout_height="match_parent"
                     android:layout_weight="3"
diff --git a/res/layout-sw580dp/people_activity.xml b/res/layout-sw580dp/people_activity.xml
index c32893e..59a218d 100644
--- a/res/layout-sw580dp/people_activity.xml
+++ b/res/layout-sw580dp/people_activity.xml
@@ -133,7 +133,7 @@
                 <!-- Most Frequent -->
                 <fragment
                     android:id="@+id/frequent_fragment"
-                    class="com.android.contacts.list.ContactTileListFragment"
+                    class="com.android.contacts.list.ContactTileFrequentFragment"
                     android:layout_width="0dip"
                     android:layout_height="match_parent"
                     android:layout_weight="8"
diff --git a/res/layout/account_filter_header.xml b/res/layout/account_filter_header.xml
index 26207f0..ef0a9c2 100644
--- a/res/layout/account_filter_header.xml
+++ b/res/layout/account_filter_header.xml
@@ -23,7 +23,7 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"
-    android:paddingTop="@dimen/contact_browser_list_top_margin"
+    android:paddingTop="@dimen/account_filter_header_top_padding"
     android:layout_marginLeft="@dimen/contact_browser_list_header_left_margin"
     android:layout_marginRight="@dimen/contact_browser_list_header_right_margin"
     android:background="?android:attr/selectableItemBackground"
diff --git a/res/layout/account_filter_header_for_phone_favorite.xml b/res/layout/account_filter_header_for_phone_favorite.xml
new file mode 100644
index 0000000..6f1d23d
--- /dev/null
+++ b/res/layout/account_filter_header_for_phone_favorite.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- Layout showing the type of account filter for phone favorite screen
+     (or, new phone "all" screen).
+     This is very similar to account_filter_header.xml but different in its
+     top padding. -->
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/account_filter_header_container"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    android:paddingTop="8dip"
+    android:layout_marginLeft="@dimen/contact_browser_list_header_left_margin"
+    android:layout_marginRight="@dimen/contact_browser_list_header_right_margin"
+    android:background="?android:attr/selectableItemBackground"
+    android:visibility="gone">
+    <TextView
+        android:id="@+id/account_filter_header"
+        style="@style/ContactListSeparatorTextViewStyle"
+        android:paddingLeft="@dimen/contact_browser_list_item_text_indent" />
+</LinearLayout>
diff --git a/res/layout/contact_tile_list_frequent.xml b/res/layout/contact_tile_list_frequent.xml
new file mode 100644
index 0000000..3707f11
--- /dev/null
+++ b/res/layout/contact_tile_list_frequent.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!--
+  This is very similar to contact_tile_list.xml (there needs to be a ListView called
+  contact_tile_list and an empty view called contact_tile_list_empty). However, this layout also
+  contains a container view for the title of the frequently contacted list.
+-->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="?attr/favorites_padding_bottom"
+    android:orientation="vertical">
+
+    <FrameLayout
+        android:id="@+id/header_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"/>
+
+    <ListView
+        android:id="@+id/contact_tile_list"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:fadingEdge="none"
+        android:divider="@null" />
+
+    <TextView
+        android:id="@+id/contact_tile_list_empty"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:gravity="center_horizontal"
+        android:layout_marginTop="@dimen/empty_message_top_margin"
+        android:textColor="?android:attr/textColorSecondary"
+        android:textAppearance="?android:attr/textAppearanceLarge"/>
+
+</LinearLayout>
diff --git a/res/values-sw580dp/dimens.xml b/res/values-sw580dp/dimens.xml
index 8621afd..cb2d173 100644
--- a/res/values-sw580dp/dimens.xml
+++ b/res/values-sw580dp/dimens.xml
@@ -38,6 +38,7 @@
     <dimen name="contact_browser_list_header_left_margin">@dimen/list_visible_scrollbar_padding</dimen>
     <dimen name="contact_browser_list_header_right_margin">24dip</dimen>
     <dimen name="list_visible_scrollbar_padding">48dip</dimen>
+    <dimen name="account_filter_header_top_padding">@dimen/contact_browser_list_top_margin</dimen>
 
     <!-- Margins and padding for text in widget -->
     <dimen name="widget_snippet_top_margin">5dip</dimen>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a5843c6..fa66877 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -167,6 +167,8 @@
     <dimen name="contact_browser_list_item_text_indent">8dip</dimen>
     <dimen name="contact_browser_list_top_margin">8dip</dimen>
 
+    <dimen name="account_filter_header_top_padding">0dip</dimen>
+
     <!-- ContactTile Layouts -->
     <!--
       Use sp instead of dip so that the shadowbox heights can all scale uniformly
diff --git a/src/com/android/contacts/ContactsUtils.java b/src/com/android/contacts/ContactsUtils.java
index b0c0508..64dfaef 100644
--- a/src/com/android/contacts/ContactsUtils.java
+++ b/src/com/android/contacts/ContactsUtils.java
@@ -31,6 +31,8 @@
 import android.provider.ContactsContract.CommonDataKinds.Phone;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
+import android.view.View;
+import android.widget.TextView;
 
 import java.util.List;
 
@@ -208,4 +210,15 @@
         intent.setData(lookupUri);
         return intent;
     }
+
+    /**
+     * Returns a header view based on the R.layout.list_separator, where the
+     * containing {@link TextView} is set using the given textResourceId.
+     */
+    public static View createHeaderView(Context context, int textResourceId) {
+        View view = View.inflate(context, R.layout.list_separator, null);
+        TextView textView = (TextView) view.findViewById(R.id.title);
+        textView.setText(context.getString(textResourceId));
+        return view;
+    }
 }
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 772fa54..b4ad78a 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -38,6 +38,7 @@
 import com.android.contacts.list.ContactListFilter;
 import com.android.contacts.list.ContactListFilterController;
 import com.android.contacts.list.ContactTileAdapter.DisplayType;
+import com.android.contacts.list.ContactTileFrequentFragment;
 import com.android.contacts.list.ContactTileListFragment;
 import com.android.contacts.list.ContactsIntentResolver;
 import com.android.contacts.list.ContactsRequest;
@@ -145,7 +146,7 @@
      */
     private DefaultContactBrowseListFragment mAllFragment;
     private ContactTileListFragment mFavoritesFragment;
-    private ContactTileListFragment mFrequentFragment;
+    private ContactTileFrequentFragment mFrequentFragment;
     private GroupBrowseListFragment mGroupsFragment;
 
     private View mFavoritesView;
diff --git a/src/com/android/contacts/calllog/CallLogGroupBuilder.java b/src/com/android/contacts/calllog/CallLogGroupBuilder.java
index b636842..9829d4a 100644
--- a/src/com/android/contacts/calllog/CallLogGroupBuilder.java
+++ b/src/com/android/contacts/calllog/CallLogGroupBuilder.java
@@ -19,7 +19,6 @@
 import com.android.common.widget.GroupingListAdapter;
 import com.google.common.annotations.VisibleForTesting;
 
-import android.database.CharArrayBuffer;
 import android.database.Cursor;
 import android.provider.CallLog.Calls;
 import android.telephony.PhoneNumberUtils;
@@ -34,11 +33,6 @@
         public void addGroup(int cursorPosition, int size, boolean expanded);
     }
 
-    /** Reusable char array buffer. */
-    private CharArrayBuffer mBuffer1 = new CharArrayBuffer(128);
-    /** Reusable char array buffer. */
-    private CharArrayBuffer mBuffer2 = new CharArrayBuffer(128);
-
     /** The object on which the groups are created. */
     private final GroupCreator mGroupCreator;
 
@@ -48,8 +42,8 @@
 
     /**
      * Finds all groups of adjacent entries in the call log which should be grouped together and
-     * calls {@link CallLogFragment.GroupCreator#addGroup(int, int, boolean)} on
-     * {@link #mGroupCreator} for each of them.
+     * calls {@link GroupCreator#addGroup(int, int, boolean)} on {@link #mGroupCreator} for each of
+     * them.
      * <p>
      * For entries that are not grouped with others, we do not need to create a group of size one.
      * <p>
@@ -64,16 +58,14 @@
         }
 
         int currentGroupSize = 1;
-        // The number of the first entry in the group.
-        CharArrayBuffer firstNumber = mBuffer1;
-        // The number of the current row in the cursor.
-        CharArrayBuffer currentNumber = mBuffer2;
         cursor.moveToFirst();
-        cursor.copyStringToBuffer(CallLogQuery.NUMBER, firstNumber);
+        // The number of the first entry in the group.
+        String firstNumber = cursor.getString(CallLogQuery.NUMBER);
         // This is the type of the first call in the group.
         int firstCallType = cursor.getInt(CallLogQuery.CALL_TYPE);
         while (cursor.moveToNext()) {
-            cursor.copyStringToBuffer(CallLogQuery.NUMBER, currentNumber);
+            // The number of the current row in the cursor.
+            final String currentNumber = cursor.getString(CallLogQuery.NUMBER);
             final int callType = cursor.getInt(CallLogQuery.CALL_TYPE);
             final boolean sameNumber = equalNumbers(firstNumber, currentNumber);
             final boolean shouldGroup;
@@ -105,12 +97,9 @@
                 }
                 // Start a new group; it will include at least the current call.
                 currentGroupSize = 1;
-                // The current entry is now the first in the group. For the CharArrayBuffers, we
-                // need to swap them.
-                firstCallType = callType;
-                CharArrayBuffer temp = firstNumber;  // Used to swap.
+                // The current entry is now the first in the group.
                 firstNumber = currentNumber;
-                currentNumber = temp;
+                firstCallType = callType;
             }
         }
         // If the last set of calls at the end of the call log was itself a group, create it now.
@@ -131,11 +120,7 @@
     }
 
     @VisibleForTesting
-    boolean equalNumbers(CharArrayBuffer buffer1, CharArrayBuffer buffer2) {
-        // TODO add PhoneNumberUtils.compare(CharSequence, CharSequence) to avoid
-        // string allocation
-        String number1 = buffer1 == null ? null : new String(buffer1.data, 0, buffer1.sizeCopied);
-        String number2 = buffer2 == null ? null : new String(buffer2.data, 0, buffer2.sizeCopied);
+    boolean equalNumbers(String number1, String number2) {
         if (PhoneNumberUtils.isUriNumber(number1) || PhoneNumberUtils.isUriNumber(number2)) {
             return compareSipAddresses(number1, number2);
         } else {
diff --git a/src/com/android/contacts/list/ContactListItemView.java b/src/com/android/contacts/list/ContactListItemView.java
index eb31e2a..5617664 100644
--- a/src/com/android/contacts/list/ContactListItemView.java
+++ b/src/com/android/contacts/list/ContactListItemView.java
@@ -394,7 +394,11 @@
         }
 
         if (isVisible(mLabelView)) {
-            mLabelView.measure(MeasureSpec.makeMeasureSpec(labelWidth, MeasureSpec.EXACTLY),
+            // For performance reason we don't want AT_MOST usually, but when the picture is
+            // on right, we need to use it anyway because mDataView is next to mLabelView.
+            final int mode = (mPhotoPosition == PhotoPosition.LEFT
+                    ? MeasureSpec.EXACTLY : MeasureSpec.AT_MOST);
+            mLabelView.measure(MeasureSpec.makeMeasureSpec(labelWidth, mode),
                     MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
             mLabelViewHeight = mLabelView.getMeasuredHeight();
         }
diff --git a/src/com/android/contacts/list/ContactTileAdapter.java b/src/com/android/contacts/list/ContactTileAdapter.java
index 782d7c1..48bc5c3 100644
--- a/src/com/android/contacts/list/ContactTileAdapter.java
+++ b/src/com/android/contacts/list/ContactTileAdapter.java
@@ -19,6 +19,7 @@
 import com.android.contacts.ContactPresenceIconUtil;
 import com.android.contacts.ContactStatusUtil;
 import com.android.contacts.ContactTileLoaderFactory;
+import com.android.contacts.ContactsUtils;
 import com.android.contacts.GroupMemberLoader;
 import com.android.contacts.R;
 
@@ -298,8 +299,8 @@
                 // Return the number of starred plus frequent rows
                 return starredRowCount + frequentRowCount;
             case FREQUENT_ONLY:
-                // Number of frequent contacts plus one for the header
-                return mContactCursor.getCount() + 1;
+                // Number of frequent contacts
+                return mContactCursor.getCount();
             default:
                 throw new IllegalArgumentException("Unrecognized DisplayType " + mDisplayType);
         }
@@ -324,8 +325,7 @@
 
         switch (mDisplayType) {
             case FREQUENT_ONLY:
-                // Taking the current position and subtracting one because of the header
-                resultList.add(createContactEntryFromCursor(mContactCursor, position - 1));
+                resultList.add(createContactEntryFromCursor(mContactCursor, position));
                 break;
             case STARRED_ONLY:
             case GROUP_MEMBERS:
@@ -403,14 +403,10 @@
      * Divider uses a list_seperator.xml along with text to denote
      * the most frequently contacted contacts.
      */
-    private View getDivider() {
-        View dividerView = View.inflate(mContext, R.layout.list_separator, null);
-        TextView text = (TextView) dividerView.findViewById(R.id.title);
-
-        text.setText(mDisplayType == DisplayType.STREQUENT_PHONE_ONLY ?
-                mContext.getString(R.string.favoritesFrequentCalled) :
-                mContext.getString(R.string.favoritesFrequentContacted));
-        return dividerView;
+    public View getDivider() {
+        return ContactsUtils.createHeaderView(mContext,
+                mDisplayType == DisplayType.STREQUENT_PHONE_ONLY ?
+                R.string.favoritesFrequentCalled : R.string.favoritesFrequentContacted);
     }
 
     private int getLayoutResourceId(int viewType) {
@@ -463,7 +459,7 @@
             case GROUP_MEMBERS:
                 return ViewTypes.STARRED;
             case FREQUENT_ONLY:
-                return position == 0 ? ViewTypes.DIVIDER : ViewTypes.FREQUENT;
+                return ViewTypes.FREQUENT;
             default:
                 throw new IllegalStateException("Unrecognized DisplayType " + mDisplayType);
         }
diff --git a/src/com/android/contacts/list/ContactTileFrequentFragment.java b/src/com/android/contacts/list/ContactTileFrequentFragment.java
new file mode 100644
index 0000000..d958c95
--- /dev/null
+++ b/src/com/android/contacts/list/ContactTileFrequentFragment.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.contacts.list;
+
+import com.android.contacts.ContactPhotoManager;
+import com.android.contacts.ContactTileLoaderFactory;
+import com.android.contacts.ContactsUtils;
+import com.android.contacts.R;
+import com.android.contacts.list.ContactTileAdapter.DisplayType;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.LoaderManager;
+import android.app.LoaderManager.LoaderCallbacks;
+import android.content.CursorLoader;
+import android.content.Loader;
+import android.content.res.Resources;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListView;
+import android.widget.TextView;
+
+/**
+ * Fragment containing a list of frequently contacted people.
+ */
+public class ContactTileFrequentFragment extends ContactTileListFragment {
+    private static final String TAG = ContactTileFrequentFragment.class.getSimpleName();
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        View listLayout = inflateAndSetupView(inflater, container, savedInstanceState,
+                R.layout.contact_tile_list_frequent);
+        View headerView = ContactsUtils.createHeaderView(getActivity(),
+                R.string.favoritesFrequentContacted);
+        ViewGroup headerContainer = (ViewGroup) listLayout.findViewById(R.id.header_container);
+        headerContainer.addView(headerView);
+        return listLayout;
+    }
+}
diff --git a/src/com/android/contacts/list/ContactTileListFragment.java b/src/com/android/contacts/list/ContactTileListFragment.java
index 875d5d2..f28c2b5 100644
--- a/src/com/android/contacts/list/ContactTileListFragment.java
+++ b/src/com/android/contacts/list/ContactTileListFragment.java
@@ -38,6 +38,11 @@
 
 /**
  * Fragment containing a list of starred contacts followed by a list of frequently contacted.
+ *
+ * TODO: Make this an abstract class so that the favorites, frequent, and group list functionality
+ * can be separated out. This will make it easier to customize any of those lists if necessary
+ * (i.e. adding header views to the ListViews in the fragment). This work was started
+ * by creating {@link ContactTileFrequentFragment}.
  */
 public class ContactTileListFragment extends Fragment {
     private static final String TAG = ContactTileListFragment.class.getSimpleName();
@@ -69,14 +74,19 @@
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
-        View listLayout = inflater.inflate(R.layout.contact_tile_list, container, false);
+        return inflateAndSetupView(inflater, container, savedInstanceState,
+                R.layout.contact_tile_list);
+    }
+
+    protected View inflateAndSetupView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState, int layoutResourceId) {
+        View listLayout = inflater.inflate(layoutResourceId, container, false);
 
         mEmptyView = (TextView) listLayout.findViewById(R.id.contact_tile_list_empty);
         mListView = (ListView) listLayout.findViewById(R.id.contact_tile_list);
 
         mListView.setItemsCanFocus(true);
         mListView.setAdapter(mAdapter);
-
         return listLayout;
     }
 
diff --git a/src/com/android/contacts/list/PhoneFavoriteFragment.java b/src/com/android/contacts/list/PhoneFavoriteFragment.java
index 9ee2d3c..6876789 100644
--- a/src/com/android/contacts/list/PhoneFavoriteFragment.java
+++ b/src/com/android/contacts/list/PhoneFavoriteFragment.java
@@ -304,7 +304,8 @@
 
         // Create the account filter header but keep it hidden until "all" contacts are loaded.
         mAccountFilterHeaderContainer = new FrameLayout(context, null);
-        mAccountFilterHeader = inflater.inflate(R.layout.account_filter_header, mListView, false);
+        mAccountFilterHeader = inflater.inflate(R.layout.account_filter_header_for_phone_favorite,
+                mListView, false);
         mAccountFilterHeader.setOnClickListener(mFilterHeaderClickListener);
         mAccountFilterHeaderContainer.addView(mAccountFilterHeader);
         mAccountFilterHeaderContainer.setVisibility(View.GONE);
diff --git a/tests/src/com/android/contacts/calllog/CallLogGroupBuilderTest.java b/tests/src/com/android/contacts/calllog/CallLogGroupBuilderTest.java
index 2e029cc..24aa428 100644
--- a/tests/src/com/android/contacts/calllog/CallLogGroupBuilderTest.java
+++ b/tests/src/com/android/contacts/calllog/CallLogGroupBuilderTest.java
@@ -18,9 +18,6 @@
 
 import static com.google.android.collect.Lists.newArrayList;
 
-import com.android.contacts.format.FormatUtils;
-
-import android.database.CharArrayBuffer;
 import android.database.MatrixCursor;
 import android.provider.CallLog.Calls;
 import android.test.AndroidTestCase;
@@ -172,40 +169,40 @@
 
     public void testEqualPhoneNumbers() {
         // Identical.
-        assertTrue(checkEqualNumbers("6505555555", "6505555555"));
-        assertTrue(checkEqualNumbers("650 555 5555", "650 555 5555"));
+        assertTrue(mBuilder.equalNumbers("6505555555", "6505555555"));
+        assertTrue(mBuilder.equalNumbers("650 555 5555", "650 555 5555"));
         // Formatting.
-        assertTrue(checkEqualNumbers("6505555555", "650 555 5555"));
-        assertTrue(checkEqualNumbers("6505555555", "(650) 555-5555"));
-        assertTrue(checkEqualNumbers("650 555 5555", "(650) 555-5555"));
+        assertTrue(mBuilder.equalNumbers("6505555555", "650 555 5555"));
+        assertTrue(mBuilder.equalNumbers("6505555555", "(650) 555-5555"));
+        assertTrue(mBuilder.equalNumbers("650 555 5555", "(650) 555-5555"));
         // Short codes.
-        assertTrue(checkEqualNumbers("55555", "55555"));
-        assertTrue(checkEqualNumbers("55555", "555 55"));
+        assertTrue(mBuilder.equalNumbers("55555", "55555"));
+        assertTrue(mBuilder.equalNumbers("55555", "555 55"));
         // Different numbers.
-        assertFalse(checkEqualNumbers("6505555555", "650555555"));
-        assertFalse(checkEqualNumbers("6505555555", "6505555551"));
-        assertFalse(checkEqualNumbers("650 555 5555", "650 555 555"));
-        assertFalse(checkEqualNumbers("650 555 5555", "650 555 5551"));
-        assertFalse(checkEqualNumbers("55555", "5555"));
-        assertFalse(checkEqualNumbers("55555", "55551"));
+        assertFalse(mBuilder.equalNumbers("6505555555", "650555555"));
+        assertFalse(mBuilder.equalNumbers("6505555555", "6505555551"));
+        assertFalse(mBuilder.equalNumbers("650 555 5555", "650 555 555"));
+        assertFalse(mBuilder.equalNumbers("650 555 5555", "650 555 5551"));
+        assertFalse(mBuilder.equalNumbers("55555", "5555"));
+        assertFalse(mBuilder.equalNumbers("55555", "55551"));
         // SIP addresses.
-        assertTrue(checkEqualNumbers("6505555555@host.com", "6505555555@host.com"));
-        assertTrue(checkEqualNumbers("6505555555@host.com", "6505555555@HOST.COM"));
-        assertTrue(checkEqualNumbers("user@host.com", "user@host.com"));
-        assertTrue(checkEqualNumbers("user@host.com", "user@HOST.COM"));
-        assertFalse(checkEqualNumbers("USER@host.com", "user@host.com"));
-        assertFalse(checkEqualNumbers("user@host.com", "user@host1.com"));
+        assertTrue(mBuilder.equalNumbers("6505555555@host.com", "6505555555@host.com"));
+        assertTrue(mBuilder.equalNumbers("6505555555@host.com", "6505555555@HOST.COM"));
+        assertTrue(mBuilder.equalNumbers("user@host.com", "user@host.com"));
+        assertTrue(mBuilder.equalNumbers("user@host.com", "user@HOST.COM"));
+        assertFalse(mBuilder.equalNumbers("USER@host.com", "user@host.com"));
+        assertFalse(mBuilder.equalNumbers("user@host.com", "user@host1.com"));
         // SIP address vs phone number.
-        assertFalse(checkEqualNumbers("6505555555@host.com", "6505555555"));
-        assertFalse(checkEqualNumbers("6505555555", "6505555555@host.com"));
-        assertFalse(checkEqualNumbers("user@host.com", "6505555555"));
-        assertFalse(checkEqualNumbers("6505555555", "user@host.com"));
+        assertFalse(mBuilder.equalNumbers("6505555555@host.com", "6505555555"));
+        assertFalse(mBuilder.equalNumbers("6505555555", "6505555555@host.com"));
+        assertFalse(mBuilder.equalNumbers("user@host.com", "6505555555"));
+        assertFalse(mBuilder.equalNumbers("6505555555", "user@host.com"));
         // Nulls.
-        assertTrue(checkEqualNumbers(null, null));
-        assertFalse(checkEqualNumbers(null, "6505555555"));
-        assertFalse(checkEqualNumbers("6505555555", null));
-        assertFalse(checkEqualNumbers(null, "6505555555@host.com"));
-        assertFalse(checkEqualNumbers("6505555555@host.com", null));
+        assertTrue(mBuilder.equalNumbers(null, null));
+        assertFalse(mBuilder.equalNumbers(null, "6505555555"));
+        assertFalse(mBuilder.equalNumbers("6505555555", null));
+        assertFalse(mBuilder.equalNumbers(null, "6505555555@host.com"));
+        assertFalse(mBuilder.equalNumbers("6505555555@host.com", null));
     }
 
     public void testCompareSipAddresses() {
@@ -227,24 +224,6 @@
         assertFalse(mBuilder.compareSipAddresses("6505555555@host.com", null));
     }
 
-    /** Calls {@link CallLogGroupBuilder#equalNumbers(CharArrayBuffer, CharArrayBuffer)}. */
-    private boolean checkEqualNumbers(String number1, String number2) {
-        final CharArrayBuffer buffer1 = stringToCharArrayBuffer(number1);
-        final CharArrayBuffer buffer2 = stringToCharArrayBuffer(number2);
-        return mBuilder.equalNumbers(buffer1, buffer2);
-    }
-
-    /** Converts a string into a {@link CharArrayBuffer}, preserving null values. */
-    private CharArrayBuffer stringToCharArrayBuffer(String value) {
-        if (value == null) {
-            return null;
-        }
-
-        final CharArrayBuffer buffer = new CharArrayBuffer(value.length());
-        FormatUtils.copyToCharArrayBuffer(value, buffer);
-        return buffer;
-    }
-
     /** Creates (or recreates) the cursor used to store the call log content for the tests. */
     private void createCursor() {
         mCursor = new MatrixCursor(CallLogQuery.EXTENDED_PROJECTION);