1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

reduce duplication

This commit is contained in:
Art O Cathain 2015-02-18 19:40:43 +00:00
parent ebef8eccb9
commit 492d65feed
2 changed files with 43 additions and 68 deletions

View File

@ -14,6 +14,7 @@ import com.fsck.k9.Preferences;
import com.fsck.k9.R;
import com.fsck.k9.activity.K9Activity;
import java.net.URI;
import java.net.URISyntaxException;
/**
* Prompts the user to select an account type. The account type, along with the
@ -49,44 +50,17 @@ public class AccountSetupAccountType extends K9Activity implements OnClickListen
mMakeDefault = getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false);
}
private void onPop() {
try {
private void setupStoreAndSmtpTransport(String schemePrefix) throws URISyntaxException {
URI uri = new URI(mAccount.getStoreUri());
uri = new URI("pop3+ssl+", uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null);
uri = new URI(schemePrefix, uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null);
mAccount.setStoreUri(uri.toString());
uri = new URI(mAccount.getTransportUri());
uri = new URI("smtp+tls+", uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null);
mAccount.setTransportUri(uri.toString());
AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault);
finish();
} catch (Exception use) {
failure(use);
}
}
private void onImap() {
try {
URI uri = new URI(mAccount.getStoreUri());
uri = new URI("imap+ssl+", uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null);
mAccount.setStoreUri(uri.toString());
uri = new URI(mAccount.getTransportUri());
uri = new URI("smtp+tls+", uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null);
mAccount.setTransportUri(uri.toString());
AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault);
finish();
} catch (Exception use) {
failure(use);
}
}
private void onWebDav() {
try {
private void setupDav() throws URISyntaxException {
URI uri = new URI(mAccount.getStoreUri());
/*
@ -106,26 +80,27 @@ public class AccountSetupAccountType extends K9Activity implements OnClickListen
}
uri = new URI("webdav+ssl+", userPass, uri.getHost(), uri.getPort(), null, null, null);
mAccount.setStoreUri(uri.toString());
AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault);
finish();
} catch (Exception use) {
failure(use);
}
}
public void onClick(View v) {
try {
switch (v.getId()) {
case R.id.pop:
onPop();
setupStoreAndSmtpTransport("pop3+ssl+");
break;
case R.id.imap:
onImap();
setupStoreAndSmtpTransport("imap+ssl+");
break;
case R.id.webdav:
onWebDav();
setupDav();
break;
}
} catch (Exception ex) {
failure(ex);
}
AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault);
finish();
}
private void failure(Exception use) {

View File

@ -347,7 +347,7 @@ public class AccountSetupBasics extends K9Activity
}
}
protected void onNext() {
private void onNext() {
if (mClientCertificateCheckBox.isChecked()) {
// Auto-setup doesn't support client certificates.