mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
BIT-2120: Add ElementID's to Add/Edit views (Login) (#1202)
This commit is contained in:
parent
11d862664d
commit
de1c76d772
3 changed files with 31 additions and 4 deletions
|
@ -12,6 +12,7 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.testTag
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.x8bit.bitwarden.R
|
||||
|
@ -48,6 +49,8 @@ fun BitwardenPasswordFieldWithActions(
|
|||
modifier: Modifier = Modifier,
|
||||
readOnly: Boolean = false,
|
||||
singleLine: Boolean = false,
|
||||
showPasswordTestTag: String? = null,
|
||||
passwordFieldTestTag: String? = null,
|
||||
actions: @Composable RowScope.() -> Unit = {},
|
||||
) {
|
||||
Row(
|
||||
|
@ -63,8 +66,10 @@ fun BitwardenPasswordFieldWithActions(
|
|||
readOnly = readOnly,
|
||||
singleLine = singleLine,
|
||||
modifier = Modifier
|
||||
.semantics { passwordFieldTestTag?.let { testTag = it } }
|
||||
.weight(1f)
|
||||
.padding(end = 8.dp),
|
||||
showPasswordTestTag = showPasswordTestTag,
|
||||
)
|
||||
actions()
|
||||
}
|
||||
|
@ -98,6 +103,8 @@ fun BitwardenPasswordFieldWithActions(
|
|||
readOnly: Boolean = false,
|
||||
singleLine: Boolean = false,
|
||||
initialShowPassword: Boolean = false,
|
||||
showPasswordTestTag: String? = null,
|
||||
passwordFieldTestTag: String? = null,
|
||||
actions: @Composable RowScope.() -> Unit = {},
|
||||
) {
|
||||
var shouldShowPassword by remember { mutableStateOf(initialShowPassword) }
|
||||
|
@ -110,6 +117,8 @@ fun BitwardenPasswordFieldWithActions(
|
|||
modifier = modifier,
|
||||
readOnly = readOnly,
|
||||
singleLine = singleLine,
|
||||
showPasswordTestTag = showPasswordTestTag,
|
||||
passwordFieldTestTag = passwordFieldTestTag,
|
||||
actions = actions,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ fun LazyListScope.vaultAddEditLoginItems(
|
|||
value = commonState.name,
|
||||
onValueChange = commonActionHandler.onNameTextChange,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "ItemNameEntry" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
|
@ -109,7 +110,8 @@ fun LazyListScope.vaultAddEditLoginItems(
|
|||
BitwardenTextFieldWithActions(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
.padding(horizontal = 16.dp)
|
||||
.semantics { testTag = "LoginTotpEntry" },
|
||||
label = stringResource(id = R.string.totp),
|
||||
value = loginState.totp,
|
||||
trailingIconContent = {
|
||||
|
@ -153,6 +155,7 @@ fun LazyListScope.vaultAddEditLoginItems(
|
|||
icon = painterResource(id = R.drawable.ic_light_bulb),
|
||||
onClick = onTotpSetupClick,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SetupTotpButton" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
|
@ -184,6 +187,7 @@ fun LazyListScope.vaultAddEditLoginItems(
|
|||
label = stringResource(id = R.string.new_uri),
|
||||
onClick = loginItemTypeHandlers.onAddNewUriClick,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "LoginAddNewUriButton" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
|
@ -393,7 +397,9 @@ private fun UsernameRow(
|
|||
modifier = Modifier.semantics { testTag = "GenerateUsernameButton" },
|
||||
)
|
||||
},
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "LoginUsernameEntry" }
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
|
||||
if (shouldShowDialog) {
|
||||
|
@ -432,6 +438,8 @@ private fun PasswordRow(
|
|||
label = stringResource(id = R.string.password),
|
||||
value = loginState.password,
|
||||
onValueChange = loginItemTypeHandlers.onPasswordTextChange,
|
||||
showPasswordTestTag = "ViewPasswordButton",
|
||||
passwordFieldTestTag = "LoginPasswordEntry",
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
|
@ -442,6 +450,8 @@ private fun PasswordRow(
|
|||
contentDescription = stringResource(id = R.string.check_password),
|
||||
),
|
||||
onClick = loginItemTypeHandlers.onPasswordCheckerClick,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "CheckPasswordButton" },
|
||||
)
|
||||
BitwardenIconButtonWithResource(
|
||||
iconRes = IconResource(
|
||||
|
@ -455,6 +465,8 @@ private fun PasswordRow(
|
|||
shouldShowDialog = true
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "RegeneratePasswordButton" },
|
||||
)
|
||||
|
||||
if (shouldShowDialog) {
|
||||
|
@ -485,7 +497,8 @@ private fun PasswordRow(
|
|||
value = loginState.password,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
.padding(horizontal = 16.dp)
|
||||
.semantics { testTag = "LoginPasswordEntry" },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.testTag
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenSelectionDialog
|
||||
|
@ -46,9 +48,12 @@ fun VaultAddEditUriItem(
|
|||
contentDescription = stringResource(id = R.string.options),
|
||||
),
|
||||
onClick = { shouldShowOptionsDialog = true },
|
||||
modifier = Modifier.semantics { testTag = "LoginUriOptionsButton" },
|
||||
)
|
||||
},
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "LoginUriEntry" }
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
|
||||
if (shouldShowOptionsDialog) {
|
||||
|
|
Loading…
Reference in a new issue