From 157a9bd57d4776b820579835850b9c432cb8e5a4 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 10 Apr 2012 09:52:59 -0700 Subject: [PATCH] Set acct sync status to "initial sync needed" until inbox exists * Notify on account when mailboxes are added Change-Id: I8b78c37b5305a28a261a82308bb5bf88c0728fdc --- .../android/email/provider/EmailProvider.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/email2/src/com/android/email/provider/EmailProvider.java b/email2/src/com/android/email/provider/EmailProvider.java index 44e8bf969..22b7de610 100644 --- a/email2/src/com/android/email/provider/EmailProvider.java +++ b/email2/src/com/android/email/provider/EmailProvider.java @@ -1027,6 +1027,11 @@ public class EmailProvider extends ContentProvider { break; } } + // Notify the account when a new mailbox is added + Long accountId = values.getAsLong(MailboxColumns.ACCOUNT_KEY); + if (accountId != null && accountId.longValue() > 0) { + notifyUI(UIPROVIDER_ACCOUNT_NOTIFIER, id); + } //$FALL-THROUGH$ case ACCOUNT: case HOSTAUTH: @@ -2486,13 +2491,6 @@ outer: getExternalUriStringEmail2("compose", id)); values.put(UIProvider.AccountColumns.MIME_TYPE, EMAIL_APP_MIME_TYPE); - - // Put the settings columns values - long mailboxId = Mailbox.findMailboxOfType(getContext(), accountId, Mailbox.TYPE_INBOX); - if (mailboxId != Mailbox.NO_MAILBOX) { - values.put(UIProvider.AccountColumns.SettingsColumns.DEFAULT_INBOX, - uiUriString("uifolder", mailboxId)); - } Preferences prefs = Preferences.getPreferences(getContext()); values.put(UIProvider.AccountColumns.SettingsColumns.CONFIRM_DELETE, prefs.getConfirmDelete() ? "1" : "0"); @@ -2506,6 +2504,15 @@ outer: int textZoom = prefs.getTextZoom(); values.put(UIProvider.AccountColumns.SettingsColumns.MESSAGE_TEXT_SIZE, textZoomToUiValue(textZoom)); + // Set default inbox, if we've got an inbox; otherwise, say initial sync needed + long mailboxId = Mailbox.findMailboxOfType(getContext(), accountId, Mailbox.TYPE_INBOX); + if (mailboxId != Mailbox.NO_MAILBOX) { + values.put(UIProvider.AccountColumns.SettingsColumns.DEFAULT_INBOX, + uiUriString("uifolder", mailboxId)); + } else { + values.put(UIProvider.AccountColumns.SYNC_STATUS, + UIProvider.SyncStatus.INITIAL_SYNC_NEEDED); + } StringBuilder sb = genSelect(sAccountListMap, uiProjection, values); sb.append(" FROM " + Account.TABLE_NAME + " WHERE " + AccountColumns.ID + "=?");