Merge "Import revised translations.  DO NOT MERGE" into ics-mr1
diff --git a/src/com/android/contacts/activities/ContactSelectionActivity.java b/src/com/android/contacts/activities/ContactSelectionActivity.java
index 3098864..ac13ba3 100644
--- a/src/com/android/contacts/activities/ContactSelectionActivity.java
+++ b/src/com/android/contacts/activities/ContactSelectionActivity.java
@@ -209,6 +209,9 @@
                 }
             }, FOCUS_DELAY);
         }
+
+        // Clear focus and suppress keyboard show-up.
+        mSearchView.clearFocus();
     }
 
     @Override
@@ -223,19 +226,6 @@
     }
 
     @Override
-    public void onStart() {
-        super.onStart();
-
-        if (mSearchView != null && mSearchView.getVisibility() == View.VISIBLE) {
-            if (mSearchView.hasFocus()) {
-                showInputMethod(mSearchView.findFocus());
-            } else {
-                mSearchView.requestFocus();
-            }
-        }
-    }
-
-    @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
             case android.R.id.home:
diff --git a/src/com/android/contacts/calllog/ContactInfoHelper.java b/src/com/android/contacts/calllog/ContactInfoHelper.java
index 95ea6dc..b4e4cf7 100644
--- a/src/com/android/contacts/calllog/ContactInfoHelper.java
+++ b/src/com/android/contacts/calllog/ContactInfoHelper.java
@@ -21,9 +21,7 @@
 import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
-import android.provider.ContactsContract.CommonDataKinds.SipAddress;
 import android.provider.ContactsContract.Contacts;
-import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.PhoneLookup;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
@@ -96,6 +94,50 @@
     }
 
     /**
+     * Looks up a contact using the given URI.
+     * <p>
+     * It returns null if an error occurs, {@link ContactInfo#EMPTY} if no matching contact is
+     * found, or the {@link ContactInfo} for the given contact.
+     * <p>
+     * The {@link ContactInfo#formattedNumber} field is always set to {@code null} in the returned
+     * value.
+     */
+    private ContactInfo lookupContactFromUri(Uri uri) {
+        final ContactInfo info;
+        Cursor phonesCursor =
+                mContext.getContentResolver().query(
+                        uri, PhoneQuery._PROJECTION, null, null, null);
+
+        if (phonesCursor != null) {
+            try {
+                if (phonesCursor.moveToFirst()) {
+                    info = new ContactInfo();
+                    long contactId = phonesCursor.getLong(PhoneQuery.PERSON_ID);
+                    String lookupKey = phonesCursor.getString(PhoneQuery.LOOKUP_KEY);
+                    info.lookupUri = Contacts.getLookupUri(contactId, lookupKey);
+                    info.name = phonesCursor.getString(PhoneQuery.NAME);
+                    info.type = phonesCursor.getInt(PhoneQuery.PHONE_TYPE);
+                    info.label = phonesCursor.getString(PhoneQuery.LABEL);
+                    info.number = phonesCursor.getString(PhoneQuery.MATCHED_NUMBER);
+                    info.normalizedNumber = phonesCursor.getString(PhoneQuery.NORMALIZED_NUMBER);
+                    info.photoId = phonesCursor.getLong(PhoneQuery.PHOTO_ID);
+                    info.photoUri =
+                            UriUtils.parseUriOrNull(phonesCursor.getString(PhoneQuery.PHOTO_URI));
+                    info.formattedNumber = null;
+                } else {
+                    info = ContactInfo.EMPTY;
+                }
+            } finally {
+                phonesCursor.close();
+            }
+        } else {
+            // Failed to fetch the data, ignore this request.
+            info = null;
+        }
+        return info;
+    }
+
+    /**
      * Determines the contact information for the given SIP address.
      * <p>
      * It returns the contact info if found.
@@ -107,81 +149,11 @@
     private ContactInfo queryContactInfoForSipAddress(String sipAddress) {
         final ContactInfo info;
 
-        // TODO: This code is duplicated from the
-        // CallerInfoAsyncQuery class.  To avoid that, could the
-        // code here just use CallerInfoAsyncQuery, rather than
-        // manually running ContentResolver.query() itself?
-
-        // We look up SIP addresses directly in the Data table:
-        Uri contactRef = Data.CONTENT_URI;
-
-        // Note Data.DATA1 and SipAddress.SIP_ADDRESS are equivalent.
-        //
-        // Also note we use "upper(data1)" in the WHERE clause, and
-        // uppercase the incoming SIP address, in order to do a
-        // case-insensitive match.
-        //
-        // TODO: SIP URIs are defined as being case sensitive for the user part (before the '@')
-        // and case insensitive everywhere else. We should change the code to handle this
-        // accordingly.
-        //
-        // TODO: May also need to normalize by adding "sip:" as a
-        // prefix, if we start storing SIP addresses that way in the
-        // database.
-        String selection = "upper(" + Data.DATA1 + ")=?"
-                + " AND "
-                + Data.MIMETYPE + "='" + SipAddress.CONTENT_ITEM_TYPE + "'";
-        String[] selectionArgs = new String[] { sipAddress.toUpperCase() };
-
-        Cursor dataTableCursor =
-                mContext.getContentResolver().query(
-                        contactRef,
-                        null,  // projection
-                        selection,  // selection
-                        selectionArgs,  // selectionArgs
-                        null);  // sortOrder
-
-        if (dataTableCursor != null) {
-            if (dataTableCursor.moveToFirst()) {
-                info = new ContactInfo();
-
-                // TODO: we could slightly speed this up using an
-                // explicit projection (and thus not have to do
-                // those getColumnIndex() calls) but the benefit is
-                // very minimal.
-
-                // Note the Data.CONTACT_ID column here is
-                // equivalent to the PERSON_ID_COLUMN_INDEX column
-                // we use with "phonesCursor" below.
-                long contactId = dataTableCursor.getLong(
-                        dataTableCursor.getColumnIndex(Data.CONTACT_ID));
-                String lookupKey = dataTableCursor.getString(
-                        dataTableCursor.getColumnIndex(Data.LOOKUP_KEY));
-                info.lookupUri = Contacts.getLookupUri(contactId, lookupKey);
-                info.name = dataTableCursor.getString(
-                        dataTableCursor.getColumnIndex(Data.DISPLAY_NAME));
-                // "type" and "label" are currently unused for SIP addresses
-                info.type = SipAddress.TYPE_OTHER;
-                info.label = null;
-
-                // And "number" is the SIP address.
-                // Note Data.DATA1 and SipAddress.SIP_ADDRESS are equivalent.
-                info.number = dataTableCursor.getString(dataTableCursor.getColumnIndex(Data.DATA1));
-                info.normalizedNumber = null;  // meaningless for SIP addresses
-                info.photoId = dataTableCursor.getLong(
-                        dataTableCursor.getColumnIndex(Data.PHOTO_ID));
-                info.photoUri = UriUtils.parseUriOrNull(dataTableCursor.getString(
-                        dataTableCursor.getColumnIndex(Data.PHOTO_URI)));
-                info.formattedNumber = null;  // meaningless for SIP addresses
-            } else {
-                info = ContactInfo.EMPTY;
-            }
-            dataTableCursor.close();
-        } else {
-            // Failed to fetch the data, ignore this request.
-            info = null;
-        }
-        return info;
+        // "contactNumber" is a SIP address, so use the PhoneLookup table with the SIP parameter.
+        Uri.Builder uriBuilder = PhoneLookup.CONTENT_FILTER_URI.buildUpon();
+        uriBuilder.appendPath(Uri.encode(sipAddress));
+        uriBuilder.appendQueryParameter(PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, "1");
+        return lookupContactFromUri(uriBuilder.build());
     }
 
     /**
@@ -194,8 +166,6 @@
      * If the lookup fails for some other reason, it returns null.
      */
     private ContactInfo queryContactInfoForPhoneNumber(String number, String countryIso) {
-        final ContactInfo info;
-
         String contactNumber = number;
         if (!TextUtils.isEmpty(countryIso)) {
             // Normalize the number: this is needed because the PhoneLookup query below does not
@@ -207,37 +177,11 @@
             }
         }
 
-        // "contactNumber" is a regular phone number, so use the
-        // PhoneLookup table:
-        Cursor phonesCursor =
-                mContext.getContentResolver().query(
-                    Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
-                            Uri.encode(contactNumber)),
-                            PhoneQuery._PROJECTION, null, null, null);
-
-        if (phonesCursor != null) {
-            if (phonesCursor.moveToFirst()) {
-                info = new ContactInfo();
-                long contactId = phonesCursor.getLong(PhoneQuery.PERSON_ID);
-                String lookupKey = phonesCursor.getString(PhoneQuery.LOOKUP_KEY);
-                info.lookupUri = Contacts.getLookupUri(contactId, lookupKey);
-                info.name = phonesCursor.getString(PhoneQuery.NAME);
-                info.type = phonesCursor.getInt(PhoneQuery.PHONE_TYPE);
-                info.label = phonesCursor.getString(PhoneQuery.LABEL);
-                info.number = phonesCursor.getString(PhoneQuery.MATCHED_NUMBER);
-                info.normalizedNumber = phonesCursor.getString(PhoneQuery.NORMALIZED_NUMBER);
-                info.photoId = phonesCursor.getLong(PhoneQuery.PHOTO_ID);
-                info.photoUri =
-                        UriUtils.parseUriOrNull(phonesCursor.getString(PhoneQuery.PHOTO_URI));
-                info.formattedNumber = formatPhoneNumber(number, null, countryIso);
-
-            } else {
-                info = ContactInfo.EMPTY;
-            }
-            phonesCursor.close();
-        } else {
-            // Failed to fetch the data, ignore this request.
-            info = null;
+        // The "contactNumber" is a regular phone number, so use the PhoneLookup table.
+        Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(contactNumber));
+        ContactInfo info = lookupContactFromUri(uri);
+        if (info != null && info != ContactInfo.EMPTY) {
+            info.formattedNumber = formatPhoneNumber(number, null, countryIso);
         }
         return info;
     }
