mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Add setting to disable the open button #126
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
5
app/src/main/res/color/text_color_button.xml
Normal file
5
app/src/main/res/color/text_color_button.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/grey" android:state_enabled="false" />
|
||||
<item android:color="@color/colorTextInverse" android:state_enabled="true" />
|
||||
</selector>
|
||||
5
app/src/main/res/drawable/button_large.xml
Normal file
5
app/src/main/res/drawable/button_large.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/button_large_enable" android:state_enabled="true" />
|
||||
<item android:drawable="@drawable/button_large_disable" android:state_enabled="false" />
|
||||
</selector>
|
||||
15
app/src/main/res/drawable/button_large_disable.xml
Normal file
15
app/src/main/res/drawable/button_large_disable.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<corners
|
||||
android:radius="0dp" />
|
||||
<padding
|
||||
android:left="0dp"
|
||||
android:right="0dp"
|
||||
android:top="12dp"
|
||||
android:bottom="12dp"/>
|
||||
<solid android:color="@color/grey_dark"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
15
app/src/main/res/drawable/button_large_enable.xml
Normal file
15
app/src/main/res/drawable/button_large_enable.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<corners
|
||||
android:radius="0dp" />
|
||||
<padding
|
||||
android:left="0dp"
|
||||
android:right="0dp"
|
||||
android:top="12dp"
|
||||
android:bottom="12dp"/>
|
||||
<solid android:color="@color/orange"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -22,6 +22,8 @@
|
||||
<color name="white">#ffffff</color>
|
||||
<color name="black">#000000</color>
|
||||
<color name="dark">#0e0e0e</color>
|
||||
<color name="grey">#bdbdbd</color>
|
||||
<color name="grey_dark">#9e9e9e</color>
|
||||
|
||||
<color name="orange_light">#ffa726</color>
|
||||
<color name="orange">#fb8c00</color>
|
||||
|
||||
@@ -93,6 +93,7 @@
|
||||
<string name="education_screen_reclicked_key" translatable="false">education_screen_reclicked_key</string>
|
||||
<string name="settings_appearance_key" translatable="false">settings_appearance_key</string>
|
||||
<string name="magic_keyboard_key" translatable="false">magic_keyboard_key</string>
|
||||
<string name="allow_no_password_key" translatable="false">allow_no_password_key</string>
|
||||
|
||||
<bool name="maskpass_default" translatable="false">true</bool>
|
||||
<bool name="keyfile_default" translatable="false">true</bool>
|
||||
@@ -124,6 +125,7 @@
|
||||
<bool name="education_entry_new_field_default" translatable="false">false</bool>
|
||||
<bool name="education_screen_reclicked_default" translatable="false">false</bool>
|
||||
<bool name="magic_keyboard_default" translatable="false">false</bool>
|
||||
<bool name="allow_no_password_default" translatable="false">true</bool>
|
||||
|
||||
<string name="app_timeout_default" translatable="false">300000</string>
|
||||
<string name="clipboard_timeout_default" translatable="false">60000</string>
|
||||
|
||||
@@ -265,6 +265,8 @@
|
||||
<string name="keyboard">Keyboard</string>
|
||||
<string name="magic_keyboard_title">Magikeyboayd</string>
|
||||
<string name="magic_keyboard_summary">Activate a custom keyboard that populates your passwords and all your identity fields easily.</string>
|
||||
<string name="allow_no_password_title">Allow no password</string>
|
||||
<string name="allow_no_password_summary">Enable the open button if no password identification is selected.</string>
|
||||
|
||||
<string name="reset_education_screens_title">Reset education screens</string>
|
||||
<string name="reset_education_screens_summary">Highlight the elements to learn how the application works</string>
|
||||
|
||||
@@ -249,8 +249,8 @@
|
||||
<!-- Button Style -->
|
||||
<style name="KeepassDXStyle.v21.Button" parent="Base.TextAppearance.AppCompat.Button" />
|
||||
<style name="KeepassDXStyle.Button" parent="KeepassDXStyle.v21.Button">
|
||||
<item name="android:textColor">?attr/textColorInverse</item>
|
||||
<item name="android:background">@drawable/button_background</item>
|
||||
<item name="android:textColor">@color/text_color_button</item>
|
||||
<item name="android:background">@drawable/button_large</item>
|
||||
<item name="android:gravity">center</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.Button.Primary" parent="KeepassDXStyle.v21.Button">
|
||||
|
||||
@@ -20,6 +20,17 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/general">
|
||||
|
||||
<SwitchPreference
|
||||
android:summary="@string/allow_no_password_summary"
|
||||
android:defaultValue="@bool/allow_no_password_default"
|
||||
android:title="@string/allow_no_password_title"
|
||||
android:key="@string/allow_no_password_key"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/search_label">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user