|
|
@ -241,12 +241,9 @@ public class FragmentIdentity extends FragmentBase {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
adapterView.setTag(position);
|
|
|
|
adapterView.setTag(position);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (FragmentIdentity.this.id < 0) {
|
|
|
|
EntityAccount account = (EntityAccount) adapterView.getAdapter().getItem(position);
|
|
|
|
EntityAccount account = (EntityAccount) adapterView.getAdapter().getItem(position);
|
|
|
|
|
|
|
|
|
|
|
|
// Select associated provider
|
|
|
|
|
|
|
|
if (position == 0)
|
|
|
|
|
|
|
|
spProvider.setSelection(0);
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
boolean found = false;
|
|
|
|
boolean found = false;
|
|
|
|
for (int pos = 1; pos < spProvider.getAdapter().getCount(); pos++) {
|
|
|
|
for (int pos = 1; pos < spProvider.getAdapter().getCount(); pos++) {
|
|
|
|
EmailProvider provider = (EmailProvider) spProvider.getItemAtPosition(pos);
|
|
|
|
EmailProvider provider = (EmailProvider) spProvider.getItemAtPosition(pos);
|
|
|
@ -254,38 +251,21 @@ public class FragmentIdentity extends FragmentBase {
|
|
|
|
provider.imap.port == account.port &&
|
|
|
|
provider.imap.port == account.port &&
|
|
|
|
provider.imap.starttls == (account.encryption == EmailService.ENCRYPTION_STARTTLS)) {
|
|
|
|
provider.imap.starttls == (account.encryption == EmailService.ENCRYPTION_STARTTLS)) {
|
|
|
|
found = true;
|
|
|
|
found = true;
|
|
|
|
|
|
|
|
spProvider.setTag(pos);
|
|
|
|
spProvider.setSelection(pos);
|
|
|
|
spProvider.setSelection(pos);
|
|
|
|
|
|
|
|
setProvider(provider);
|
|
|
|
// This is needed because the spinner might be invisible
|
|
|
|
|
|
|
|
etHost.setText(provider.smtp.host);
|
|
|
|
|
|
|
|
etPort.setText(Integer.toString(provider.smtp.port));
|
|
|
|
|
|
|
|
rgEncryption.check(provider.smtp.starttls ? R.id.radio_starttls : R.id.radio_ssl);
|
|
|
|
|
|
|
|
cbUseIp.setChecked(provider.useip);
|
|
|
|
|
|
|
|
etEhlo.setText(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
if (!found) {
|
|
|
|
|
|
|
|
spProvider.setTag(0);
|
|
|
|
|
|
|
|
spProvider.setSelection(0);
|
|
|
|
|
|
|
|
setProvider((EmailProvider) spProvider.getItemAtPosition(0));
|
|
|
|
grpAdvanced.setVisibility(View.VISIBLE);
|
|
|
|
grpAdvanced.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Copy account credentials
|
|
|
|
setAccount(account);
|
|
|
|
auth = account.auth_type;
|
|
|
|
}
|
|
|
|
provider = account.provider;
|
|
|
|
|
|
|
|
etEmail.setText(account.user);
|
|
|
|
|
|
|
|
etUser.setText(account.user);
|
|
|
|
|
|
|
|
tilPassword.getEditText().setText(account.password);
|
|
|
|
|
|
|
|
tilPassword.setEndIconMode(Helper.isSecure(getContext()) ? END_ICON_PASSWORD_TOGGLE : END_ICON_NONE);
|
|
|
|
|
|
|
|
certificate = account.certificate_alias;
|
|
|
|
|
|
|
|
tvCertificate.setText(certificate == null ? getString(R.string.title_optional) : certificate);
|
|
|
|
|
|
|
|
etRealm.setText(account.realm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
etUser.setEnabled(auth == EmailService.AUTH_TYPE_PASSWORD);
|
|
|
|
|
|
|
|
tilPassword.setEnabled(auth == EmailService.AUTH_TYPE_PASSWORD);
|
|
|
|
|
|
|
|
btnCertificate.setEnabled(auth == EmailService.AUTH_TYPE_PASSWORD);
|
|
|
|
|
|
|
|
cbTrust.setChecked(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -378,24 +358,12 @@ public class FragmentIdentity extends FragmentBase {
|
|
|
|
adapterView.setTag(position);
|
|
|
|
adapterView.setTag(position);
|
|
|
|
|
|
|
|
|
|
|
|
EmailProvider provider = (EmailProvider) adapterView.getSelectedItem();
|
|
|
|
EmailProvider provider = (EmailProvider) adapterView.getSelectedItem();
|
|
|
|
|
|
|
|
if (provider != null)
|
|
|
|
// Set associated host/port/starttls
|
|
|
|
setProvider(provider);
|
|
|
|
etHost.setText(provider.smtp.host);
|
|
|
|
|
|
|
|
etPort.setText(position == 0 ? null : Integer.toString(provider.smtp.port));
|
|
|
|
|
|
|
|
rgEncryption.check(provider.smtp.starttls ? R.id.radio_starttls : R.id.radio_ssl);
|
|
|
|
|
|
|
|
cbUseIp.setChecked(provider.useip);
|
|
|
|
|
|
|
|
etEhlo.setText(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EntityAccount account = (EntityAccount) spAccount.getSelectedItem();
|
|
|
|
EntityAccount account = (EntityAccount) spAccount.getSelectedItem();
|
|
|
|
if (account == null ||
|
|
|
|
if (account != null && Objects.equals(account.host, provider.imap.host))
|
|
|
|
provider.imap.host == null || !provider.imap.host.equals(account.host))
|
|
|
|
setAccount(account);
|
|
|
|
auth = EmailService.AUTH_TYPE_PASSWORD;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
auth = account.auth_type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
etUser.setEnabled(auth == EmailService.AUTH_TYPE_PASSWORD);
|
|
|
|
|
|
|
|
tilPassword.setEnabled(auth == EmailService.AUTH_TYPE_PASSWORD);
|
|
|
|
|
|
|
|
btnCertificate.setEnabled(auth == EmailService.AUTH_TYPE_PASSWORD);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -516,6 +484,31 @@ public class FragmentIdentity extends FragmentBase {
|
|
|
|
return view;
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setAccount(EntityAccount account) {
|
|
|
|
|
|
|
|
auth = account.auth_type;
|
|
|
|
|
|
|
|
provider = account.provider;
|
|
|
|
|
|
|
|
etEmail.setText(account.user);
|
|
|
|
|
|
|
|
etUser.setText(account.user);
|
|
|
|
|
|
|
|
tilPassword.getEditText().setText(account.password);
|
|
|
|
|
|
|
|
tilPassword.setEndIconMode(Helper.isSecure(getContext()) ? END_ICON_PASSWORD_TOGGLE : END_ICON_NONE);
|
|
|
|
|
|
|
|
certificate = account.certificate_alias;
|
|
|
|
|
|
|
|
tvCertificate.setText(certificate == null ? getString(R.string.title_optional) : certificate);
|
|
|
|
|
|
|
|
etRealm.setText(account.realm);
|
|
|
|
|
|
|
|
cbTrust.setChecked(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
etUser.setEnabled(auth == EmailService.AUTH_TYPE_PASSWORD);
|
|
|
|
|
|
|
|
tilPassword.setEnabled(auth == EmailService.AUTH_TYPE_PASSWORD);
|
|
|
|
|
|
|
|
btnCertificate.setEnabled(auth == EmailService.AUTH_TYPE_PASSWORD);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setProvider(EmailProvider provider) {
|
|
|
|
|
|
|
|
etHost.setText(provider.smtp.host);
|
|
|
|
|
|
|
|
etPort.setText(provider.smtp.port == 0 ? null : Integer.toString(provider.smtp.port));
|
|
|
|
|
|
|
|
rgEncryption.check(provider.smtp.starttls ? R.id.radio_starttls : R.id.radio_ssl);
|
|
|
|
|
|
|
|
cbUseIp.setChecked(provider.useip);
|
|
|
|
|
|
|
|
etEhlo.setText(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onAutoConfig() {
|
|
|
|
private void onAutoConfig() {
|
|
|
|
etDomain.setEnabled(false);
|
|
|
|
etDomain.setEnabled(false);
|
|
|
|
btnAutoConfig.setEnabled(false);
|
|
|
|
btnAutoConfig.setEnabled(false);
|
|
|
|