auto import //branches/master/...@140412
diff --git a/src/com/android/contacts/ContactEntryAdapter.java b/src/com/android/contacts/ContactEntryAdapter.java
index c5b7ccf..869755b 100644
--- a/src/com/android/contacts/ContactEntryAdapter.java
+++ b/src/com/android/contacts/ContactEntryAdapter.java
@@ -108,6 +108,9 @@
public static final int ORGANIZATIONS_TITLE_COLUMN = 4;
public static final int ORGANIZATIONS_ISPRIMARY_COLUMN = 5;
+ /** Directory for group memberships. */
+ public static final String GROUP_CONTENT_DIRECTORY = "groupmembership";
+
protected ArrayList<ArrayList<E>> mSections;
protected LayoutInflater mInflater;
protected Context mContext;
@@ -122,7 +125,9 @@
/** Synthesized phone entry that will send an SMS instead of call the number */
public static final int KIND_SMS = -2;
/** A section separator */
- public static final int KIND_SEPARATOR = -3;
+ public static final int KIND_SEPARATOR = -3;
+ /** Signifies a group row that is stored in the group membership table */
+ public static final int KIND_GROUP = -4;
public String label;
public String data;
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index 5ba0ec5..c4dce18 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -243,12 +243,12 @@
private static final int QUERY_TOKEN = 42;
- private static final String[] GROUPS_PROJECTION = new String[] {
+ static final String[] GROUPS_PROJECTION = new String[] {
Groups.SYSTEM_ID, // 0
Groups.NAME, // 1
};
- private static final int GROUPS_COLUMN_INDEX_SYSTEM_ID = 0;
- private static final int GROUPS_COLUMN_INDEX_NAME = 1;
+ static final int GROUPS_COLUMN_INDEX_SYSTEM_ID = 0;
+ static final int GROUPS_COLUMN_INDEX_NAME = 1;
static final String GROUP_WITH_PHONES = "android_smartgroup_phone";
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java
index 99e72b0..bb9c42d 100644
--- a/src/com/android/contacts/ViewContactActivity.java
+++ b/src/com/android/contacts/ViewContactActivity.java
@@ -73,6 +73,7 @@
import android.provider.Contacts;
import android.provider.Im;
import android.provider.Contacts.ContactMethods;
+import android.provider.Contacts.Groups;
import android.provider.Contacts.Organizations;
import android.provider.Contacts.People;
import android.provider.Contacts.Phones;
@@ -136,6 +137,7 @@
/* package */ ArrayList<ViewEntry> mPostalEntries = new ArrayList<ViewEntry>();
/* package */ ArrayList<ViewEntry> mImEntries = new ArrayList<ViewEntry>();
/* package */ ArrayList<ViewEntry> mOrganizationEntries = new ArrayList<ViewEntry>();
+ /* package */ ArrayList<ViewEntry> mGroupEntries = new ArrayList<ViewEntry>();
/* package */ ArrayList<ViewEntry> mOtherEntries = new ArrayList<ViewEntry>();
/* package */ ArrayList<ArrayList<ViewEntry>> mSections = new ArrayList<ArrayList<ViewEntry>>();
@@ -229,6 +231,7 @@
mSections.add(mImEntries);
mSections.add(mPostalEntries);
mSections.add(mOrganizationEntries);
+ mSections.add(mGroupEntries);
mSections.add(mOtherEntries);
//TODO Read this value from a preference
@@ -576,6 +579,11 @@
separator = new ViewEntry();
separator.kind = ViewEntry.KIND_SEPARATOR;
+ separator.data = getString(R.string.listSeparatorGroups);
+ mGroupEntries.add(separator);
+
+ separator = new ViewEntry();
+ separator.kind = ViewEntry.KIND_SEPARATOR;
separator.data = getString(R.string.listSeparatorOtherInformation);
mOtherEntries.add(separator);
}
@@ -845,6 +853,47 @@
organizationsCursor.close();
}
+ // Build the group entries
+ final Uri groupsUri = Uri.withAppendedPath(mUri,
+ ContactEntryAdapter.GROUP_CONTENT_DIRECTORY);
+ Cursor cursor = mResolver.query(groupsUri, ContactsListActivity.GROUPS_PROJECTION,
+ null, null, Groups.DEFAULT_SORT_ORDER);
+ try {
+ ArrayList<CharSequence> groups = new ArrayList<CharSequence>();
+ ArrayList<CharSequence> prefStrings = new ArrayList<CharSequence>();
+ StringBuilder sb = new StringBuilder();
+
+ while (cursor.moveToNext()) {
+ String systemId = cursor.getString(
+ ContactsListActivity.GROUPS_COLUMN_INDEX_SYSTEM_ID);
+
+ if (systemId != null || Groups.GROUP_MY_CONTACTS.equals(systemId)) {
+ continue;
+ }
+
+ String name = cursor.getString(ContactsListActivity.GROUPS_COLUMN_INDEX_NAME);
+ if (!TextUtils.isEmpty(name)) {
+ if (sb.length() == 0) {
+ sb.append(name);
+ } else {
+ sb.append(getString(R.string.group_list, name));
+ }
+ }
+ }
+
+ if (sb.length() > 0) {
+ ViewEntry entry = new ViewEntry();
+ entry.kind = ContactEntryAdapter.Entry.KIND_GROUP;
+ entry.label = getString(R.string.label_groups);
+ entry.data = sb.toString();
+
+ // TODO: Add an icon for the groups item.
+
+ mGroupEntries.add(entry);
+ }
+ } finally {
+ cursor.close();
+ }
// Build the other entries
String note = personCursor.getString(CONTACT_NOTES_COLUMN);