Group editor on tablet

- Allow autocomplete to add new members which presents
the user with suggestions from the raw_contacts table
with the same account name and type as the group
- Hook up the "new" and "edit" group buttons on the tablet
- Once the user exits the editor, update the group list
and scroll the group list to the group that was just edited
- Allow rename of groups (make the names of read-only groups
not editable)
- Allow removal of members
- Hook up the done / cancel / up / back buttons

- TODO: Be able to create a new group + add new members
in the same transaction. Then the new group editor
will allow adding members at the same time. Currently
you can only add a name to a new group. Once it's created,
then you can go and edit the membership.

- TODO: Bulk add/remove members in one transaction when the
user exits the editor. Currently it's saving the change
after you modify the membership list (even before you hit
the "Done" button in the editor).

- TODO: Add member status message and chat presence

- TODO: Add UI for non-editable groups

Change-Id: I1f32a28862c358b8bd1469666743cd240d28f80b
diff --git a/src/com/android/contacts/ContactSaveService.java b/src/com/android/contacts/ContactSaveService.java
index 9b56f5b..d8dbdbc 100644
--- a/src/com/android/contacts/ContactSaveService.java
+++ b/src/com/android/contacts/ContactSaveService.java
@@ -396,6 +396,7 @@
         values.put(GroupMembership.GROUP_ROW_ID, ContentUris.parseId(groupUri));
 
         Intent callbackIntent = intent.getParcelableExtra(EXTRA_CALLBACK_INTENT);
+        callbackIntent.setData(groupUri);
         callbackIntent.putExtra(ContactsContract.Intents.Insert.DATA, Lists.newArrayList(values));
 
         deliverCallback(callbackIntent);
@@ -404,11 +405,18 @@
     /**
      * Creates an intent that can be sent to this service to rename a group.
      */
-    public static Intent createGroupRenameIntent(Context context, long groupId, String newLabel) {
+    public static Intent createGroupRenameIntent(Context context, long groupId, String newLabel,
+            Class<?> callbackActivity, String callbackAction) {
         Intent serviceIntent = new Intent(context, ContactSaveService.class);
         serviceIntent.setAction(ContactSaveService.ACTION_RENAME_GROUP);
         serviceIntent.putExtra(ContactSaveService.EXTRA_GROUP_ID, groupId);
         serviceIntent.putExtra(ContactSaveService.EXTRA_GROUP_LABEL, newLabel);
+
+        // Callback intent will be invoked by the service once the group is renamed.
+        Intent callbackIntent = new Intent(context, callbackActivity);
+        callbackIntent.setAction(callbackAction);
+        serviceIntent.putExtra(ContactSaveService.EXTRA_CALLBACK_INTENT, callbackIntent);
+
         return serviceIntent;
     }
 
@@ -423,8 +431,12 @@
 
         ContentValues values = new ContentValues();
         values.put(Groups.TITLE, label);
-        getContentResolver().update(
-                ContentUris.withAppendedId(Groups.CONTENT_URI, groupId), values, null, null);
+        final Uri groupUri = ContentUris.withAppendedId(Groups.CONTENT_URI, groupId);
+        getContentResolver().update(groupUri, values, null, null);
+
+        Intent callbackIntent = intent.getParcelableExtra(EXTRA_CALLBACK_INTENT);
+        callbackIntent.setData(groupUri);
+        deliverCallback(callbackIntent);
     }
 
     /**