Merge change I3040fa30 into eclair

* changes:
  Taping the dialed number allows editing.
diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml
index 4f1b1ca..3c9a660 100644
--- a/res/values-es-rUS/strings.xml
+++ b/res/values-es-rUS/strings.xml
@@ -157,8 +157,6 @@
     <string name="listSeparatorOtherInformation" msgid="7844959649638482329">"Otra información"</string>
     <string name="listSeparatorOtherInformation_edit" msgid="1326921768011367750">"Otras opciones"</string>
     <string name="listSeparatorMore_edit" msgid="858454837482243176">"Más"</string>
-    <string name="listTotalPhoneContacts" msgid="7371957507364352596">"<xliff:g id="NUM">%s</xliff:g> contactos con números de teléfono"</string>
-    <string name="listTotalAllContacts" msgid="4516547509985949443">"<xliff:g id="NUM">%s</xliff:g> contactos"</string>
     <string name="socialStreamIconLabel" msgid="4367712449555075376">"Social"</string>
     <string name="contactsIconLabel" msgid="7666609097606552806">"Contactos"</string>
     <string name="contactsFavoritesLabel" msgid="8417039765586853670">"Favoritos"</string>
diff --git a/res/values/ids.xml b/res/values/ids.xml
index 72ab82f..5e287ad 100644
--- a/res/values/ids.xml
+++ b/res/values/ids.xml
@@ -43,7 +43,7 @@
 
     <!-- For ContactsListActivity -->
     <item type="id" name="dialog_delete_contact_confirmation" />
-    <item type="id" name="dialog_cannot_delete_readonly_contact" />
+    <item type="id" name="dialog_readonly_contact_hide_confirmation" />
     <item type="id" name="dialog_multiple_contact_delete_confirmation" />
     <item type="id" name="dialog_readonly_contact_delete_confirmation" />
 
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 60f784d..dbe8d09 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -120,13 +120,21 @@
     <string name="menu_makeDefaultEmail">Make default email</string>
 
     <!-- Menu item that splits an item from the contact detail into a separate aggregate -->
-    <string name="menu_splitAggregate">Split</string>
+    <string name="menu_splitAggregate">Separate</string>
 
     <!-- Dialog title for the list of constituent contacts in the split aggregate dialog. -->
     <string name="splitAggregate_title">Split contact</string>
 
     <!-- Toast shown after a contact has been split from an aggregate by a user action -->
-    <string name="contactsSplitMessage">Contact split</string>
+    <string name="contactsSplitMessage">Contacts separated</string>
+
+    <!-- Title of the confirmation dialog for separating contacts into multiple instances  -->
+    <string name="splitConfirmation_title">Separate Contact</string>
+
+    <!-- Confirmation dialog for separating contacts into multiple instances  -->
+    <string name="splitConfirmation">Are you sure you want to separate this single contact
+        into multiple contacts: one for each set of contact information that was joined into it?
+    </string>
 
     <!-- Menu item that joins an aggregate with another aggregate -->
     <string name="menu_joinAggregate">Join</string>
@@ -166,10 +174,10 @@
     <string name="deleteConfirmation_title">Delete</string>
 
     <!-- Warning dialog contents after users selects to delete a ReadOnly contact. -->
-    <string name="readOnlyContactWarning">You cannot delete contacts from read-only accounts.</string>
+    <string name="readOnlyContactWarning">You cannot delete contacts from read-only accounts, but you can hide them in your contacts lists.</string>
 
     <!-- Warning dialog contents after users selects to delete a contact with ReadOnly and Writable sources. -->
-    <string name="readOnlyContactDeleteConfirmation">This contact contains information from multiple accounts. The information from read-only accounts will not be deleted.</string>
+    <string name="readOnlyContactDeleteConfirmation">This contact contains information from multiple accounts. Information from read-only accounts will be hidden in your contacts lists, not deleted.</string>
 
     <!-- Warning dialog contents after users selects to delete a contact with multiple Writable sources. -->
     <string name="multipleContactDeleteConfirmation">Deleting this contact will delete information from multiple accounts.</string>
