mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 13:12:25 -05: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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -301,9 +300,12 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
}
|
||||
|
||||
private void updatePortFromSecurityType() {
|
||||
if (mAccountPorts != null)
|
||||
{
|
||||
int securityType = (Integer)((SpinnerOption)mSecurityTypeView.getSelectedItem()).value;
|
||||
mPortView.setText(Integer.toString(mAccountPorts[securityType]));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
@ -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,22 +378,22 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
try
|
||||
{
|
||||
switch (v.getId()) {
|
||||
case R.id.next:
|
||||
onNext();
|
||||
@ -410,6 +412,11 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
failure(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void selectImapFolder(int activityCode) {
|
||||
String curFolder = null;
|
||||
@ -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