Merge "Fix possible NPE. mDigits may be null on onNewIntent()"
diff --git a/res/drawable-hdpi/ic_hold_pause_disabled_holo_dark.png b/res/drawable-hdpi/ic_hold_pause_disabled_holo_dark.png
new file mode 100644
index 0000000..60fecb2
--- /dev/null
+++ b/res/drawable-hdpi/ic_hold_pause_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_contacts_holo_light.png b/res/drawable-hdpi/ic_menu_contacts_holo_light.png
index 8a7358c..6327545 100644
--- a/res/drawable-hdpi/ic_menu_contacts_holo_light.png
+++ b/res/drawable-hdpi/ic_menu_contacts_holo_light.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_minus_disabled_holo_dark.png b/res/drawable-hdpi/ic_minus_disabled_holo_dark.png
new file mode 100644
index 0000000..0d2d93b
--- /dev/null
+++ b/res/drawable-hdpi/ic_minus_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_play_disabled_holo_dark.png b/res/drawable-hdpi/ic_play_disabled_holo_dark.png
new file mode 100644
index 0000000..f7e404b
--- /dev/null
+++ b/res/drawable-hdpi/ic_play_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_plus_disabled_holo_dark.png b/res/drawable-hdpi/ic_plus_disabled_holo_dark.png
new file mode 100644
index 0000000..ed65c1c
--- /dev/null
+++ b/res/drawable-hdpi/ic_plus_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_sound_holo_dark.png b/res/drawable-hdpi/ic_sound_holo_dark.png
deleted file mode 100644
index 9968405..0000000
--- a/res/drawable-hdpi/ic_sound_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_sound_off_speakerphone_disabled_holo_dark.png b/res/drawable-hdpi/ic_sound_off_speakerphone_disabled_holo_dark.png
new file mode 100644
index 0000000..e2cb0e4
--- /dev/null
+++ b/res/drawable-hdpi/ic_sound_off_speakerphone_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_sound_off_speakerphone_holo_dark.png b/res/drawable-hdpi/ic_sound_off_speakerphone_holo_dark.png
new file mode 100644
index 0000000..6f12d52
--- /dev/null
+++ b/res/drawable-hdpi/ic_sound_off_speakerphone_holo_dark.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_sound_speakerphone_disabled_holo_dark.png b/res/drawable-hdpi/ic_sound_speakerphone_disabled_holo_dark.png
new file mode 100644
index 0000000..3e0f47e
--- /dev/null
+++ b/res/drawable-hdpi/ic_sound_speakerphone_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_sound_speakerphone_holo_dark.png b/res/drawable-hdpi/ic_sound_speakerphone_holo_dark.png
new file mode 100644
index 0000000..eadd0cd
--- /dev/null
+++ b/res/drawable-hdpi/ic_sound_speakerphone_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_hold_pause_disabled_holo_dark.png b/res/drawable-mdpi/ic_hold_pause_disabled_holo_dark.png
new file mode 100644
index 0000000..1f32576
--- /dev/null
+++ b/res/drawable-mdpi/ic_hold_pause_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_contacts_holo_light.png b/res/drawable-mdpi/ic_menu_contacts_holo_light.png
index 5ef1184..4a15754 100644
--- a/res/drawable-mdpi/ic_menu_contacts_holo_light.png
+++ b/res/drawable-mdpi/ic_menu_contacts_holo_light.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_minus_disabled_holo_dark.png b/res/drawable-mdpi/ic_minus_disabled_holo_dark.png
new file mode 100644
index 0000000..76ef6e8
--- /dev/null
+++ b/res/drawable-mdpi/ic_minus_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_play_disabled_holo_dark.png b/res/drawable-mdpi/ic_play_disabled_holo_dark.png
new file mode 100644
index 0000000..584f448
--- /dev/null
+++ b/res/drawable-mdpi/ic_play_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_plus_disabled_holo_dark.png b/res/drawable-mdpi/ic_plus_disabled_holo_dark.png
new file mode 100644
index 0000000..2a5947c
--- /dev/null
+++ b/res/drawable-mdpi/ic_plus_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_sound_holo_dark.png b/res/drawable-mdpi/ic_sound_holo_dark.png
deleted file mode 100644
index 3261ec0..0000000
--- a/res/drawable-mdpi/ic_sound_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_sound_off_speakerphone_disabled_holo_dark.png b/res/drawable-mdpi/ic_sound_off_speakerphone_disabled_holo_dark.png
new file mode 100644
index 0000000..2e4cee7
--- /dev/null
+++ b/res/drawable-mdpi/ic_sound_off_speakerphone_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_sound_off_speakerphone_holo_dark.png b/res/drawable-mdpi/ic_sound_off_speakerphone_holo_dark.png
new file mode 100644
index 0000000..adaff60
--- /dev/null
+++ b/res/drawable-mdpi/ic_sound_off_speakerphone_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_sound_speakerphone_disabled_holo_dark.png b/res/drawable-mdpi/ic_sound_speakerphone_disabled_holo_dark.png
new file mode 100644
index 0000000..d722707
--- /dev/null
+++ b/res/drawable-mdpi/ic_sound_speakerphone_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_sound_speakerphone_holo_dark.png b/res/drawable-mdpi/ic_sound_speakerphone_holo_dark.png
new file mode 100644
index 0000000..2b9600b
--- /dev/null
+++ b/res/drawable-mdpi/ic_sound_speakerphone_holo_dark.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_hold_pause_disabled_holo_dark.png b/res/drawable-xhdpi/ic_hold_pause_disabled_holo_dark.png
new file mode 100644
index 0000000..4a45288
--- /dev/null
+++ b/res/drawable-xhdpi/ic_hold_pause_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_contacts_holo_light.png b/res/drawable-xhdpi/ic_menu_contacts_holo_light.png
index ac9cf65..c054505 100644
--- a/res/drawable-xhdpi/ic_menu_contacts_holo_light.png
+++ b/res/drawable-xhdpi/ic_menu_contacts_holo_light.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_minus_disabled_holo_dark.png b/res/drawable-xhdpi/ic_minus_disabled_holo_dark.png
new file mode 100644
index 0000000..1f09cf8
--- /dev/null
+++ b/res/drawable-xhdpi/ic_minus_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_play_disabled_holo_dark.png b/res/drawable-xhdpi/ic_play_disabled_holo_dark.png
new file mode 100644
index 0000000..7fbcb37
--- /dev/null
+++ b/res/drawable-xhdpi/ic_play_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_plus_disabled_holo_dark.png b/res/drawable-xhdpi/ic_plus_disabled_holo_dark.png
new file mode 100644
index 0000000..5728d50
--- /dev/null
+++ b/res/drawable-xhdpi/ic_plus_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sound_holo_dark.png b/res/drawable-xhdpi/ic_sound_holo_dark.png
deleted file mode 100644
index 9ffe70e..0000000
--- a/res/drawable-xhdpi/ic_sound_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sound_off_speakerphone_disabled_holo_dark.png b/res/drawable-xhdpi/ic_sound_off_speakerphone_disabled_holo_dark.png
new file mode 100644
index 0000000..8381be1
--- /dev/null
+++ b/res/drawable-xhdpi/ic_sound_off_speakerphone_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sound_off_speakerphone_holo_dark.png b/res/drawable-xhdpi/ic_sound_off_speakerphone_holo_dark.png
new file mode 100644
index 0000000..98a449f
--- /dev/null
+++ b/res/drawable-xhdpi/ic_sound_off_speakerphone_holo_dark.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sound_speakerphone_disabled_holo_dark.png b/res/drawable-xhdpi/ic_sound_speakerphone_disabled_holo_dark.png
new file mode 100644
index 0000000..b836d49
--- /dev/null
+++ b/res/drawable-xhdpi/ic_sound_speakerphone_disabled_holo_dark.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sound_speakerphone_holo_dark.png b/res/drawable-xhdpi/ic_sound_speakerphone_holo_dark.png
new file mode 100644
index 0000000..71aad97
--- /dev/null
+++ b/res/drawable-xhdpi/ic_sound_speakerphone_holo_dark.png
Binary files differ
diff --git a/res/drawable/ic_hold_pause.xml b/res/drawable/ic_hold_pause.xml
new file mode 100644
index 0000000..b99689c
--- /dev/null
+++ b/res/drawable/ic_hold_pause.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_enabled="false"
+            android:drawable="@drawable/ic_hold_pause_disabled_holo_dark" />
+    <item android:drawable="@drawable/ic_hold_pause_holo_dark" />
+</selector>
diff --git a/res/drawable/ic_minus.xml b/res/drawable/ic_minus.xml
new file mode 100644
index 0000000..1fa9210
--- /dev/null
+++ b/res/drawable/ic_minus.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_enabled="false" android:drawable="@drawable/ic_minus_disabled_holo_dark" />
+    <item android:drawable="@drawable/ic_minus_holo_dark" />
+</selector>
diff --git a/res/drawable/ic_play.xml b/res/drawable/ic_play.xml
new file mode 100644
index 0000000..68e656f
--- /dev/null
+++ b/res/drawable/ic_play.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_enabled="false" android:drawable="@drawable/ic_play_disabled_holo_dark" />
+    <item android:drawable="@drawable/ic_play_holo_dark" />
+</selector>
diff --git a/res/drawable/ic_plus.xml b/res/drawable/ic_plus.xml
new file mode 100644
index 0000000..d5aa2e7
--- /dev/null
+++ b/res/drawable/ic_plus.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_enabled="false" android:drawable="@drawable/ic_plus_disabled_holo_dark" />
+    <item android:drawable="@drawable/ic_plus_holo_dark" />
+</selector>
diff --git a/res/drawable/ic_speakerphone_off.xml b/res/drawable/ic_speakerphone_off.xml
new file mode 100644
index 0000000..85cf810
--- /dev/null
+++ b/res/drawable/ic_speakerphone_off.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_enabled="false" android:drawable="@drawable/ic_sound_off_speakerphone_disabled_holo_dark" />
+    <item android:drawable="@drawable/ic_sound_off_speakerphone_holo_dark" />
+</selector>
diff --git a/res/drawable/ic_speakerphone_on.xml b/res/drawable/ic_speakerphone_on.xml
new file mode 100644
index 0000000..eb79f71
--- /dev/null
+++ b/res/drawable/ic_speakerphone_on.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_enabled="false" android:drawable="@drawable/ic_sound_speakerphone_disabled_holo_dark" />
+    <item android:drawable="@drawable/ic_sound_speakerphone_holo_dark" />
+</selector>
diff --git a/res/layout/call_detail.xml b/res/layout/call_detail.xml
index 076f37f..936bca8 100644
--- a/res/layout/call_detail.xml
+++ b/res/layout/call_detail.xml
@@ -209,5 +209,6 @@
         android:layout_alignParentTop="true"
         android:background="#000000"
         android:visibility="gone"