@@ -427,10 +435,31 @@
     <string name="listSeparatorMore_edit">More</string>
 
     <!-- Displayed at the top of the contacts showing the total number of contacts visible when "Only contacts with phones" is selected -->
-    <string name="listTotalPhoneContacts"><xliff:g id="num">%s</xliff:g> contacts with phone numbers</string>
+    <plurals name="listTotalPhoneContacts">
+        <item quantity="one">Displaying 1 contact with phone number</item>
+        <item quantity="other">Displaying <xliff:g id="count">%d</xliff:g> contacts with phone numbers</item>
+    </plurals>
+
+    <!-- Displayed at the top of the contacts showing the zero as total number of contacts visible when "Only contacts with phones" is selected -->
+    <string name="listTotalPhoneContactsZero">No visible contacts with phone numbers</string>
 
     <!-- Displayed at the top of the contacts showing the total number of contacts visible when "Only contacts with phones" not selected -->
-    <string name="listTotalAllContacts"><xliff:g id="num">%s</xliff:g> contacts</string>
+    <plurals name="listTotalAllContacts">
+        <item quantity="one">Displaying 1 contact</item>
+        <item quantity="other">Displaying <xliff:g id="count">%d</xliff:g> contacts</item>
+    </plurals>
+
+    <!-- Displayed at the top of the contacts showing the zero total number of contacts visible when "Only contacts with phones" not selected -->
+    <string name="listTotalAllContactsZero">No visible contacts</string>
+
+    <!-- Displayed at the top of the contacts showing the total number of contacts found when "Only contacts with phones" not selected -->
+    <plurals name="listFoundAllContacts">
+        <item quantity="one">Found 1 contact</item>
+        <item quantity="other">Found <xliff:g id="count">%d</xliff:g> contacts</item>
+    </plurals>
+
+    <!-- Displayed at the top of the contacts showing the zero total number of contacts found when "Only contacts with phones" not selected -->
+    <string name="listFoundAllContactsZero">Contact not found</string>
 
     <!-- The description text for the social activity stream tab. Space is limited for this string, so the shorter the better -->
     <string name="socialStreamIconLabel">Social</string>
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index a0dcd6f..4125d7a 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -233,7 +233,7 @@
             56 | MODE_MASK_PICKER | MODE_MASK_NO_PRESENCE | MODE_MASK_NO_FILTER;
     static final int MODE_GROUP = 57 | MODE_MASK_SHOW_PHOTOS;
     /** Run a search query */
-    static final int MODE_QUERY = 60 | MODE_MASK_NO_FILTER;
+    static final int MODE_QUERY = 60 | MODE_MASK_NO_FILTER | MODE_MASK_SHOW_NUMBER_OF_CONTACTS;
     /** Run a search query in PICK mode, but that still launches to VIEW */
     static final int MODE_QUERY_PICK_TO_VIEW = 65 | MODE_MASK_NO_FILTER | MODE_MASK_PICKER;
 
@@ -402,15 +402,7 @@
         }
 
         public void onClick(DialogInterface dialog, int which) {
-	    if (mReadOnlySourcesCnt > 0) {
-	        for (long rawContactIdToDelete: mWritableRawContactIds) {
-		    final Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI,
-                            rawContactIdToDelete);
-                    getContentResolver().delete(rawContactUri, null, null);
-		}
-            } else {
-	        getContentResolver().delete(mUri, null, null);
-            }
+            getContentResolver().delete(mUri, null, null);
         }
     }
 
@@ -890,18 +882,21 @@
                         .setPositiveButton(android.R.string.ok,
                                 new DeleteClickListener(mSelectedContactUri)).create();
             }
