From fe033e014f3a9009daf3d2fd6bdcfc1e9ca20072 Mon Sep 17 00:00:00 2001 From: Joe Steele <joe@madewell.net> Date: Fri, 25 Jul 2014 18:05:16 -0400 Subject: [PATCH] Avoid setting conflict warning when SMTP login not required --- .../activity/setup/AccountSetupOutgoing.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java b/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java index 02f02e8f3..daf907ab0 100644 --- a/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java +++ b/src/com/fsck/k9/activity/setup/AccountSetupOutgoing.java @@ -210,6 +210,30 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener, public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { updatePortFromSecurityType(); + + boolean isInsecure = ConnectionSecurity.NONE.equals(mSecurityTypeView.getSelectedItem()); + boolean isAuthExternal = AuthType.EXTERNAL.equals(mAuthTypeView.getSelectedItem()); + boolean loginNotRequired = !mRequireLoginView.isChecked(); + + /* + * If the user selects ConnectionSecurity.NONE, a + * warning would normally pop up if the authentication + * is AuthType.EXTERNAL (i.e., using client + * certificates). But such a warning is irrelevant if + * login is not required. So to avoid such a warning + * (generated in validateFields()) under those + * conditions, we change the (irrelevant) authentication + * method to PLAIN. + */ + if (isInsecure && isAuthExternal && loginNotRequired) { + OnItemSelectedListener onItemSelectedListener = mAuthTypeView.getOnItemSelectedListener(); + mAuthTypeView.setOnItemSelectedListener(null); + mCurrentAuthTypeViewPosition = mAuthTypeAdapter.getPosition(AuthType.PLAIN); + mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false); + mAuthTypeView.setOnItemSelectedListener(onItemSelectedListener); + updateViewFromAuthType(); + } + validateFields(); }