Improved switching to password

This commit is contained in:
M66B 2022-04-17 13:34:38 +02:00
parent 31a215d92b
commit 03bb67b7d0
1 changed files with 13 additions and 10 deletions

View File

@ -680,6 +680,11 @@ public class FragmentAccount extends FragmentBase {
saving = false; saving = false;
invalidateOptionsMenu(); invalidateOptionsMenu();
Helper.setViewsEnabled(view, true); Helper.setViewsEnabled(view, true);
if (auth != AUTH_TYPE_PASSWORD) {
etUser.setEnabled(false);
tilPassword.getEditText().setEnabled(false);
btnCertificate.setEnabled(false);
}
pbCheck.setVisibility(View.GONE); pbCheck.setVisibility(View.GONE);
} }
@ -720,11 +725,6 @@ public class FragmentAccount extends FragmentBase {
result.account = db.account().getAccount(id); result.account = db.account().getAccount(id);
result.folders = new ArrayList<>(); result.folders = new ArrayList<>();
if (result.account != null &&
result.account.auth_type != AUTH_TYPE_PASSWORD &&
!Objects.equals(result.account.password, password))
auth = AUTH_TYPE_PASSWORD;
// Check IMAP server / get folders // Check IMAP server / get folders
String protocol = "imap" + (encryption == EmailService.ENCRYPTION_SSL ? "s" : ""); String protocol = "imap" + (encryption == EmailService.ENCRYPTION_SSL ? "s" : "");
try (EmailService iservice = new EmailService( try (EmailService iservice = new EmailService(
@ -911,6 +911,11 @@ public class FragmentAccount extends FragmentBase {
saving = false; saving = false;
invalidateOptionsMenu(); invalidateOptionsMenu();
Helper.setViewsEnabled(view, true); Helper.setViewsEnabled(view, true);
if (auth != AUTH_TYPE_PASSWORD) {
etUser.setEnabled(false);
tilPassword.getEditText().setEnabled(false);
btnCertificate.setEnabled(false);
}
pbSave.setVisibility(View.GONE); pbSave.setVisibility(View.GONE);
} }
@ -989,11 +994,6 @@ public class FragmentAccount extends FragmentBase {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
EntityAccount account = db.account().getAccount(id); EntityAccount account = db.account().getAccount(id);
if (account != null &&
account.auth_type != AUTH_TYPE_PASSWORD &&
!Objects.equals(account.password, password))
auth = AUTH_TYPE_PASSWORD;
if (should) { if (should) {
if (account == null) if (account == null)
return !TextUtils.isEmpty(host) && !TextUtils.isEmpty(user); return !TextUtils.isEmpty(host) && !TextUtils.isEmpty(user);
@ -1641,8 +1641,11 @@ public class FragmentAccount extends FragmentBase {
} }
private void onPassword() { private void onPassword() {
auth = AUTH_TYPE_PASSWORD;
etUser.setEnabled(true);
tilPassword.getEditText().setText(null); tilPassword.getEditText().setText(null);
tilPassword.getEditText().setEnabled(true); tilPassword.getEditText().setEnabled(true);
tilPassword.setEndIconMode(END_ICON_PASSWORD_TOGGLE);
tilPassword.requestFocus(); tilPassword.requestFocus();
} }
}); });