-            case R.id.dialog_cannot_delete_readonly_contact: {
+            case R.id.dialog_readonly_contact_hide_confirmation: {
                 return new AlertDialog.Builder(this)
                         .setTitle(R.string.deleteConfirmation_title)
                         .setIcon(android.R.drawable.ic_dialog_alert)
                         .setMessage(R.string.readOnlyContactWarning)
-                        .setPositiveButton(android.R.string.ok, null).create();
+                        .setNegativeButton(android.R.string.cancel, null)
+                        .setPositiveButton(android.R.string.ok,
+                                new DeleteClickListener(mSelectedContactUri)).create();
             }
             case R.id.dialog_readonly_contact_delete_confirmation: {
                 return new AlertDialog.Builder(this)
                         .setTitle(R.string.deleteConfirmation_title)
                         .setIcon(android.R.drawable.ic_dialog_alert)
                         .setMessage(R.string.readOnlyContactDeleteConfirmation)
+                        .setNegativeButton(android.R.string.cancel, null)
                         .setPositiveButton(android.R.string.ok,
                                 new DeleteClickListener(mSelectedContactUri)).create();
             }
@@ -910,6 +905,7 @@
                         .setTitle(R.string.deleteConfirmation_title)
                         .setIcon(android.R.drawable.ic_dialog_alert)
                         .setMessage(R.string.multipleContactDeleteConfirmation)
+                        .setNegativeButton(android.R.string.cancel, null)
                         .setPositiveButton(android.R.string.ok,
                                 new DeleteClickListener(mSelectedContactUri)).create();
             }
