mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
reduce duplication
This commit is contained in:
parent
ebef8eccb9
commit
492d65feed
@ -14,6 +14,7 @@ import com.fsck.k9.Preferences;
|
|||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.activity.K9Activity;
|
import com.fsck.k9.activity.K9Activity;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prompts the user to select an account type. The account type, along with the
|
* 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);
|
mMakeDefault = getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPop() {
|
private void setupStoreAndSmtpTransport(String schemePrefix) throws URISyntaxException {
|
||||||
try {
|
|
||||||
URI uri = new URI(mAccount.getStoreUri());
|
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());
|
mAccount.setStoreUri(uri.toString());
|
||||||
|
|
||||||
uri = new URI(mAccount.getTransportUri());
|
uri = new URI(mAccount.getTransportUri());
|
||||||
uri = new URI("smtp+tls+", uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null);
|
uri = new URI("smtp+tls+", uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null);
|
||||||
mAccount.setTransportUri(uri.toString());
|
mAccount.setTransportUri(uri.toString());
|
||||||
|
|
||||||
AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault);
|
|
||||||
finish();
|
|
||||||
} catch (Exception use) {
|
|
||||||
failure(use);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private void setupDav() throws URISyntaxException {
|
||||||
|
|
||||||
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 {
|
|
||||||
URI uri = new URI(mAccount.getStoreUri());
|
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);
|
uri = new URI("webdav+ssl+", userPass, uri.getHost(), uri.getPort(), null, null, null);
|
||||||
mAccount.setStoreUri(uri.toString());
|
mAccount.setStoreUri(uri.toString());
|
||||||
AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault);
|
|
||||||
finish();
|
|
||||||
} catch (Exception use) {
|
|
||||||
failure(use);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
try {
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.pop:
|
case R.id.pop:
|
||||||
onPop();
|
setupStoreAndSmtpTransport("pop3+ssl+");
|
||||||
break;
|
break;
|
||||||
case R.id.imap:
|
case R.id.imap:
|
||||||
onImap();
|
setupStoreAndSmtpTransport("imap+ssl+");
|
||||||
break;
|
break;
|
||||||
case R.id.webdav:
|
case R.id.webdav:
|
||||||
onWebDav();
|
setupDav();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
failure(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountSetupIncoming.actionIncomingSettings(this, mAccount, mMakeDefault);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void failure(Exception use) {
|
private void failure(Exception use) {
|
||||||
|
@ -347,7 +347,7 @@ public class AccountSetupBasics extends K9Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onNext() {
|
private void onNext() {
|
||||||
if (mClientCertificateCheckBox.isChecked()) {
|
if (mClientCertificateCheckBox.isChecked()) {
|
||||||
|
|
||||||
// Auto-setup doesn't support client certificates.
|
// Auto-setup doesn't support client certificates.
|
||||||
|
Loading…
Reference in New Issue
Block a user