mirror of
https://github.com/moparisthebest/k-9
synced 2024-10-31 15:45:08 -04:00
Fixes Issue 738
Fixes Issue 133 Really, just displays a Toast and allows K-9 to continue in some situations that otherwise cause a crash. Will hopefully allow users of Android 2.0 to use K-9, but may just provide better info about what is going wrong.
This commit is contained in:
parent
2f4b9a1178
commit
b9642ee5f3
@ -323,7 +323,7 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based
|
||||
<string name="account_setup_outgoing_authentication_imap_before_smtp_label">IMAP before SMTP</string>
|
||||
<string name="account_setup_outgoing_authentication_webdav_before_smtp_label">WebDav(Exchange) before SMTP</string>
|
||||
|
||||
<string name="account_setup_bad_uri">Invalid account: <xliff:g id="err_mess">%s</xliff:g></string>
|
||||
<string name="account_setup_bad_uri">Invalid setup: <xliff:g id="err_mess">%s</xliff:g></string>
|
||||
|
||||
<string name="account_setup_options_title">Account options</string>
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user