am e811c774: am 40236a89: Display sync errors using snackbar and not as a TL footer

* commit 'e811c77465ebbff11035754139e85444713e2d17':
  Display sync errors using snackbar and not as a TL footer
This commit is contained in:
James Lemieux 2014-11-02 17:30:03 +00:00 committed by Android Git Automerger
commit 05629b2975
5 changed files with 36 additions and 26 deletions

View File

@ -35,10 +35,10 @@ import android.os.Parcelable;
import android.os.RemoteException; import android.os.RemoteException;
import android.provider.BaseColumns; import android.provider.BaseColumns;
import com.android.emailcommon.utility.TextUtilities;
import com.android.emailcommon.utility.Utility;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.R; import com.android.emailcommon.R;
import com.android.emailcommon.utility.TextUtilities;
import com.android.emailcommon.utility.Utility;
import com.android.mail.providers.UIProvider; import com.android.mail.providers.UIProvider;
import com.android.mail.utils.LogUtils; import com.android.mail.utils.LogUtils;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
@ -101,6 +101,7 @@ public abstract class EmailContent {
public static final int LAST_SYNC_RESULT_SUCCESS = UIProvider.LastSyncResult.SUCCESS; public static final int LAST_SYNC_RESULT_SUCCESS = UIProvider.LastSyncResult.SUCCESS;
public static final int LAST_SYNC_RESULT_AUTH_ERROR = UIProvider.LastSyncResult.AUTH_ERROR; public static final int LAST_SYNC_RESULT_AUTH_ERROR = UIProvider.LastSyncResult.AUTH_ERROR;
public static final int LAST_SYNC_RESULT_SERVER_ERROR = UIProvider.LastSyncResult.SERVER_ERROR;
public static final int LAST_SYNC_RESULT_SECURITY_ERROR = public static final int LAST_SYNC_RESULT_SECURITY_ERROR =
UIProvider.LastSyncResult.SECURITY_ERROR; UIProvider.LastSyncResult.SECURITY_ERROR;
public static final int LAST_SYNC_RESULT_CONNECTION_ERROR = public static final int LAST_SYNC_RESULT_CONNECTION_ERROR =

View File

@ -33,6 +33,7 @@ import android.os.Bundle;
public abstract class EmailServiceStatus { public abstract class EmailServiceStatus {
public static final int SUCCESS = 0; public static final int SUCCESS = 0;
public static final int IN_PROGRESS = 1; public static final int IN_PROGRESS = 1;
public static final int FAILURE = 2;
public static final int MESSAGE_NOT_FOUND = 0x10; public static final int MESSAGE_NOT_FOUND = 0x10;
public static final int ATTACHMENT_NOT_FOUND = 0x11; public static final int ATTACHMENT_NOT_FOUND = 0x11;

View File

@ -72,8 +72,6 @@ public class EmailConversationCursor extends CursorWrapper implements
if (mailbox != null) { if (mailbox != null) {
mMailboxTypeId = mailbox.mType; mMailboxTypeId = mailbox.mType;
mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_ERROR,
mailbox.mUiLastSyncResult);
mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_TOTAL_COUNT, mailbox.mTotalCount); mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_TOTAL_COUNT, mailbox.mTotalCount);
if (mailbox.mUiSyncStatus == EmailContent.SYNC_STATUS_BACKGROUND if (mailbox.mUiSyncStatus == EmailContent.SYNC_STATUS_BACKGROUND
|| mailbox.mUiSyncStatus == EmailContent.SYNC_STATUS_USER || mailbox.mUiSyncStatus == EmailContent.SYNC_STATUS_USER
@ -106,8 +104,6 @@ public class EmailConversationCursor extends CursorWrapper implements
} else { } else {
mMailboxTypeId = -1; mMailboxTypeId = -1;
// TODO for virtual mailboxes, we may want to do something besides just fake it // 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, mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_TOTAL_COUNT,
cursor != null ? cursor.getCount() : 0); cursor != null ? cursor.getCount() : 0);
mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_STATUS, mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_STATUS,

View File

@ -65,10 +65,10 @@ import android.util.SparseArray;
import com.android.common.content.ProjectionMap; import com.android.common.content.ProjectionMap;
import com.android.email.DebugUtils; import com.android.email.DebugUtils;
import com.android.email.NotificationController;
import com.android.email.NotificationControllerCreatorHolder;
import com.android.email.Preferences; import com.android.email.Preferences;
import com.android.email.R; import com.android.email.R;
import com.android.email.NotificationControllerCreatorHolder;
import com.android.email.NotificationController;
import com.android.email.SecurityPolicy; import com.android.email.SecurityPolicy;
import com.android.email.activity.setup.AccountSecurity; import com.android.email.activity.setup.AccountSecurity;
import com.android.email.activity.setup.AccountSettingsUtils; import com.android.email.activity.setup.AccountSettingsUtils;
@ -5751,13 +5751,13 @@ public class EmailProvider extends ContentProvider
.monitorRefreshStatus(mailbox.mId, new RefreshStatusMonitor.Callback() { .monitorRefreshStatus(mailbox.mId, new RefreshStatusMonitor.Callback() {
@Override @Override
public void onRefreshCompleted(long mailboxId, int result) { 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(); final ContentValues values = new ContentValues();
values.put(Mailbox.UI_SYNC_STATUS, UIProvider.SyncStatus.NO_SYNC); values.put(Mailbox.UI_SYNC_STATUS, UIProvider.SyncStatus.NO_SYNC);
values.put(Mailbox.UI_LAST_SYNC_RESULT, result); values.put(Mailbox.UI_LAST_SYNC_RESULT, syncValue);
mDatabase.update( mDatabase.update(Mailbox.TABLE_NAME, values, WHERE_ID,
Mailbox.TABLE_NAME,
values,
WHERE_ID,
new String[] { String.valueOf(mailboxId) }); new String[] { String.valueOf(mailboxId) });
notifyUIFolder(mailbox.mId, mailbox.mAccountKey); notifyUIFolder(mailbox.mId, mailbox.mAccountKey);
} }

View File

@ -122,17 +122,21 @@ public class PopImapSyncAdapterService extends Service {
Uri mailboxUri = ContentUris.withAppendedId(Mailbox.CONTENT_URI, mailboxId); Uri mailboxUri = ContentUris.withAppendedId(Mailbox.CONTENT_URI, mailboxId);
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
// Set mailbox sync state // Set mailbox sync state
values.put(Mailbox.UI_SYNC_STATUS, final int syncStatus = uiRefresh ? EmailContent.SYNC_STATUS_USER :
uiRefresh ? EmailContent.SYNC_STATUS_USER : EmailContent.SYNC_STATUS_BACKGROUND); EmailContent.SYNC_STATUS_BACKGROUND;
values.put(Mailbox.UI_SYNC_STATUS, syncStatus);
resolver.update(mailboxUri, values, null, null); resolver.update(mailboxUri, values, null, null);
try { try {
int lastSyncResult;
try { try {
String legacyImapProtocol = context.getString(R.string.protocol_legacy_imap); String legacyImapProtocol = context.getString(R.string.protocol_legacy_imap);
if (mailbox.mType == Mailbox.TYPE_OUTBOX) { if (mailbox.mType == Mailbox.TYPE_OUTBOX) {
EmailServiceStub.sendMailImpl(context, account.mId); EmailServiceStub.sendMailImpl(context, account.mId);
} else { } else {
lastSyncResult = UIProvider.createSyncValue(syncStatus,
EmailContent.LAST_SYNC_RESULT_SUCCESS);
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId,
EmailServiceStatus.IN_PROGRESS, 0, UIProvider.LastSyncResult.SUCCESS); EmailServiceStatus.IN_PROGRESS, 0, lastSyncResult);
final int status; final int status;
if (protocol.equals(legacyImapProtocol)) { if (protocol.equals(legacyImapProtocol)) {
status = ImapService.synchronizeMailboxSynchronous(context, account, status = ImapService.synchronizeMailboxSynchronous(context, account,
@ -142,30 +146,38 @@ public class PopImapSyncAdapterService extends Service {
mailbox, deltaMessageCount); mailbox, deltaMessageCount);
} }
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, status, 0, EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, status, 0,
UIProvider.LastSyncResult.SUCCESS); lastSyncResult);
} }
} catch (MessagingException e) { } catch (MessagingException e) {
final int type = e.getExceptionType(); final int type = e.getExceptionType();
// type must be translated into the domain of values used by EmailServiceStatus // type must be translated into the domain of values used by EmailServiceStatus
switch(type) { switch (type) {
case MessagingException.IOERROR: case MessagingException.IOERROR:
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0, lastSyncResult = UIProvider.createSyncValue(syncStatus,
UIProvider.LastSyncResult.CONNECTION_ERROR); EmailContent.LAST_SYNC_RESULT_CONNECTION_ERROR);
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId,
EmailServiceStatus.FAILURE, 0, lastSyncResult);
syncResult.stats.numIoExceptions++; syncResult.stats.numIoExceptions++;
break; break;
case MessagingException.AUTHENTICATION_FAILED: case MessagingException.AUTHENTICATION_FAILED:
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0, lastSyncResult = UIProvider.createSyncValue(syncStatus,
UIProvider.LastSyncResult.AUTH_ERROR); EmailContent.LAST_SYNC_RESULT_AUTH_ERROR);
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId,
EmailServiceStatus.FAILURE, 0, lastSyncResult);
syncResult.stats.numAuthExceptions++; syncResult.stats.numAuthExceptions++;
break; break;
case MessagingException.SERVER_ERROR: case MessagingException.SERVER_ERROR:
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0, lastSyncResult = UIProvider.createSyncValue(syncStatus,
UIProvider.LastSyncResult.SERVER_ERROR); EmailContent.LAST_SYNC_RESULT_SERVER_ERROR);
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId,
EmailServiceStatus.FAILURE, 0, lastSyncResult);
break; break;
default: default:
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0, lastSyncResult = UIProvider.createSyncValue(syncStatus,
UIProvider.LastSyncResult.INTERNAL_ERROR); EmailContent.LAST_SYNC_RESULT_INTERNAL_ERROR);
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId,
EmailServiceStatus.FAILURE, 0, lastSyncResult);
} }
} }
} finally { } finally {