mirror of
https://github.com/bitwarden/android.git
synced 2024-11-26 19:36:18 +03:00
BIT-1180: Adding element IDs for passphrases (#902)
This commit is contained in:
parent
2d0353d744
commit
d711360bad
2 changed files with 24 additions and 1 deletions
|
@ -3,6 +3,8 @@ package com.x8bit.bitwarden.ui.platform.components
|
|||
import androidx.compose.runtime.Composable
|
||||
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.text.input.KeyboardType
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.ZERO_WIDTH_CHARACTER
|
||||
|
@ -24,6 +26,7 @@ import com.x8bit.bitwarden.ui.platform.components.model.IconResource
|
|||
* @param textFieldReadOnly whether or not the text field should be read only. The stepper
|
||||
* increment and decrement buttons function regardless of this value.
|
||||
*/
|
||||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
fun BitwardenStepper(
|
||||
label: String,
|
||||
|
@ -34,6 +37,8 @@ fun BitwardenStepper(
|
|||
isIncrementEnabled: Boolean = true,
|
||||
isDecrementEnabled: Boolean = true,
|
||||
textFieldReadOnly: Boolean = true,
|
||||
increaseButtonTestTag: String? = null,
|
||||
decreaseButtonTestTag: String? = null,
|
||||
) {
|
||||
val clampedValue = value?.coerceIn(range)
|
||||
if (clampedValue != value && clampedValue != null) {
|
||||
|
@ -59,6 +64,11 @@ fun BitwardenStepper(
|
|||
}
|
||||
},
|
||||
isEnabled = isDecrementEnabled,
|
||||
modifier = Modifier.semantics {
|
||||
if (decreaseButtonTestTag != null) {
|
||||
testTag = decreaseButtonTestTag
|
||||
}
|
||||
},
|
||||
)
|
||||
BitwardenIconButtonWithResource(
|
||||
iconRes = IconResource(
|
||||
|
@ -72,6 +82,11 @@ fun BitwardenStepper(
|
|||
}
|
||||
},
|
||||
isEnabled = isIncrementEnabled,
|
||||
modifier = Modifier.semantics {
|
||||
if (increaseButtonTestTag != null) {
|
||||
testTag = increaseButtonTestTag
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
readOnly = textFieldReadOnly,
|
||||
|
|
|
@ -257,6 +257,7 @@ private fun DefaultAppBar(
|
|||
OverflowMenuItemData(
|
||||
text = stringResource(id = R.string.password_history),
|
||||
onClick = onPasswordHistoryClick,
|
||||
testTag = "Options",
|
||||
),
|
||||
),
|
||||
)
|
||||
|
@ -779,7 +780,11 @@ private fun PassphraseNumWordsCounterItem(
|
|||
value = numWords,
|
||||
range = PASSPHRASE_MIN_NUMBER_OF_WORDS..PASSPHRASE_MAX_NUMBER_OF_WORDS,
|
||||
onValueChange = onPassphraseNumWordsCounterChange,
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
increaseButtonTestTag = "NumberOfWordsIncreaseButton",
|
||||
decreaseButtonTestTag = "NumberOfWordsDecreaseButton",
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "NumberOfWordsLabel" }
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -795,6 +800,7 @@ private fun PassphraseWordSeparatorInputItem(
|
|||
onPassphraseWordSeparatorChange(it.toCharArray().firstOrNull())
|
||||
},
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "WordSeparatorEntry" }
|
||||
.width(267.dp)
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
|
@ -810,6 +816,7 @@ private fun PassphraseCapitalizeToggleItem(
|
|||
isChecked = capitalize,
|
||||
onCheckedChange = onPassphraseCapitalizeToggleChange,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "CapitalizePassphraseToggle" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
|
@ -825,6 +832,7 @@ private fun PassphraseIncludeNumberToggleItem(
|
|||
isChecked = includeNumber,
|
||||
onCheckedChange = onPassphraseIncludeNumberToggleChange,
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "IncludeNumbersToggle" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue