[Issue 2149076] More wording cleanup on contacts Display Options

Change-Id: I8ec4e7ab63387fffa6f32063776176e8dbcff600
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3fdcf76..35c0bf8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -969,9 +969,12 @@
     <string name="dialog_sync_add">Add sync group</string>
     <string name="display_more_groups">More groups\u2026</string>
 
+    <!-- List title for a special contacts group that covers all contacts.-->
+    <string name="display_ungrouped">All Other Contacts</string>
+
     <!-- List title for a special contacts group that covers all contacts that
-         aren't members of any other group.  -->
-    <string name="display_ungrouped">(Ungrouped contacts)</string>
+         aren't members of any other group. -->
+    <string name="display_all_contacts">All Contacts</string>
 
     <!-- Warning message given to users just before they remove a currently syncing
          group that would also cause all ungrouped contacts to stop syncing. -->
diff --git a/src/com/android/contacts/ui/DisplayGroupsActivity.java b/src/com/android/contacts/ui/DisplayGroupsActivity.java
index dcbe0f6..7bd7b9d 100644
--- a/src/com/android/contacts/ui/DisplayGroupsActivity.java
+++ b/src/com/android/contacts/ui/DisplayGroupsActivity.java
@@ -187,6 +187,7 @@
      */
     protected static class GroupDelta extends ValuesDelta {
         private boolean mUngrouped = false;
+        private boolean mAccountHasGroups;
 
         private GroupDelta() {
             super();
@@ -197,7 +198,7 @@
          * {@link Settings#ACCOUNT_NAME} and {@link Settings#ACCOUNT_TYPE}.
          */
         public static GroupDelta fromSettings(ContentResolver resolver, String accountName,
-                String accountType) {
+                String accountType, boolean accountHasGroups) {
             final Uri settingsUri = Settings.CONTENT_URI.buildUpon()
                     .appendQueryParameter(Settings.ACCOUNT_NAME, accountName)
                     .appendQueryParameter(Settings.ACCOUNT_TYPE, accountType).build();
@@ -214,12 +215,12 @@
                     // Read existing values when present
                     values.put(Settings.SHOULD_SYNC, cursor.getInt(0));
                     values.put(Settings.UNGROUPED_VISIBLE, cursor.getInt(1));
-                    return fromBefore(values).setUngrouped();
+                    return fromBefore(values).setUngrouped(accountHasGroups);
                 } else {
                     // Nothing found, so treat as create
                     values.put(Settings.SHOULD_SYNC, DEFAULT_SHOULD_SYNC);
                     values.put(Settings.UNGROUPED_VISIBLE, DEFAULT_VISIBLE);
-                    return fromAfter(values).setUngrouped();
+                    return fromAfter(values).setUngrouped(accountHasGroups);
                 }
             } finally {
                 if (cursor != null) cursor.close();
@@ -240,8 +241,9 @@
             return entry;
         }
 
-        protected GroupDelta setUngrouped() {
+        protected GroupDelta setUngrouped(boolean accountHasGroups) {
             mUngrouped = true;
+            mAccountHasGroups = accountHasGroups;
             return this;
         }
 
@@ -270,7 +272,11 @@
 
         public CharSequence getTitle(Context context) {
             if (mUngrouped) {
-                return context.getText(R.string.display_ungrouped);
+                if (mAccountHasGroups) {
+                    return context.getText(R.string.display_ungrouped);
+                } else {
+                    return context.getText(R.string.display_all_contacts);
+                }
             } else {
                 final Integer titleRes = getAsInteger(Groups.TITLE_RES);
                 if (titleRes != null) {
@@ -359,9 +365,7 @@
             mName = accountName;
             mType = accountType;
 
-            // Create single entry handling ungrouped status
-            mUngrouped = GroupDelta.fromSettings(resolver, accountName, accountType);
-            addGroup(mUngrouped);
+            boolean hasGroups = false;
 
             final Uri groupsUri = Groups.CONTENT_URI.buildUpon()
                     .appendQueryParameter(Groups.ACCOUNT_NAME, accountName)
@@ -374,12 +378,17 @@
                     final ContentValues values = iterator.next().getEntityValues();
                     final GroupDelta group = GroupDelta.fromBefore(values);
                     addGroup(group);
+                    hasGroups = true;
                 }
             } catch (RemoteException e) {
                 Log.w(TAG, "Problem reading groups: " + e.toString());
             } finally {
                 if (iterator != null) iterator.close();
             }
+
+            // Create single entry handling ungrouped status
+            mUngrouped = GroupDelta.fromSettings(resolver, accountName, accountType, hasGroups);
+            addGroup(mUngrouped);
         }
 
         /**