mirror of
https://github.com/bitwarden/android.git
synced 2025-02-16 11:59:57 +03:00
BIT-2233: Hide master password reprompt on add edit screen (#1265)
This commit is contained in:
parent
dad57de5c3
commit
074de1e1b6
7 changed files with 115 additions and 90 deletions
|
@ -198,29 +198,30 @@ fun LazyListScope.vaultAddEditCardItems(
|
|||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
}
|
||||
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
BitwardenSwitchWithActions(
|
||||
label = stringResource(id = R.string.password_prompt),
|
||||
isChecked = commonState.masterPasswordReprompt,
|
||||
onCheckedChange = commonHandlers.onToggleMasterPasswordReprompt,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "MasterPasswordRepromptToggle" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
actions = {
|
||||
IconButton(onClick = commonHandlers.onTooltipClick) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_tooltip),
|
||||
tint = MaterialTheme.colorScheme.onSurface,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.master_password_re_prompt_help,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
if (commonState.isUnlockWithPasswordEnabled) {
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
BitwardenSwitchWithActions(
|
||||
label = stringResource(id = R.string.password_prompt),
|
||||
isChecked = commonState.masterPasswordReprompt,
|
||||
onCheckedChange = commonHandlers.onToggleMasterPasswordReprompt,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "MasterPasswordRepromptToggle" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
actions = {
|
||||
IconButton(onClick = commonHandlers.onTooltipClick) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_tooltip),
|
||||
tint = MaterialTheme.colorScheme.onSurface,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.master_password_re_prompt_help,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
|
|
|
@ -315,28 +315,30 @@ fun LazyListScope.vaultAddEditIdentityItems(
|
|||
)
|
||||
}
|
||||
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
BitwardenSwitchWithActions(
|
||||
label = stringResource(id = R.string.password_prompt),
|
||||
isChecked = commonState.masterPasswordReprompt,
|
||||
onCheckedChange = commonTypeHandlers.onToggleMasterPasswordReprompt,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "MasterPasswordRepromptToggle" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
actions = {
|
||||
IconButton(onClick = commonTypeHandlers.onTooltipClick) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_tooltip),
|
||||
tint = MaterialTheme.colorScheme.onSurface,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.master_password_re_prompt_help,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
if (commonState.isUnlockWithPasswordEnabled) {
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
BitwardenSwitchWithActions(
|
||||
label = stringResource(id = R.string.password_prompt),
|
||||
isChecked = commonState.masterPasswordReprompt,
|
||||
onCheckedChange = commonTypeHandlers.onToggleMasterPasswordReprompt,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "MasterPasswordRepromptToggle" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
actions = {
|
||||
IconButton(onClick = commonTypeHandlers.onTooltipClick) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_tooltip),
|
||||
tint = MaterialTheme.colorScheme.onSurface,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.master_password_re_prompt_help,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
|
|
|
@ -239,29 +239,30 @@ fun LazyListScope.vaultAddEditLoginItems(
|
|||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
}
|
||||
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
BitwardenSwitchWithActions(
|
||||
label = stringResource(id = R.string.password_prompt),
|
||||
isChecked = commonState.masterPasswordReprompt,
|
||||
onCheckedChange = commonActionHandler.onToggleMasterPasswordReprompt,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "MasterPasswordRepromptToggle" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
actions = {
|
||||
IconButton(onClick = commonActionHandler.onTooltipClick) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_tooltip),
|
||||
tint = MaterialTheme.colorScheme.onSurface,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.master_password_re_prompt_help,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
if (commonState.isUnlockWithPasswordEnabled) {
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
BitwardenSwitchWithActions(
|
||||
label = stringResource(id = R.string.password_prompt),
|
||||
isChecked = commonState.masterPasswordReprompt,
|
||||
onCheckedChange = commonActionHandler.onToggleMasterPasswordReprompt,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "MasterPasswordRepromptToggle" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
actions = {
|
||||
IconButton(onClick = commonActionHandler.onTooltipClick) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_tooltip),
|
||||
tint = MaterialTheme.colorScheme.onSurface,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.master_password_re_prompt_help,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
|
|
|
@ -94,28 +94,30 @@ fun LazyListScope.vaultAddEditSecureNotesItems(
|
|||
)
|
||||
}
|
||||
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
BitwardenSwitchWithActions(
|
||||
label = stringResource(id = R.string.password_prompt),
|
||||
isChecked = commonState.masterPasswordReprompt,
|
||||
onCheckedChange = commonTypeHandlers.onToggleMasterPasswordReprompt,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "MasterPasswordRepromptToggle" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
actions = {
|
||||
IconButton(onClick = commonTypeHandlers.onTooltipClick) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_tooltip),
|
||||
tint = MaterialTheme.colorScheme.onSurface,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.master_password_re_prompt_help,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
if (commonState.isUnlockWithPasswordEnabled) {
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
BitwardenSwitchWithActions(
|
||||
label = stringResource(id = R.string.password_prompt),
|
||||
isChecked = commonState.masterPasswordReprompt,
|
||||
onCheckedChange = commonTypeHandlers.onToggleMasterPasswordReprompt,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "MasterPasswordRepromptToggle" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
actions = {
|
||||
IconButton(onClick = commonTypeHandlers.onTooltipClick) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_tooltip),
|
||||
tint = MaterialTheme.colorScheme.onSurface,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.master_password_re_prompt_help,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
|
|
|
@ -1517,6 +1517,7 @@ data class VaultAddEditState(
|
|||
@IgnoredOnParcel
|
||||
val originalCipher: CipherView? = null,
|
||||
val name: String = "",
|
||||
val isUnlockWithPasswordEnabled: Boolean = true,
|
||||
val masterPasswordReprompt: Boolean = false,
|
||||
val favorite: Boolean = false,
|
||||
val customFieldData: List<Custom> = emptyList(),
|
||||
|
|
|
@ -128,6 +128,8 @@ fun VaultAddEditState.ViewState.appendFolderAndOwnerData(
|
|||
cipherView = currentContentState.common.originalCipher,
|
||||
isIndividualVaultDisabled = isIndividualVaultDisabled,
|
||||
),
|
||||
isUnlockWithPasswordEnabled =
|
||||
activeAccount.trustedDevice?.hasMasterPassword != false,
|
||||
),
|
||||
)
|
||||
} ?: this
|
||||
|
|
|
@ -2107,6 +2107,22 @@ class VaultAddEditScreenTest : BaseComposeTest() {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `re-prompt toggle should display according to state`() {
|
||||
mutableStateFlow.value = DEFAULT_STATE_SECURE_NOTES
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithTextAfterScroll("Master password re-prompt")
|
||||
.assertIsDisplayed()
|
||||
|
||||
mutableStateFlow.update { currentState ->
|
||||
updateCommonContent(currentState) { copy(isUnlockWithPasswordEnabled = false) }
|
||||
}
|
||||
composeTestRule
|
||||
.onNodeWithText("Master password re-prompt")
|
||||
.assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the master password re-prompt toggle should be enabled or disabled according to state`() {
|
||||
mutableStateFlow.value = DEFAULT_STATE_SECURE_NOTES
|
||||
|
|
Loading…
Add table
Reference in a new issue