@@ -1178,7 +1174,7 @@
 	    if (mReadOnlySourcesCnt > 0 && mWritableSourcesCnt > 0) {
 	        showDialog(R.id.dialog_readonly_contact_delete_confirmation);
 	    } else if (mReadOnlySourcesCnt > 0 && mWritableSourcesCnt == 0) {
-	        showDialog(R.id.dialog_cannot_delete_readonly_contact);
+	        showDialog(R.id.dialog_readonly_contact_hide_confirmation);
 	    } else if (mReadOnlySourcesCnt == 0 && mWritableSourcesCnt > 1) {
 	        showDialog(R.id.dialog_multiple_contact_delete_confirmation);
             } else {
@@ -2215,14 +2211,7 @@
 
             // handle the total contacts item
             if (position == 0 && (mMode & MODE_MASK_SHOW_NUMBER_OF_CONTACTS) != 0) {
-                final LayoutInflater inflater = getLayoutInflater();
-                TextView totalContacts = (TextView) inflater.inflate(R.layout.total_contacts,
-                        parent, false);
-                int stringId = mDisplayOnlyPhones ? R.string.listTotalPhoneContacts
-                        : R.string.listTotalAllContacts;
-
-                totalContacts.setText(getString(stringId, getRealCount()));
-                return totalContacts;
+                return getTotalContactCountView(parent);
             }
 
             if (isShowAllContactsItemPosition(position)) {
@@ -2267,6 +2256,40 @@
             return v;
         }
 
+        private View getTotalContactCountView(ViewGroup parent) {
+            final LayoutInflater inflater = getLayoutInflater();
+            TextView totalContacts = (TextView) inflater.inflate(R.layout.total_contacts,
+                    parent, false);
+
+            String text;
+            int count = getRealCount();
+
+            if (mMode == MODE_QUERY || !TextUtils.isEmpty(getListView().getTextFilter())) {
+                text = getQuantityText(count, R.string.listFoundAllContactsZero,
+                        R.plurals.listFoundAllContacts);
+            } else {
+                if (mDisplayOnlyPhones) {
+                    text = getQuantityText(count, R.string.listTotalPhoneContactsZero,
+                            R.plurals.listTotalPhoneContacts);
+                } else {
+                    text = getQuantityText(count, R.string.listTotalAllContactsZero,
+                            R.plurals.listTotalAllContacts);
+                }
+            }
+            totalContacts.setText(text);
+            return totalContacts;
+        }
+
+        // TODO: fix PluralRules to handle zero correctly and use Resources.getQuantityText directly
+        private String getQuantityText(int count, int zeroResourceId, int pluralResourceId) {
+            if (count == 0) {
+                return getString(zeroResourceId);
+            } else {
+                String format = getResources().getQuantityText(pluralResourceId, count).toString();
+                return String.format(format, count);
+            }
+        }
+
         private boolean isShowAllContactsItemPosition(int position) {
             return mMode == MODE_JOIN_CONTACT && mJoinModeShowAllContacts
                     && mSuggestionsCursorCount != 0 && position == mSuggestionsCursorCount + 2;
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java
index ab8e931..d6ab83c 100644
--- a/src/com/android/contacts/ViewContactActivity.java
+++ b/src/com/android/contacts/ViewContactActivity.java
@@ -91,6 +91,7 @@
     private static final int DIALOG_CONFIRM_DELETE = 1;
     private static final int DIALOG_CONFIRM_READONLY_DELETE = 2;
     private static final int DIALOG_CONFIRM_MULTIPLE_DELETE = 3;
+    private static final int DIALOG_CONFIRM_READONLY_HIDE = 4;
 
     private static final int REQUEST_JOIN_CONTACT = 1;
     private static final int REQUEST_EDIT_CONTACT = 2;
@@ -146,15 +147,7 @@
 
     public void onClick(DialogInterface dialog, int which) {
         closeCursor();
-	if (mReadOnlySourcesCnt > 0) {
-	    for (long rawContactIdToDelete: mWritableRawContactIds) {
-		final Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI,
-                        rawContactIdToDelete);
-                getContentResolver().delete(rawContactUri, null, null);
-            }
-        } else {
-	    getContentResolver().delete(mLookupUri, null, null);
-	}
+        getContentResolver().delete(mLookupUri, null, null);
         finish();
     }
 
@@ -264,6 +257,15 @@
                         .setPositiveButton(android.R.string.ok, this)
                         .setCancelable(false)
                         .create();
+	    case DIALOG_CONFIRM_READONLY_HIDE: {
+                return new AlertDialog.Builder(this)
+                        .setTitle(R.string.deleteConfirmation_title)
+                        .setIcon(android.R.drawable.ic_dialog_alert)
+                        .setMessage(R.string.readOnlyContactWarning)
+                        .setPositiveButton(android.R.string.ok, this)
+			.create();
+            }
+
         }
         return null;
     }
@@ -384,10 +386,6 @@
         final boolean hasRawContact = (mRawContactIds.size() > 0);
         menu.findItem(R.id.menu_edit).setEnabled(hasRawContact);
 
-        // Disable delete for readonly contact
-	if (mWritableSourcesCnt == 0) {
-            menu.findItem(R.id.menu_delete).setEnabled(false);
-        }
         return true;
     }
 
