From 79ef52cfb33e9fb2a2e71d31e0b3810ed1babea5 Mon Sep 17 00:00:00 2001 From: Andrew Stadler Date: Wed, 14 Apr 2010 19:16:46 -0700 Subject: [PATCH] Improve handling of UI reset cases * When account disappears (e.g. delete from Accounts & Sync) the Welcome activity should launch with FLAG_ACTIVITY_CLEAR_TOP to remove any stacked activities as well. * When account disappears entering AccountSetupNames, don't fall out of Eas Flow Mode. * Followup to 5e354cd1db1baabad061032af5a0632cd0f58d1a Bug: 2563998 Change-Id: Ifbe086e26205bb28c2514f84cb28e839888b1eb0 --- src/com/android/email/activity/Welcome.java | 6 ++++++ .../email/activity/setup/AccountSetupNames.java | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/com/android/email/activity/Welcome.java b/src/com/android/email/activity/Welcome.java index 86d56783e..7ec685002 100644 --- a/src/com/android/email/activity/Welcome.java +++ b/src/com/android/email/activity/Welcome.java @@ -40,8 +40,14 @@ import android.os.Bundle; */ public class Welcome extends Activity { + /** + * Launch this activity. Note: It's assumed that this activity is only called as a means to + * 'reset' the UI state; Because of this, it is always launched with FLAG_ACTIVITY_CLEAR_TOP, + * which will drop any other activities on the stack (e.g. AccountFolderList or MessageList). + */ public static void actionStart(Activity fromActivity) { Intent i = new Intent(fromActivity, Welcome.class); + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); fromActivity.startActivity(i); } diff --git a/src/com/android/email/activity/setup/AccountSetupNames.java b/src/com/android/email/activity/setup/AccountSetupNames.java index 55387eaab..1b148c5c6 100644 --- a/src/com/android/email/activity/setup/AccountSetupNames.java +++ b/src/com/android/email/activity/setup/AccountSetupNames.java @@ -94,10 +94,7 @@ public class AccountSetupNames extends Activity implements OnClickListener { mAccount = EmailContent.Account.restoreAccountWithId(this, accountId); // Shouldn't happen, but it could if (mAccount == null) { - // The safe thing to do here is to rewind all the way to the entry activity, - // which can handle any configuration of accounts (0, 1, or 2+) - Welcome.actionStart(this); - finish(); + onBackPressed(); return; } // Get the hostAuth for receiving @@ -153,7 +150,13 @@ public class AccountSetupNames extends Activity implements OnClickListener { if (easFlowMode) { AccountSetupBasics.actionAccountCreateFinishedEas(this); } else { - AccountSetupBasics.actionAccountCreateFinished(this, mAccount.mId); + if (mAccount != null) { + AccountSetupBasics.actionAccountCreateFinished(this, mAccount.mId); + } else { + // Safety check here; If mAccount is null (due to external issues or bugs) + // just rewind back to Welcome, which can handle any configuration of accounts + Welcome.actionStart(this); + } } finish(); }