From 4038f464dee0a33f1e7a58102857c24edf7e0eb2 Mon Sep 17 00:00:00 2001 From: Paul Westbrook Date: Fri, 20 Jun 2014 00:09:07 -0700 Subject: [PATCH] Enable supression of combined account This enables the client of the provider to suppress the email combined account. Later, the UI can enable a combined account that spans all of the account types Change-Id: I77e201f751019240af2274a1f74e2124b9889aab --- .../com/android/emailcommon/provider/EmailContent.java | 5 +++++ src/com/android/email/provider/EmailProvider.java | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/emailcommon/src/com/android/emailcommon/provider/EmailContent.java b/emailcommon/src/com/android/emailcommon/provider/EmailContent.java index a10e91db8..0ae908d7e 100755 --- a/emailcommon/src/com/android/emailcommon/provider/EmailContent.java +++ b/emailcommon/src/com/android/emailcommon/provider/EmailContent.java @@ -144,6 +144,11 @@ public abstract class EmailContent { public static String NOTIFIER_AUTHORITY; public static Uri CONTENT_URI; public static final String PARAMETER_LIMIT = "limit"; + + /** + * Query parameter for the UI accounts query to enable suppression of the combined account. + */ + public static final String SUPPRESS_COMBINED_ACCOUNT_PARAM = "suppress_combined"; public static Uri CONTENT_NOTIFIER_URI; public static Uri PICK_TRASH_FOLDER_URI; public static Uri PICK_SENT_FOLDER_URI; diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index 479bba7a0..5779c6d53 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -1289,7 +1289,11 @@ public class EmailProvider extends ContentProvider c = uiSearch(uri, projection); return c; case UI_ACCTS: - c = uiAccounts(projection); + final String suppressParam = + uri.getQueryParameter(EmailContent.SUPPRESS_COMBINED_ACCOUNT_PARAM); + final boolean suppressCombined = + suppressParam != null && Boolean.parseBoolean(suppressParam); + c = uiAccounts(projection, suppressCombined); return c; case UI_UNDO: return uiUndo(projection); @@ -3801,7 +3805,7 @@ public class EmailProvider extends ContentProvider return values; } - private Cursor uiAccounts(String[] uiProjection) { + private Cursor uiAccounts(String[] uiProjection, boolean suppressCombined) { final Context context = getContext(); final SQLiteDatabase db = getDatabase(context); final Cursor accountIdCursor = @@ -3809,7 +3813,7 @@ public class EmailProvider extends ContentProvider final MatrixCursor mc; try { boolean combinedAccount = false; - if (accountIdCursor.getCount() > 1) { + if (!suppressCombined && accountIdCursor.getCount() > 1) { combinedAccount = true; } final Bundle extras = new Bundle();