Address various groups TODOs and small bug fixes

* Style the group name edit dialog with standard min
  width style.  Also restrict names to be a single
  line and add a hint to the EditText.  Finally,
  bring up the keyboard when the dialog is first created.
* Change the "edit" group menu option name to "rename",
  remove the icon, and keep it under the overflow.
* Sort groups consistently on the main list and contact
  editor spinnner.
* Don't load deleted groups. We don't need to  handle
  deleted groups in the members loader because the metadata
  loader omits them in the selection clause.
* Show a toast after deleting a group.  Also don't prompt
  for confirmation when deleting if the group is empty.
* Remove some unnecessary header binding in the group member
  list adapter.

Bug 28955365
Bug 28936603
Bug 18641067

Change-Id: Icec1e1d3bbafb7e1e94a7e841860836d256177f1
diff --git a/src/com/android/contacts/ContactSaveService.java b/src/com/android/contacts/ContactSaveService.java
index 08eb1c7..b9fc949 100755
--- a/src/com/android/contacts/ContactSaveService.java
+++ b/src/com/android/contacts/ContactSaveService.java
@@ -46,6 +46,7 @@
 import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.RawContactsEntity;
 import android.support.v4.os.ResultReceiver;
+import android.text.TextUtils;
 import android.util.Log;
 import android.widget.Toast;
 
@@ -777,10 +778,19 @@
     /**
      * Creates an intent that can be sent to this service to delete a group.
      */
-    public static Intent createGroupDeletionIntent(Context context, long groupId) {
+    public static Intent createGroupDeletionIntent(Context context, long groupId,
+            Class<? extends Activity> callbackActivity, String callbackAction) {
         Intent serviceIntent = new Intent(context, ContactSaveService.class);
         serviceIntent.setAction(ContactSaveService.ACTION_DELETE_GROUP);
         serviceIntent.putExtra(ContactSaveService.EXTRA_GROUP_ID, groupId);
+
+        // Callback intent will be invoked by the service once the group is updated
+        if (callbackActivity != null && !TextUtils.isEmpty(callbackAction)) {
+            final Intent callbackIntent = new Intent(context, callbackActivity);
+            callbackIntent.setAction(callbackAction);
+            serviceIntent.putExtra(ContactSaveService.EXTRA_CALLBACK_INTENT, callbackIntent);
+        }
+
         return serviceIntent;
     }
 
@@ -793,6 +803,13 @@
 
         getContentResolver().delete(
                 ContentUris.withAppendedId(Groups.CONTENT_URI, groupId), null, null);
+
+        final Intent callbackIntent = intent.getParcelableExtra(EXTRA_CALLBACK_INTENT);
+        if (callbackIntent != null) {
+            final Uri groupUri = ContentUris.withAppendedId(Groups.CONTENT_URI, groupId);
+            callbackIntent.setData(groupUri);
+            deliverCallback(callbackIntent);
+        }
     }
 
     /**