From 29b6d046d380e1818394d4637aac7298c9f40d12 Mon Sep 17 00:00:00 2001 From: Sander Bogaert Date: Fri, 24 Aug 2012 10:29:17 -0400 Subject: [PATCH] Separate the welcome message in it's own activity. Cleaner solution and it prevents it from having the same actionbar as the Accounts activity. --- AndroidManifest.xml | 6 ++++ res/layout/accounts.xml | 30 ---------------- res/layout/welcome_message.xml | 35 +++++++++++++++++++ res/values/strings.xml | 1 + src/com/fsck/k9/activity/Accounts.java | 23 +++++++----- .../k9/activity/setup/AccountSetupNames.java | 2 ++ .../k9/activity/setup/WelcomeMessage.java | 33 +++++++++++++++++ 7 files changed, 91 insertions(+), 39 deletions(-) create mode 100644 res/layout/welcome_message.xml create mode 100644 src/com/fsck/k9/activity/setup/WelcomeMessage.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 995677ca8..57c63d027 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -91,6 +91,12 @@ android:excludeFromRecents="true" > + + - - - - - - - - - diff --git a/res/layout/welcome_message.xml b/res/layout/welcome_message.xml new file mode 100644 index 000000000..70e019cf0 --- /dev/null +++ b/res/layout/welcome_message.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index cfec22e87..94f32cf45 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -78,6 +78,7 @@ http://k9mail.googlecode.com/ About %s Accounts + Welcome to K-9 Mail! Folders Advanced %s diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 874433fb9..5851e0e02 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -67,6 +67,7 @@ import com.fsck.k9.activity.misc.NonConfigurationInstance; import com.fsck.k9.activity.setup.AccountSettings; import com.fsck.k9.activity.setup.AccountSetupBasics; import com.fsck.k9.activity.setup.Prefs; +import com.fsck.k9.activity.setup.WelcomeMessage; import com.fsck.k9.controller.MessagingController; import com.fsck.k9.controller.MessagingListener; import com.fsck.k9.helper.SizeFormatter; @@ -87,7 +88,7 @@ import com.fsck.k9.preferences.SettingsImporter.ImportContents; import com.fsck.k9.preferences.SettingsImporter.ImportResults; -public class Accounts extends K9ListActivity implements OnItemClickListener, OnClickListener { +public class Accounts extends K9ListActivity implements OnItemClickListener { /** * Immutable empty {@link BaseAccount} array @@ -355,6 +356,12 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC Intent intent = getIntent(); //onNewIntent(intent); + // see if we should show the welcome message + if (accounts.length < 1) { + WelcomeMessage.showWelcomeMessage(this); + finish(); + } + boolean startup = intent.getBooleanExtra(EXTRA_STARTUP, true); if (startup && K9.startIntegratedInbox() && !K9.isHideSpecialAccounts()) { onOpenAccount(integratedInboxAccount); @@ -371,9 +378,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC ListView listView = getListView(); listView.setOnItemClickListener(this); listView.setItemsCanFocus(false); - listView.setEmptyView(findViewById(R.id.empty)); listView.setScrollingCacheEnabled(false); - findViewById(R.id.next).setOnClickListener(this); registerForContextMenu(listView); if (icicle != null && icicle.containsKey(SELECTED_CONTEXT_ACCOUNT)) { @@ -481,6 +486,12 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC private void refresh() { accounts = Preferences.getPreferences(this).getAccounts(); + // see if we should show the welcome message + if (accounts.length < 1) { + WelcomeMessage.showWelcomeMessage(this); + finish(); + } + List newAccounts; if (!K9.isHideSpecialAccounts() && accounts.length > 0) { if (integratedInboxAccount == null || unreadAccount == null) { @@ -916,12 +927,6 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC } } - public void onClick(View view) { - if (view.getId() == R.id.next) { - onAddNewAccount(); - } - } - private void onDeleteAccount(Account account) { mSelectedContextAccount = account; showDialog(DIALOG_REMOVE_ACCOUNT); diff --git a/src/com/fsck/k9/activity/setup/AccountSetupNames.java b/src/com/fsck/k9/activity/setup/AccountSetupNames.java index 6079f3825..95c8ee490 100644 --- a/src/com/fsck/k9/activity/setup/AccountSetupNames.java +++ b/src/com/fsck/k9/activity/setup/AccountSetupNames.java @@ -13,6 +13,7 @@ import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import com.fsck.k9.*; +import com.fsck.k9.activity.Accounts; import com.fsck.k9.activity.K9Activity; import com.fsck.k9.helper.Utility; @@ -85,6 +86,7 @@ public class AccountSetupNames extends K9Activity implements OnClickListener { } mAccount.setName(mName.getText().toString()); mAccount.save(Preferences.getPreferences(this)); + Accounts.listAccountsClearTop(this); finish(); } diff --git a/src/com/fsck/k9/activity/setup/WelcomeMessage.java b/src/com/fsck/k9/activity/setup/WelcomeMessage.java new file mode 100644 index 000000000..1aaefff2b --- /dev/null +++ b/src/com/fsck/k9/activity/setup/WelcomeMessage.java @@ -0,0 +1,33 @@ +package com.fsck.k9.activity.setup; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; + +import com.fsck.k9.R; +import com.fsck.k9.activity.K9Activity; + +public class WelcomeMessage extends K9Activity implements OnClickListener{ + + public static void showWelcomeMessage(Context context) { + Intent intent = new Intent(context, WelcomeMessage.class); + context.startActivity(intent); + } + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + setContentView(R.layout.welcome_message); + ((Button) findViewById(R.id.next)).setOnClickListener(this); + } + + public void onClick(View view) { + if (view.getId() == R.id.next) { + AccountSetupBasics.actionNewAccount(this); + finish(); + } + } +}