From 3c7f0d4c000f24e39fb4b0f1e10f762f5ff011c9 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Fri, 11 Sep 2009 08:53:07 -0700 Subject: [PATCH] Make exchange contact category names visible; also their members Change-Id: Icaf7c2828db4fda7323b3ec3a6c9cd783ae80c9a --- .../exchange/adapter/ContactsSyncAdapter.java | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/com/android/exchange/adapter/ContactsSyncAdapter.java b/src/com/android/exchange/adapter/ContactsSyncAdapter.java index 1fb885ecd..db28a102f 100644 --- a/src/com/android/exchange/adapter/ContactsSyncAdapter.java +++ b/src/com/android/exchange/adapter/ContactsSyncAdapter.java @@ -112,7 +112,9 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { ArrayList mDeletedIdList = new ArrayList(); ArrayList mUpdatedIdList = new ArrayList(); - android.accounts.Account mAccountManagerAccount; + private boolean mGroupsUsed = false; + + private android.accounts.Account mAccountManagerAccount; public ContactsSyncAdapter(Mailbox mailbox, EasSyncService service) { super(mailbox, service); @@ -522,14 +524,11 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { ops.addNote(entity, getValue()); break; - // TODO Handle Categories/Category - // If we don't handle this properly, we'll lose the information if/when we - // upload changes to the server! case Tags.CONTACTS_CATEGORIES: + mGroupsUsed = true; categoriesParser(ops, entity); break; - case Tags.CONTACTS_COMPRESSED_RTF: // We don't use this, and it isn't necessary to upload, so we'll ignore it skipTag(); @@ -1379,6 +1378,28 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { .build()); } ops.execute(); + ContentResolver cr = mContext.getContentResolver(); + if (mGroupsUsed) { + // Make sure the title column is set for all of our groups + // And that all of our groups are visible + // TODO Perhaps the visible part should only happen when the group is created, but + // this is fine for now. + Uri groupsUri = uriWithAccount(Groups.CONTENT_URI); + Cursor c = cr.query(groupsUri, new String[] {Groups.SOURCE_ID, Groups.TITLE}, + Groups.TITLE + " IS NULL", null, null); + ContentValues values = new ContentValues(); + values.put(Groups.GROUP_VISIBLE, 1); + try { + while (c.moveToNext()) { + String sourceId = c.getString(0); + values.put(Groups.TITLE, sourceId); + cr.update(uriWithAccount(groupsUri), values, Groups.SOURCE_ID + "=?", + new String[] {sourceId}); + } + } finally { + c.close(); + } + } } @Override