diff --git a/src/com/android/contacts/format/DisplayNameFormatter.java b/src/com/android/contacts/format/DisplayNameFormatter.java
deleted file mode 100644
index 2099c53..0000000
--- a/src/com/android/contacts/format/DisplayNameFormatter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.format;
-
-import com.android.contacts.widget.TextWithHighlighting;
-import com.android.contacts.widget.TextWithHighlightingFactory;
-
-import android.database.CharArrayBuffer;
-import android.widget.TextView;
-
-/**
- * Sets the content of the given text view, to contain the formatted display name, with a
- * prefix if necessary.
- */
-public final class DisplayNameFormatter {
-    private final CharArrayBuffer mNameBuffer = new CharArrayBuffer(128);
-    private final CharArrayBuffer mAlternateNameBuffer = new CharArrayBuffer(128);
-    private final PrefixHighlighter mPrefixHighlighter;
-
-    private TextWithHighlightingFactory mTextWithHighlightingFactory;
-    private TextWithHighlighting mTextWithHighlighting;
-    private CharSequence mUnknownNameText;
-
-    public DisplayNameFormatter(PrefixHighlighter prefixHighlighter) {
-        mPrefixHighlighter = prefixHighlighter;
-    }
-
-    public CharArrayBuffer getNameBuffer() {
-        return mNameBuffer;
-    }
-
-    public CharArrayBuffer getAlternateNameBuffer() {
-        return mAlternateNameBuffer;
-    }
-
-    public void setUnknownNameText(CharSequence unknownNameText) {
-        mUnknownNameText = unknownNameText;
-    }
-
-    public void setDisplayName(TextView view, int displayOrder,
-            boolean highlightingEnabled, char[] highlightedPrefix) {
-        view.setText(getDisplayName(displayOrder, highlightingEnabled, highlightedPrefix));
-    }
-
-    public CharSequence getDisplayName(int displayOrder, boolean highlightingEnabled,
-            char[] highlightedPrefix) {
-        int size = mNameBuffer.sizeCopied;
-        if (size == 0) {
-            return mUnknownNameText;
-        }
-
-        CharSequence text;
-        if (highlightingEnabled) {
-            if (mTextWithHighlighting == null) {
-                mTextWithHighlighting =
-                        mTextWithHighlightingFactory.createTextWithHighlighting();
-            }
-            mTextWithHighlighting.setText(mNameBuffer, mAlternateNameBuffer);
-            text = mTextWithHighlighting;
-        } else {
-            text = FormatUtils.charArrayBufferToString(mNameBuffer);
-        }
-        if (highlightedPrefix != null) {
-            text = mPrefixHighlighter.apply(text, highlightedPrefix);
-        }
-        return text;
-    }
-}
diff --git a/src/com/android/contacts/list/ContactListAdapter.java b/src/com/android/contacts/list/ContactListAdapter.java
index bc988e4..1592004 100644
--- a/src/com/android/contacts/list/ContactListAdapter.java
+++ b/src/com/android/contacts/list/ContactListAdapter.java
@@ -38,63 +38,62 @@
  */
 public abstract class ContactListAdapter extends ContactEntryListAdapter {
 
-    protected static final String[] PROJECTION_CONTACT = new String[] {
-        Contacts._ID,                           // 0
-        Contacts.DISPLAY_NAME_PRIMARY,          // 1
-        Contacts.DISPLAY_NAME_ALTERNATIVE,      // 2
-        Contacts.CONTACT_PRESENCE,              // 3
-        Contacts.CONTACT_STATUS,                // 4
-        Contacts.PHOTO_ID,                      // 5
-        Contacts.PHOTO_THUMBNAIL_URI,           // 6
-        Contacts.LOOKUP_KEY,                    // 7
-        Contacts.IS_USER_PROFILE,               // 8
-    };
+    protected static class ContactQuery {
+        public static final String[] PROJECTION_CONTACT = new String[] {
+            Contacts._ID,                           // 0
+            Contacts.DISPLAY_NAME_PRIMARY,          // 1
+            Contacts.DISPLAY_NAME_ALTERNATIVE,      // 2
+            Contacts.CONTACT_PRESENCE,              // 3
+            Contacts.CONTACT_STATUS,                // 4
+            Contacts.PHOTO_ID,                      // 5
+            Contacts.PHOTO_THUMBNAIL_URI,           // 6
+            Contacts.LOOKUP_KEY,                    // 7
+            Contacts.IS_USER_PROFILE,               // 8
+        };
 
-    protected static final String[] PROJECTION_DATA = new String[] {
-        Data.CONTACT_ID,                        // 0
-        Data.DISPLAY_NAME_PRIMARY,              // 1
-        Data.DISPLAY_NAME_ALTERNATIVE,          // 2
-        Data.CONTACT_PRESENCE,                  // 3
-        Data.CONTACT_STATUS,                    // 4
-        Data.PHOTO_ID,                          // 5
-        Data.PHOTO_THUMBNAIL_URI,               // 6
-        Data.LOOKUP_KEY,                        // 7
-    };
+        public static final String[] PROJECTION_DATA = new String[] {
+            Data.CONTACT_ID,                        // 0
+            Data.DISPLAY_NAME_PRIMARY,              // 1
+            Data.DISPLAY_NAME_ALTERNATIVE,          // 2
+            Data.CONTACT_PRESENCE,                  // 3
+            Data.CONTACT_STATUS,                    // 4
+            Data.PHOTO_ID,                          // 5
+            Data.PHOTO_THUMBNAIL_URI,               // 6
+            Data.LOOKUP_KEY,                        // 7
+        };
 
-    protected static final String[] FILTER_PROJECTION = new String[] {
-        Contacts._ID,                           // 0
-        Contacts.DISPLAY_NAME_PRIMARY,          // 1
-        Contacts.DISPLAY_NAME_ALTERNATIVE,      // 2
-        Contacts.CONTACT_PRESENCE,              // 3
-        Contacts.CONTACT_STATUS,                // 4
-        Contacts.PHOTO_ID,                      // 5
-        Contacts.PHOTO_THUMBNAIL_URI,           // 6
-        Contacts.LOOKUP_KEY,                    // 7
-        Contacts.IS_USER_PROFILE,               // 8
-        SearchSnippetColumns.SNIPPET,           // 9
-    };
+        public static final String[] FILTER_PROJECTION = new String[] {
+            Contacts._ID,                           // 0
+            Contacts.DISPLAY_NAME_PRIMARY,          // 1
+            Contacts.DISPLAY_NAME_ALTERNATIVE,      // 2
+            Contacts.CONTACT_PRESENCE,              // 3
+            Contacts.CONTACT_STATUS,                // 4
+            Contacts.PHOTO_ID,                      // 5
+            Contacts.PHOTO_THUMBNAIL_URI,           // 6
+            Contacts.LOOKUP_KEY,                    // 7
+            Contacts.IS_USER_PROFILE,               // 8
+            SearchSnippetColumns.SNIPPET,           // 9
+        };
 
-    protected static final int CONTACT_ID_COLUMN_INDEX = 0;
-    protected static final int CONTACT_DISPLAY_NAME_PRIMARY_COLUMN_INDEX = 1;
-    protected static final int CONTACT_DISPLAY_NAME_ALTERNATIVE_COLUMN_INDEX = 2;
-    protected static final int CONTACT_PRESENCE_STATUS_COLUMN_INDEX = 3;
-    protected static final int CONTACT_CONTACT_STATUS_COLUMN_INDEX = 4;
-    protected static final int CONTACT_PHOTO_ID_COLUMN_INDEX = 5;
-    protected static final int CONTACT_PHOTO_URI_COLUMN_INDEX = 6;
-    protected static final int CONTACT_LOOKUP_KEY_COLUMN_INDEX = 7;
-    protected static final int CONTACT_IS_USER_PROFILE = 8;
-    protected static final int CONTACT_SNIPPET_COLUMN_INDEX = 9;
+        public static final int CONTACT_ID                       = 0;
+        public static final int CONTACT_DISPLAY_NAME_PRIMARY     = 1;
+        public static final int CONTACT_DISPLAY_NAME_ALTERNATIVE = 2;
+        public static final int CONTACT_PRESENCE_STATUS          = 3;
+        public static final int CONTACT_CONTACT_STATUS           = 4;
+        public static final int CONTACT_PHOTO_ID                 = 5;
+        public static final int CONTACT_PHOTO_URI                = 6;
+        public static final int CONTACT_LOOKUP_KEY               = 7;
+        public static final int CONTACT_IS_USER_PROFILE          = 8;
+        public static final int CONTACT_SNIPPET                  = 9;
+    }
 
     private CharSequence mUnknownNameText;
     private int mDisplayNameColumnIndex;
-    private int mAlternativeDisplayNameColumnIndex;
 
     private long mSelectedContactDirectoryId;
     private String mSelectedContactLookupKey;
     private long mSelectedContactId;
 
-    private ContactListFilter mFilter;
-
     public ContactListAdapter(Context context) {
         super(context);
 
@@ -137,11 +136,9 @@
     public void setContactNameDisplayOrder(int displayOrder) {
         super.setContactNameDisplayOrder(displayOrder);
         if (getContactNameDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
-            mDisplayNameColumnIndex = CONTACT_DISPLAY_NAME_PRIMARY_COLUMN_INDEX;
-            mAlternativeDisplayNameColumnIndex = CONTACT_DISPLAY_NAME_ALTERNATIVE_COLUMN_INDEX;
+            mDisplayNameColumnIndex = ContactQuery.CONTACT_DISPLAY_NAME_PRIMARY;
         } else {
-            mDisplayNameColumnIndex = CONTACT_DISPLAY_NAME_ALTERNATIVE_COLUMN_INDEX;
-            mAlternativeDisplayNameColumnIndex = CONTACT_DISPLAY_NAME_PRIMARY_COLUMN_INDEX;
+            mDisplayNameColumnIndex = ContactQuery.CONTACT_DISPLAY_NAME_ALTERNATIVE;
         }
     }
 
@@ -156,8 +153,8 @@
     }
 
     public Uri getContactUri(int partitionIndex, Cursor cursor) {
-        long contactId = cursor.getLong(CONTACT_ID_COLUMN_INDEX);
-        String lookupKey = cursor.getString(CONTACT_LOOKUP_KEY_COLUMN_INDEX);
+        long contactId = cursor.getLong(ContactQuery.CONTACT_ID);
+        String lookupKey = cursor.getString(ContactQuery.CONTACT_LOOKUP_KEY);
         Uri uri = Contacts.getLookupUri(contactId, lookupKey);
         long directoryId = ((DirectoryPartition)getPartition(partitionIndex)).getDirectoryId();
         if (directoryId != Directory.DEFAULT) {
@@ -180,12 +177,12 @@
         }
         String lookupKey = getSelectedContactLookupKey();
         if (lookupKey != null && TextUtils.equals(lookupKey,
-                cursor.getString(CONTACT_LOOKUP_KEY_COLUMN_INDEX))) {
+                cursor.getString(ContactQuery.CONTACT_LOOKUP_KEY))) {
             return true;
         }
 
         return directoryId != Directory.DEFAULT && directoryId != Directory.LOCAL_INVISIBLE
-                && getSelectedContactId() == cursor.getLong(CONTACT_ID_COLUMN_INDEX);
+                && getSelectedContactId() == cursor.getLong(ContactQuery.CONTACT_ID);
     }
 
     @Override
