am e8bcbd31: am 06a3b269: am 1a10b8f7: am e4a62a76: am 7b44fda9: Merge "Set mailbox uiSyncStatus when IMAP and POP folders are created" into ub-gmail-ur14-dev
* commit 'e8bcbd3159862f07bf53e709221a4d0389e54701':
Set mailbox uiSyncStatus when IMAP and POP folders are created
diff --git a/provider_src/com/android/email/mail/Store.java b/provider_src/com/android/email/mail/Store.java
index 377b594..310238f 100644
--- a/provider_src/com/android/email/mail/Store.java
+++ b/provider_src/com/android/email/mail/Store.java
@@ -156,6 +156,16 @@
return true;
}
+ /**
+ * Some protocols allow for syncing of folder types other than inbox. The store for any such
+ * protocol should override this to return what types can be synced.
+ * @param type The type of mailbox
+ * @return true if the given type of mailbox can be synced.
+ */
+ public boolean canSyncFolderType(final int type) {
+ return (type == Mailbox.TYPE_INBOX);
+ }
+
public Folder getFolder(String name) throws MessagingException {
return null;
}
diff --git a/provider_src/com/android/email/mail/store/ImapStore.java b/provider_src/com/android/email/mail/store/ImapStore.java
index 89667eb..0aee551 100644
--- a/provider_src/com/android/email/mail/store/ImapStore.java
+++ b/provider_src/com/android/email/mail/store/ImapStore.java
@@ -40,6 +40,7 @@
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.Credential;
+import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.HostAuth;
import com.android.emailcommon.provider.Mailbox;
import com.android.emailcommon.service.EmailServiceProxy;
@@ -133,6 +134,26 @@
return mPassword;
}
+ public boolean canSyncFolderType(final int type) {
+ switch (type) {
+ case Mailbox.TYPE_INBOX:
+ case Mailbox.TYPE_MAIL:
+ case Mailbox.TYPE_SENT:
+ case Mailbox.TYPE_TRASH:
+ case Mailbox.TYPE_JUNK:
+ return true;
+ case Mailbox.TYPE_NONE:
+ case Mailbox.TYPE_PARENT:
+ case Mailbox.TYPE_DRAFTS:
+ case Mailbox.TYPE_OUTBOX:
+ case Mailbox.TYPE_SEARCH:
+ case Mailbox.TYPE_STARRED:
+ case Mailbox.TYPE_UNREAD:
+ default:
+ return false;
+ }
+ }
+
@VisibleForTesting
Collection<ImapConnection> getConnectionPoolForTest() {
return mConnectionPool;
@@ -373,6 +394,11 @@
// outside of #saveMailboxList()
folder.mHash = mailbox.getHashes();
// We must save this here to make sure we have a valid ID for later
+
+ // This is a newly created folder from the server. By definition, if it came from
+ // the server, it can be synched. We need to set the uiSyncStatus so that the UI
+ // will not try to display the empty state until the sync completes.
+ mailbox.mUiSyncStatus = EmailContent.SYNC_STATUS_INITIAL_SYNC_NEEDED;
mailbox.save(mContext);
}
folder.mMailbox = mailbox;
diff --git a/provider_src/com/android/email/service/EmailServiceStub.java b/provider_src/com/android/email/service/EmailServiceStub.java
index aa73d29..055c360 100644
--- a/provider_src/com/android/email/service/EmailServiceStub.java
+++ b/provider_src/com/android/email/service/EmailServiceStub.java
@@ -293,10 +293,18 @@
Cursor localFolderCursor = null;
Store store = null;
try {
+ store = Store.getInstance(account, mContext);
+
// Step 0: Make sure the default system mailboxes exist.
for (final int type : Mailbox.REQUIRED_FOLDER_TYPES) {
if (Mailbox.findMailboxOfType(mContext, accountId, type) == Mailbox.NO_MAILBOX) {
final Mailbox mailbox = Mailbox.newSystemMailbox(mContext, accountId, type);
+ if (store.canSyncFolderType(type)) {
+ // If this folder is syncable, then we should set its UISyncStatus.
+ // Otherwise the UI could show the empty state until the sync
+ // actually occurs.
+ mailbox.mUiSyncStatus = Mailbox.SYNC_STATUS_INITIAL_SYNC_NEEDED;
+ }
mailbox.save(mContext);
if (type == Mailbox.TYPE_INBOX) {
inboxId = mailbox.mId;
@@ -305,7 +313,6 @@
}
// Step 1: Get remote mailboxes
- store = Store.getInstance(account, mContext);
final Folder[] remoteFolders = store.updateFolders();
final HashSet<String> remoteFolderNames = new HashSet<String>();
for (final Folder remoteFolder : remoteFolders) {