+        android:clickable="true"
     />
 </RelativeLayout>
diff --git a/res/layout/playback_layout.xml b/res/layout/playback_layout.xml
index efd45b8..c2fdb3e 100644
--- a/res/layout/playback_layout.xml
+++ b/res/layout/playback_layout.xml
@@ -25,7 +25,7 @@
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:background="@drawable/btn_dial"
-                android:src="@drawable/ic_hold_pause_holo_dark"
+                android:src="@drawable/ic_hold_pause"
             />
         </LinearLayout>
         <LinearLayout
@@ -39,7 +39,7 @@
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:background="@drawable/btn_dial"
-                android:src="@drawable/ic_sound_holo_dark"
+                android:src="@drawable/ic_speakerphone_on"
             />
         </LinearLayout>
     </LinearLayout>
@@ -94,7 +94,7 @@
         />
         <ImageButton
             android:id="@+id/rate_decrease_button"
-            android:src="@drawable/ic_minus_holo_dark"
+            android:src="@drawable/ic_minus"
             android:layout_width="64dip"
             android:layout_height="wrap_content"
             android:background="@drawable/btn_dial"
@@ -105,7 +105,7 @@
         />
         <ImageButton
             android:id="@+id/rate_increase_button"
-            android:src="@drawable/ic_plus_holo_dark"
+            android:src="@drawable/ic_plus"
             android:layout_width="64dip"
             android:layout_height="wrap_content"
             android:background="@drawable/btn_dial"