@@ -204,7 +201,7 @@
             Placement placement = getItemPlacementInSection(position);
 
             // First position, set the contacts number string
-            if (position == 0 && cursor.getInt(CONTACT_IS_USER_PROFILE) == 1) {
+            if (position == 0 && cursor.getInt(ContactQuery.CONTACT_IS_USER_PROFILE) == 1) {
                 view.setCountView(getContactsCount());
             } else {
                 view.setCountView(null);
@@ -226,32 +223,31 @@
 
         // Set the photo, if available
         long photoId = 0;
-        if (!cursor.isNull(CONTACT_PHOTO_ID_COLUMN_INDEX)) {
-            photoId = cursor.getLong(CONTACT_PHOTO_ID_COLUMN_INDEX);
+        if (!cursor.isNull(ContactQuery.CONTACT_PHOTO_ID)) {
+            photoId = cursor.getLong(ContactQuery.CONTACT_PHOTO_ID);
         }
 
         if (photoId != 0) {
             getPhotoLoader().loadPhoto(view.getPhotoView(), photoId, false, false);
         } else {
-            final String photoUriString = cursor.getString(CONTACT_PHOTO_URI_COLUMN_INDEX);
+            final String photoUriString = cursor.getString(ContactQuery.CONTACT_PHOTO_URI);
             final Uri photoUri = photoUriString == null ? null : Uri.parse(photoUriString);
             getPhotoLoader().loadPhoto(view.getPhotoView(), photoUri, false, false);
         }
     }
 
     protected void bindName(final ContactListItemView view, Cursor cursor) {
-        view.showDisplayName(cursor, mDisplayNameColumnIndex, mAlternativeDisplayNameColumnIndex,
-                false, getContactNameDisplayOrder());
+        view.showDisplayName(cursor, mDisplayNameColumnIndex, getContactNameDisplayOrder());
         // Note: we don't show phonetic any more (See issue 5265330)
     }
 
     protected void bindPresenceAndStatusMessage(final ContactListItemView view, Cursor cursor) {
-        view.showPresenceAndStatusMessage(cursor, CONTACT_PRESENCE_STATUS_COLUMN_INDEX,
-                CONTACT_CONTACT_STATUS_COLUMN_INDEX);
+        view.showPresenceAndStatusMessage(cursor, ContactQuery.CONTACT_PRESENCE_STATUS,
+                ContactQuery.CONTACT_CONTACT_STATUS);
     }
 
     protected void bindSearchSnippet(final ContactListItemView view, Cursor cursor) {
-        view.showSnippet(cursor, CONTACT_SNIPPET_COLUMN_INDEX);
+        view.showSnippet(cursor, ContactQuery.CONTACT_SNIPPET);
     }
 
     public int getSelectedContactPosition() {
@@ -282,7 +278,7 @@
         int offset = -1;
         while (cursor.moveToNext()) {
             if (mSelectedContactLookupKey != null) {
-                String lookupKey = cursor.getString(CONTACT_LOOKUP_KEY_COLUMN_INDEX);
+                String lookupKey = cursor.getString(ContactQuery.CONTACT_LOOKUP_KEY);
                 if (mSelectedContactLookupKey.equals(lookupKey)) {
                     offset = cursor.getPosition();
                     break;
@@ -290,7 +286,7 @@
             }
             if (mSelectedContactId != 0 && (mSelectedContactDirectoryId == Directory.DEFAULT
                     || mSelectedContactDirectoryId == Directory.LOCAL_INVISIBLE)) {
-                long contactId = cursor.getLong(CONTACT_ID_COLUMN_INDEX);
+                long contactId = cursor.getLong(ContactQuery.CONTACT_ID);
                 if (contactId == mSelectedContactId) {
                     offset = cursor.getPosition();
                     break;
@@ -342,7 +338,7 @@
         // Check if a profile exists
         if (cursor != null && cursor.getCount() > 0) {
             cursor.moveToFirst();
-            setProfileExists(cursor.getInt(CONTACT_IS_USER_PROFILE) == 1);
+            setProfileExists(cursor.getInt(ContactQuery.CONTACT_IS_USER_PROFILE) == 1);
         }
     }
 }
diff --git a/src/com/android/contacts/list/ContactListItemView.java b/src/com/android/contacts/list/ContactListItemView.java
index 5617664..4390d78 100644
--- a/src/com/android/contacts/list/ContactListItemView.java
+++ b/src/com/android/contacts/list/ContactListItemView.java
@@ -19,7 +19,6 @@
 import com.android.contacts.ContactPresenceIconUtil;
 import com.android.contacts.ContactStatusUtil;
 import com.android.contacts.R;
-import com.android.contacts.format.DisplayNameFormatter;
 import com.android.contacts.format.PrefixHighlighter;
 
 import android.content.Context;
@@ -36,7 +35,7 @@
 import android.provider.ContactsContract;
 import android.provider.ContactsContract.Contacts;
 import android.text.Spannable;
-import android.text.SpannableStringBuilder;
+import android.text.SpannableString;
 import android.text.TextUtils;
 import android.text.TextUtils.TruncateAt;
 import android.util.AttributeSet;
@@ -188,8 +187,14 @@
     private int mLabelAndDataViewMaxHeight;
 
     private OnClickListener mCallButtonClickListener;
-    private CharArrayBuffer mDataBuffer = new CharArrayBuffer(128);
-    private CharArrayBuffer mPhoneticNameBuffer = new CharArrayBuffer(128);
+    // TODO: some TextView fields are using CharArrayBuffer while some are not. Determine which is
+    // more efficient for each case or in general, and simplify the whole implementation.
+    // Note: if we're sure MARQUEE will be used every time, there's no reason to use
+    // CharArrayBuffer, since MARQUEE requires Span and thus we need to copy characters inside the
+    // buffer to Spannable once, while CharArrayBuffer is for directly applying char array to
+    // TextView without any modification.
+    private final CharArrayBuffer mDataBuffer = new CharArrayBuffer(128);
+    private final CharArrayBuffer mPhoneticNameBuffer = new CharArrayBuffer(128);
 
     private boolean mActivatedStateSupported;
 
@@ -197,8 +202,7 @@
 
     /** A helper used to highlight a prefix in a text field. */
     private PrefixHighlighter mPrefixHighligher;
-    /** A helper used to format display names. */
-    private DisplayNameFormatter mDisplayNameFormatter;
+    private CharSequence mUnknownNameText;
 
     /**
      * Special class to allow the parent to be pressed without being pressed itself.
@@ -295,8 +299,6 @@
         if (mActivatedBackgroundDrawable != null) {
             mActivatedBackgroundDrawable.setCallback(this);
         }
-
-        mDisplayNameFormatter = new DisplayNameFormatter(mPrefixHighligher);
     }
 
     /**
@@ -307,7 +309,7 @@
     }
 
     public void setUnknownNameText(CharSequence unknownNameText) {
-        mDisplayNameFormatter.setUnknownNameText(unknownNameText);
+        mUnknownNameText = unknownNameText;
     }
 
     public void setQuickContactEnabled(boolean flag) {
@@ -790,7 +792,7 @@
                 mHeaderDivider.setBackgroundColor(mHeaderUnderlineColor);
                 addView(mHeaderDivider);
             }
-            mHeaderTextView.setText(getMarqueeText(title));
+            setMarqueeText(mHeaderTextView, title);
             mHeaderTextView.setVisibility(View.VISIBLE);
             mHeaderDivider.setVisibility(View.VISIBLE);
             mHeaderTextView.setAllCaps(true);
@@ -936,7 +938,7 @@
             }
         } else {
             getPhoneticNameTextView();
-            mPhoneticNameTextView.setText(getMarqueeText(text, size));
+            setMarqueeText(mPhoneticNameTextView, text, size);
             mPhoneticNameTextView.setVisibility(VISIBLE);
         }
     }
@@ -967,22 +969,7 @@
             }
         } else {
             getLabelView();
-            mLabelView.setText(getMarqueeText(text));
-            mLabelView.setVisibility(VISIBLE);
-        }
-    }
-
-    /**
-     * Adds or updates a text view for the data label.
-     */
-    public void setLabel(char[] text, int size) {
-        if (text == null || size == 0) {
-            if (mLabelView != null) {
-                mLabelView.setVisibility(View.GONE);
-            }
-        } else {
-            getLabelView();
-            mLabelView.setText(getMarqueeText(text, size));
+            setMarqueeText(mLabelView, text);
             mLabelView.setVisibility(VISIBLE);
         }
     }
@@ -1017,28 +1004,31 @@
             if (mDataView != null) {
                 mDataView.setVisibility(View.GONE);
             }
-            return;
         } else {
             getDataView();
-            mDataView.setText(getMarqueeText(text, size));
+            setMarqueeText(mDataView, text, size);
             mDataView.setVisibility(VISIBLE);
         }
     }
 
-    private CharSequence getMarqueeText(char[] text, int size) {
-        return getMarqueeText(new String(text, 0, size));
+    private void setMarqueeText(TextView textView, char[] text, int size) {
+        if (getTextEllipsis() == TruncateAt.MARQUEE) {
+            setMarqueeText(textView, new String(text, 0, size));
+        } else {
+            textView.setText(text, 0, size);
+        }
     }
 
-    private CharSequence getMarqueeText(CharSequence text) {
+    private void setMarqueeText(TextView textView, CharSequence text) {
         if (getTextEllipsis() == TruncateAt.MARQUEE) {
             // To show MARQUEE correctly (with END effect during non-active state), we need
             // to build Spanned with MARQUEE in addition to TextView's ellipsize setting.
-            final SpannableStringBuilder builder = new SpannableStringBuilder(text);
-            builder.setSpan(TruncateAt.MARQUEE, 0, builder.length(),
+            final SpannableString spannable = new SpannableString(text);
+            spannable.setSpan(TruncateAt.MARQUEE, 0, spannable.length(),
                     Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-            return builder;
+            textView.setText(spannable);
         } else {
-            return text;
+            textView.setText(text);
         }
     }
 
@@ -1128,7 +1118,7 @@
             }
         } else {
             getCountView();
-            mCountView.setText(getMarqueeText(text));
+            setMarqueeText(mCountView, text);
             mCountView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mCountViewTextSize);
             mCountView.setGravity(Gravity.CENTER_VERTICAL);
             mCountView.setTextColor(mContactsCountTextColor);
@@ -1146,7 +1136,7 @@
             }
         } else {
             getStatusView();
-            mStatusView.setText(getMarqueeText(text));
+            setMarqueeText(mStatusView, text);
             mStatusView.setVisibility(VISIBLE);
         }
     }
@@ -1174,16 +1164,14 @@
         return TruncateAt.MARQUEE;
     }
 
-    public void showDisplayName(Cursor cursor, int nameColumnIndex, int alternativeNameColumnIndex,
-            boolean highlightingEnabled, int displayOrder) {
-        // Copy out the display name and alternate display name.
-        cursor.copyStringToBuffer(nameColumnIndex, mDisplayNameFormatter.getNameBuffer());
-        cursor.copyStringToBuffer(alternativeNameColumnIndex,
-                mDisplayNameFormatter.getAlternateNameBuffer());
-
-        CharSequence displayName = mDisplayNameFormatter.getDisplayName(
-                displayOrder, highlightingEnabled, mHighlightedPrefix);
-        getNameTextView().setText(getMarqueeText(displayName));
+    public void showDisplayName(Cursor cursor, int nameColumnIndex, int displayOrder) {
+        CharSequence name = cursor.getString(nameColumnIndex);
+        if (!TextUtils.isEmpty(name)) {
+            name = mPrefixHighligher.apply(name, mHighlightedPrefix);
+        } else {
+            name = mUnknownNameText;
+        }
+        setMarqueeText(getNameTextView(), name);
 
         // Since the quick contact content description is derived from the display name and there is
         // no guarantee that when the quick contact is initialized the display name is already set,
diff --git a/src/com/android/contacts/list/DefaultContactListAdapter.java b/src/com/android/contacts/list/DefaultContactListAdapter.java
index 3409f56..deab8ab 100644
--- a/src/com/android/contacts/list/DefaultContactListAdapter.java
+++ b/src/com/android/contacts/list/DefaultContactListAdapter.java
@@ -72,7 +72,7 @@
                 // Regardless of the directory, we don't want anything returned,
                 // so let's just send a "nothing" query to the local directory.
                 loader.setUri(Contacts.CONTENT_URI);
-                loader.setProjection(PROJECTION_CONTACT);
+                loader.setProjection(ContactQuery.PROJECTION_CONTACT);
                 loader.setSelection("0");
             } else {
                 Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
@@ -87,7 +87,7 @@
                         SNIPPET_ARGS);
                 builder.appendQueryParameter(SearchSnippetColumns.DEFERRED_SNIPPETING_KEY,"1");
                 loader.setUri(builder.build());
-                loader.setProjection(FILTER_PROJECTION);
+                loader.setProjection(ContactQuery.FILTER_PROJECTION);
             }
         } else {
             configureUri(loader, directoryId, filter);
@@ -139,9 +139,9 @@
     protected void configureProjection(
             CursorLoader loader, long directoryId, ContactListFilter filter) {
         if (filter != null && filter.filterType == ContactListFilter.FILTER_TYPE_GROUP) {
-            loader.setProjection(PROJECTION_DATA);
+            loader.setProjection(ContactQuery.PROJECTION_DATA);
         } else {
-            loader.setProjection(PROJECTION_CONTACT);
+            loader.setProjection(ContactQuery.PROJECTION_CONTACT);
         }
     }
 
@@ -228,9 +228,8 @@
         bindSectionHeaderAndDivider(view, position, cursor);
 
         if (isQuickContactEnabled()) {
-            bindQuickContact(view, partition, cursor,
-                    CONTACT_PHOTO_ID_COLUMN_INDEX, CONTACT_ID_COLUMN_INDEX,
-                    CONTACT_LOOKUP_KEY_COLUMN_INDEX);
+            bindQuickContact(view, partition, cursor, ContactQuery.CONTACT_PHOTO_ID,
+                    ContactQuery.CONTACT_ID, ContactQuery.CONTACT_LOOKUP_KEY);
         } else {
             bindPhoto(view, partition, cursor);
         }
diff --git a/src/com/android/contacts/list/EmailAddressListAdapter.java b/src/com/android/contacts/list/EmailAddressListAdapter.java
index 52daaa0..e0c561f 100644
--- a/src/com/android/contacts/list/EmailAddressListAdapter.java
+++ b/src/com/android/contacts/list/EmailAddressListAdapter.java
@@ -34,27 +34,34 @@
  */
 public class EmailAddressListAdapter extends ContactEntryListAdapter {
 
-    static final String[] EMAILS_PROJECTION = new String[] {
-        Email._ID,                       // 0
-        Email.TYPE,                      // 1
-        Email.LABEL,                     // 2
-        Email.DATA,                      // 3
-        Email.DISPLAY_NAME_PRIMARY,      // 4
-        Email.DISPLAY_NAME_ALTERNATIVE,  // 5
-        Email.PHOTO_ID,                  // 6
-    };
+    protected static class EmailQuery {
+        private static final String[] PROJECTION_PRIMARY = new String[] {
+            Email._ID,                       // 0
+            Email.TYPE,                      // 1
+            Email.LABEL,                     // 2
+            Email.DATA,                      // 3
+            Email.PHOTO_ID,                  // 4
+            Email.DISPLAY_NAME_PRIMARY,      // 5
+        };
 
-    protected static final int EMAIL_ID_COLUMN_INDEX = 0;
-    protected static final int EMAIL_TYPE_COLUMN_INDEX = 1;
-    protected static final int EMAIL_LABEL_COLUMN_INDEX = 2;
-    protected static final int EMAIL_ADDRESS_COLUMN_INDEX = 3;
-    protected static final int EMAIL_PRIMARY_DISPLAY_NAME_COLUMN_INDEX = 4;
-    protected static final int EMAIL_ALTERNATIVE_DISPLAY_NAME_COLUMN_INDEX = 5;
-    protected static final int EMAIL_PHOTO_ID_COLUMN_INDEX = 6;
+        private static final String[] PROJECTION_ALTERNATIVE = new String[] {
+            Email._ID,                       // 0
+            Email.TYPE,                      // 1
+            Email.LABEL,                     // 2
+            Email.DATA,                      // 3
+            Email.PHOTO_ID,                  // 4
+            Email.DISPLAY_NAME_ALTERNATIVE,  // 5
+        };
 
-    private CharSequence mUnknownNameText;
-    private int mDisplayNameColumnIndex;
-    private int mAlternativeDisplayNameColumnIndex;
+        public static final int EMAIL_ID           = 0;
+        public static final int EMAIL_TYPE         = 1;
+        public static final int EMAIL_LABEL        = 2;
+        public static final int EMAIL_ADDRESS      = 3;
+        public static final int EMAIL_PHOTO_ID     = 4;
+        public static final int EMAIL_DISPLAY_NAME = 5;
+    }
+
+    private final CharSequence mUnknownNameText;
 
     public EmailAddressListAdapter(Context context) {
         super(context);
@@ -75,7 +82,12 @@
         builder.appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY,
                 String.valueOf(directoryId));
         loader.setUri(builder.build());
-        loader.setProjection(EMAILS_PROJECTION);
+
+        if (getContactNameDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
+            loader.setProjection(EmailQuery.PROJECTION_PRIMARY);
+        } else {
+            loader.setProjection(EmailQuery.PROJECTION_ALTERNATIVE);
+        }
 
         if (getSortOrder() == ContactsContract.Preferences.SORT_ORDER_PRIMARY) {
             loader.setSortOrder(Email.SORT_KEY_PRIMARY);
@@ -91,19 +103,7 @@
 
     @Override
     public String getContactDisplayName(int position) {
-        return ((Cursor)getItem(position)).getString(mDisplayNameColumnIndex);
-    }
-
-    @Override
-    public void setContactNameDisplayOrder(int displayOrder) {
-        super.setContactNameDisplayOrder(displayOrder);
-        if (getContactNameDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
-            mDisplayNameColumnIndex = EMAIL_PRIMARY_DISPLAY_NAME_COLUMN_INDEX;
-            mAlternativeDisplayNameColumnIndex = EMAIL_ALTERNATIVE_DISPLAY_NAME_COLUMN_INDEX;
-        } else {
-            mDisplayNameColumnIndex = EMAIL_ALTERNATIVE_DISPLAY_NAME_COLUMN_INDEX;
-            mAlternativeDisplayNameColumnIndex = EMAIL_PRIMARY_DISPLAY_NAME_COLUMN_INDEX;
-        }
+        return ((Cursor) getItem(position)).getString(EmailQuery.EMAIL_DISPLAY_NAME);
     }
 
     /**
@@ -111,7 +111,7 @@
      * position.
      */
     public Uri getDataUri(int position) {
-        long id = ((Cursor)getItem(position)).getLong(EMAIL_ID_COLUMN_INDEX);
+        long id = ((Cursor)getItem(position)).getLong(EmailQuery.EMAIL_ID);
         return ContentUris.withAppendedId(Data.CONTENT_URI, id);
     }
 
@@ -135,15 +135,15 @@
 
     protected void bindEmailAddress(ContactListItemView view, Cursor cursor) {
         CharSequence label = null;
-        if (!cursor.isNull(EMAIL_TYPE_COLUMN_INDEX)) {
-            final int type = cursor.getInt(EMAIL_TYPE_COLUMN_INDEX);
-            final String customLabel = cursor.getString(EMAIL_LABEL_COLUMN_INDEX);
+        if (!cursor.isNull(EmailQuery.EMAIL_TYPE)) {
+            final int type = cursor.getInt(EmailQuery.EMAIL_TYPE);
+            final String customLabel = cursor.getString(EmailQuery.EMAIL_LABEL);
 
             // TODO cache
             label = Email.getTypeLabel(getContext().getResources(), type, customLabel);
         }
         view.setLabel(label);
-        view.showData(cursor, EMAIL_ADDRESS_COLUMN_INDEX);
+        view.showData(cursor, EmailQuery.EMAIL_ADDRESS);
     }
 
     protected void bindSectionHeaderAndDivider(final ContactListItemView view, int position) {
@@ -165,14 +165,13 @@
     }
 
     protected void bindName(final ContactListItemView view, Cursor cursor) {
-        view.showDisplayName(cursor, mDisplayNameColumnIndex, mAlternativeDisplayNameColumnIndex,
-                false, getContactNameDisplayOrder());
+        view.showDisplayName(cursor, EmailQuery.EMAIL_DISPLAY_NAME, getContactNameDisplayOrder());
     }
 
     protected void bindPhoto(final ContactListItemView view, Cursor cursor) {
         long photoId = 0;
-        if (!cursor.isNull(EMAIL_PHOTO_ID_COLUMN_INDEX)) {
-            photoId = cursor.getLong(EMAIL_PHOTO_ID_COLUMN_INDEX);
+        if (!cursor.isNull(EmailQuery.EMAIL_PHOTO_ID)) {
+            photoId = cursor.getLong(EmailQuery.EMAIL_PHOTO_ID);
         }
 
         getPhotoLoader().loadPhoto(view.getPhotoView(), photoId, false, false);
diff --git a/src/com/android/contacts/list/JoinContactListAdapter.java b/src/com/android/contacts/list/JoinContactListAdapter.java
index 73bca52..b81dd3b 100644
--- a/src/com/android/contacts/list/JoinContactListAdapter.java
+++ b/src/com/android/contacts/list/JoinContactListAdapter.java
@@ -43,15 +43,12 @@
 
     private long mTargetContactId;
 
-    private int mShowAllContactsViewType;
-
     public JoinContactListAdapter(Context context) {
         super(context);
         setPinnedPartitionHeadersEnabled(true);
         setSectionHeaderDisplayEnabled(true);
         setIndexedPartition(PARTITION_ALL_CONTACTS);
         setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_NONE);
-        mShowAllContactsViewType = getViewTypeCount() - 1;
     }
 
     @Override
@@ -86,7 +83,7 @@
         loader.setSuggestionUri(builder.build());
 
         // TODO simplify projection
-        loader.setProjection(PROJECTION_CONTACT);
+        loader.setProjection(ContactQuery.PROJECTION_CONTACT);
         Uri allContactsUri = buildSectionIndexerUri(Contacts.CONTENT_URI).buildUpon()
                 .appendQueryParameter(
                         ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(Directory.DEFAULT))
@@ -193,16 +190,16 @@
     }
 
     public Cursor getShowAllContactsLabelCursor() {
-        MatrixCursor matrixCursor = new MatrixCursor(PROJECTION_CONTACT);
-        Object[] row = new Object[PROJECTION_CONTACT.length];
+        MatrixCursor matrixCursor = new MatrixCursor(ContactQuery.PROJECTION_CONTACT);
+        Object[] row = new Object[ContactQuery.PROJECTION_CONTACT.length];
         matrixCursor.addRow(row);
         return matrixCursor;
     }
 
     @Override
     public Uri getContactUri(int partitionIndex, Cursor cursor) {
-        long contactId = cursor.getLong(CONTACT_ID_COLUMN_INDEX);
-        String lookupKey = cursor.getString(CONTACT_LOOKUP_KEY_COLUMN_INDEX);
+        long contactId = cursor.getLong(ContactQuery.CONTACT_ID);
+        String lookupKey = cursor.getString(ContactQuery.CONTACT_LOOKUP_KEY);
         return Contacts.getLookupUri(contactId, lookupKey);
     }
 }
diff --git a/src/com/android/contacts/list/LegacyContactListAdapter.java b/src/com/android/contacts/list/LegacyContactListAdapter.java
index b21d484..dbdce5e 100644
--- a/src/com/android/contacts/list/LegacyContactListAdapter.java
+++ b/src/com/android/contacts/list/LegacyContactListAdapter.java
@@ -85,7 +85,7 @@
     }
 
     protected void bindName(final ContactListItemView view, Cursor cursor) {
-        view.showDisplayName(cursor, PERSON_DISPLAY_NAME_COLUMN_INDEX, 0, false,
+        view.showDisplayName(cursor, PERSON_DISPLAY_NAME_COLUMN_INDEX,
                 getContactNameDisplayOrder());
         view.showPhoneticName(cursor, PERSON_PHONETIC_NAME_COLUMN_INDEX);
     }
diff --git a/src/com/android/contacts/list/LegacyPhoneNumberListAdapter.java b/src/com/android/contacts/list/LegacyPhoneNumberListAdapter.java
index 547650d..1ef106a 100644
--- a/src/com/android/contacts/list/LegacyPhoneNumberListAdapter.java
+++ b/src/com/android/contacts/list/LegacyPhoneNumberListAdapter.java
@@ -89,8 +89,7 @@
     }
 
     protected void bindName(final ContactListItemView view, Cursor cursor) {
-        view.showDisplayName(cursor, PHONE_DISPLAY_NAME_COLUMN_INDEX, 0, false,
-                getContactNameDisplayOrder());
+        view.showDisplayName(cursor, PHONE_DISPLAY_NAME_COLUMN_INDEX, getContactNameDisplayOrder());
         view.showPhoneticName(cursor, PHONE_PHONETIC_NAME_COLUMN_INDEX);
     }
 
diff --git a/src/com/android/contacts/list/LegacyPostalAddressListAdapter.java b/src/com/android/contacts/list/LegacyPostalAddressListAdapter.java
index 48b3f0c..91a0e3b 100644
--- a/src/com/android/contacts/list/LegacyPostalAddressListAdapter.java
+++ b/src/com/android/contacts/list/LegacyPostalAddressListAdapter.java
@@ -90,7 +90,7 @@
     }
 
     protected void bindName(final ContactListItemView view, Cursor cursor) {
-        view.showDisplayName(cursor, POSTAL_DISPLAY_NAME_COLUMN_INDEX, 0, false,
+        view.showDisplayName(cursor, POSTAL_DISPLAY_NAME_COLUMN_INDEX,
                 getContactNameDisplayOrder());
         view.showPhoneticName(cursor, POSTAL_PHONETIC_NAME_COLUMN_INDEX);
     }
diff --git a/src/com/android/contacts/list/PhoneNumberListAdapter.java b/src/com/android/contacts/list/PhoneNumberListAdapter.java
index 459d232..d55787b 100644
--- a/src/com/android/contacts/list/PhoneNumberListAdapter.java
+++ b/src/com/android/contacts/list/PhoneNumberListAdapter.java
@@ -22,7 +22,6 @@
 import android.net.Uri;
 import android.net.Uri.Builder;
 import android.provider.ContactsContract;
-import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
 import android.provider.ContactsContract.CommonDataKinds.Phone;
 import android.provider.ContactsContract.ContactCounts;
 import android.provider.ContactsContract.Contacts;
@@ -43,31 +42,40 @@
 public class PhoneNumberListAdapter extends ContactEntryListAdapter {
     private static final String TAG = PhoneNumberListAdapter.class.getSimpleName();
 
-    protected static final String[] PHONES_PROJECTION = new String[] {
-        Phone._ID,                          // 0
-        Phone.TYPE,                         // 1
-        Phone.LABEL,                        // 2
-        Phone.NUMBER,                       // 3
-        Phone.DISPLAY_NAME_PRIMARY,         // 4
-        Phone.DISPLAY_NAME_ALTERNATIVE,     // 5
-        Phone.CONTACT_ID,                   // 6
-        Phone.LOOKUP_KEY,                   // 7
-        Phone.PHOTO_ID,                     // 8
-    };
+    protected static class PhoneQuery {
+        private static final String[] PROJECTION_PRIMARY = new String[] {
+            Phone._ID,                          // 0
+            Phone.TYPE,                         // 1
+            Phone.LABEL,                        // 2
+            Phone.NUMBER,                       // 3
+            Phone.CONTACT_ID,                   // 4
+            Phone.LOOKUP_KEY,                   // 5
+            Phone.PHOTO_ID,                     // 6
+            Phone.DISPLAY_NAME_PRIMARY,         // 7
+        };
 
-    protected static final int PHONE_ID_COLUMN_INDEX = 0;
-    protected static final int PHONE_TYPE_COLUMN_INDEX = 1;
-    protected static final int PHONE_LABEL_COLUMN_INDEX = 2;
-    protected static final int PHONE_NUMBER_COLUMN_INDEX = 3;
-    protected static final int PHONE_PRIMARY_DISPLAY_NAME_COLUMN_INDEX = 4;
-    protected static final int PHONE_ALTERNATIVE_DISPLAY_NAME_COLUMN_INDEX = 5;
-    protected static final int PHONE_CONTACT_ID_COLUMN_INDEX = 6;
-    protected static final int PHONE_LOOKUP_KEY_COLUMN_INDEX = 7;
-    protected static final int PHONE_PHOTO_ID_COLUMN_INDEX = 8;
+        private static final String[] PROJECTION_ALTERNATIVE = new String[] {
+            Phone._ID,                          // 0
+            Phone.TYPE,                         // 1
+            Phone.LABEL,                        // 2
+            Phone.NUMBER,                       // 3
+            Phone.CONTACT_ID,                   // 4
+            Phone.LOOKUP_KEY,                   // 5
+            Phone.PHOTO_ID,                     // 6
+            Phone.DISPLAY_NAME_ALTERNATIVE,     // 7
+        };
 
-    private CharSequence mUnknownNameText;
-    private int mDisplayNameColumnIndex;
-    private int mAlternativeDisplayNameColumnIndex;
+        public static final int PHONE_ID           = 0;
+        public static final int PHONE_TYPE         = 1;
+        public static final int PHONE_LABEL        = 2;
+        public static final int PHONE_NUMBER       = 3;
+        public static final int PHONE_CONTACT_ID   = 4;
+        public static final int PHONE_LOOKUP_KEY   = 5;
+        public static final int PHONE_PHOTO_ID     = 6;
+        public static final int PHONE_DISPLAY_NAME = 7;
+    }
+
+    private final CharSequence mUnknownNameText;
 
     private ContactListItemView.PhotoPosition mPhotoPosition;
 
@@ -102,8 +110,6 @@
             builder.appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY,
                     String.valueOf(directoryId));
             uri = builder.build();
-            // TODO a projection that includes the search snippet
-            loader.setProjection(PHONES_PROJECTION);
         } else {
             uri = Phone.CONTENT_URI.buildUpon().appendQueryParameter(
                     ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(Directory.DEFAULT))
@@ -111,14 +117,18 @@
             if (isSectionHeaderDisplayEnabled()) {
                 uri = buildSectionIndexerUri(uri);
             }
-
-            loader.setProjection(PHONES_PROJECTION);
             configureSelection(loader, directoryId, getFilter());
         }
 
         loader.setUri(uri);
 
-        // TODO: we probably want to use default sort order in search mode.
+        // TODO a projection that includes the search snippet
+        if (getContactNameDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
+            loader.setProjection(PhoneQuery.PROJECTION_PRIMARY);
+        } else {
+            loader.setProjection(PhoneQuery.PROJECTION_ALTERNATIVE);
+        }
+
         if (getSortOrder() == ContactsContract.Preferences.SORT_ORDER_PRIMARY) {
             loader.setSortOrder(Phone.SORT_KEY_PRIMARY);
         } else {
@@ -180,19 +190,7 @@
 
     @Override
     public String getContactDisplayName(int position) {
-        return ((Cursor)getItem(position)).getString(mDisplayNameColumnIndex);
-    }
-
-    @Override
-    public void setContactNameDisplayOrder(int displayOrder) {
-        super.setContactNameDisplayOrder(displayOrder);
-        if (getContactNameDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
-            mDisplayNameColumnIndex = PHONE_PRIMARY_DISPLAY_NAME_COLUMN_INDEX;
-            mAlternativeDisplayNameColumnIndex = PHONE_ALTERNATIVE_DISPLAY_NAME_COLUMN_INDEX;
-        } else {
-            mDisplayNameColumnIndex = PHONE_ALTERNATIVE_DISPLAY_NAME_COLUMN_INDEX;
-            mAlternativeDisplayNameColumnIndex = PHONE_PRIMARY_DISPLAY_NAME_COLUMN_INDEX;
-        }
+        return ((Cursor) getItem(position)).getString(PhoneQuery.PHONE_DISPLAY_NAME);
     }
 
     /**
@@ -203,7 +201,7 @@
     public Uri getDataUri(int position) {
         Cursor cursor = ((Cursor)getItem(position));
         if (cursor != null) {
-            long id = cursor.getLong(PHONE_ID_COLUMN_INDEX);
+            long id = cursor.getLong(PhoneQuery.PHONE_ID);
             return ContentUris.withAppendedId(Data.CONTENT_URI, id);
         } else {
             Log.w(TAG, "Cursor was null in getDataUri() call. Returning null instead.");
@@ -233,16 +231,16 @@
         cursor.moveToPosition(position);
         boolean isFirstEntry = true;
         boolean showBottomDivider = true;
-        final long currentContactId = cursor.getLong(PHONE_CONTACT_ID_COLUMN_INDEX);
+        final long currentContactId = cursor.getLong(PhoneQuery.PHONE_CONTACT_ID);
         if (cursor.moveToPrevious() && !cursor.isBeforeFirst()) {
-            final long previousContactId = cursor.getLong(PHONE_CONTACT_ID_COLUMN_INDEX);
+            final long previousContactId = cursor.getLong(PhoneQuery.PHONE_CONTACT_ID);
             if (currentContactId == previousContactId) {
                 isFirstEntry = false;
             }
         }
         cursor.moveToPosition(position);
         if (cursor.moveToNext() && !cursor.isAfterLast()) {
-            final long nextContactId = cursor.getLong(PHONE_CONTACT_ID_COLUMN_INDEX);
+            final long nextContactId = cursor.getLong(PhoneQuery.PHONE_CONTACT_ID);
             if (currentContactId == nextContactId) {
                 // The following entry should be in the same group, which means we don't want a
                 // divider between them.
@@ -257,9 +255,8 @@
         if (isFirstEntry) {
             bindName(view, cursor);
             if (isQuickContactEnabled()) {
-                bindQuickContact(view, partition, cursor,
-                        PHONE_PHOTO_ID_COLUMN_INDEX, PHONE_CONTACT_ID_COLUMN_INDEX,
-                        PHONE_LOOKUP_KEY_COLUMN_INDEX);
+                bindQuickContact(view, partition, cursor, PhoneQuery.PHONE_PHOTO_ID,
+                        PhoneQuery.PHONE_CONTACT_ID, PhoneQuery.PHONE_LOOKUP_KEY);
             } else {
                 bindPhoto(view, cursor);
             }
@@ -274,15 +271,15 @@
 
     protected void bindPhoneNumber(ContactListItemView view, Cursor cursor) {
         CharSequence label = null;
-        if (!cursor.isNull(PHONE_TYPE_COLUMN_INDEX)) {
-            final int type = cursor.getInt(PHONE_TYPE_COLUMN_INDEX);
-            final String customLabel = cursor.getString(PHONE_LABEL_COLUMN_INDEX);
+        if (!cursor.isNull(PhoneQuery.PHONE_TYPE)) {
+            final int type = cursor.getInt(PhoneQuery.PHONE_TYPE);
+            final String customLabel = cursor.getString(PhoneQuery.PHONE_LABEL);
 
             // TODO cache
             label = Phone.getTypeLabel(getContext().getResources(), type, customLabel);
         }
         view.setLabel(label);
-        view.showData(cursor, PHONE_NUMBER_COLUMN_INDEX);
+        view.showData(cursor, PhoneQuery.PHONE_NUMBER);
     }
 
     protected void bindSectionHeaderAndDivider(final ContactListItemView view, int position) {
@@ -297,8 +294,7 @@
     }
 
     protected void bindName(final ContactListItemView view, Cursor cursor) {
-        view.showDisplayName(cursor, mDisplayNameColumnIndex, mAlternativeDisplayNameColumnIndex,
-                false, getContactNameDisplayOrder());
+        view.showDisplayName(cursor, PhoneQuery.PHONE_DISPLAY_NAME, getContactNameDisplayOrder());
         // Note: we don't show phonetic names any more (see issue 5265330)
     }
 
@@ -308,8 +304,8 @@
 
     protected void bindPhoto(final ContactListItemView view, Cursor cursor) {
         long photoId = 0;
-        if (!cursor.isNull(PHONE_PHOTO_ID_COLUMN_INDEX)) {
-            photoId = cursor.getLong(PHONE_PHOTO_ID_COLUMN_INDEX);
+        if (!cursor.isNull(PhoneQuery.PHONE_PHOTO_ID)) {
+            photoId = cursor.getLong(PhoneQuery.PHONE_PHOTO_ID);
         }
 
         getPhotoLoader().loadPhoto(view.getPhotoView(), photoId, false, false);
diff --git a/src/com/android/contacts/list/PostalAddressListAdapter.java b/src/com/android/contacts/list/PostalAddressListAdapter.java
index 7e58a8e..e9bd11a 100644
--- a/src/com/android/contacts/list/PostalAddressListAdapter.java
+++ b/src/com/android/contacts/list/PostalAddressListAdapter.java
@@ -32,27 +32,34 @@
  */
 public class PostalAddressListAdapter extends ContactEntryListAdapter {
 
-    static final String[] POSTALS_PROJECTION = new String[] {
-        StructuredPostal._ID,                       // 0
-        StructuredPostal.TYPE,                      // 1
-        StructuredPostal.LABEL,                     // 2
-        StructuredPostal.DATA,                      // 3
-        StructuredPostal.DISPLAY_NAME_PRIMARY,      // 4
-        StructuredPostal.DISPLAY_NAME_ALTERNATIVE,  // 5
-        StructuredPostal.PHOTO_ID,                  // 6
-    };
+    protected static class PostalQuery {
+        private static final String[] PROJECTION_PRIMARY = new String[] {
+            StructuredPostal._ID,                       // 0
+            StructuredPostal.TYPE,                      // 1
+            StructuredPostal.LABEL,                     // 2
+            StructuredPostal.DATA,                      // 3
+            StructuredPostal.PHOTO_ID,                  // 4
+            StructuredPostal.DISPLAY_NAME_PRIMARY,      // 5
+        };
 
-    protected static final int POSTAL_ID_COLUMN_INDEX = 0;
-    protected static final int POSTAL_TYPE_COLUMN_INDEX = 1;
-    protected static final int POSTAL_LABEL_COLUMN_INDEX = 2;
-    protected static final int POSTAL_ADDRESS_COLUMN_INDEX = 3;
-    protected static final int POSTAL_PRIMARY_DISPLAY_NAME_COLUMN_INDEX = 4;
-    protected static final int POSTAL_ALTERNATIVE_DISPLAY_NAME_COLUMN_INDEX = 5;
-    protected static final int POSTAL_PHOTO_ID_COLUMN_INDEX = 6;
+        private static final String[] PROJECTION_ALTERNATIVE = new String[] {
+            StructuredPostal._ID,                       // 0
+            StructuredPostal.TYPE,                      // 1
+            StructuredPostal.LABEL,                     // 2
+            StructuredPostal.DATA,                      // 3
+            StructuredPostal.PHOTO_ID,                  // 4
+            StructuredPostal.DISPLAY_NAME_ALTERNATIVE,  // 5
+        };
 
-    private CharSequence mUnknownNameText;
-    private int mDisplayNameColumnIndex;
-    private int mAlternativeDisplayNameColumnIndex;
+        public static final int POSTAL_ID           = 0;
+        public static final int POSTAL_TYPE         = 1;
+        public static final int POSTAL_LABEL        = 2;
+        public static final int POSTAL_ADDRESS      = 3;
+        public static final int POSTAL_PHOTO_ID     = 4;
+        public static final int POSTAL_DISPLAY_NAME = 5;
+    }
+
+    private final CharSequence mUnknownNameText;
 
     public PostalAddressListAdapter(Context context) {
         super(context);
@@ -64,7 +71,12 @@
     public void configureLoader(CursorLoader loader, long directoryId) {
         Uri uri = buildSectionIndexerUri(StructuredPostal.CONTENT_URI);
         loader.setUri(uri);
-        loader.setProjection(POSTALS_PROJECTION);
+
+        if (getContactNameDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
+            loader.setProjection(PostalQuery.PROJECTION_PRIMARY);
+        } else {
+            loader.setProjection(PostalQuery.PROJECTION_ALTERNATIVE);
+        }
 
         if (getSortOrder() == ContactsContract.Preferences.SORT_ORDER_PRIMARY) {
             loader.setSortOrder(StructuredPostal.SORT_KEY_PRIMARY);
@@ -80,19 +92,7 @@
 
     @Override
     public String getContactDisplayName(int position) {
-        return ((Cursor)getItem(position)).getString(mDisplayNameColumnIndex);
-    }
-
-    @Override
-    public void setContactNameDisplayOrder(int displayOrder) {
-        super.setContactNameDisplayOrder(displayOrder);
-        if (getContactNameDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
-            mDisplayNameColumnIndex = POSTAL_PRIMARY_DISPLAY_NAME_COLUMN_INDEX;
-            mAlternativeDisplayNameColumnIndex = POSTAL_ALTERNATIVE_DISPLAY_NAME_COLUMN_INDEX;
-        } else {
-            mDisplayNameColumnIndex = POSTAL_ALTERNATIVE_DISPLAY_NAME_COLUMN_INDEX;
-            mAlternativeDisplayNameColumnIndex = POSTAL_PRIMARY_DISPLAY_NAME_COLUMN_INDEX;
-        }
+        return ((Cursor) getItem(position)).getString(PostalQuery.POSTAL_DISPLAY_NAME);
     }
 
     /**
@@ -100,7 +100,7 @@
      * position.
      */
     public Uri getDataUri(int position) {
-        long id = ((Cursor)getItem(position)).getLong(POSTAL_ID_COLUMN_INDEX);
+        long id = ((Cursor)getItem(position)).getLong(PostalQuery.POSTAL_ID);
         return ContentUris.withAppendedId(Data.CONTENT_URI, id);
     }
 
@@ -124,15 +124,15 @@
 
     protected void bindPostalAddress(ContactListItemView view, Cursor cursor) {
         CharSequence label = null;
-        if (!cursor.isNull(POSTAL_TYPE_COLUMN_INDEX)) {
-            final int type = cursor.getInt(POSTAL_TYPE_COLUMN_INDEX);
-            final String customLabel = cursor.getString(POSTAL_LABEL_COLUMN_INDEX);
+        if (!cursor.isNull(PostalQuery.POSTAL_TYPE)) {
+            final int type = cursor.getInt(PostalQuery.POSTAL_TYPE);
+            final String customLabel = cursor.getString(PostalQuery.POSTAL_LABEL);
 
             // TODO cache
             label = StructuredPostal.getTypeLabel(getContext().getResources(), type, customLabel);
         }
         view.setLabel(label);
-        view.showData(cursor, POSTAL_ADDRESS_COLUMN_INDEX);
+        view.showData(cursor, PostalQuery.POSTAL_ADDRESS);
     }
 
     protected void bindSectionHeaderAndDivider(final ContactListItemView view, int position) {
@@ -154,14 +154,13 @@
     }
 
     protected void bindName(final ContactListItemView view, Cursor cursor) {
-        view.showDisplayName(cursor, mDisplayNameColumnIndex, mAlternativeDisplayNameColumnIndex,
-                false, getContactNameDisplayOrder());
+        view.showDisplayName(cursor, PostalQuery.POSTAL_DISPLAY_NAME, getContactNameDisplayOrder());
     }
 
     protected void bindPhoto(final ContactListItemView view, Cursor cursor) {
         long photoId = 0;
-        if (!cursor.isNull(POSTAL_PHOTO_ID_COLUMN_INDEX)) {
-            photoId = cursor.getLong(POSTAL_PHOTO_ID_COLUMN_INDEX);
+        if (!cursor.isNull(PostalQuery.POSTAL_PHOTO_ID)) {
+            photoId = cursor.getLong(PostalQuery.POSTAL_PHOTO_ID);
         }
 
         getPhotoLoader().loadPhoto(view.getPhotoView(), photoId, false, false);
diff --git a/tests/src/com/android/contacts/format/DisplayNameFormatterTest.java b/tests/src/com/android/contacts/format/DisplayNameFormatterTest.java
deleted file mode 100644
index 4dc932b..0000000
--- a/tests/src/com/android/contacts/format/DisplayNameFormatterTest.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * 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.format;
-
-
-import android.provider.ContactsContract;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.widget.TextView;
-
-/**
- * Unit tests for {@link DisplayNameFormatter}.
- */
-@SmallTest
-public class DisplayNameFormatterTest extends AndroidTestCase {
-    private static final int TEST_PREFIX_HIGHLIGHT_COLOR = 0xFF0000;
-    /** The HTML code used to mark the start of the highlighted part. */
-    private static final String START = "<font color =\"#1ff0000\">";
-    /** The HTML code used to mark the end of the highlighted part. */
-    private static final String END = "</font>";
-
-    private PrefixHighlighter mPrefixHighlighter;
-    /** The object under test. */
-    private DisplayNameFormatter mDisplayNameFormatter;
-    /** The view to on which the text is set. */
-    private TextView mView;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mPrefixHighlighter = new PrefixHighlighter(TEST_PREFIX_HIGHLIGHT_COLOR);
-        mDisplayNameFormatter = new DisplayNameFormatter(mPrefixHighlighter);
-        mView = new TextView(getContext());
-        // This guarantees that the text will be stored as a Spannable so that we can determine
-        // which styles have been applied to it.
-        mView.setText("", TextView.BufferType.SPANNABLE);
-    }
-
-    public void testSetDisplayName_Simple() {
-        setNames("John Doe", "Doe John");
-        setDisplayName();
-        SpannedTestUtils.checkHtmlText("John Doe", mView);
-        setNames("Jean Pierre Doe", "Doe Jean Pierre");
-        setDisplayName();
-        SpannedTestUtils.checkHtmlText("Jean Pierre Doe", mView);
-        setNames("John Doe Smith", "Doe Smith John");
-        setDisplayName();
-        SpannedTestUtils.checkHtmlText("John Doe Smith", mView);
-    }
-    public void testSetDisplayName_AccidentalOverlap() {
-        // This is probably not what we want, but we assume that the two names differ only in the
-        // order in which the two components are listed.
-        setNames("Johnson John", "Johnson Smith");
-        setDisplayName();
-        SpannedTestUtils.checkHtmlText("Johnson John", mView);
-    }
-
-    public void testSetDisplayName_Reversed() {
-        setNames("John Doe", "Doe John");
-        setDisplayNameReversed();
-        SpannedTestUtils.checkHtmlText("John Doe", mView);
-        setNames("Jean Pierre Doe", "Doe Jean Pierre");
-        setDisplayNameReversed();
-        SpannedTestUtils.checkHtmlText("Jean Pierre Doe", mView);
-        setNames("John Doe Smith", "Doe Smith John");
-        setDisplayNameReversed();
-        SpannedTestUtils.checkHtmlText("John Doe Smith", mView);
-    }
-
-    public void testSetDisplayName_NoOverlap() {
-        setNames("John Smith", "Doe Albert");
-        setDisplayName();
-        SpannedTestUtils.checkHtmlText("John Smith", mView);
-    }
-
-    public void testSetDisplayName_Prefix() {
-        setNames("John Doe", "Doe John");
-        setDisplayNameWithPrefix("DO");
-        SpannedTestUtils.checkHtmlText("John " + START + "Do" + END + "e", mView);
-    }
-
-    public void testSetDisplayName_PrefixFirstName() {
-        setNames("John Doe", "Doe John");
-        setDisplayNameWithPrefix("JO");
-        SpannedTestUtils.checkHtmlText(START + "Jo" + END + "hn Doe", mView);
-    }
-
-    public void testSetDisplayName_PrefixMiddleName() {
-        setNames("John Paul Doe", "Doe John Paul");
-        setDisplayNameWithPrefix("PAU");
-        SpannedTestUtils.checkHtmlText("John " + START + "Pau" + END + "l Doe",
-                mView);
-    }
-
-    public void testSetDisplayName_ReversedPrefix() {
-        setNames("John Doe", "Doe John");
-        setDisplayNameReversedWithPrefix("DO");
-        SpannedTestUtils.checkHtmlText("John " + START + "Do" + END + "e", mView);
-    }
-
-    public void testSetDisplayName_Empty() {
-        setNames("", "");
-        setDisplayName();
-        SpannedTestUtils.checkHtmlText("", mView);
-    }
-
-    public void testSetDisplayName_Unknown() {
-        mDisplayNameFormatter.setUnknownNameText("unknown");
-        setNames("", "");
-        setDisplayName();
-        SpannedTestUtils.checkHtmlText("unknown", mView);
-    }
-
-    /**
-     * Sets the name and alternate name on the formatter.
-     *
-     * @param name the name to be display
-     * @param alternateName the alternate name to be displayed
-     */
-    private void setNames(String name, String alternateName) {
-        FormatUtils.copyToCharArrayBuffer(name, mDisplayNameFormatter.getNameBuffer());
-        FormatUtils.copyToCharArrayBuffer(alternateName,
-                mDisplayNameFormatter.getAlternateNameBuffer());
-    }
-
-    /**
-     * Sets the display name on the text view.
-     */
-    private void setDisplayName() {
-        mDisplayNameFormatter.setDisplayName(mView,
-                ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY, false, null);
-    }
-
-    /**
-     * Sets the display name on the text view using the reverted order.
-     */
-    private void setDisplayNameReversed() {
-        mDisplayNameFormatter.setDisplayName(mView,
-                ContactsContract.Preferences.DISPLAY_ORDER_ALTERNATIVE, false, null);
-    }
-
-    /**
-     * Sets the display name on the text view with prefix highlighting enabled.
-     */
-    private void setDisplayNameWithPrefix(String prefix) {
-        mDisplayNameFormatter.setDisplayName(mView,
-                ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY, false, prefix.toCharArray());
-    }
-
-    /**
-     * Sets the display name reversed on the text view with prefix highlighting enabled.
-     */
-    private void setDisplayNameReversedWithPrefix(String prefix) {
-        mDisplayNameFormatter.setDisplayName(mView,
-                ContactsContract.Preferences.DISPLAY_ORDER_ALTERNATIVE, false,
-                prefix.toCharArray());
-    }
-
-    /**
-     * Sets the display name on the text view with highlighting enabled.
-     */
-    private void setDisplayNameWithHighlighting() {
-        mDisplayNameFormatter.setDisplayName(mView,
-                ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY, true, null);
-    }
-}
diff --git a/tests/src/com/android/contacts/list/ContactListItemViewTest.java b/tests/src/com/android/contacts/list/ContactListItemViewTest.java
index aaf7521..82305d5 100644
--- a/tests/src/com/android/contacts/list/ContactListItemViewTest.java
+++ b/tests/src/com/android/contacts/list/ContactListItemViewTest.java
@@ -64,8 +64,7 @@
         Cursor cursor = createCursor("John Doe", "Doe John");
         ContactListItemView view = createView();
 
-        view.showDisplayName(cursor, 0, 1, false,
-                ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY);
+        view.showDisplayName(cursor, 0, ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY);
 
         SpannedTestUtils.checkHtmlText("John Doe", view.getNameTextView());
     }
@@ -75,8 +74,7 @@
         ContactListItemView view = createView();
 
         view.setUnknownNameText("unknown");
-        view.showDisplayName(cursor, 0, 1, false,
-                ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY);
+        view.showDisplayName(cursor, 0, ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY);
 
         SpannedTestUtils.checkHtmlText("unknown", view.getNameTextView());
     }
@@ -86,8 +84,7 @@
         ContactListItemView view = createView();
 
         view.setHighlightedPrefix("DOE".toCharArray());
-        view.showDisplayName(cursor, 0, 1, false,
-                ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY);
+        view.showDisplayName(cursor, 0, ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY);
 
         SpannedTestUtils.checkHtmlText("John " + START + "Doe" + END,
                 view.getNameTextView());
@@ -98,8 +95,7 @@
         ContactListItemView view = createView();
 
         view.setHighlightedPrefix("DOE".toCharArray());
-        view.showDisplayName(cursor, 0, 1, false,
-                ContactsContract.Preferences.DISPLAY_ORDER_ALTERNATIVE);
+        view.showDisplayName(cursor, 0, ContactsContract.Preferences.DISPLAY_ORDER_ALTERNATIVE);
 
         SpannedTestUtils.checkHtmlText("John " + START + "Doe" + END,
                 view.getNameTextView());