Browse Source

Setup improvements

main
M66B 6 years ago
parent
commit
6e66ddcd53
2 changed files with 28 additions and 13 deletions
  1. +5
    -2
      app/src/main/java/eu/faircode/email/FragmentAccount.java
  2. +23
    -11
      app/src/main/java/eu/faircode/email/FragmentIdentity.java

+ 5
- 2
app/src/main/java/eu/faircode/email/FragmentAccount.java View File

@ -730,12 +730,15 @@ public class FragmentAccount extends FragmentEx {
if (savedInstanceState == null) {
if (account != null) {
for (int pos = 2; pos < providers.size(); pos++)
if (providers.get(pos).imap_host.equals(account.host)) {
for (int pos = 2; pos < providers.size(); pos++) {
Provider provider = providers.get(pos);
if (provider.imap_host.equals(account.host) &&
provider.imap_port == account.port) {
spProvider.setTag(pos);
spProvider.setSelection(pos);
break;
}
}
etHost.setText(account.host);
etPort.setText(Long.toString(account.port));
}


+ 23
- 11
app/src/main/java/eu/faircode/email/FragmentIdentity.java View File

@ -119,6 +119,8 @@ public class FragmentIdentity extends FragmentEx {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
btnAdvanced.setVisibility(position > 0 ? View.VISIBLE : View.GONE);
if (position == 0)
grpAdvanced.setVisibility(View.GONE);
tilPassword.setPasswordVisibilityToggleEnabled(position == 0);
btnSave.setVisibility(position > 0 ? View.VISIBLE : View.GONE);
@ -130,18 +132,28 @@ public class FragmentIdentity extends FragmentEx {
EntityAccount account = (EntityAccount) adapterView.getAdapter().getItem(position);
// Select associated provider
for (int pos = 1; pos < spProvider.getAdapter().getCount(); pos++) {
Provider provider = (Provider) spProvider.getItemAtPosition(pos);
if (provider.imap_host.equals(account.host) && provider.imap_port == account.port) {
spProvider.setSelection(pos);
// This is needed because the spinner might be invisible
etHost.setText(provider.smtp_host);
etPort.setText(Integer.toString(provider.smtp_port));
cbStartTls.setChecked(provider.starttls);
break;
if (position == 0)
spProvider.setSelection(0);
else {
boolean found = false;
for (int pos = 1; pos < spProvider.getAdapter().getCount(); pos++) {
Provider provider = (Provider) spProvider.getItemAtPosition(pos);
if (provider.imap_host.equals(account.host) &&
provider.imap_port == account.port) {
found = true;
spProvider.setSelection(pos);
// This is needed because the spinner might be invisible
etHost.setText(provider.smtp_host);
etPort.setText(Integer.toString(provider.smtp_port));
cbStartTls.setChecked(provider.starttls);
break;
}
}
if (!found)
grpAdvanced.setVisibility(View.VISIBLE);
}
// Copy account user name


Loading…
Cancel
Save