mirror of
https://github.com/bitwarden/android.git
synced 2026-06-09 08:09:16 -05:00
Rename URI detection method related VM and Screen items add add tests (#750)
This commit is contained in:
committed by
Álison Fernandes
parent
5279f1a4ba
commit
862d9b5c94
@@ -172,10 +172,10 @@ fun AutoFillScreen(
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
UriMatchDetectionDialog(
|
||||
selectedUriDetection = state.uriDetectionMethod,
|
||||
onDetectionSelect = remember(viewModel) {
|
||||
{ viewModel.trySendAction(AutoFillAction.UriDetectionMethodSelect(it)) }
|
||||
DefaultUriMatchTypeRow(
|
||||
selectedUriMatchType = state.defaultUriMatchType,
|
||||
onUriMatchTypeSelect = remember(viewModel) {
|
||||
{ viewModel.trySendAction(AutoFillAction.DefaultUriMatchTypeSelect(it)) }
|
||||
},
|
||||
)
|
||||
BitwardenTextRow(
|
||||
@@ -194,9 +194,9 @@ fun AutoFillScreen(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun UriMatchDetectionDialog(
|
||||
selectedUriDetection: UriMatchType,
|
||||
onDetectionSelect: (UriMatchType) -> Unit,
|
||||
private fun DefaultUriMatchTypeRow(
|
||||
selectedUriMatchType: UriMatchType,
|
||||
onUriMatchTypeSelect: (UriMatchType) -> Unit,
|
||||
) {
|
||||
var shouldShowDialog by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
@@ -207,7 +207,7 @@ private fun UriMatchDetectionDialog(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text(
|
||||
text = selectedUriDetection.displayLabel(),
|
||||
text = selectedUriMatchType.displayLabel(),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
@@ -222,10 +222,10 @@ private fun UriMatchDetectionDialog(
|
||||
uriMatchTypes.forEach { option ->
|
||||
BitwardenSelectionRow(
|
||||
text = option.displayLabel,
|
||||
isSelected = option == selectedUriDetection,
|
||||
isSelected = option == selectedUriMatchType,
|
||||
onClick = {
|
||||
shouldShowDialog = false
|
||||
onDetectionSelect(
|
||||
onUriMatchTypeSelect(
|
||||
uriMatchTypes.first { it == option },
|
||||
)
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ class AutoFillViewModel @Inject constructor(
|
||||
isAutoFillServicesEnabled = settingsRepository.isAutofillEnabledStateFlow.value,
|
||||
isCopyTotpAutomaticallyEnabled = false,
|
||||
isUseInlineAutoFillEnabled = settingsRepository.isInlineAutofillEnabled,
|
||||
uriDetectionMethod = settingsRepository.defaultUriMatchType,
|
||||
defaultUriMatchType = settingsRepository.defaultUriMatchType,
|
||||
),
|
||||
) {
|
||||
|
||||
@@ -56,7 +56,7 @@ class AutoFillViewModel @Inject constructor(
|
||||
is AutoFillAction.AutoFillServicesClick -> handleAutoFillServicesClick(action)
|
||||
AutoFillAction.BackClick -> handleBackClick()
|
||||
is AutoFillAction.CopyTotpAutomaticallyClick -> handleCopyTotpAutomaticallyClick(action)
|
||||
is AutoFillAction.UriDetectionMethodSelect -> handleUriDetectionMethodSelect(action)
|
||||
is AutoFillAction.DefaultUriMatchTypeSelect -> handleDefaultUriMatchTypeSelect(action)
|
||||
AutoFillAction.BlockAutoFillClick -> handleBlockAutoFillClick()
|
||||
is AutoFillAction.UseInlineAutofillClick -> handleUseInlineAutofillClick(action)
|
||||
is AutoFillAction.Internal.AutofillEnabledUpdateReceive -> {
|
||||
@@ -95,10 +95,10 @@ class AutoFillViewModel @Inject constructor(
|
||||
mutableStateFlow.update { it.copy(isUseInlineAutoFillEnabled = action.isEnabled) }
|
||||
}
|
||||
|
||||
private fun handleUriDetectionMethodSelect(action: AutoFillAction.UriDetectionMethodSelect) {
|
||||
settingsRepository.defaultUriMatchType = action.uriDetectionMethod
|
||||
private fun handleDefaultUriMatchTypeSelect(action: AutoFillAction.DefaultUriMatchTypeSelect) {
|
||||
settingsRepository.defaultUriMatchType = action.defaultUriMatchType
|
||||
mutableStateFlow.update {
|
||||
it.copy(uriDetectionMethod = action.uriDetectionMethod)
|
||||
it.copy(defaultUriMatchType = action.defaultUriMatchType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ data class AutoFillState(
|
||||
val isAutoFillServicesEnabled: Boolean,
|
||||
val isCopyTotpAutomaticallyEnabled: Boolean,
|
||||
val isUseInlineAutoFillEnabled: Boolean,
|
||||
val uriDetectionMethod: UriMatchType,
|
||||
val defaultUriMatchType: UriMatchType,
|
||||
) : Parcelable {
|
||||
|
||||
/**
|
||||
@@ -195,8 +195,8 @@ sealed class AutoFillAction {
|
||||
/**
|
||||
* User selected a [UriMatchType].
|
||||
*/
|
||||
data class UriDetectionMethodSelect(
|
||||
val uriDetectionMethod: UriMatchType,
|
||||
data class DefaultUriMatchTypeSelect(
|
||||
val defaultUriMatchType: UriMatchType,
|
||||
) : AutoFillAction()
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user