From 99b239fa71e4d5455c4dd3421aafd58bb1423de5 Mon Sep 17 00:00:00 2001 From: Daniel Applebaum Date: Fri, 23 Oct 2009 01:20:12 +0000 Subject: [PATCH] Issue 675 Prevent a crash, and puts up a Toast, but you have to start over setting up the account again. This page needs an effective Back button. --- res/values/strings.xml | 2 + .../setup/AccountSetupAccountType.java | 45 ++++++++++--------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index bf2114b17..6be1f12b0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -320,6 +320,8 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based IMAP before SMTP WebDav(Exchange) before SMTP + Invalid account: %s + Account options Compact diff --git a/src/com/android/email/activity/setup/AccountSetupAccountType.java b/src/com/android/email/activity/setup/AccountSetupAccountType.java index 58231f13f..9e5ba9e64 100644 --- a/src/com/android/email/activity/setup/AccountSetupAccountType.java +++ b/src/com/android/email/activity/setup/AccountSetupAccountType.java @@ -11,9 +11,11 @@ import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; +import android.widget.Toast; import com.android.email.Account; import com.android.email.R; +import com.android.email.activity.SizeFormatter; /** * Prompts the user to select an account type. The account type, along with the @@ -53,14 +55,12 @@ public class AccountSetupAccountType extends K9Activity implements OnClickListen URI uri = new URI(mAccount.getStoreUri()); uri = new URI("pop3", uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null); mAccount.setStoreUri(uri.toString()); - } catch (URISyntaxException use) { - /* - * This should not happen. - */ - throw new Error(use); + AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault); + finish(); + } catch (Exception use) { + failure(use); } - AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault); - finish(); + } private void onImap() { @@ -68,14 +68,12 @@ public class AccountSetupAccountType extends K9Activity implements OnClickListen URI uri = new URI(mAccount.getStoreUri()); uri = new URI("imap", uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null); mAccount.setStoreUri(uri.toString()); - } catch (URISyntaxException use) { - /* - * This should not happen. - */ - throw new Error(use); + AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault); + finish(); + } catch (Exception use) { + failure(use); } - AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault); - finish(); + } private void onWebDav() { @@ -83,14 +81,12 @@ public class AccountSetupAccountType extends K9Activity implements OnClickListen URI uri = new URI(mAccount.getStoreUri()); uri = new URI("webdav", uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null); mAccount.setStoreUri(uri.toString()); - } catch (URISyntaxException use) { - /* - * This should not happen. - */ - throw new Error(use); + AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault); + finish(); + } catch (Exception use) { + failure(use); } - AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault); - finish(); + } public void onClick(View v) { @@ -106,4 +102,11 @@ public class AccountSetupAccountType extends K9Activity implements OnClickListen break; } } + private void failure(Exception use) + { + String toastText = getString(R.string.account_setup_bad_uri, use.getMessage()); + + Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG); + toast.show(); + } }