fix: refresh when activate setting

This commit is contained in:
J-Jamet
2025-08-12 11:11:12 +02:00
parent 756454abc3
commit 2d398908de
2 changed files with 12 additions and 4 deletions

View File

@@ -172,6 +172,7 @@ class DeviceUnlockFragment: Fragment() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
mDeviceUnlockViewModel.checkUnlockAvailability()
keepConnection = false keepConnection = false
} }

View File

@@ -45,12 +45,11 @@ class DeviceUnlockViewModel(application: Application): AndroidViewModel(applicat
} }
/** /**
* Check unlock availability and change the current mode depending of device's state * Check unlock availability by verifying device settings and database mode
*/ */
fun checkUnlockAvailability(databaseFileUri: Uri?) { fun checkUnlockAvailability() {
databaseUri = databaseFileUri
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
cipherDatabaseAction.containsCipherDatabase(databaseFileUri) { containsCipherDatabase -> cipherDatabaseAction.containsCipherDatabase(databaseUri) { containsCipherDatabase ->
if (PreferencesUtil.isBiometricUnlockEnable(getApplication())) { if (PreferencesUtil.isBiometricUnlockEnable(getApplication())) {
// biometric not supported (by API level or hardware) so keep option hidden // biometric not supported (by API level or hardware) so keep option hidden
// or manually disable // or manually disable
@@ -80,6 +79,14 @@ class DeviceUnlockViewModel(application: Application): AndroidViewModel(applicat
} }
} }
/**
* Check unlock availability and change the current mode depending of device's state
*/
fun checkUnlockAvailability(databaseFileUri: Uri?) {
databaseUri = databaseFileUri
checkUnlockAvailability()
}
private fun isModeChanging(newMode: DeviceUnlockMode): Boolean { private fun isModeChanging(newMode: DeviceUnlockMode): Boolean {
return _uiState.value.deviceUnlockMode != newMode return _uiState.value.deviceUnlockMode != newMode
} }