From d727c2bb527508ee45d094c30a49ab7031357bc1 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 16 Aug 2018 11:26:53 +0000 Subject: [PATCH] Improvements --- .../eu/faircode/email/FragmentAccount.java | 26 +++++++------- .../eu/faircode/email/FragmentFolder.java | 16 ++++----- .../eu/faircode/email/FragmentIdentity.java | 35 ++++++++++--------- 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index 8d8c4978..0e60d65a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -609,33 +609,33 @@ public class FragmentAccount extends FragmentEx { spProvider.setAdapter(padapter); if (savedInstanceState == null) { - if (!once) { - once = true; - - etName.setText(account == null ? null : account.name); - etHost.setText(account == null ? null : account.host); - etPort.setText(account == null ? null : Long.toString(account.port)); - etUser.setText(account == null ? null : account.user); - tilPassword.getEditText().setText(account == null ? null : account.password); - cbSynchronize.setChecked(account == null ? true : account.synchronize); - cbPrimary.setChecked(account == null ? true : account.primary); - } + if (once) + return; + once = true; + + etName.setText(account == null ? null : account.name); + etHost.setText(account == null ? null : account.host); + etPort.setText(account == null ? null : Long.toString(account.port)); + etUser.setText(account == null ? null : account.user); + tilPassword.getEditText().setText(account == null ? null : account.password); + cbSynchronize.setChecked(account == null ? true : account.synchronize); + cbPrimary.setChecked(account == null ? true : account.primary); } else { int provider = savedInstanceState.getInt("provider"); spProvider.setTag(provider); spProvider.setSelection(provider); - tilPassword.getEditText().setText(savedInstanceState.getString("password")); } Helper.setViewsEnabled(view, true); cbPrimary.setEnabled(cbSynchronize.isChecked()); - ibDelete.setVisibility(account == null ? View.GONE : View.VISIBLE); btnCheck.setVisibility(cbSynchronize.isChecked() ? View.VISIBLE : View.GONE); btnSave.setVisibility(cbSynchronize.isChecked() ? View.GONE : View.VISIBLE); + // Consider previous check/save/delete as cancelled + ibDelete.setVisibility(account == null ? View.GONE : View.VISIBLE); btnCheck.setEnabled(true); pbWait.setVisibility(View.GONE); } diff --git a/app/src/main/java/eu/faircode/email/FragmentFolder.java b/app/src/main/java/eu/faircode/email/FragmentFolder.java index 5153da1d..3c1c55b6 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolder.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolder.java @@ -133,11 +133,6 @@ public class FragmentFolder extends FragmentEx { return view; } - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - } - @Override public void onActivityCreated(@Nullable final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -158,14 +153,15 @@ public class FragmentFolder extends FragmentEx { } if (savedInstanceState == null) { - if (!once) { - once = true; + if (once) + return; + once = true; - cbSynchronize.setChecked(folder.synchronize); - etAfter.setText(Integer.toString(folder.after)); - } + cbSynchronize.setChecked(folder.synchronize); + etAfter.setText(Integer.toString(folder.after)); } + // Consider previous save as cancelled pbWait.setVisibility(View.GONE); Helper.setViewsEnabled(view, true); btnSave.setEnabled(true); diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index d4a78307..0ba2d17b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -398,30 +398,31 @@ public class FragmentIdentity extends FragmentEx { @Override public void onChanged(@Nullable final EntityIdentity identity) { if (savedInstanceState == null) { - if (!once) { - once = true; - - etName.setText(identity == null ? null : identity.name); - etEmail.setText(identity == null ? null : identity.email); - etReplyTo.setText(identity == null ? null : identity.replyto); - etHost.setText(identity == null ? null : identity.host); - cbStartTls.setChecked(identity == null ? false : identity.starttls); - etPort.setText(identity == null ? null : Long.toString(identity.port)); - etUser.setText(identity == null ? null : identity.user); - tilPassword.getEditText().setText(identity == null ? null : identity.password); - cbSynchronize.setChecked(identity == null ? true : identity.synchronize); - cbPrimary.setChecked(identity == null ? true : identity.primary); - - etName.requestFocus(); - } + if (once) + return; + once = true; + + etName.setText(identity == null ? null : identity.name); + etEmail.setText(identity == null ? null : identity.email); + etReplyTo.setText(identity == null ? null : identity.replyto); + etHost.setText(identity == null ? null : identity.host); + cbStartTls.setChecked(identity == null ? false : identity.starttls); + etPort.setText(identity == null ? null : Long.toString(identity.port)); + etUser.setText(identity == null ? null : identity.user); + tilPassword.getEditText().setText(identity == null ? null : identity.password); + cbSynchronize.setChecked(identity == null ? true : identity.synchronize); + cbPrimary.setChecked(identity == null ? true : identity.primary); + + etName.requestFocus(); } else tilPassword.getEditText().setText(savedInstanceState.getString("password")); Helper.setViewsEnabled(view, true); cbPrimary.setEnabled(cbSynchronize.isChecked()); - ibDelete.setVisibility(identity == null ? View.GONE : View.VISIBLE); + // Consider previous save/delete as cancelled + ibDelete.setVisibility(identity == null ? View.GONE : View.VISIBLE); btnSave.setEnabled(true); pbWait.setVisibility(View.GONE);