diff options
author | James Lemieux <jplemieux@google.com> | 2014-09-29 17:51:27 -0700 |
---|---|---|
committer | James Lemieux <jplemieux@google.com> | 2014-09-29 17:51:27 -0700 |
commit | 40236a89316ab2151a8c93de0e286c2f1a9a8d37 (patch) | |
tree | 87337a7e3d8e9824a852221348c034edbbf09263 /provider_src | |
parent | abd75d1adb299237def0d5f072a186fefea77459 (diff) | |
download | android_packages_apps_Email-40236a89316ab2151a8c93de0e286c2f1a9a8d37.tar.gz android_packages_apps_Email-40236a89316ab2151a8c93de0e286c2f1a9a8d37.tar.bz2 android_packages_apps_Email-40236a89316ab2151a8c93de0e286c2f1a9a8d37.zip |
Display sync errors using snackbar and not as a TL footer
b/16463253
The FAB compose button overlaps the action button found in the TL footer
when network errors occur during sync. To avoid this overlap, the snackbar
is used to display these errors and they no longer appear as a TL footer.
In order to signal the sync error to AAC for display in the snackbar, the
Folder.lastSyncResult needed to be encoded in the manner that AAC reads.
This was not happening for POP/IMAP/Exchange accounts, so a large portion
of this change is encoding that value properly every place it is written.
To ensure the value is read/written properly everywhere, common methods were
introduced in UIProvider that do this work. UIProviderTest was also added
to ensure the read/write methods agree with each other.
Finally, the display of the "Load More" TL footer was updated to match the
latest spec.
Change-Id: I9d3ae1157f288f05b0fed4d1385858f6c9ebfbf9
Diffstat (limited to 'provider_src')
3 files changed, 32 insertions, 24 deletions
diff --git a/provider_src/com/android/email/provider/EmailConversationCursor.java b/provider_src/com/android/email/provider/EmailConversationCursor.java index f6a17e37f..f2c481b41 100644 --- a/provider_src/com/android/email/provider/EmailConversationCursor.java +++ b/provider_src/com/android/email/provider/EmailConversationCursor.java @@ -72,8 +72,6 @@ public class EmailConversationCursor extends CursorWrapper implements if (mailbox != null) { mMailboxTypeId = mailbox.mType; - mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_ERROR, - mailbox.mUiLastSyncResult); mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_TOTAL_COUNT, mailbox.mTotalCount); if (mailbox.mUiSyncStatus == EmailContent.SYNC_STATUS_BACKGROUND || mailbox.mUiSyncStatus == EmailContent.SYNC_STATUS_USER @@ -106,8 +104,6 @@ public class EmailConversationCursor extends CursorWrapper implements } else { mMailboxTypeId = -1; // TODO for virtual mailboxes, we may want to do something besides just fake it - mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_ERROR, - UIProvider.LastSyncResult.SUCCESS); mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_TOTAL_COUNT, cursor != null ? cursor.getCount() : 0); mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_STATUS, diff --git a/provider_src/com/android/email/provider/EmailProvider.java b/provider_src/com/android/email/provider/EmailProvider.java index 52e796b3a..e4d052081 100644 --- a/provider_src/com/android/email/provider/EmailProvider.java +++ b/provider_src/com/android/email/provider/EmailProvider.java @@ -65,10 +65,10 @@ import android.util.SparseArray; import com.android.common.content.ProjectionMap; import com.android.email.DebugUtils; +import com.android.email.NotificationController; +import com.android.email.NotificationControllerCreatorHolder; import com.android.email.Preferences; import com.android.email.R; -import com.android.email.NotificationControllerCreatorHolder; -import com.android.email.NotificationController; import com.android.email.SecurityPolicy; import com.android.email.activity.setup.AccountSecurity; import com.android.email.activity.setup.AccountSettingsUtils; @@ -5751,13 +5751,13 @@ public class EmailProvider extends ContentProvider .monitorRefreshStatus(mailbox.mId, new RefreshStatusMonitor.Callback() { @Override public void onRefreshCompleted(long mailboxId, int result) { + // all calls to this method assumed to be started by a user action + final int syncValue = UIProvider.createSyncValue(EmailContent.SYNC_STATUS_USER, + result); final ContentValues values = new ContentValues(); values.put(Mailbox.UI_SYNC_STATUS, UIProvider.SyncStatus.NO_SYNC); - values.put(Mailbox.UI_LAST_SYNC_RESULT, result); - mDatabase.update( - Mailbox.TABLE_NAME, - values, - WHERE_ID, + values.put(Mailbox.UI_LAST_SYNC_RESULT, syncValue); + mDatabase.update(Mailbox.TABLE_NAME, values, WHERE_ID, new String[] { String.valueOf(mailboxId) }); notifyUIFolder(mailbox.mId, mailbox.mAccountKey); } diff --git a/provider_src/com/android/email/service/PopImapSyncAdapterService.java b/provider_src/com/android/email/service/PopImapSyncAdapterService.java index 4fae4d0a9..08a6f3adb 100644 --- a/provider_src/com/android/email/service/PopImapSyncAdapterService.java +++ b/provider_src/com/android/email/service/PopImapSyncAdapterService.java @@ -122,17 +122,21 @@ public class PopImapSyncAdapterService extends Service { Uri mailboxUri = ContentUris.withAppendedId(Mailbox.CONTENT_URI, mailboxId); ContentValues values = new ContentValues(); // Set mailbox sync state - values.put(Mailbox.UI_SYNC_STATUS, - uiRefresh ? EmailContent.SYNC_STATUS_USER : EmailContent.SYNC_STATUS_BACKGROUND); + final int syncStatus = uiRefresh ? EmailContent.SYNC_STATUS_USER : + EmailContent.SYNC_STATUS_BACKGROUND; + values.put(Mailbox.UI_SYNC_STATUS, syncStatus); resolver.update(mailboxUri, values, null, null); try { + int lastSyncResult; try { String legacyImapProtocol = context.getString(R.string.protocol_legacy_imap); if (mailbox.mType == Mailbox.TYPE_OUTBOX) { EmailServiceStub.sendMailImpl(context, account.mId); } else { + lastSyncResult = UIProvider.createSyncValue(syncStatus, + EmailContent.LAST_SYNC_RESULT_SUCCESS); EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, - EmailServiceStatus.IN_PROGRESS, 0, UIProvider.LastSyncResult.SUCCESS); + EmailServiceStatus.IN_PROGRESS, 0, lastSyncResult); final int status; if (protocol.equals(legacyImapProtocol)) { status = ImapService.synchronizeMailboxSynchronous(context, account, @@ -142,30 +146,38 @@ public class PopImapSyncAdapterService extends Service { mailbox, deltaMessageCount); } EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, status, 0, - UIProvider.LastSyncResult.SUCCESS); + lastSyncResult); } } catch (MessagingException e) { final int type = e.getExceptionType(); // type must be translated into the domain of values used by EmailServiceStatus - switch(type) { + switch (type) { case MessagingException.IOERROR: - EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0, - UIProvider.LastSyncResult.CONNECTION_ERROR); + lastSyncResult = UIProvider.createSyncValue(syncStatus, + EmailContent.LAST_SYNC_RESULT_CONNECTION_ERROR); + EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, + EmailServiceStatus.FAILURE, 0, lastSyncResult); syncResult.stats.numIoExceptions++; break; case MessagingException.AUTHENTICATION_FAILED: - EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0, - UIProvider.LastSyncResult.AUTH_ERROR); + lastSyncResult = UIProvider.createSyncValue(syncStatus, + EmailContent.LAST_SYNC_RESULT_AUTH_ERROR); + EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, + EmailServiceStatus.FAILURE, 0, lastSyncResult); syncResult.stats.numAuthExceptions++; break; case MessagingException.SERVER_ERROR: - EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0, - UIProvider.LastSyncResult.SERVER_ERROR); + lastSyncResult = UIProvider.createSyncValue(syncStatus, + EmailContent.LAST_SYNC_RESULT_SERVER_ERROR); + EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, + EmailServiceStatus.FAILURE, 0, lastSyncResult); break; default: - EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0, - UIProvider.LastSyncResult.INTERNAL_ERROR); + lastSyncResult = UIProvider.createSyncValue(syncStatus, + EmailContent.LAST_SYNC_RESULT_INTERNAL_ERROR); + EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, + EmailServiceStatus.FAILURE, 0, lastSyncResult); } } } finally { |