diff --git a/res/layout/quickcontact_photo_container.xml b/res/layout/quickcontact_photo_container.xml
index 7df54d9..ffaf12f 100644
--- a/res/layout/quickcontact_photo_container.xml
+++ b/res/layout/quickcontact_photo_container.xml
@@ -84,6 +84,7 @@
             android:id="@+id/open_details_push_layer"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
+            android:contentDescription="@string/viewContactDesription"
             android:background="?android:attr/selectableItemBackground" />
     </RelativeLayout>
 </merge>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 57ed7c5..06a461d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -724,6 +724,14 @@
     -->
     <string name="description_plus_button">plus</string>
 
+    <!-- String describing a contact picture that introduces users to the contact detail screen.
+
+         Used by AccessibilityService to announce the purpose of the button.
+
+         [CHAR LIMIT=NONE]
+      -->
+    <string name="description_view_contact_detail" msgid="2795575601596468581">View contact</string>
+
     <!-- Dialog title shown when (USB) storage does not exist [CHAR LIMIT=25] -->
     <string name="no_sdcard_title" product="nosdcard">Storage unavailable</string>
     <!-- Dialog title shown when SD Card does not exist -->
diff --git a/res/xml/social_widget_info.xml b/res/xml/social_widget_info.xml
index a7bece6..1003c62 100644
--- a/res/xml/social_widget_info.xml
+++ b/res/xml/social_widget_info.xml
@@ -17,8 +17,8 @@
  <!-- It is enough to update once per day, as the widget watches the database for changes -->
  
 <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
