mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 05:02:26 -05:00
remove duplication
This commit is contained in:
parent
d0cd7c368d
commit
520e327775
@ -1,6 +1,7 @@
|
||||
package com.fsck.k9.account;
|
||||
|
||||
import com.fsck.k9.Account.DeletePolicy;
|
||||
import com.fsck.k9.mail.ConnectionSecurity;
|
||||
import com.fsck.k9.mail.ServerSettings.Type;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -25,4 +26,16 @@ public class AccountCreator {
|
||||
return defaults.get(type);
|
||||
}
|
||||
|
||||
public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) {
|
||||
switch (securityType) {
|
||||
case NONE:
|
||||
case STARTTLS_REQUIRED:
|
||||
return storeType.defaultPort;
|
||||
case SSL_TLS_REQUIRED:
|
||||
return storeType.defaultTlsPort;
|
||||
default:
|
||||
throw new AssertionError("Unhandled ConnectionSecurity type encountered: " + securityType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -473,22 +473,10 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
// Remove listener so as not to trigger validateFields() which is called
|
||||
// elsewhere as a result of user interaction.
|
||||
mPortView.removeTextChangedListener(validationTextWatcher);
|
||||
mPortView.setText(String.valueOf(getDefaultPort(securityType)));
|
||||
mPortView.setText(String.valueOf(AccountCreator.getDefaultPort(securityType, mStoreType)));
|
||||
mPortView.addTextChangedListener(validationTextWatcher);
|
||||
}
|
||||
|
||||
private int getDefaultPort(ConnectionSecurity securityType) {
|
||||
switch (securityType) {
|
||||
case NONE:
|
||||
case STARTTLS_REQUIRED:
|
||||
return mStoreType.defaultPort;
|
||||
case SSL_TLS_REQUIRED:
|
||||
return mStoreType.defaultTlsPort;
|
||||
default:
|
||||
throw new AssertionError("Unhandled ConnectionSecurity type encountered: " + securityType);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAuthPlainTextFromSecurityType(ConnectionSecurity securityType) {
|
||||
mAuthTypeAdapter.useInsecureText(securityType == ConnectionSecurity.NONE);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
|
||||
import com.fsck.k9.*;
|
||||
import com.fsck.k9.account.AccountCreator;
|
||||
import com.fsck.k9.activity.K9Activity;
|
||||
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
@ -424,22 +425,10 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
// Remove listener so as not to trigger validateFields() which is called
|
||||
// elsewhere as a result of user interaction.
|
||||
mPortView.removeTextChangedListener(validationTextWatcher);
|
||||
mPortView.setText(String.valueOf(getDefaultSmtpPort(securityType)));
|
||||
mPortView.setText(String.valueOf(AccountCreator.getDefaultPort(securityType, Type.SMTP)));
|
||||
mPortView.addTextChangedListener(validationTextWatcher);
|
||||
}
|
||||
|
||||
private int getDefaultSmtpPort(ConnectionSecurity securityType) {
|
||||
switch (securityType) {
|
||||
case NONE:
|
||||
case STARTTLS_REQUIRED:
|
||||
return Type.SMTP.defaultPort;
|
||||
case SSL_TLS_REQUIRED:
|
||||
return Type.SMTP.defaultTlsPort;
|
||||
default:
|
||||
throw new AssertionError("Unhandled ConnectionSecurity type encountered: " + securityType);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAuthPlainTextFromSecurityType(ConnectionSecurity securityType) {
|
||||
mAuthTypeAdapter.useInsecureText(securityType == ConnectionSecurity.NONE);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user