mirror of
https://github.com/bitwarden/android.git
synced 2024-11-26 19:36:18 +03:00
BIT-1594: Send form element IDs (#929)
This commit is contained in:
parent
33c64db85c
commit
f57eec5aa5
4 changed files with 37 additions and 1 deletions
|
@ -39,6 +39,7 @@ fun SendContent(
|
|||
BitwardenPolicyWarningText(
|
||||
text = stringResource(id = R.string.send_disabled_warning),
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendOptionsPolicyInEffectLabel" }
|
||||
.padding(horizontal = 16.dp)
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
|
|
|
@ -27,11 +27,14 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clipToBounds
|
||||
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.semantics.testTagsAsResourceId
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenFilledTonalButton
|
||||
|
@ -51,6 +54,7 @@ import com.x8bit.bitwarden.ui.tools.feature.send.addsend.handlers.AddSendHandler
|
|||
/**
|
||||
* Content view for the [AddSendScreen].
|
||||
*/
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
fun AddSendContent(
|
||||
|
@ -68,6 +72,7 @@ fun AddSendContent(
|
|||
|
||||
Column(
|
||||
modifier = modifier
|
||||
.semantics { testTagsAsResourceId = true }
|
||||
.verticalScroll(rememberScrollState()),
|
||||
) {
|
||||
if (policyDisablesSend) {
|
||||
|
@ -82,6 +87,7 @@ fun AddSendContent(
|
|||
|
||||
BitwardenTextField(
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendNameEntry" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
label = stringResource(id = R.string.name),
|
||||
|
@ -150,7 +156,9 @@ fun AddSendContent(
|
|||
)
|
||||
} else if (isAddMode) {
|
||||
Text(
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendCurrentFileNameLabel" }
|
||||
.align(Alignment.CenterHorizontally),
|
||||
text = type.name ?: stringResource(id = R.string.no_file_chosen),
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
|
@ -168,6 +176,7 @@ fun AddSendContent(
|
|||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendChooseFileButton" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
|
@ -214,6 +223,7 @@ fun AddSendContent(
|
|||
is AddSendState.ViewState.Content.SendType.Text -> {
|
||||
BitwardenTextField(
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendTextContentEntry" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
label = stringResource(id = R.string.text),
|
||||
|
@ -226,6 +236,7 @@ fun AddSendContent(
|
|||
Spacer(modifier = Modifier.height(16.dp))
|
||||
BitwardenWideSwitch(
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendHideTextByDefaultToggle" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
label = stringResource(id = R.string.hide_text_by_default),
|
||||
|
@ -270,6 +281,7 @@ private fun AddSendOptions(
|
|||
var isExpanded by rememberSaveable { mutableStateOf(false) }
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendShowHideOptionsButton" }
|
||||
.fillMaxWidth()
|
||||
.clickable(
|
||||
onClickLabel = if (isExpanded) {
|
||||
|
@ -310,6 +322,7 @@ private fun AddSendOptions(
|
|||
if (isAddMode) {
|
||||
SendDeletionDateChooser(
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendDeletionOptionsPicker" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
dateFormatPattern = state.common.dateFormatPattern,
|
||||
|
@ -321,6 +334,7 @@ private fun AddSendOptions(
|
|||
Spacer(modifier = Modifier.height(8.dp))
|
||||
SendExpirationDateChooser(
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendExpirationOptionsPicker" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
dateFormatPattern = state.common.dateFormatPattern,
|
||||
|
@ -407,6 +421,7 @@ private fun AddSendOptions(
|
|||
range = 0..Int.MAX_VALUE,
|
||||
textFieldReadOnly = sendRestrictionPolicy,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendMaxAccessCountEntry" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
|
@ -451,6 +466,7 @@ private fun AddSendOptions(
|
|||
value = state.common.passwordInput,
|
||||
onValueChange = addSendHandlers.onPasswordChange,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendNewPasswordEntry" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
|
@ -469,6 +485,7 @@ private fun AddSendOptions(
|
|||
Spacer(modifier = Modifier.height(16.dp))
|
||||
BitwardenWideSwitch(
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendHideEmailSwitch" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
label = stringResource(id = R.string.hide_email),
|
||||
|
@ -480,6 +497,7 @@ private fun AddSendOptions(
|
|||
Spacer(modifier = Modifier.height(16.dp))
|
||||
BitwardenWideSwitch(
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendDeactivateSwitch" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
label = stringResource(id = R.string.disable_send),
|
||||
|
|
|
@ -19,6 +19,8 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
|||
import androidx.compose.ui.platform.LocalContext
|
||||
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.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.x8bit.bitwarden.R
|
||||
|
@ -44,6 +46,7 @@ import com.x8bit.bitwarden.ui.platform.theme.LocalIntentManager
|
|||
import com.x8bit.bitwarden.ui.platform.theme.LocalPermissionsManager
|
||||
import com.x8bit.bitwarden.ui.platform.util.persistentListOfNotNull
|
||||
import com.x8bit.bitwarden.ui.tools.feature.send.addsend.handlers.AddSendHandlers
|
||||
import com.x8bit.bitwarden.ui.tools.feature.send.addsend.util.testTag
|
||||
|
||||
/**
|
||||
* Displays new send UX.
|
||||
|
@ -144,6 +147,8 @@ fun AddSendScreen(
|
|||
onClick = remember(viewModel) {
|
||||
{ viewModel.trySendAction(AddSendAction.SaveClick) }
|
||||
},
|
||||
modifier = Modifier
|
||||
.semantics { testTag = state.viewState.testTag },
|
||||
)
|
||||
if (!state.isAddMode) {
|
||||
BitwardenOverflowActionItem(
|
||||
|
|
|
@ -57,3 +57,15 @@ private fun AddSendState.ViewState.Content.toSendTextView(): SendTextView? =
|
|||
hidden = it.isHideByDefaultChecked,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension function to get the semantic test tag based on the AddSendState.ViewState.
|
||||
*/
|
||||
val AddSendState.ViewState.testTag: String
|
||||
get() = when (this) {
|
||||
is AddSendState.ViewState.Content -> {
|
||||
if (isFileType) "SendFileButton" else "SendTextButton"
|
||||
}
|
||||
is AddSendState.ViewState.Error -> ""
|
||||
AddSendState.ViewState.Loading -> ""
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue