diff --git a/app/src/main/java/com/kunzisoft/keepass/password/PasswordActivity.java b/app/src/main/java/com/kunzisoft/keepass/password/PasswordActivity.java index ce38fe592..cafe326e5 100644 --- a/app/src/main/java/com/kunzisoft/keepass/password/PasswordActivity.java +++ b/app/src/main/java/com/kunzisoft/keepass/password/PasswordActivity.java @@ -121,6 +121,7 @@ public class PasswordActivity extends StylishActivity private CompoundButton checkboxPasswordView; private CompoundButton checkboxKeyfileView; private CompoundButton checkboxDefaultDatabaseView; + private CompoundButton.OnCheckedChangeListener enableButtonOncheckedChangeListener; private DefaultCheckChange defaultCheckChange; private ValidateButtonViewClickListener validateButtonViewClickListener; @@ -322,6 +323,18 @@ public class PasswordActivity extends StylishActivity // For check shutdown super.onResume(); + // Enable or not the open button + if (!PreferencesUtil.emptyPasswordAllowed(PasswordActivity.this)) { + confirmButtonView.setEnabled(checkboxPasswordView.isChecked()); + } else { + confirmButtonView.setEnabled(true); + } + enableButtonOncheckedChangeListener = (buttonView, isChecked) -> { + if (!PreferencesUtil.emptyPasswordAllowed(PasswordActivity.this)) { + confirmButtonView.setEnabled(isChecked); + } + }; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // Check if fingerprint well init (be called the first time the fingerprint is configured // and the activity still active) @@ -511,6 +524,9 @@ public class PasswordActivity extends StylishActivity } } } + + // Add old listener to enable the button, only be call here because of onCheckedChange bug + enableButtonOncheckedChangeListener.onCheckedChanged(compoundButton, checked); }); // callback for fingerprint findings diff --git a/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.java b/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.java index 62025bb8e..ee713e0ea 100644 --- a/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.java +++ b/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.java @@ -152,6 +152,12 @@ public class PreferencesUtil { context.getString(R.string.setting_icon_pack_choose_default)); } + public static boolean emptyPasswordAllowed(Context context) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + return prefs.getBoolean(context.getString(R.string.allow_no_password_key), + context.getResources().getBoolean(R.bool.allow_no_password_default)); + } + /** * All preference keys associated with education */ diff --git a/app/src/main/res/color/text_color_button.xml b/app/src/main/res/color/text_color_button.xml new file mode 100644 index 000000000..7c2d988bf --- /dev/null +++ b/app/src/main/res/color/text_color_button.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-v21/button_background.xml b/app/src/main/res/drawable-v21/button_large_enable.xml similarity index 100% rename from app/src/main/res/drawable-v21/button_background.xml rename to app/src/main/res/drawable-v21/button_large_enable.xml diff --git a/app/src/main/res/drawable/button_large.xml b/app/src/main/res/drawable/button_large.xml new file mode 100644 index 000000000..dfb9db2d0 --- /dev/null +++ b/app/src/main/res/drawable/button_large.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_large_disable.xml b/app/src/main/res/drawable/button_large_disable.xml new file mode 100644 index 000000000..201c24fcb --- /dev/null +++ b/app/src/main/res/drawable/button_large_disable.xml @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_large_enable.xml b/app/src/main/res/drawable/button_large_enable.xml new file mode 100644 index 000000000..737973744 --- /dev/null +++ b/app/src/main/res/drawable/button_large_enable.xml @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f3e4e8e4c..6d1f08c8a 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -22,6 +22,8 @@ #ffffff #000000 #0e0e0e + #bdbdbd + #9e9e9e #ffa726 #fb8c00 diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 31a0ef50a..7ee71eadf 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -93,6 +93,7 @@ education_screen_reclicked_key settings_appearance_key magic_keyboard_key + allow_no_password_key true true @@ -124,6 +125,7 @@ false false false + true 300000 60000 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c7d2e8e5c..27f69c84e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -265,6 +265,8 @@ Keyboard Magikeyboayd Activate a custom keyboard that populates your passwords and all your identity fields easily. + Allow no password + Enable the open button if no password identification is selected. Reset education screens Highlight the elements to learn how the application works diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 9b34d1b73..cf64837b5 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -249,8 +249,8 @@