mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-30 13:52:58 -08:00
fix: Condition for credential #2541
This commit is contained in:
2 files changed
+7
-19
No files matched your search
@@ -160,12 +160,9 @@ class MainCredentialActivity : DatabaseModeActivity() {
|
||||
// Listen password checkbox to init advanced unlock and confirmation button
|
||||
mainCredentialView.onConditionToStoreCredentialChanged = { _, verified ->
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mDeviceUnlockViewModel?.checkConditionToStoreCredential(
|
||||
condition = verified
|
||||
)
|
||||
mDeviceUnlockViewModel?.checkConditionToStoreCredential(condition = verified)
|
||||
}
|
||||
// TODO Async by ViewModel
|
||||
enableConfirmationButton()
|
||||
mMainCredentialViewModel.onConditionChanged(mainCredentialView.isFill())
|
||||
}
|
||||
|
||||
// Encapsulate function to load database
|
||||
@@ -212,9 +209,9 @@ class MainCredentialActivity : DatabaseModeActivity() {
|
||||
filenameView?.text = state.fileName
|
||||
mainCredentialView.populateKeyFileView(state.keyFileUri)
|
||||
mainCredentialView.populateHardwareKeyView(state.hardwareKey)
|
||||
enableConfirmationButton()
|
||||
// Enable or not the open button if setting is checked
|
||||
confirmButtonView?.isEnabled = state.confirmButtonEnabled
|
||||
invalidateOptionsMenu()
|
||||
// TODO Check
|
||||
mainCredentialView.focusPasswordFieldAndOpenKeyboard()
|
||||
}
|
||||
}
|
||||
@@ -497,15 +494,6 @@ class MainCredentialActivity : DatabaseModeActivity() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun enableConfirmationButton() {
|
||||
// Enable or not the open button if setting is checked
|
||||
if (!PreferencesUtil.emptyPasswordAllowed(this@MainCredentialActivity)) {
|
||||
confirmButtonView?.isEnabled = mainCredentialView.isFill()
|
||||
} else {
|
||||
confirmButtonView?.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearCredentialsViews(
|
||||
clearKeyFile: Boolean,
|
||||
clearHardwareKey: Boolean
|
||||
|
||||
@@ -77,10 +77,10 @@ class MainCredentialViewModel(application: Application) : AndroidViewModel(appli
|
||||
mEmptyPasswordAllowed = PreferencesUtil.emptyPasswordAllowed(getApplication())
|
||||
}
|
||||
|
||||
fun refreshUI() {
|
||||
fun onConditionChanged(mainCredentialIsFilled: Boolean) {
|
||||
_databaseFileUIState.update {
|
||||
it.copy(
|
||||
emptyPasswordAllowed = mEmptyPasswordAllowed
|
||||
confirmButtonEnabled = if (mEmptyPasswordAllowed) true else mainCredentialIsFilled
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -289,7 +289,7 @@ class MainCredentialViewModel(application: Application) : AndroidViewModel(appli
|
||||
data class DatabaseFileUIState(
|
||||
val loading: Boolean = false,
|
||||
val showFileRevokedErrorMessage: Boolean = false,
|
||||
val emptyPasswordAllowed: Boolean = false,
|
||||
val confirmButtonEnabled: Boolean = false,
|
||||
val fileName: String = "",
|
||||
val keyFileUri: Uri? = null,
|
||||
val hardwareKey: HardwareKey? = null,
|
||||
|
||||
Reference in new issue
Block a user