-    android:minWidth="294dip"
-    android:minHeight="72dip"
+    android:minWidth="260dip"
+    android:minHeight="40dip"
     android:updatePeriodMillis="86400000"
     android:initialLayout="@layout/social_widget"
     android:previewImage="@drawable/contacts_widget_preview"
diff --git a/src/com/android/contacts/ContactSaveService.java b/src/com/android/contacts/ContactSaveService.java
index 78c4b18..2df2e47 100644
--- a/src/com/android/contacts/ContactSaveService.java
+++ b/src/com/android/contacts/ContactSaveService.java
@@ -18,6 +18,7 @@
 
 import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.model.AccountWithDataSet;
+import com.android.contacts.model.EntityDelta;
 import com.android.contacts.model.EntityDeltaList;
 import com.android.contacts.model.EntityModifier;
 import com.google.android.collect.Lists;
@@ -48,6 +49,7 @@
 import android.provider.ContactsContract.Groups;
 import android.provider.ContactsContract.Profile;
 import android.provider.ContactsContract.RawContacts;
+import android.provider.ContactsContract.RawContactsEntity;
 import android.util.Log;
 import android.widget.Toast;
 
@@ -355,9 +357,19 @@
                     throw new IllegalStateException("Version consistency failed for a new contact");
                 }
 
-                final EntityDeltaList newState = EntityDeltaList.fromQuery(resolver,
-                        sb.toString(), null, null);
+                final EntityDeltaList newState = EntityDeltaList.fromQuery(
+                        isProfile
+                                ? RawContactsEntity.PROFILE_CONTENT_URI
+                                : RawContactsEntity.CONTENT_URI,
+                        resolver, sb.toString(), null, null);
                 state = EntityDeltaList.mergeAfter(newState, state);
+
+                // Update the new state to use profile URIs if appropriate.
+                if (isProfile) {
+                    for (EntityDelta delta : state) {
+                        delta.setProfileQueryUri();
+                    }
+                }
             }
         }
 
diff --git a/src/com/android/contacts/ContactsUtils.java b/src/com/android/contacts/ContactsUtils.java
index d3d8f34..f1f73ed 100644
--- a/src/com/android/contacts/ContactsUtils.java
+++ b/src/com/android/contacts/ContactsUtils.java
@@ -18,6 +18,7 @@
 
 import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.model.AccountWithDataSet;
