diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7199302da..d6f744b76 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -323,7 +323,7 @@ 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
+ Invalid setup: %s
Account options
diff --git a/src/com/android/email/activity/setup/AccountSetupAccountType.java b/src/com/android/email/activity/setup/AccountSetupAccountType.java
index 9e5ba9e64..7d0f851d2 100644
--- a/src/com/android/email/activity/setup/AccountSetupAccountType.java
+++ b/src/com/android/email/activity/setup/AccountSetupAccountType.java
@@ -8,12 +8,14 @@ import com.android.email.K9Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.util.Log;
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.Email;
import com.android.email.R;
import com.android.email.activity.SizeFormatter;
@@ -104,6 +106,7 @@ public class AccountSetupAccountType extends K9Activity implements OnClickListen
}
private void failure(Exception use)
{
+ Log.e(Email.LOG_TAG, "Failure", use);
String toastText = getString(R.string.account_setup_bad_uri, use.getMessage());
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
diff --git a/src/com/android/email/activity/setup/AccountSetupIncoming.java b/src/com/android/email/activity/setup/AccountSetupIncoming.java
index 998acf51a..7909ef3de 100644
--- a/src/com/android/email/activity/setup/AccountSetupIncoming.java
+++ b/src/com/android/email/activity/setup/AccountSetupIncoming.java
@@ -21,6 +21,7 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
+import android.widget.Toast;
import com.android.email.Account;
import com.android.email.Email;
@@ -257,7 +258,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
}
}
} else {
- throw new Error("Unknown account type: " + mAccount.getStoreUri());
+ throw new Exception("Unknown account type: " + mAccount.getStoreUri());
}
for (int i = 0; i < mAccountSchemes.length; i++) {
@@ -275,14 +276,12 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
} else {
updatePortFromSecurityType();
}
- } catch (URISyntaxException use) {
- /*
- * We should always be able to parse our own settings.
- */
- throw new Error(use);
+
+ validateFields();
+ } catch (Exception e) {
+ failure(e);
}
- validateFields();
}
@Override
@@ -301,8 +300,11 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
}
private void updatePortFromSecurityType() {
- int securityType = (Integer)((SpinnerOption)mSecurityTypeView.getSelectedItem()).value;
- mPortView.setText(Integer.toString(mAccountPorts[securityType]));
+ if (mAccountPorts != null)
+ {
+ int securityType = (Integer)((SpinnerOption)mSecurityTypeView.getSelectedItem()).value;
+ mPortView.setText(Integer.toString(mAccountPorts[securityType]));
+ }
}
@Override
@@ -356,8 +358,8 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
}
private void onNext() {
- int securityType = (Integer)((SpinnerOption)mSecurityTypeView.getSelectedItem()).value;
try {
+ int securityType = (Integer)((SpinnerOption)mSecurityTypeView.getSelectedItem()).value;
String path = null;
if (mAccountSchemes[securityType].startsWith("imap")) {
path = "/" + mImapPathPrefixView.getText();
@@ -376,38 +378,43 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
null, // query
null);
mAccount.setStoreUri(uri.toString());
- } catch (URISyntaxException use) {
- /*
- * It's unrecoverable if we cannot create a URI from components that
- * we validated to be safe.
- */
- throw new Error(use);
+
+
+ mAccount.setDraftsFolderName(mImapFolderDrafts.getText().toString());
+ mAccount.setSentFolderName(mImapFolderSent.getText().toString());
+ mAccount.setTrashFolderName(mImapFolderTrash.getText().toString());
+ mAccount.setOutboxFolderName(mImapFolderOutbox.getText().toString());
+ AccountSetupCheckSettings.actionCheckSettings(this, mAccount, true, false);
+ } catch (Exception e) {
+ failure(e);
}
- mAccount.setDraftsFolderName(mImapFolderDrafts.getText().toString());
- mAccount.setSentFolderName(mImapFolderSent.getText().toString());
- mAccount.setTrashFolderName(mImapFolderTrash.getText().toString());
- mAccount.setOutboxFolderName(mImapFolderOutbox.getText().toString());
- AccountSetupCheckSettings.actionCheckSettings(this, mAccount, true, false);
}
public void onClick(View v) {
- switch (v.getId()) {
- case R.id.next:
- onNext();
- break;
- case R.id.account_imap_folder_drafts:
- selectImapFolder(SELECT_DRAFT_FOLDER);
- break;
- case R.id.account_imap_folder_sent:
- selectImapFolder(SELECT_SENT_FOLDER);
- break;
- case R.id.account_imap_folder_trash:
- selectImapFolder(SELECT_TRASH_FOLDER);
- break;
- case R.id.account_imap_folder_outbox:
- selectImapFolder(SELECT_OUTBOX_FOLDER);
- break;
+ try
+ {
+ switch (v.getId()) {
+ case R.id.next:
+ onNext();
+ break;
+ case R.id.account_imap_folder_drafts:
+ selectImapFolder(SELECT_DRAFT_FOLDER);
+ break;
+ case R.id.account_imap_folder_sent:
+ selectImapFolder(SELECT_SENT_FOLDER);
+ break;
+ case R.id.account_imap_folder_trash:
+ selectImapFolder(SELECT_TRASH_FOLDER);
+ break;
+ case R.id.account_imap_folder_outbox:
+ selectImapFolder(SELECT_OUTBOX_FOLDER);
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ failure(e);
}
}
@@ -437,4 +444,13 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
selectIntent.putExtra(ChooseFolder.EXTRA_SHOW_CURRENT, "yes");
startActivityForResult(selectIntent, activityCode);
}
+
+ private void failure(Exception use)
+ {
+ Log.e(Email.LOG_TAG, "Failure", use);
+ String toastText = getString(R.string.account_setup_bad_uri, use.getMessage());
+
+ Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
+ toast.show();
+ }
}
diff --git a/src/com/android/email/activity/setup/AccountSetupOutgoing.java b/src/com/android/email/activity/setup/AccountSetupOutgoing.java
index a3779ce3d..63537efc6 100644
--- a/src/com/android/email/activity/setup/AccountSetupOutgoing.java
+++ b/src/com/android/email/activity/setup/AccountSetupOutgoing.java
@@ -11,6 +11,7 @@ import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.DigitsKeyListener;
+import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
@@ -21,9 +22,11 @@ import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner;
+import android.widget.Toast;
import android.widget.CompoundButton.OnCheckedChangeListener;
import com.android.email.Account;
+import com.android.email.Email;
import com.android.email.Preferences;
import com.android.email.R;
import com.android.email.Utility;
@@ -203,14 +206,15 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
} else {
updatePortFromSecurityType();
}
- } catch (URISyntaxException use) {
+
+ validateFields();
+ } catch (Exception e) {
/*
* We should always be able to parse our own settings.
*/
- throw new Error(use);
+ failure(e);
}
- validateFields();
}
@Override
@@ -260,14 +264,15 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
uri = new URI(smtpSchemes[securityType], userInfo, mServerView.getText().toString(),
Integer.parseInt(mPortView.getText().toString()), null, null, null);
mAccount.setTransportUri(uri.toString());
- } catch (URISyntaxException use) {
+ AccountSetupCheckSettings.actionCheckSettings(this, mAccount, false, true);
+ } catch (Exception e) {
/*
* It's unrecoverable if we cannot create a URI from components that
* we validated to be safe.
*/
- throw new Error(use);
+ failure(e);
}
- AccountSetupCheckSettings.actionCheckSettings(this, mAccount, false, true);
+
}
public void onClick(View v) {
@@ -282,4 +287,12 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
mRequireLoginSettingsView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
validateFields();
}
+ private void failure(Exception use)
+ {
+ Log.e(Email.LOG_TAG, "Failure", use);
+ String toastText = getString(R.string.account_setup_bad_uri, use.getMessage());
+
+ Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
+ toast.show();
+ }
}