From e8c1247d62607dd9cb16f08c6a7cba7f98834e6a Mon Sep 17 00:00:00 2001 From: Joshua Soberg Date: Sat, 30 Jan 2021 11:56:28 -0500 Subject: [PATCH] Remove unused import, make some fields final, and simplify an if statement --- .../andotp/Preferences/CredentialsPreference.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java b/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java index 6d4a621c..0976a253 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java @@ -30,7 +30,6 @@ import android.preference.DialogPreference; import android.text.Editable; import android.text.InputType; import android.text.TextWatcher; -import android.text.method.PasswordTransformationMethod; import android.util.AttributeSet; import android.view.View; import android.widget.AdapterView; @@ -67,7 +66,7 @@ public class CredentialsPreference extends DialogPreference boolean testEncryptionChange(byte[] newKey); } - private List entries; + private final List entries; private static final List entryValues = Arrays.asList( AuthMethod.NONE, AuthMethod.PASSWORD, @@ -77,7 +76,7 @@ public class CredentialsPreference extends DialogPreference private int minLength = 0; - private Settings settings; + private final Settings settings; private AuthMethod value = AuthMethod.NONE; private EncryptionChangeCallback encryptionChangeCallback = null; @@ -230,14 +229,10 @@ public class CredentialsPreference extends DialogPreference if (password.length() >= minLength) { toShortWarning.setVisibility(View.GONE); - String confirm = passwordConfirm.getEditableText().toString(); - if (!password.isEmpty() && !confirm.isEmpty() && password.equals(confirm)) { - btnSave.setEnabled(true); - } else { - btnSave.setEnabled(false); - } + boolean canSave = !password.isEmpty() && !confirm.isEmpty() && password.equals(confirm); + btnSave.setEnabled(canSave); } else { toShortWarning.setVisibility(View.VISIBLE); }