diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/AuthenticationViewModel.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/AuthenticationViewModel.kt index c8671b49d..ebac6466b 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/AuthenticationViewModel.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/AuthenticationViewModel.kt @@ -42,6 +42,7 @@ class AuthenticationViewModel( private val biometricManager: BiometricManager, private val getVersionInfo: GetVersionInfoProvider, private val standardPreferenceProvider: StandardPreferenceProvider, + private val walletViewModel: WalletViewModel, ) : AndroidViewModel(application) { private val executor: Executor by lazy { ContextCompat.getMainExecutor(application) } private lateinit var biometricPrompt: BiometricPrompt @@ -94,10 +95,20 @@ class AuthenticationViewModel( combine( isAppAccessAuthenticationRequired.filterNotNull(), appAccessAuthentication, - ) { required: Boolean, state: AuthenticationUIState -> + walletViewModel.secretState, + ) { required: Boolean, state: AuthenticationUIState, secretState: SecretState -> when { (!required || versionInfo.isRunningUnderTestService) -> AuthenticationUIState.NotRequired - state == AuthenticationUIState.Initial -> AuthenticationUIState.Required + (state == AuthenticationUIState.Initial) -> { + if (secretState == SecretState.None || + secretState == SecretState.NeedsWarning + ) { + appAccessAuthentication.value = AuthenticationUIState.NotRequired + AuthenticationUIState.NotRequired + } else { + AuthenticationUIState.Required + } + } else -> state } }.stateIn( diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/AuthenticationView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/AuthenticationView.kt index f49c59148..24318cace 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/AuthenticationView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/AuthenticationView.kt @@ -118,6 +118,7 @@ fun AuthenticationErrorDialog( ) } +// Currently unused, we keep it for further iterations @Composable fun AuthenticationFailedDialog( onDismiss: () -> Unit, diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/paymentrequest/viewmodel/PaymentRequestViewModel.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/paymentrequest/viewmodel/PaymentRequestViewModel.kt index d1d991fe2..82a2edf4f 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/paymentrequest/viewmodel/PaymentRequestViewModel.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/paymentrequest/viewmodel/PaymentRequestViewModel.kt @@ -45,7 +45,7 @@ class PaymentRequestViewModel( getMonetarySeparators: GetMonetarySeparatorProvider, private val getSpendingKeyUseCase: GetSpendingKeyUseCase, private val getSynchronizer: GetSynchronizerUseCase, - private val supportViewModel: SupportViewModel, + supportViewModel: SupportViewModel, walletViewModel: WalletViewModel, observeAddressBookContacts: ObserveAddressBookContactsUseCase, ) : ViewModel() {