+import com.android.contacts.test.NeededForTesting;
 import com.android.i18n.phonenumbers.PhoneNumberUtil;
 
 import android.content.Context;
@@ -91,6 +92,7 @@
     /**
      * Returns true if two objects are considered equal.  Two null references are equal here.
      */
+    @NeededForTesting
     public static boolean areObjectsEqual(Object a, Object b) {
         return a == b || (a != null && a.equals(b));
     }
diff --git a/src/com/android/contacts/activities/ConfirmAddDetailActivity.java b/src/com/android/contacts/activities/ConfirmAddDetailActivity.java
index 418c8e3..3d4b70f 100644
--- a/src/com/android/contacts/activities/ConfirmAddDetailActivity.java
+++ b/src/com/android/contacts/activities/ConfirmAddDetailActivity.java
@@ -58,6 +58,7 @@
 import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.RawContacts;
+import android.provider.ContactsContract.RawContactsEntity;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
 import android.util.Log;
@@ -378,7 +379,10 @@
                 mSelection = Data.RAW_CONTACT_ID + "=?";
             }
 
-            return EntityDeltaList.fromQuery(activityTarget.getContentResolver(), mSelection,
+            // Note that this query does not need to concern itself with whether the contact is
+            // the user's profile, since the profile does not show up in the picker.
+            return EntityDeltaList.fromQuery(RawContactsEntity.CONTENT_URI,
+                    activityTarget.getContentResolver(), mSelection,
                     new String[] { selectionArg }, null);
         }
 
diff --git a/src/com/android/contacts/dialpad/DigitsEditText.java b/src/com/android/contacts/dialpad/DigitsEditText.java
index 580a44a..753afd4 100644
--- a/src/com/android/contacts/dialpad/DigitsEditText.java
+++ b/src/com/android/contacts/dialpad/DigitsEditText.java
@@ -21,6 +21,7 @@
 import android.text.InputType;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
+import android.view.accessibility.AccessibilityEvent;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.EditText;
 
@@ -54,4 +55,18 @@
         }
         return ret;
     }
+
+    @Override
+    public void sendAccessibilityEventUnchecked(AccessibilityEvent event) {
+        if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED) {
+            // AsYouTypeFormatter frequently replaces digits with formatted ones, which makes
+            // tts too verbose. Let's ignore the whole event.
+            return;
+        } else if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED) {
+            // The parent EditText class lets tts read "edit box" when this View has a focus, which
+            // confuses users on app launch (issue 5275935).
+            return;
+        }
+        super.sendAccessibilityEventUnchecked(event);
+    }
 }
\ No newline at end of file
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index 9abcef1..2e54642 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -479,9 +479,26 @@
 
         // For user profile, change the contacts query URI
         mIsUserProfile = data.isUserProfile();
+        boolean localProfileExists = false;
+
         if (mIsUserProfile) {
             for (EntityDelta state : mState) {
+                // For profile contacts, we need a different query URI
                 state.setProfileQueryUri();
+                // Try to find a local profile contact
+                if (state.getValues().getAsString(RawContacts.ACCOUNT_TYPE) == null) {
+                    localProfileExists = true;
+                }
+            }
+            // Editor should always present a local profile for editing
+            if (!localProfileExists) {
+                final ContentValues values = new ContentValues();
+                values.putNull(RawContacts.ACCOUNT_NAME);
+                values.putNull(RawContacts.ACCOUNT_TYPE);
+                values.putNull(RawContacts.DATA_SET);
+                EntityDelta insert = new EntityDelta(ValuesDelta.fromAfter(values));
+                insert.setProfileQueryUri();
+                mState.add(insert);
             }
         }
         mRequestFocus = true;
diff --git a/src/com/android/contacts/format/DisplayNameFormatter.java b/src/com/android/contacts/format/DisplayNameFormatter.java
index e525217..2099c53 100644
--- a/src/com/android/contacts/format/DisplayNameFormatter.java
+++ b/src/com/android/contacts/format/DisplayNameFormatter.java
@@ -20,9 +20,6 @@
 import com.android.contacts.widget.TextWithHighlightingFactory;
 
 import android.database.CharArrayBuffer;
