mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 06:08:25 -05:00
Don't trigger validateFields() except on user input
Previously, with settings of Security=SSL and authentication=certificate, attempting to change Security=None would (of course) be blocked. So Security would remain SSL. But the authentication options would then include "Password, transmitted insecurely", whereas the option should have remained as "Normal password" (because the security remained SSL). The problem could have been fixed with a simple shuffling in updatePortFromSecurityType() so that updateAuthPlainTextFromSecurityType() was invoked before mPortView.setText(), but the logic for requiring that ordering was not plain to see. (Although no longer necessary, the shuffling was done as well.)
This commit is contained in:
parent
c861b27df8
commit
2e981e0c7d
@ -308,8 +308,8 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
// this indirectly triggers validateFields because the port text is watched
|
||||
updatePortFromSecurityType();
|
||||
validateFields();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -365,6 +365,11 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is invoked only when the user makes changes to a widget, not when
|
||||
* widgets are changed programmatically. (The logic is simpler when you know
|
||||
* that this is the last thing called after an input change.)
|
||||
*/
|
||||
private void validateFields() {
|
||||
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
|
||||
boolean isAuthTypeExternal = AuthType.EXTERNAL.equals(authType);
|
||||
@ -430,8 +435,13 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
||||
|
||||
private void updatePortFromSecurityType() {
|
||||
ConnectionSecurity securityType = (ConnectionSecurity) mSecurityTypeView.getSelectedItem();
|
||||
mPortView.setText(getDefaultPort(securityType));
|
||||
updateAuthPlainTextFromSecurityType(securityType);
|
||||
|
||||
// Remove listener so as not to trigger validateFields() which is called
|
||||
// elsewhere as a result of user interaction.
|
||||
mPortView.removeTextChangedListener(validationTextWatcher);
|
||||
mPortView.setText(getDefaultPort(securityType));
|
||||
mPortView.addTextChangedListener(validationTextWatcher);
|
||||
}
|
||||
|
||||
private String getDefaultPort(ConnectionSecurity securityType) {
|
||||
|
@ -208,8 +208,8 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
// this indirectly triggers validateFields because the port text is watched
|
||||
updatePortFromSecurityType();
|
||||
validateFields();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -266,6 +266,11 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is invoked only when the user makes changes to a widget, not when
|
||||
* widgets are changed programmatically. (The logic is simpler when you know
|
||||
* that this is the last thing called after an input change.)
|
||||
*/
|
||||
private void validateFields() {
|
||||
AuthType authType = (AuthType) mAuthTypeView.getSelectedItem();
|
||||
boolean isAuthTypeExternal = AuthType.EXTERNAL.equals(authType);
|
||||
@ -333,8 +338,13 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
|
||||
private void updatePortFromSecurityType() {
|
||||
ConnectionSecurity securityType = (ConnectionSecurity) mSecurityTypeView.getSelectedItem();
|
||||
mPortView.setText(getDefaultSmtpPort(securityType));
|
||||
updateAuthPlainTextFromSecurityType(securityType);
|
||||
|
||||
// Remove listener so as not to trigger validateFields() which is called
|
||||
// elsewhere as a result of user interaction.
|
||||
mPortView.removeTextChangedListener(validationTextWatcher);
|
||||
mPortView.setText(getDefaultSmtpPort(securityType));
|
||||
mPortView.addTextChangedListener(validationTextWatcher);
|
||||
}
|
||||
|
||||
private String getDefaultSmtpPort(ConnectionSecurity securityType) {
|
||||
|
Loading…
Reference in New Issue
Block a user