From 0aac2bc55bc90526acc69610ea6bb541cfda876b Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Tue, 8 Dec 2020 12:05:35 +0100 Subject: [PATCH] Fix settings --- .../AdvancedUnlockNotificationService.kt | 4 ++++ .../settings/NestedAppSettingsFragment.kt | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/src/main/java/com/kunzisoft/keepass/notifications/AdvancedUnlockNotificationService.kt b/app/src/main/java/com/kunzisoft/keepass/notifications/AdvancedUnlockNotificationService.kt index 3bcbd1d56..60e860c0d 100644 --- a/app/src/main/java/com/kunzisoft/keepass/notifications/AdvancedUnlockNotificationService.kt +++ b/app/src/main/java/com/kunzisoft/keepass/notifications/AdvancedUnlockNotificationService.kt @@ -135,5 +135,9 @@ class AdvancedUnlockNotificationService : NotificationService() { }) } } + + fun stopService(context: Context) { + context.stopService(Intent(context, AdvancedUnlockNotificationService::class.java)) + } } } \ No newline at end of file diff --git a/app/src/main/java/com/kunzisoft/keepass/settings/NestedAppSettingsFragment.kt b/app/src/main/java/com/kunzisoft/keepass/settings/NestedAppSettingsFragment.kt index d6d14c4f6..5fe13714e 100644 --- a/app/src/main/java/com/kunzisoft/keepass/settings/NestedAppSettingsFragment.kt +++ b/app/src/main/java/com/kunzisoft/keepass/settings/NestedAppSettingsFragment.kt @@ -44,6 +44,7 @@ import com.kunzisoft.keepass.app.database.FileDatabaseHistoryAction import com.kunzisoft.keepass.biometric.BiometricUnlockDatabaseHelper import com.kunzisoft.keepass.education.Education import com.kunzisoft.keepass.icons.IconPackChooser +import com.kunzisoft.keepass.notifications.AdvancedUnlockNotificationService import com.kunzisoft.keepass.settings.preference.IconPackListPreference import com.kunzisoft.keepass.utils.UriUtil @@ -214,6 +215,7 @@ class NestedAppSettingsFragment : NestedSettingsFragment() { val biometricUnlockEnablePreference: SwitchPreference? = findPreference(getString(R.string.biometric_unlock_enable_key)) val deviceCredentialUnlockEnablePreference: SwitchPreference? = findPreference(getString(R.string.device_credential_unlock_enable_key)) val autoOpenPromptPreference: SwitchPreference? = findPreference(getString(R.string.biometric_auto_open_prompt_key)) + val tempAdvancedUnlockPreference: SwitchPreference? = findPreference(getString(R.string.temp_advanced_unlock_enable_key)) val biometricUnlockSupported = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { BiometricUnlockDatabaseHelper.biometricUnlockSupported(activity) @@ -237,6 +239,7 @@ class NestedAppSettingsFragment : NestedSettingsFragment() { deleteKeysMessage(activity) { biometricUnlockEnablePreference.isChecked = false autoOpenPromptPreference?.isEnabled = deviceCredentialChecked + tempAdvancedUnlockPreference?.isEnabled = deviceCredentialChecked } } else { if (deviceCredentialChecked) { @@ -247,6 +250,7 @@ class NestedAppSettingsFragment : NestedSettingsFragment() { } } else { autoOpenPromptPreference?.isEnabled = true + tempAdvancedUnlockPreference?.isEnabled = true } } true @@ -275,6 +279,7 @@ class NestedAppSettingsFragment : NestedSettingsFragment() { deleteKeysMessage(activity) { deviceCredentialUnlockEnablePreference.isChecked = false autoOpenPromptPreference?.isEnabled = biometricChecked + tempAdvancedUnlockPreference?.isEnabled = biometricChecked } } else { if (biometricChecked) { @@ -285,6 +290,7 @@ class NestedAppSettingsFragment : NestedSettingsFragment() { } } else { autoOpenPromptPreference?.isEnabled = true + tempAdvancedUnlockPreference?.isEnabled = true } } true @@ -294,6 +300,16 @@ class NestedAppSettingsFragment : NestedSettingsFragment() { autoOpenPromptPreference?.isEnabled = biometricUnlockEnablePreference?.isChecked == true || deviceCredentialUnlockEnablePreference?.isChecked == true + tempAdvancedUnlockPreference?.isEnabled = biometricUnlockEnablePreference?.isChecked == true + || deviceCredentialUnlockEnablePreference?.isChecked == true + + tempAdvancedUnlockPreference?.setOnPreferenceClickListener { + tempAdvancedUnlockPreference.isChecked = !tempAdvancedUnlockPreference.isChecked + deleteKeysMessage(activity) { + tempAdvancedUnlockPreference.isChecked = !tempAdvancedUnlockPreference.isChecked + } + true + } val deleteKeysFingerprints: Preference? = findPreference(getString(R.string.biometric_delete_all_key_key)) if (biometricUnlockSupported || deviceCredentialUnlockSupported) { @@ -339,6 +355,7 @@ class NestedAppSettingsFragment : NestedSettingsFragment() { } }) } + AdvancedUnlockNotificationService.stopService(activity.applicationContext) CipherDatabaseAction.getInstance(activity.applicationContext).deleteAll() } .setNegativeButton(resources.getString(android.R.string.cancel)