1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00
Joe Steele 2014-08-18 18:12:39 -04:00
parent a659393326
commit f7fb0cca41
10 changed files with 39 additions and 45 deletions

View File

@ -1892,7 +1892,7 @@ public class Account implements BaseAccount {
public void addCertificate(CheckDirection direction,
X509Certificate certificate) throws CertificateException {
Uri uri;
if (direction.equals(CheckDirection.INCOMING)) {
if (direction == CheckDirection.INCOMING) {
uri = Uri.parse(getStoreUri());
} else {
uri = Uri.parse(getTransportUri());
@ -1909,7 +1909,7 @@ public class Account implements BaseAccount {
public void deleteCertificate(String newHost, int newPort,
CheckDirection direction) {
Uri uri;
if (direction.equals(CheckDirection.INCOMING)) {
if (direction == CheckDirection.INCOMING) {
uri = Uri.parse(getStoreUri());
} else {
uri = Uri.parse(getTransportUri());

View File

@ -779,16 +779,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
* this account type. Also don't ask when the username is missing.
* Also don't ask when the AuthType is EXTERNAL.
*/
boolean configureOutgoingServer = !AuthType.EXTERNAL
.equals(outgoing.authenticationType)
boolean configureOutgoingServer = AuthType.EXTERNAL != outgoing.authenticationType
&& !WebDavStore.STORE_TYPE.equals(outgoing.type)
&& outgoing.username != null
&& !outgoing.username.isEmpty()
&& (outgoing.password == null || outgoing.password
.isEmpty());
boolean configureIncomingServer = !AuthType.EXTERNAL
.equals(incoming.authenticationType)
boolean configureIncomingServer = AuthType.EXTERNAL != incoming.authenticationType
&& (incoming.password == null || incoming.password
.isEmpty());

View File

@ -114,7 +114,7 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
ctrl.clearCertificateErrorNotifications(AccountSetupCheckSettings.this,
mAccount, mDirection);
if (mDirection.equals(CheckDirection.INCOMING)) {
if (mDirection == CheckDirection.INCOMING) {
store = mAccount.getRemoteStore();
if (store instanceof WebDavStore) {
@ -137,7 +137,7 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
finish();
return;
}
if (mDirection.equals(CheckDirection.OUTGOING)) {
if (mDirection == CheckDirection.OUTGOING) {
if (!(mAccount.getRemoteStore() instanceof WebDavStore)) {
setMessage(R.string.account_setup_check_settings_check_outgoing_msg);
}

View File

@ -354,7 +354,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
AuthType selection = (AuthType) mAuthTypeView.getSelectedItem();
// Have the user select (or confirm) the client certificate
if (AuthType.EXTERNAL.equals(selection)) {
if (AuthType.EXTERNAL == selection) {
// This may again invoke validateFields()
mClientCertificateSpinner.chooseCertificate();
@ -400,7 +400,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
*/
private void updateViewFromAuthType() {
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
boolean isAuthTypeExternal = AuthType.EXTERNAL.equals(authType);
boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
if (isAuthTypeExternal) {
@ -426,10 +426,10 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
*/
private void validateFields() {
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
boolean isAuthTypeExternal = AuthType.EXTERNAL.equals(authType);
boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
ConnectionSecurity connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem();
boolean hasConnectionSecurity = (!connectionSecurity.equals(ConnectionSecurity.NONE));
boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
if (isAuthTypeExternal && !hasConnectionSecurity) {
@ -459,10 +459,10 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
mPortView.addTextChangedListener(validationTextWatcher);
authType = (AuthType) mAuthTypeView.getSelectedItem();
isAuthTypeExternal = AuthType.EXTERNAL.equals(authType);
isAuthTypeExternal = (AuthType.EXTERNAL == authType);
connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem();
hasConnectionSecurity = (!connectionSecurity.equals(ConnectionSecurity.NONE));
hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
} else {
mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
@ -552,7 +552,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
String password = null;
String clientCertificateAlias = null;
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
if (AuthType.EXTERNAL.equals(authType)) {
if (AuthType.EXTERNAL == authType) {
clientCertificateAlias = mClientCertificateSpinner.getAlias();
} else {
password = mPasswordView.getText().toString();
@ -586,7 +586,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
String clientCertificateAlias = null;
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
if (authType.equals(AuthType.EXTERNAL)) {
if (authType == AuthType.EXTERNAL) {
clientCertificateAlias = mClientCertificateSpinner.getAlias();
} else {
password = mPasswordView.getText().toString();

View File

@ -234,8 +234,8 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
if (mCurrentSecurityTypeViewPosition != position) {
updatePortFromSecurityType();
boolean isInsecure = ConnectionSecurity.NONE.equals(mSecurityTypeView.getSelectedItem());
boolean isAuthExternal = AuthType.EXTERNAL.equals(mAuthTypeView.getSelectedItem());
boolean isInsecure = (ConnectionSecurity.NONE == mSecurityTypeView.getSelectedItem());
boolean isAuthExternal = (AuthType.EXTERNAL == mAuthTypeView.getSelectedItem());
boolean loginNotRequired = !mRequireLoginView.isChecked();
/*
@ -278,7 +278,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
AuthType selection = (AuthType) mAuthTypeView.getSelectedItem();
// Have the user select (or confirm) the client certificate
if (AuthType.EXTERNAL.equals(selection)) {
if (AuthType.EXTERNAL == selection) {
// This may again invoke validateFields()
mClientCertificateSpinner.chooseCertificate();
@ -331,7 +331,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
*/
private void updateViewFromAuthType() {
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
boolean isAuthTypeExternal = AuthType.EXTERNAL.equals(authType);
boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
if (isAuthTypeExternal) {
@ -357,10 +357,10 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
*/
private void validateFields() {
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
boolean isAuthTypeExternal = AuthType.EXTERNAL.equals(authType);
boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
ConnectionSecurity connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem();
boolean hasConnectionSecurity = (!connectionSecurity.equals(ConnectionSecurity.NONE));
boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
if (isAuthTypeExternal && !hasConnectionSecurity) {
@ -390,10 +390,10 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
mPortView.addTextChangedListener(validationTextWatcher);
authType = (AuthType) mAuthTypeView.getSelectedItem();
isAuthTypeExternal = AuthType.EXTERNAL.equals(authType);
isAuthTypeExternal = (AuthType.EXTERNAL == authType);
connectionSecurity = (ConnectionSecurity) mSecurityTypeView.getSelectedItem();
hasConnectionSecurity = (!connectionSecurity.equals(ConnectionSecurity.NONE));
hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
} else {
mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
@ -482,7 +482,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
username = mUsernameView.getText().toString();
authType = (AuthType) mAuthTypeView.getSelectedItem();
if (AuthType.EXTERNAL.equals(authType)) {
if (AuthType.EXTERNAL == authType) {
clientCertificateAlias = mClientCertificateSpinner.getAlias();
} else {
password = mPasswordView.getText().toString();

View File

@ -2673,7 +2673,7 @@ public class MessagingController implements Runnable {
final NotificationManager nm = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
if (direction.equals(CheckDirection.INCOMING)) {
if (direction == CheckDirection.INCOMING) {
nm.cancel(null, K9.CERTIFICATE_EXCEPTION_NOTIFICATION_INCOMING + account.getAccountNumber());
} else {
nm.cancel(null, K9.CERTIFICATE_EXCEPTION_NOTIFICATION_OUTGOING + account.getAccountNumber());

View File

@ -214,7 +214,7 @@ public class ImapStore extends Store {
authenticationType = AuthType.valueOf(userInfoParts[0]);
username = URLDecoder.decode(userInfoParts[1], "UTF-8");
if (AuthType.EXTERNAL.equals(authenticationType)) {
if (AuthType.EXTERNAL == authenticationType) {
clientCertificateAlias = URLDecoder.decode(userInfoParts[2], "UTF-8");
} else {
password = URLDecoder.decode(userInfoParts[2], "UTF-8");
@ -290,7 +290,7 @@ public class ImapStore extends Store {
AuthType authType = server.authenticationType;
String userInfo;
if (authType.equals(AuthType.EXTERNAL)) {
if (authType == AuthType.EXTERNAL) {
userInfo = authType.name() + ":" + userEnc + ":" + clientCertificateAliasEnc;
} else {
userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc;

View File

@ -128,7 +128,7 @@ public class Pop3Store extends Store {
}
username = URLDecoder.decode(userInfoParts[userIndex], "UTF-8");
if (userInfoParts.length > passwordIndex) {
if (authType.equals(AuthType.EXTERNAL)) {
if (authType == AuthType.EXTERNAL) {
clientCertificateAlias = URLDecoder.decode(userInfoParts[passwordIndex], "UTF-8");
} else {
password = URLDecoder.decode(userInfoParts[passwordIndex], "UTF-8");
@ -186,7 +186,7 @@ public class Pop3Store extends Store {
AuthType authType = server.authenticationType;
String userInfo;
if (AuthType.EXTERNAL.equals(authType)) {
if (AuthType.EXTERNAL == authType) {
userInfo = authType.name() + ":" + userEnc + ":" + clientCertificateAliasEnc;
} else {
userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc;

View File

@ -105,7 +105,7 @@ public class SmtpTransport extends Transport {
// NOTE: In SmptTransport URIs, the authType comes last!
authType = AuthType.valueOf(userInfoParts[2]);
username = URLDecoder.decode(userInfoParts[0], "UTF-8");
if (authType.equals(AuthType.EXTERNAL)) {
if (authType == AuthType.EXTERNAL) {
clientCertificateAlias = URLDecoder.decode(userInfoParts[1], "UTF-8");
} else {
password = URLDecoder.decode(userInfoParts[1], "UTF-8");
@ -166,7 +166,7 @@ public class SmtpTransport extends Transport {
AuthType authType = server.authenticationType;
// NOTE: authType is append at last item, in contrast to ImapStore and Pop3Store!
if (authType != null) {
if (AuthType.EXTERNAL.equals(authType)) {
if (AuthType.EXTERNAL == authType) {
userInfo = userEnc + ":" + clientCertificateAliasEnc + ":" + authType.name();
} else {
userInfo = userEnc + ":" + passwordEnc + ":" + authType.name();
@ -326,8 +326,7 @@ public class SmtpTransport extends Transport {
if (mUsername != null
&& mUsername.length() > 0
&& (mPassword != null && mPassword.length() > 0 || AuthType.EXTERNAL
.equals(mAuthType))) {
&& (mPassword != null && mPassword.length() > 0 || AuthType.EXTERNAL == mAuthType)) {
switch (mAuthType) {

View File

@ -381,9 +381,8 @@ public class SettingsImporter {
// Mark account as disabled if the AuthType isn't EXTERNAL and the
// settings file didn't contain a password
boolean createAccountDisabled = !AuthType.EXTERNAL
.equals(incoming.authenticationType)
&& (incoming.password == null || incoming.password.isEmpty());
boolean createAccountDisabled = AuthType.EXTERNAL != incoming.authenticationType &&
(incoming.password == null || incoming.password.isEmpty());
if (account.outgoing == null && !WebDavStore.STORE_TYPE.equals(account.incoming.type)) {
// All account types except WebDAV need to provide outgoing server settings
@ -403,14 +402,12 @@ public class SettingsImporter {
* outgoing servers are identical for this account type. Nor is a
* password required if the AuthType is EXTERNAL.
*/
if (!AuthType.EXTERNAL.equals(outgoing.authenticationType)
&& !WebDavStore.STORE_TYPE.equals(outgoing.type)
&& outgoing.username != null
&& !outgoing.username.isEmpty()
&& (outgoing.password == null || outgoing.password
.isEmpty())) {
createAccountDisabled = true;
}
boolean outgoingPasswordNeeded = AuthType.EXTERNAL != outgoing.authenticationType &&
!WebDavStore.STORE_TYPE.equals(outgoing.type) &&
outgoing.username != null &&
!outgoing.username.isEmpty() &&
(outgoing.password == null || outgoing.password.isEmpty());
createAccountDisabled = outgoingPasswordNeeded || createAccountDisabled;
}
// Write key to mark account as disabled if necessary