1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-11 20:15:03 -05:00

Restore TCP port value in incoming/outgoing server settings screens

Special thanks to zjw for the detailed analysis of this bug:
https://github.com/k9mail/k-9/pull/193
This commit is contained in:
cketti 2012-10-21 20:04:53 +02:00
parent 1ac666bbd1
commit 6af48bd262
2 changed files with 42 additions and 26 deletions

View File

@ -160,18 +160,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
authTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mAuthTypeView.setAdapter(authTypesAdapter);
/*
* Updates the port when the user changes the security type. This allows
* us to show a reasonable default which the user can change.
*/
mSecurityTypeView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
updatePortFromSecurityType();
}
public void onNothingSelected(AdapterView<?> parent) { /* unused */ }
});
/*
* Calls validateFields() which enables or disables the Next button
* based on the fields' validity.
@ -294,12 +282,33 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
throw new Exception("Unknown account type: " + mAccount.getStoreUri());
}
// Select currently configured security type
for (int i = 0; i < CONNECTION_SECURITY_TYPES.length; i++) {
if (CONNECTION_SECURITY_TYPES[i] == settings.connectionSecurity) {
SpinnerOption.setSpinnerOptionValue(mSecurityTypeView, i);
}
}
/*
* Updates the port when the user changes the security type. This allows
* us to show a reasonable default which the user can change.
*
* Note: It's important that we set the listener *after* an initial option has been
* selected by the code above. Otherwise the listener might be called after
* onCreate() has been processed and the current port value set later in this
* method is overridden with the default port for the selected security type.
*/
mSecurityTypeView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
updatePortFromSecurityType();
}
@Override
public void onNothingSelected(AdapterView<?> parent) { /* unused */ }
});
mCompressionMobile.setChecked(mAccount.useCompression(Account.TYPE_MOBILE));
mCompressionWifi.setChecked(mAccount.useCompression(Account.TYPE_WIFI));
mCompressionOther.setChecked(mAccount.useCompression(Account.TYPE_OTHER));

View File

@ -137,19 +137,6 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
authTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mAuthTypeView.setAdapter(authTypesAdapter);
/*
* Updates the port when the user changes the security type. This allows
* us to show a reasonable default which the user can change.
*/
mSecurityTypeView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
updatePortFromSecurityType();
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
/*
* Calls validateFields() which enables or disables the Next button
* based on the fields' validity.
@ -223,13 +210,33 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
}
}
// Select currently configured security type
for (int i = 0; i < smtpSchemes.length; i++) {
if (smtpSchemes[i].equals(uri.getScheme())) {
SpinnerOption.setSpinnerOptionValue(mSecurityTypeView, i);
}
}
/*
* Updates the port when the user changes the security type. This allows
* us to show a reasonable default which the user can change.
*
* Note: It's important that we set the listener *after* an initial option has been
* selected by the code above. Otherwise the listener might be called after
* onCreate() has been processed and the current port value set later in this
* method is overridden with the default port for the selected security type.
*/
mSecurityTypeView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
updatePortFromSecurityType();
}
@Override
public void onNothingSelected(AdapterView<?> parent) { /* unused */ }
});
if (uri.getHost() != null) {
mServerView.setText(uri.getHost());
}