mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 10:25:51 +03:00
Fix crash when entering to "Protect access" screen.
This commit is contained in:
parent
79b451546d
commit
8b7601029b
1 changed files with 30 additions and 36 deletions
|
@ -16,9 +16,7 @@
|
|||
|
||||
package im.vector.app.features.settings
|
||||
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.SwitchPreference
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
@ -80,13 +78,13 @@ class VectorSettingsPinFragment :
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
updateBiometricPrefState(isPinCodeChecked = usePinCodePref.isChecked)
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
refreshPinCodeStatus()
|
||||
}
|
||||
}
|
||||
|
||||
override fun bindPref() {
|
||||
refreshPinCodeStatus()
|
||||
|
||||
usePinCodePref.setOnPreferenceChangeListener { _, value ->
|
||||
val isChecked = (value as? Boolean).orFalse()
|
||||
updateBiometricPrefState(isPinCodeChecked = isChecked)
|
||||
|
@ -130,9 +128,7 @@ class VectorSettingsPinFragment :
|
|||
.onFailure { Timber.e(it) }
|
||||
}
|
||||
|
||||
private fun refreshPinCodeStatus() {
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||
private suspend fun refreshPinCodeStatus() {
|
||||
val hasPinCode = pinCodeStore.hasEncodedPin()
|
||||
usePinCodePref.isChecked = hasPinCode
|
||||
usePinCodePref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
|
@ -162,14 +158,12 @@ class VectorSettingsPinFragment :
|
|||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showEnableBiometricErrorMessage() {
|
||||
context?.toast(R.string.settings_security_pin_code_use_biometrics_error)
|
||||
}
|
||||
|
||||
private val pinActivityResultLauncher = registerStartForActivityResult {
|
||||
refreshPinCodeStatus()
|
||||
// Nothing to do, refreshPinCodeStatus() will be called by `onResume`
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue