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: Ib8692a2b9e164d25f982a2d7a54b07d2d3950358
diff --git a/src/com/android/exchange/eas/EasFullSyncOperation.java b/src/com/android/exchange/eas/EasFullSyncOperation.java
index 8714834..99c65b3 100644
--- a/src/com/android/exchange/eas/EasFullSyncOperation.java
+++ b/src/com/android/exchange/eas/EasFullSyncOperation.java
@@ -5,7 +5,6 @@
 import android.content.Context;
 import android.database.Cursor;
 import android.os.Bundle;
-import android.os.RemoteException;
 import android.provider.CalendarContract;
 import android.provider.ContactsContract;
 
@@ -240,31 +239,34 @@
             return EmailServiceStatus.SUCCESS;
         }
 
-        int result = 0;
+        int syncResult = 0;
         // Non-mailbox syncs are whole account syncs initiated by the AccountManager and are
         // treated as background syncs.
         if (mailbox.mType == Mailbox.TYPE_OUTBOX || mailbox.isSyncable()) {
             final ContentValues cv = new ContentValues(2);
-            updateMailbox(mailbox, cv, isUserSync ?
-                    EmailContent.SYNC_STATUS_USER : EmailContent.SYNC_STATUS_BACKGROUND);
+            final int syncStatus = isUserSync ?
+                    EmailContent.SYNC_STATUS_USER : EmailContent.SYNC_STATUS_BACKGROUND;
+            updateMailbox(mailbox, cv, syncStatus);
             try {
                 if (mailbox.mType == Mailbox.TYPE_OUTBOX) {
                     return syncOutbox(mailbox.mId);
                 }
                 if (hasCallbackMethod) {
-                    EmailServiceStatus.syncMailboxStatus(mContext.getContentResolver(), mSyncExtras,
-                            mailbox.mId, EmailServiceStatus.IN_PROGRESS, 0,
+                    final int lastSyncResult = UIProvider.createSyncValue(syncStatus,
                             UIProvider.LastSyncResult.SUCCESS);
+                    EmailServiceStatus.syncMailboxStatus(mContext.getContentResolver(), mSyncExtras,
+                            mailbox.mId, EmailServiceStatus.IN_PROGRESS, 0, lastSyncResult);
                 }
                 final EasSyncBase operation = new EasSyncBase(mContext, mAccount, mailbox);
                 LogUtils.d(TAG, "IEmailService.syncMailbox account %d", mAccount.mId);
-                result = operation.performOperation();
+                syncResult = operation.performOperation();
             } finally {
                 updateMailbox(mailbox, cv, EmailContent.SYNC_STATUS_NONE);
                 if (hasCallbackMethod) {
+                    final int uiSyncResult = translateSyncResultToUiResult(syncResult);
+                    final int lastSyncResult = UIProvider.createSyncValue(syncStatus, uiSyncResult);
                     EmailServiceStatus.syncMailboxStatus(mContext.getContentResolver(), mSyncExtras,
-                            mailbox.mId, EmailServiceStatus.SUCCESS, 0,
-                            EasOperation.translateSyncResultToUiResult(result));
+                            mailbox.mId, EmailServiceStatus.SUCCESS, 0, lastSyncResult);
                 }
             }
         } else {
@@ -272,7 +274,7 @@
             LogUtils.d(TAG, "Skipping sync of non syncable folder");
         }
 
-        return result;
+        return syncResult;
     }
 
     private int syncOutbox(final long mailboxId) {