-import android.graphics.Typeface;
-import android.provider.ContactsContract;
-import android.text.Spannable;
 import android.widget.TextView;
 
 /**
@@ -50,10 +47,6 @@
         return mAlternateNameBuffer;
     }
 
-    public void setTextWithHighlightingFactory(TextWithHighlightingFactory factory) {
-        mTextWithHighlightingFactory = factory;
-    }
-
     public void setUnknownNameText(CharSequence unknownNameText) {
         mUnknownNameText = unknownNameText;
     }
diff --git a/src/com/android/contacts/list/ContactListItemView.java b/src/com/android/contacts/list/ContactListItemView.java
index 7e81dcd..a6e241f 100644
--- a/src/com/android/contacts/list/ContactListItemView.java
+++ b/src/com/android/contacts/list/ContactListItemView.java
@@ -21,7 +21,6 @@
 import com.android.contacts.R;
 import com.android.contacts.format.DisplayNameFormatter;
 import com.android.contacts.format.PrefixHighlighter;
-import com.android.contacts.widget.TextWithHighlightingFactory;
 
 import android.content.Context;
 import android.content.res.ColorStateList;
@@ -33,6 +32,9 @@
 import android.graphics.Rect;
 import android.graphics.Typeface;
 import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.provider.ContactsContract;
+import android.provider.ContactsContract.Contacts;
 import android.text.TextUtils;
 import android.text.TextUtils.TruncateAt;
 import android.util.AttributeSet;
@@ -46,6 +48,11 @@
 import android.widget.QuickContactBadge;
 import android.widget.TextView;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 /**
  * A custom view for an item in the contact list.
  * The view contains the contact's photo, a set of text views (for name, status, etc...) and
@@ -271,10 +278,6 @@
         mCallButtonClickListener = callButtonClickListener;
     }
 
-    public void setTextWithHighlightingFactory(TextWithHighlightingFactory factory) {
-        mDisplayNameFormatter.setTextWithHighlightingFactory(factory);
-    }
-
     public void setUnknownNameText(CharSequence unknownNameText) {
         mDisplayNameFormatter.setUnknownNameText(unknownNameText);
     }
@@ -1094,8 +1097,25 @@
             setSnippet(null);
             return;
         }
+        String snippet;
+        String columnContent = cursor.getString(summarySnippetColumnIndex);
 
-        String snippet = cursor.getString(summarySnippetColumnIndex);
+        // Do client side snippeting if provider didn't do it
+        Bundle extras = cursor.getExtras();
+        if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) {
+            int displayNameIndex = cursor.getColumnIndex(Contacts.DISPLAY_NAME);
+
+            snippet = ContactsContract.snippetize(columnContent,
+                    displayNameIndex < 0 ? null : cursor.getString(displayNameIndex),
+                            extras.getString(ContactsContract.DEFERRED_SNIPPETING_QUERY),
+                            DefaultContactListAdapter.SNIPPET_START_MATCH,
+                            DefaultContactListAdapter.SNIPPET_END_MATCH,
+                            DefaultContactListAdapter.SNIPPET_ELLIPSIS,
+                            DefaultContactListAdapter.SNIPPET_MAX_TOKENS);
+        } else {
+            snippet = columnContent;
+        }
+
         if (snippet != null) {
             int from = 0;
             int to = snippet.length();
diff --git a/src/com/android/contacts/list/CustomContactListFilterActivity.java b/src/com/android/contacts/list/CustomContactListFilterActivity.java
index bbfbf32..638a28e 100644
--- a/src/com/android/contacts/list/CustomContactListFilterActivity.java
+++ b/src/com/android/contacts/list/CustomContactListFilterActivity.java
@@ -160,7 +160,8 @@
                     }
                     // Create single entry handling ungrouped status
                     accountDisplay.mUngrouped =
-                        GroupDelta.fromSettings(resolver, account.name, account.type, hasGroups);
+                        GroupDelta.fromSettings(resolver, account.name, account.type,
+                                account.dataSet, hasGroups);
                     accountDisplay.addGroup(accountDisplay.mUngrouped);
                 } finally {
                     iterator.close();
@@ -246,14 +247,18 @@
 
         /**
          * Build {@link GroupDelta} from the {@link Settings} row for the given
-         * {@link Settings#ACCOUNT_NAME} and {@link Settings#ACCOUNT_TYPE}.
+         * {@link Settings#ACCOUNT_NAME}, {@link Settings#ACCOUNT_TYPE}, and
+         * {@link Settings#DATA_SET}.
          */
         public static GroupDelta fromSettings(ContentResolver resolver, String accountName,
-                String accountType, boolean accountHasGroups) {
-            final Uri settingsUri = Settings.CONTENT_URI.buildUpon()
+                String accountType, String dataSet, boolean accountHasGroups) {
+            final Uri.Builder settingsUri = Settings.CONTENT_URI.buildUpon()
                     .appendQueryParameter(Settings.ACCOUNT_NAME, accountName)
-                    .appendQueryParameter(Settings.ACCOUNT_TYPE, accountType).build();
-            final Cursor cursor = resolver.query(settingsUri, new String[] {
+                    .appendQueryParameter(Settings.ACCOUNT_TYPE, accountType);
+            if (dataSet != null) {
+                settingsUri.appendQueryParameter(Settings.DATA_SET, dataSet);
+            }
+            final Cursor cursor = resolver.query(settingsUri.build(), new String[] {
                     Settings.SHOULD_SYNC, Settings.UNGROUPED_VISIBLE
             }, null, null, null);
 
@@ -261,6 +266,7 @@
                 final ContentValues values = new ContentValues();
                 values.put(Settings.ACCOUNT_NAME, accountName);
                 values.put(Settings.ACCOUNT_TYPE, accountType);
+                values.put(Settings.DATA_SET, dataSet);
 
                 if (cursor != null && cursor.moveToFirst()) {
                     // Read existing values when present
diff --git a/src/com/android/contacts/list/DefaultContactListAdapter.java b/src/com/android/contacts/list/DefaultContactListAdapter.java
index f202522..2a8d665 100644
--- a/src/com/android/contacts/list/DefaultContactListAdapter.java
+++ b/src/com/android/contacts/list/DefaultContactListAdapter.java
@@ -85,6 +85,7 @@
                 }
                 builder.appendQueryParameter(SearchSnippetColumns.SNIPPET_ARGS_PARAM_KEY,
                         SNIPPET_ARGS);
+                builder.appendQueryParameter(SearchSnippetColumns.DEFERRED_SNIPPETING_KEY,"1");
                 loader.setUri(builder.build());
                 loader.setProjection(FILTER_PROJECTION);
             }
diff --git a/src/com/android/contacts/model/EntityDeltaList.java b/src/com/android/contacts/model/EntityDeltaList.java
index 9b7bdc6..5a9355b 100644
--- a/src/com/android/contacts/model/EntityDeltaList.java
+++ b/src/com/android/contacts/model/EntityDeltaList.java
@@ -21,6 +21,7 @@
 import android.content.Entity;
 import android.content.EntityIterator;
 import android.content.ContentProviderOperation.Builder;
+import android.net.Uri;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.provider.ContactsContract.AggregationExceptions;
@@ -63,10 +64,10 @@
      * given query parameters. This closes the {@link EntityIterator} when
      * finished, so it doesn't subscribe to updates.
      */
-    public static EntityDeltaList fromQuery(ContentResolver resolver, String selection,
-            String[] selectionArgs, String sortOrder) {
+    public static EntityDeltaList fromQuery(Uri entityUri, ContentResolver resolver,
+            String selection, String[] selectionArgs, String sortOrder) {
         final EntityIterator iterator = RawContacts.newEntityIterator(resolver.query(
-                RawContactsEntity.CONTENT_URI, null, selection, selectionArgs,
+                entityUri, null, selection, selectionArgs,
                 sortOrder));
         try {
             return fromIterator(iterator);
diff --git a/src/com/android/contacts/voicemail/VoicemailPlaybackFragment.java b/src/com/android/contacts/voicemail/VoicemailPlaybackFragment.java
index 8d549a7..df4d9af 100644
--- a/src/com/android/contacts/voicemail/VoicemailPlaybackFragment.java
+++ b/src/com/android/contacts/voicemail/VoicemailPlaybackFragment.java
@@ -397,9 +397,9 @@
         public void setSpeakerPhoneOn(boolean on) {
             getAudioManager().setSpeakerphoneOn(on);
             if (on) {
-                mPlaybackSpeakerphone.setImageResource(R.drawable.ic_sound_holo_dark);
+                mPlaybackSpeakerphone.setImageResource(R.drawable.ic_speakerphone_on);
             } else {
-                mPlaybackSpeakerphone.setImageResource(R.drawable.ic_sound_holo_dark);
+                mPlaybackSpeakerphone.setImageResource(R.drawable.ic_speakerphone_off);
             }
         }
 
diff --git a/tests/src/com/android/contacts/format/DisplayNameFormatterTest.java b/tests/src/com/android/contacts/format/DisplayNameFormatterTest.java
index 24714cd..4dc932b 100644
--- a/tests/src/com/android/contacts/format/DisplayNameFormatterTest.java
+++ b/tests/src/com/android/contacts/format/DisplayNameFormatterTest.java
@@ -125,20 +125,6 @@
         SpannedTestUtils.checkHtmlText("unknown", mView);
     }
 
-    public void testSetDisplayName_Highlighting() {
-        mDisplayNameFormatter.setTextWithHighlightingFactory(new TestTextWithHighlightingFactory());
-        setNames("John Doe", "Sue Anne");
-        setDisplayNameWithHighlighting();
-        SpannedTestUtils.checkHtmlText("<i>John Doe</i> <i>Sue Anne</i>", mView);
-    }
-
-    public void testSetDisplayName_HighlightingAndBoldFirstName() {
-        mDisplayNameFormatter.setTextWithHighlightingFactory(new TestTextWithHighlightingFactory());
-        setNames("John Doe", "Doe John");
-        setDisplayNameWithHighlighting();
-        SpannedTestUtils.checkHtmlText("<i>John Doe</i> <i>Doe John</i>", mView);
-    }
-
     /**
      * Sets the name and alternate name on the formatter.
      *
diff --git a/tests/src/com/android/contacts/list/ContactListItemViewTest.java b/tests/src/com/android/contacts/list/ContactListItemViewTest.java
index 8372f96..aaf7521 100644
--- a/tests/src/com/android/contacts/list/ContactListItemViewTest.java
+++ b/tests/src/com/android/contacts/list/ContactListItemViewTest.java
@@ -18,7 +18,6 @@
 
 import com.android.contacts.activities.PeopleActivity;
 import com.android.contacts.format.SpannedTestUtils;
-import com.android.contacts.format.TestTextWithHighlightingFactory;
 import com.android.contacts.util.IntegrationTestUtils;
 
 import android.database.Cursor;
@@ -37,7 +36,7 @@
 @LargeTest
 public class ContactListItemViewTest extends ActivityInstrumentationTestCase2<PeopleActivity> {
     /** The HTML code used to mark the start of the highlighted part. */
-    private static final String START = "<font color =\"#729a27\">";
+    private static final String START = "<font color =\"#99cc00\">";
     /** The HTML code used to mark the end of the highlighted part. */
     private static final String END = "</font>";
 
@@ -106,18 +105,6 @@
                 view.getNameTextView());
     }
 
-    public void testShowDisplayName_WithHighlight() {
-        Cursor cursor = createCursor("John Doe", "Doe John");
-        ContactListItemView view = createView();
-
-        view.setTextWithHighlightingFactory(new TestTextWithHighlightingFactory());
-        view.showDisplayName(cursor, 0, 1, true,
-                ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY);
-
-        SpannedTestUtils.checkHtmlText("<i>John Doe</i> <i>Doe John</i>",
-                view.getNameTextView());
-    }
-
     public void testSetSnippet_Prefix() {
         ContactListItemView view = createView();
         view.setHighlightedPrefix("TEST".toCharArray());