@@ -446,7 +444,9 @@
                 // Get confirmation
 		if (mReadOnlySourcesCnt > 0 & mWritableSourcesCnt > 0) {
                     showDialog(DIALOG_CONFIRM_READONLY_DELETE);
-		} else if (mWritableSourcesCnt > 1) {
+		} else if (mReadOnlySourcesCnt > 0 && mWritableSourcesCnt == 0) {
+                    showDialog(DIALOG_CONFIRM_READONLY_HIDE);
+		} else if (mReadOnlySourcesCnt == 0 && mWritableSourcesCnt > 1) {
 		    showDialog(DIALOG_CONFIRM_MULTIPLE_DELETE);
 		} else {
 		    showDialog(DIALOG_CONFIRM_DELETE);
@@ -649,7 +649,9 @@
             case KeyEvent.KEYCODE_DEL: {
 		if (mReadOnlySourcesCnt > 0 & mWritableSourcesCnt > 0) {
                     showDialog(DIALOG_CONFIRM_READONLY_DELETE);
-		} else if (mWritableSourcesCnt > 1) {
+		} else if (mReadOnlySourcesCnt > 0 && mWritableSourcesCnt == 0) {
+                    showDialog(DIALOG_CONFIRM_READONLY_HIDE);
+		} else if (mReadOnlySourcesCnt == 0 && mWritableSourcesCnt > 1) {
 		    showDialog(DIALOG_CONFIRM_MULTIPLE_DELETE);
 		} else {
 		    showDialog(DIALOG_CONFIRM_DELETE);
@@ -725,6 +727,15 @@
                 if (!mRawContactIds.contains(rawContactId)) {
                     mRawContactIds.add(rawContactId);
                 }
+                ContactsSource contactsSource = sources.getInflatedSource(accountType,
+                        ContactsSource.LEVEL_SUMMARY);
+                if (contactsSource != null && contactsSource.readOnly) {
+                    mReadOnlySourcesCnt += 1;
+                } else {
+                    mWritableSourcesCnt += 1;
+		    mWritableRawContactIds.add(rawContactId);
+		}
+
 
                 for (NamedContentValues subValue : entity.getSubValues()) {
                     ViewEntry entry = new ViewEntry();
diff --git a/src/com/android/contacts/ui/EditContactActivity.java b/src/com/android/contacts/ui/EditContactActivity.java
index 36c1551..fef6a9f 100644
--- a/src/com/android/contacts/ui/EditContactActivity.java
+++ b/src/com/android/contacts/ui/EditContactActivity.java
@@ -19,7 +19,6 @@
 import com.android.contacts.ContactsListActivity;
 import com.android.contacts.ContactsUtils;
 import com.android.contacts.R;
-import com.android.contacts.ScrollingTabWidget;
 import com.android.contacts.model.ContactsSource;
 import com.android.contacts.model.Editor;
 import com.android.contacts.model.EntityDelta;
@@ -30,10 +29,8 @@
 import com.android.contacts.model.Editor.EditorListener;
 import com.android.contacts.model.EntityDelta.ValuesDelta;
 import com.android.contacts.ui.widget.ContactEditorView;
-import com.android.contacts.ui.widget.PhotoEditorView;
 import com.android.contacts.util.EmptyService;
 import com.android.contacts.util.WeakAsyncTask;
-import com.android.internal.widget.ContactHeaderWidget;
 import com.google.android.collect.Lists;
 
 import android.accounts.Account;
@@ -108,6 +105,10 @@
 
     private long mRawContactIdRequestingPhoto = -1;
 
+    private static final int DIALOG_CONFIRM_DELETE = 1;
+    private static final int DIALOG_CONFIRM_READONLY_DELETE = 2;
+    private static final int DIALOG_CONFIRM_MULTIPLE_DELETE = 3;
+    private static final int DIALOG_CONFIRM_READONLY_HIDE = 4;
 
     String mQuerySelection;
 
@@ -243,6 +244,48 @@
         }
     }
 
+    @Override
+    protected Dialog onCreateDialog(int id) {
+        switch (id) {
+            case DIALOG_CONFIRM_DELETE:
+                return new AlertDialog.Builder(this)
+                        .setTitle(R.string.deleteConfirmation_title)
+                        .setIcon(android.R.drawable.ic_dialog_alert)
+                        .setMessage(R.string.deleteConfirmation)
+                        .setNegativeButton(android.R.string.cancel, null)
+                        .setPositiveButton(android.R.string.ok, new DeleteClickListener())
+                        .setCancelable(false)
+                        .create();
+            case DIALOG_CONFIRM_READONLY_DELETE:
+                return new AlertDialog.Builder(this)
+                        .setTitle(R.string.deleteConfirmation_title)
+                        .setIcon(android.R.drawable.ic_dialog_alert)
+                        .setMessage(R.string.readOnlyContactDeleteConfirmation)
+                        .setNegativeButton(android.R.string.cancel, null)
+                        .setPositiveButton(android.R.string.ok, new DeleteClickListener())
+                        .setCancelable(false)
+                        .create();
+            case DIALOG_CONFIRM_MULTIPLE_DELETE:
+                return new AlertDialog.Builder(this)
+                        .setTitle(R.string.deleteConfirmation_title)
+                        .setIcon(android.R.drawable.ic_dialog_alert)
+                        .setMessage(R.string.multipleContactDeleteConfirmation)
+                        .setNegativeButton(android.R.string.cancel, null)
+                        .setPositiveButton(android.R.string.ok, new DeleteClickListener())
+                        .setCancelable(false)
+                        .create();
+            case DIALOG_CONFIRM_READONLY_HIDE:
+                return new AlertDialog.Builder(this)
+                        .setTitle(R.string.deleteConfirmation_title)
+                        .setIcon(android.R.drawable.ic_dialog_alert)
+                        .setMessage(R.string.readOnlyContactWarning)
+                        .setPositiveButton(android.R.string.ok, new DeleteClickListener())
+                        .setCancelable(false)
+                        .create();
+        }
+        return null;
+    }
+
     /**
      * Start managing this {@link Dialog} along with the {@link Activity}.
      */
@@ -358,15 +401,13 @@
         switch (requestCode) {
             case PHOTO_PICKED_WITH_DATA: {
                 ContactEditorView requestingEditor = null;
-                if (mRawContactIdRequestingPhoto > 0) {
-                    for (int i = 0; i < mContent.getChildCount(); i++) {
-                        View childView = mContent.getChildAt(i);
-                        if (childView instanceof ContactEditorView) {
-                            ContactEditorView editor = (ContactEditorView) childView;
-                            if (editor.getRawContactId() == mRawContactIdRequestingPhoto) {
-                                requestingEditor = editor;
-                                break;
-                            }
+                for (int i = 0; i < mContent.getChildCount(); i++) {
+                    View childView = mContent.getChildAt(i);
+                    if (childView instanceof ContactEditorView) {
+                        ContactEditorView editor = (ContactEditorView) childView;
+                        if (editor.getRawContactId() == mRawContactIdRequestingPhoto) {
+                            requestingEditor = editor;
+                            break;
                         }
                     }
                 }
@@ -398,6 +439,14 @@
 
         MenuInflater inflater = getMenuInflater();
         inflater.inflate(R.menu.edit, menu);
+
+
+        return true;
+    }
+
+    @Override
+    public boolean onPrepareOptionsMenu(Menu menu) {
+        menu.findItem(R.id.menu_split).setVisible(mState != null && mState.size() > 1);
         return true;
     }
 
@@ -563,6 +612,20 @@
         return true;
     }
 
+    private class DeleteClickListener implements DialogInterface.OnClickListener {
+
+        public void onClick(DialogInterface dialog, int which) {
+            Sources sources = Sources.getInstance(EditContactActivity.this);
+            // Mark all raw contacts for deletion
+            for (EntityDelta delta : mState) {
+                delta.markDeleted();
+            }
+            // Save the deletes
+            doSaveAction(SAVE_MODE_DEFAULT);
+            finish();
+        }
+    }
+
     private void onSaveCompleted(boolean success, int saveMode, Uri contactLookupUri) {
         switch (saveMode) {
             case SAVE_MODE_DEFAULT:
@@ -699,9 +762,30 @@
      */
     private boolean doDeleteAction() {
         if (!hasValidState()) return false;
+        int readOnlySourcesCnt = 0;
+	int writableSourcesCnt = 0;
+        Sources sources = Sources.getInstance(EditContactActivity.this);
+        for (EntityDelta delta : mState) {
+	    final String accountType = delta.getValues().getAsString(RawContacts.ACCOUNT_TYPE);
+            final ContactsSource contactsSource = sources.getInflatedSource(accountType,
+                    ContactsSource.LEVEL_CONSTRAINTS);
+            if (contactsSource != null && contactsSource.readOnly) {
+                readOnlySourcesCnt += 1;
+            } else {
+                writableSourcesCnt += 1;
+            }
+	}
 
-        showAndManageDialog(createDeleteDialog());
-        return true;
+        if (readOnlySourcesCnt > 0 && writableSourcesCnt > 0) {
+	    showDialog(DIALOG_CONFIRM_READONLY_DELETE);
+	} else if (readOnlySourcesCnt > 0 && writableSourcesCnt == 0) {
+	    showDialog(DIALOG_CONFIRM_READONLY_HIDE);
+	} else if (readOnlySourcesCnt == 0 && writableSourcesCnt > 1) {
+	    showDialog(DIALOG_CONFIRM_MULTIPLE_DELETE);
+        } else {
+	    showDialog(DIALOG_CONFIRM_DELETE);
+	}
+	return true;
     }
 
     /**
@@ -727,8 +811,27 @@
     }
 
     private boolean doSplitContactAction() {
-        mState.splitRawContacts();
-        return doSaveAction(SAVE_MODE_SPLIT);
+        if (!hasValidState()) return false;
+
+        showAndManageDialog(createSplitDialog());
+        return true;
+    }
+
+    private Dialog createSplitDialog() {
+        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
+        builder.setTitle(R.string.splitConfirmation_title);
+        builder.setIcon(android.R.drawable.ic_dialog_alert);
+        builder.setMessage(R.string.splitConfirmation);
+        builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+            public void onClick(DialogInterface dialog, int which) {
+                // Split the contacts
+                mState.splitRawContacts();
+                doSaveAction(SAVE_MODE_SPLIT);
+            }
+        });
+        builder.setNegativeButton(android.R.string.cancel, null);
+        builder.setCancelable(false);
+        return builder.create();
     }
 
     private boolean doJoinContactAction() {
diff --git a/src/com/android/contacts/ui/QuickContactWindow.java b/src/com/android/contacts/ui/QuickContactWindow.java
index 756dd1e..747c204 100644
--- a/src/com/android/contacts/ui/QuickContactWindow.java
+++ b/src/com/android/contacts/ui/QuickContactWindow.java
@@ -1328,27 +1328,27 @@
         final CheckableImageView actionView = isActionView ? (CheckableImageView)view : null;
         final Object tag = view.getTag();
         if (tag instanceof Action) {
+            // Incoming tag is concrete intent, so try launching
+            final Action action = (Action)tag;
+
+            try {
+                mContext.startActivity(action.getIntent());
+            } catch (ActivityNotFoundException e) {
+                Toast.makeText(mContext, R.string.quickcontact_missing_app, Toast.LENGTH_SHORT)
+                        .show();
+            }
+
             // Hide the resolution list, if present
             setResolveVisible(false, actionView);
             this.dismiss();
 
-            try {
-                // Incoming tag is concrete intent, so try launching
-                final Action action = (Action)tag;
-                mContext.startActivity(action.getIntent());
-
-                if (mMakePrimary) {
-                    ContentValues values = new ContentValues(1);
-                    values.put(Data.IS_SUPER_PRIMARY, 1);
-                    final Uri dataUri = action.getDataUri();
-                    if (dataUri != null) {
-                        mContext.getContentResolver().update(dataUri, values, null, null);
-                    }
+            if (mMakePrimary) {
+                ContentValues values = new ContentValues(1);
+                values.put(Data.IS_SUPER_PRIMARY, 1);
+                final Uri dataUri = action.getDataUri();
+                if (dataUri != null) {
+                    mContext.getContentResolver().update(dataUri, values, null, null);
                 }
-
-            } catch (ActivityNotFoundException e) {
-                Toast.makeText(mContext, R.string.quickcontact_missing_app, Toast.LENGTH_SHORT)
-                        .show();
             }
         } else if (tag instanceof ActionList) {
             // Incoming tag is a MIME-type, so show resolution list