From c1ca222b759ab5412ec732f6696f76e929f3cd01 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Thu, 19 May 2011 16:24:47 -0700 Subject: [PATCH] Show a toast for stale shortcuts. Change-Id: Ibd7b9ae6a39169604136faafc1a7f87876ba55a1 --- src/com/android/email/activity/Welcome.java | 29 ++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/com/android/email/activity/Welcome.java b/src/com/android/email/activity/Welcome.java index 0edd14e2e..5a19da315 100644 --- a/src/com/android/email/activity/Welcome.java +++ b/src/com/android/email/activity/Welcome.java @@ -18,12 +18,14 @@ package com.android.email.activity; import com.android.email.Email; import com.android.email.ExchangeUtils; +import com.android.email.R; import com.android.email.activity.setup.AccountSetupBasics; import com.android.email.provider.AccountBackupRestore; import com.android.email.service.MailService; import com.android.emailcommon.provider.EmailContent; import com.android.emailcommon.provider.EmailContent.Account; import com.android.emailcommon.utility.EmailAsyncTask; +import com.android.emailcommon.utility.Utility; import com.google.common.annotations.VisibleForTesting; import android.app.Activity; @@ -210,16 +212,31 @@ public class Welcome extends Activity { } @VisibleForTesting - static long resolveAccountId(Context context, long accountId, String uuid) { - // TODO show "account may have been removed" toast when an account is specified but - // can't find it. + static long resolveAccountId(Context context, long inputAccountId, String uuid) { + final long accountId; + if (!TextUtils.isEmpty(uuid)) { accountId = Account.getAccountIdFromUuid(context, uuid); - } - if (accountId == -1 || !Account.isValidId(context, accountId)) { + // accountId will be NO_ACCOUNT if the UUID is invalid. + + } else if (inputAccountId != Account.NO_ACCOUNT) { + if (Account.isValidId(context, inputAccountId)) { + accountId = inputAccountId; + } else { + accountId = Account.NO_ACCOUNT; + } + } else { + // Use the default (without showing the toast) accountId = EmailContent.Account.getDefaultAccountId(context); } - return accountId; + if (accountId != Account.NO_ACCOUNT) { + // Okay, the given account is valid. + return accountId; + } else { + // No, it's invalid. Show the warning toast and use the default. + Utility.showToast(context, R.string.toast_account_not_found); + return EmailContent.Account.getDefaultAccountId(context); + } } @Override