From f89d5c282faf34234440a89d1765ac43baa54be9 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 25 Apr 2020 16:53:40 +0530 Subject: Improve UX around settings items (#744) Fixes #461 --- app/src/main/java/com/zeapo/pwdstore/UserPreference.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/UserPreference.kt') diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt index a9629c6c..67a9bc2d 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt @@ -101,7 +101,6 @@ class UserPreference : AppCompatActivity() { // General preferences val showTimePreference = findPreference("general_show_time") - val clearAfterCopyPreference = findPreference("clear_after_copy") val clearClipboard20xPreference = findPreference("clear_clipboard_20x") // Autofill preferences @@ -129,7 +128,6 @@ class UserPreference : AppCompatActivity() { viewSshKeyPreference?.isVisible = sharedPreferences.getBoolean("use_generated_key", false) deleteRepoPreference?.isVisible = !sharedPreferences.getBoolean("git_external", false) clearHotpIncrementPreference?.isVisible = sharedPreferences.getBoolean("hotp_remember_check", false) - clearAfterCopyPreference?.isVisible = sharedPreferences.getString("general_show_time", "45")?.toInt() != 0 clearClipboard20xPreference?.isVisible = sharedPreferences.getString("general_show_time", "45")?.toInt() != 0 val selectedKeys = (sharedPreferences.getStringSet("openpgp_key_ids_set", null) ?: HashSet()).toTypedArray() @@ -273,7 +271,6 @@ class UserPreference : AppCompatActivity() { showTimePreference?.onPreferenceChangeListener = ChangeListener { _, newValue: Any? -> try { val isEnabled = newValue.toString().toInt() != 0 - clearAfterCopyPreference?.isVisible = isEnabled clearClipboard20xPreference?.isVisible = isEnabled true } catch (e: NumberFormatException) { @@ -282,10 +279,10 @@ class UserPreference : AppCompatActivity() { } showTimePreference?.summaryProvider = Preference.SummaryProvider { - getString(R.string.pref_show_time_summary, sharedPreferences.getString("general_show_time", "45")) + getString(R.string.pref_clipboard_timeout_summary, sharedPreferences.getString("general_show_time", "45")) } - findPreference("biometric_auth")?.apply { + findPreference("biometric_auth")?.apply { val isFingerprintSupported = BiometricManager.from(requireContext()).canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS if (!isFingerprintSupported) { isEnabled = false @@ -337,10 +334,10 @@ class UserPreference : AppCompatActivity() { val prefIsCustomDict = findPreference("pref_key_is_custom_dict") val prefCustomDictPicker = findPreference("pref_key_custom_dict") val prefPwgenType = findPreference("pref_key_pwgen_type") - showHideDependentPrefs(prefPwgenType?.value, prefIsCustomDict, prefCustomDictPicker) + updateXkPasswdPrefsVisibility(prefPwgenType?.value, prefIsCustomDict, prefCustomDictPicker) prefPwgenType?.onPreferenceChangeListener = ChangeListener { _, newValue -> - showHideDependentPrefs(newValue, prefIsCustomDict, prefCustomDictPicker) + updateXkPasswdPrefsVisibility(newValue, prefIsCustomDict, prefCustomDictPicker) true } @@ -356,7 +353,7 @@ class UserPreference : AppCompatActivity() { } } - private fun showHideDependentPrefs(newValue: Any?, prefIsCustomDict: CheckBoxPreference?, prefCustomDictPicker: Preference?) { + private fun updateXkPasswdPrefsVisibility(newValue: Any?, prefIsCustomDict: CheckBoxPreference?, prefCustomDictPicker: Preference?) { when (newValue as String) { PgpActivity.KEY_PWGEN_TYPE_CLASSIC -> { prefIsCustomDict?.isVisible = false -- cgit v1.2.3