mirror of
https://github.com/bitwarden/android.git
synced 2025-12-11 13:57:03 -06:00
PM-27046: Add overflow to Authenticator (#6039)
This commit is contained in:
parent
53d04375b1
commit
714f7cfadc
@ -677,7 +677,7 @@ private fun ContentPreview() {
|
|||||||
authCode = "123456",
|
authCode = "123456",
|
||||||
favorite = false,
|
favorite = false,
|
||||||
showMoveToBitwarden = true,
|
showMoveToBitwarden = true,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
sharedItems = SharedCodesDisplayState.Codes(
|
sharedItems = SharedCodesDisplayState.Codes(
|
||||||
@ -698,7 +698,7 @@ private fun ContentPreview() {
|
|||||||
authCode = "123456",
|
authCode = "123456",
|
||||||
favorite = false,
|
favorite = false,
|
||||||
showMoveToBitwarden = false,
|
showMoveToBitwarden = false,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
isExpanded = true,
|
isExpanded = true,
|
||||||
|
|||||||
@ -512,7 +512,7 @@ class ItemListingViewModel @Inject constructor(
|
|||||||
sharedVerificationCodesState = authenticatorRepository
|
sharedVerificationCodesState = authenticatorRepository
|
||||||
.sharedCodesStateFlow
|
.sharedCodesStateFlow
|
||||||
.value,
|
.value,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.toImmutableList(),
|
.toImmutableList(),
|
||||||
@ -524,7 +524,7 @@ class ItemListingViewModel @Inject constructor(
|
|||||||
sharedVerificationCodesState = authenticatorRepository
|
sharedVerificationCodesState = authenticatorRepository
|
||||||
.sharedCodesStateFlow
|
.sharedCodesStateFlow
|
||||||
.value,
|
.value,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.toImmutableList(),
|
.toImmutableList(),
|
||||||
|
|||||||
@ -194,7 +194,7 @@ class ItemSearchViewModel @Inject constructor(
|
|||||||
sharedVerificationCodesState = authenticatorRepository
|
sharedVerificationCodesState = authenticatorRepository
|
||||||
.sharedCodesStateFlow
|
.sharedCodesStateFlow
|
||||||
.value,
|
.value,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.toImmutableList(),
|
.toImmutableList(),
|
||||||
|
|||||||
@ -27,7 +27,7 @@ fun SharedVerificationCodesState.Success.toSharedCodesDisplayState(
|
|||||||
// Always map based on Error state, because shared codes will never
|
// Always map based on Error state, because shared codes will never
|
||||||
// show "Copy to Bitwarden vault" action.
|
// show "Copy to Bitwarden vault" action.
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.Error,
|
sharedVerificationCodesState = SharedVerificationCodesState.Error,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import com.bitwarden.authenticator.ui.platform.components.listitem.model.Verific
|
|||||||
fun VerificationCodeItem.toDisplayItem(
|
fun VerificationCodeItem.toDisplayItem(
|
||||||
alertThresholdSeconds: Int,
|
alertThresholdSeconds: Int,
|
||||||
sharedVerificationCodesState: SharedVerificationCodesState,
|
sharedVerificationCodesState: SharedVerificationCodesState,
|
||||||
allowLongPressActions: Boolean,
|
showOverflow: Boolean,
|
||||||
): VerificationCodeDisplayItem = VerificationCodeDisplayItem(
|
): VerificationCodeDisplayItem = VerificationCodeDisplayItem(
|
||||||
id = id,
|
id = id,
|
||||||
title = issuer ?: label ?: "--",
|
title = issuer ?: label ?: "--",
|
||||||
@ -25,7 +25,7 @@ fun VerificationCodeItem.toDisplayItem(
|
|||||||
periodSeconds = periodSeconds,
|
periodSeconds = periodSeconds,
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
authCode = code,
|
authCode = code,
|
||||||
allowLongPressActions = allowLongPressActions,
|
showOverflow = showOverflow,
|
||||||
favorite = (source as? AuthenticatorItem.Source.Local)?.isFavorite ?: false,
|
favorite = (source as? AuthenticatorItem.Source.Local)?.isFavorite ?: false,
|
||||||
showMoveToBitwarden = when (source) {
|
showMoveToBitwarden = when (source) {
|
||||||
// Shared items should never show "Copy to Bitwarden vault" action:
|
// Shared items should never show "Copy to Bitwarden vault" action:
|
||||||
|
|||||||
@ -1,39 +1,27 @@
|
|||||||
package com.bitwarden.authenticator.ui.platform.components.listitem
|
package com.bitwarden.authenticator.ui.platform.components.listitem
|
||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
|
||||||
import androidx.compose.foundation.combinedClickable
|
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.defaultMinSize
|
import androidx.compose.foundation.layout.defaultMinSize
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.material3.DropdownMenu
|
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.ripple
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.setValue
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.testTag
|
import androidx.compose.ui.platform.testTag
|
||||||
import androidx.compose.ui.res.painterResource
|
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.bitwarden.authenticator.ui.platform.components.listitem.model.VaultDropdownMenuAction
|
import com.bitwarden.authenticator.ui.platform.components.listitem.model.VaultDropdownMenuAction
|
||||||
import com.bitwarden.authenticator.ui.platform.components.listitem.model.VerificationCodeDisplayItem
|
import com.bitwarden.authenticator.ui.platform.components.listitem.model.VerificationCodeDisplayItem
|
||||||
import com.bitwarden.ui.platform.base.util.cardBackground
|
import com.bitwarden.core.util.persistentListOfNotNull
|
||||||
import com.bitwarden.ui.platform.base.util.cardPadding
|
import com.bitwarden.ui.platform.base.util.cardStyle
|
||||||
import com.bitwarden.ui.platform.components.divider.BitwardenHorizontalDivider
|
import com.bitwarden.ui.platform.components.appbar.action.BitwardenOverflowActionItem
|
||||||
|
import com.bitwarden.ui.platform.components.appbar.model.OverflowMenuItemData
|
||||||
|
import com.bitwarden.ui.platform.components.button.BitwardenStandardIconButton
|
||||||
import com.bitwarden.ui.platform.components.icon.BitwardenIcon
|
import com.bitwarden.ui.platform.components.icon.BitwardenIcon
|
||||||
import com.bitwarden.ui.platform.components.icon.model.IconData
|
import com.bitwarden.ui.platform.components.icon.model.IconData
|
||||||
import com.bitwarden.ui.platform.components.indicator.BitwardenCircularCountdownIndicator
|
import com.bitwarden.ui.platform.components.indicator.BitwardenCircularCountdownIndicator
|
||||||
@ -69,7 +57,7 @@ fun VaultVerificationCodeItem(
|
|||||||
startIcon = displayItem.startIcon,
|
startIcon = displayItem.startIcon,
|
||||||
onItemClick = onItemClick,
|
onItemClick = onItemClick,
|
||||||
onDropdownMenuClick = onDropdownMenuClick,
|
onDropdownMenuClick = onDropdownMenuClick,
|
||||||
allowLongPress = displayItem.allowLongPressActions,
|
showOverflow = displayItem.showOverflow,
|
||||||
showMoveToBitwarden = displayItem.showMoveToBitwarden,
|
showMoveToBitwarden = displayItem.showMoveToBitwarden,
|
||||||
cardStyle = cardStyle,
|
cardStyle = cardStyle,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
@ -88,7 +76,7 @@ fun VaultVerificationCodeItem(
|
|||||||
* @param startIcon The leading icon for the item.
|
* @param startIcon The leading icon for the item.
|
||||||
* @param onItemClick The lambda function to be invoked when the item is clicked.
|
* @param onItemClick The lambda function to be invoked when the item is clicked.
|
||||||
* @param onDropdownMenuClick A lambda function invoked when a dropdown menu action is clicked.
|
* @param onDropdownMenuClick A lambda function invoked when a dropdown menu action is clicked.
|
||||||
* @param allowLongPress Whether long-press interactions are enabled for the item.
|
* @param showOverflow Whether overflow menu should be available or not.
|
||||||
* @param showMoveToBitwarden Whether the option to move the item to Bitwarden is displayed.
|
* @param showMoveToBitwarden Whether the option to move the item to Bitwarden is displayed.
|
||||||
* @param cardStyle The card style to be applied to this item.
|
* @param cardStyle The card style to be applied to this item.
|
||||||
* @param modifier The modifier for the item.
|
* @param modifier The modifier for the item.
|
||||||
@ -105,166 +93,107 @@ fun VaultVerificationCodeItem(
|
|||||||
startIcon: IconData,
|
startIcon: IconData,
|
||||||
onItemClick: () -> Unit,
|
onItemClick: () -> Unit,
|
||||||
onDropdownMenuClick: (VaultDropdownMenuAction) -> Unit,
|
onDropdownMenuClick: (VaultDropdownMenuAction) -> Unit,
|
||||||
allowLongPress: Boolean,
|
showOverflow: Boolean,
|
||||||
showMoveToBitwarden: Boolean,
|
showMoveToBitwarden: Boolean,
|
||||||
cardStyle: CardStyle,
|
cardStyle: CardStyle,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
var shouldShowDropdownMenu by remember { mutableStateOf(value = false) }
|
Row(
|
||||||
Box(modifier = modifier) {
|
modifier = modifier
|
||||||
Row(
|
.testTag(tag = "Item")
|
||||||
modifier = Modifier
|
.defaultMinSize(minHeight = 60.dp)
|
||||||
.testTag(tag = "Item")
|
.cardStyle(
|
||||||
.defaultMinSize(minHeight = 60.dp)
|
cardStyle = cardStyle,
|
||||||
.cardBackground(cardStyle = cardStyle)
|
onClick = onItemClick,
|
||||||
.then(
|
paddingStart = 16.dp,
|
||||||
if (allowLongPress) {
|
paddingEnd = 4.dp,
|
||||||
Modifier.combinedClickable(
|
),
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
indication = ripple(
|
horizontalArrangement = Arrangement.spacedBy(space = 16.dp),
|
||||||
color = BitwardenTheme.colorScheme.background.pressed,
|
) {
|
||||||
),
|
BitwardenIcon(
|
||||||
onClick = onItemClick,
|
iconData = startIcon,
|
||||||
onLongClick = { shouldShowDropdownMenu = true },
|
tint = BitwardenTheme.colorScheme.icon.primary,
|
||||||
)
|
modifier = Modifier.size(size = 24.dp),
|
||||||
} else {
|
)
|
||||||
Modifier.clickable(
|
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
Column(
|
||||||
indication = ripple(
|
horizontalAlignment = Alignment.Start,
|
||||||
color = BitwardenTheme.colorScheme.background.pressed,
|
verticalArrangement = Arrangement.SpaceEvenly,
|
||||||
),
|
modifier = Modifier.weight(weight = 1f),
|
||||||
onClick = onItemClick,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.cardPadding(
|
|
||||||
cardStyle = cardStyle,
|
|
||||||
paddingValues = PaddingValues(vertical = 8.dp, horizontal = 16.dp),
|
|
||||||
),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
|
||||||
) {
|
) {
|
||||||
BitwardenIcon(
|
if (!primaryLabel.isNullOrEmpty()) {
|
||||||
iconData = startIcon,
|
Text(
|
||||||
tint = BitwardenTheme.colorScheme.icon.primary,
|
modifier = Modifier.testTag(tag = "Name"),
|
||||||
modifier = Modifier.size(24.dp),
|
text = primaryLabel,
|
||||||
)
|
style = BitwardenTheme.typography.bodyLarge,
|
||||||
|
color = BitwardenTheme.colorScheme.text.primary,
|
||||||
Column(
|
maxLines = 1,
|
||||||
horizontalAlignment = Alignment.Start,
|
overflow = TextOverflow.Ellipsis,
|
||||||
verticalArrangement = Arrangement.SpaceEvenly,
|
)
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
) {
|
|
||||||
if (!primaryLabel.isNullOrEmpty()) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.testTag("Name"),
|
|
||||||
text = primaryLabel,
|
|
||||||
style = BitwardenTheme.typography.bodyLarge,
|
|
||||||
color = BitwardenTheme.colorScheme.text.primary,
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!secondaryLabel.isNullOrEmpty()) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.testTag("Username"),
|
|
||||||
text = secondaryLabel,
|
|
||||||
style = BitwardenTheme.typography.bodyMedium,
|
|
||||||
color = BitwardenTheme.colorScheme.text.secondary,
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BitwardenCircularCountdownIndicator(
|
if (!secondaryLabel.isNullOrEmpty()) {
|
||||||
modifier = Modifier.testTag("CircularCountDown"),
|
Text(
|
||||||
timeLeftSeconds = timeLeftSeconds,
|
modifier = Modifier.testTag(tag = "Username"),
|
||||||
periodSeconds = periodSeconds,
|
text = secondaryLabel,
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
style = BitwardenTheme.typography.bodyMedium,
|
||||||
)
|
color = BitwardenTheme.colorScheme.text.secondary,
|
||||||
|
maxLines = 1,
|
||||||
Text(
|
overflow = TextOverflow.Ellipsis,
|
||||||
modifier = Modifier.testTag("AuthCode"),
|
)
|
||||||
text = authCode.chunked(3).joinToString(" "),
|
}
|
||||||
style = BitwardenTheme.typography.sensitiveInfoSmall,
|
|
||||||
color = BitwardenTheme.colorScheme.text.primary,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DropdownMenu(
|
BitwardenCircularCountdownIndicator(
|
||||||
expanded = shouldShowDropdownMenu,
|
modifier = Modifier.testTag(tag = "CircularCountDown"),
|
||||||
onDismissRequest = { shouldShowDropdownMenu = false },
|
timeLeftSeconds = timeLeftSeconds,
|
||||||
shape = BitwardenTheme.shapes.menu,
|
periodSeconds = periodSeconds,
|
||||||
containerColor = BitwardenTheme.colorScheme.background.primary,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
) {
|
)
|
||||||
DropdownMenuItem(
|
|
||||||
text = {
|
Text(
|
||||||
Text(text = stringResource(id = BitwardenString.copy))
|
modifier = Modifier.testTag(tag = "AuthCode"),
|
||||||
},
|
text = authCode.chunked(size = 3).joinToString(separator = " "),
|
||||||
onClick = {
|
style = BitwardenTheme.typography.sensitiveInfoSmall,
|
||||||
shouldShowDropdownMenu = false
|
color = BitwardenTheme.colorScheme.text.primary,
|
||||||
onDropdownMenuClick(VaultDropdownMenuAction.COPY_CODE)
|
)
|
||||||
},
|
|
||||||
leadingIcon = {
|
if (showOverflow) {
|
||||||
Icon(
|
BitwardenOverflowActionItem(
|
||||||
painter = painterResource(id = BitwardenDrawable.ic_copy),
|
contentDescription = stringResource(id = BitwardenString.more),
|
||||||
contentDescription = stringResource(id = BitwardenString.copy),
|
menuItemDataList = persistentListOfNotNull(
|
||||||
)
|
OverflowMenuItemData(
|
||||||
},
|
text = stringResource(id = BitwardenString.copy),
|
||||||
)
|
onClick = { onDropdownMenuClick(VaultDropdownMenuAction.COPY_CODE) },
|
||||||
BitwardenHorizontalDivider()
|
),
|
||||||
DropdownMenuItem(
|
OverflowMenuItemData(
|
||||||
text = {
|
text = stringResource(id = BitwardenString.edit),
|
||||||
Text(text = stringResource(id = BitwardenString.edit))
|
onClick = { onDropdownMenuClick(VaultDropdownMenuAction.EDIT) },
|
||||||
},
|
),
|
||||||
onClick = {
|
if (showMoveToBitwarden) {
|
||||||
shouldShowDropdownMenu = false
|
OverflowMenuItemData(
|
||||||
onDropdownMenuClick(VaultDropdownMenuAction.EDIT)
|
text = stringResource(id = BitwardenString.copy_to_bitwarden_vault),
|
||||||
},
|
onClick = {
|
||||||
leadingIcon = {
|
onDropdownMenuClick(VaultDropdownMenuAction.COPY_TO_BITWARDEN)
|
||||||
Icon(
|
},
|
||||||
painter = painterResource(id = BitwardenDrawable.ic_edit_item),
|
|
||||||
contentDescription = stringResource(BitwardenString.edit),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if (showMoveToBitwarden) {
|
|
||||||
BitwardenHorizontalDivider()
|
|
||||||
DropdownMenuItem(
|
|
||||||
text = {
|
|
||||||
Text(text = stringResource(id = BitwardenString.copy_to_bitwarden_vault))
|
|
||||||
},
|
|
||||||
onClick = {
|
|
||||||
shouldShowDropdownMenu = false
|
|
||||||
onDropdownMenuClick(VaultDropdownMenuAction.COPY_TO_BITWARDEN)
|
|
||||||
},
|
|
||||||
leadingIcon = {
|
|
||||||
Icon(
|
|
||||||
painter = painterResource(id = BitwardenDrawable.ic_arrow_right),
|
|
||||||
contentDescription = stringResource(
|
|
||||||
id = BitwardenString.copy_to_bitwarden_vault,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
},
|
},
|
||||||
)
|
OverflowMenuItemData(
|
||||||
}
|
text = stringResource(id = BitwardenString.delete_item),
|
||||||
BitwardenHorizontalDivider()
|
onClick = { onDropdownMenuClick(VaultDropdownMenuAction.DELETE) },
|
||||||
DropdownMenuItem(
|
),
|
||||||
text = {
|
),
|
||||||
Text(text = stringResource(id = BitwardenString.delete_item))
|
vectorIconRes = BitwardenDrawable.ic_ellipsis_horizontal,
|
||||||
},
|
testTag = "Options",
|
||||||
onClick = {
|
)
|
||||||
shouldShowDropdownMenu = false
|
} else {
|
||||||
onDropdownMenuClick(VaultDropdownMenuAction.DELETE)
|
BitwardenStandardIconButton(
|
||||||
},
|
vectorIconRes = BitwardenDrawable.ic_copy,
|
||||||
leadingIcon = {
|
contentDescription = stringResource(id = BitwardenString.copy),
|
||||||
Icon(
|
onClick = onItemClick,
|
||||||
painter = painterResource(id = BitwardenDrawable.ic_delete_item),
|
|
||||||
contentDescription = stringResource(id = BitwardenString.delete_item),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,7 +214,7 @@ private fun VerificationCodeItem_preview() {
|
|||||||
startIcon = IconData.Local(BitwardenDrawable.ic_login_item),
|
startIcon = IconData.Local(BitwardenDrawable.ic_login_item),
|
||||||
onItemClick = {},
|
onItemClick = {},
|
||||||
onDropdownMenuClick = {},
|
onDropdownMenuClick = {},
|
||||||
allowLongPress = true,
|
showOverflow = true,
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
modifier = Modifier.padding(horizontal = 16.dp),
|
||||||
showMoveToBitwarden = true,
|
showMoveToBitwarden = true,
|
||||||
cardStyle = CardStyle.Full,
|
cardStyle = CardStyle.Full,
|
||||||
|
|||||||
@ -22,6 +22,6 @@ data class VerificationCodeDisplayItem(
|
|||||||
testTag = "BitwardenIcon",
|
testTag = "BitwardenIcon",
|
||||||
),
|
),
|
||||||
val favorite: Boolean,
|
val favorite: Boolean,
|
||||||
val allowLongPressActions: Boolean,
|
val showOverflow: Boolean,
|
||||||
val showMoveToBitwarden: Boolean,
|
val showMoveToBitwarden: Boolean,
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|||||||
@ -2,7 +2,10 @@ package com.bitwarden.authenticator.ui.authenticator.feature.itemlisting
|
|||||||
|
|
||||||
import androidx.compose.ui.test.assertIsDisplayed
|
import androidx.compose.ui.test.assertIsDisplayed
|
||||||
import androidx.compose.ui.test.assertIsNotDisplayed
|
import androidx.compose.ui.test.assertIsNotDisplayed
|
||||||
|
import androidx.compose.ui.test.filterToOne
|
||||||
|
import androidx.compose.ui.test.hasContentDescription
|
||||||
import androidx.compose.ui.test.longClick
|
import androidx.compose.ui.test.longClick
|
||||||
|
import androidx.compose.ui.test.onChildren
|
||||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
@ -359,8 +362,10 @@ class ItemListingScreenTest : AuthenticatorComposeTest() {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
composeTestRule
|
composeTestRule
|
||||||
.onNodeWithText("issuer")
|
.onNodeWithText(text = "issuer")
|
||||||
.performTouchInput { longClick() }
|
.onChildren()
|
||||||
|
.filterToOne(hasContentDescription(value = "More"))
|
||||||
|
.performClick()
|
||||||
|
|
||||||
composeTestRule
|
composeTestRule
|
||||||
.onNodeWithText(text = "Copy to Bitwarden vault")
|
.onNodeWithText(text = "Copy to Bitwarden vault")
|
||||||
@ -543,7 +548,7 @@ private val LOCAL_CODE = VerificationCodeDisplayItem(
|
|||||||
alertThresholdSeconds = 7,
|
alertThresholdSeconds = 7,
|
||||||
authCode = "123456",
|
authCode = "123456",
|
||||||
favorite = false,
|
favorite = false,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
showMoveToBitwarden = true,
|
showMoveToBitwarden = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -560,7 +565,7 @@ private val SHARED_ACCOUNTS_SECTION = SharedCodesDisplayState.SharedCodesAccount
|
|||||||
alertThresholdSeconds = ALERT_THRESHOLD,
|
alertThresholdSeconds = ALERT_THRESHOLD,
|
||||||
authCode = "123456",
|
authCode = "123456",
|
||||||
favorite = false,
|
favorite = false,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
showMoveToBitwarden = false,
|
showMoveToBitwarden = false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -571,7 +571,7 @@ private val LOCAL_CODE = VerificationCodeDisplayItem(
|
|||||||
alertThresholdSeconds = 7,
|
alertThresholdSeconds = 7,
|
||||||
authCode = "123456",
|
authCode = "123456",
|
||||||
favorite = false,
|
favorite = false,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
showMoveToBitwarden = true,
|
showMoveToBitwarden = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -620,7 +620,7 @@ private val LOCAL_DISPLAY_ITEMS = LOCAL_VERIFICATION_ITEMS.map {
|
|||||||
it.toDisplayItem(
|
it.toDisplayItem(
|
||||||
alertThresholdSeconds = AUTHENTICATOR_ALERT_SECONDS,
|
alertThresholdSeconds = AUTHENTICATOR_ALERT_SECONDS,
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.AppNotInstalled,
|
sharedVerificationCodesState = SharedVerificationCodesState.AppNotInstalled,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -144,7 +144,7 @@ private val SHARED_DISPLAY_ITEMS = SharedCodesDisplayState.Codes(
|
|||||||
alertThresholdSeconds = 7,
|
alertThresholdSeconds = 7,
|
||||||
authCode = "mockCode-2",
|
authCode = "mockCode-2",
|
||||||
favorite = false,
|
favorite = false,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
showMoveToBitwarden = false,
|
showMoveToBitwarden = false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -167,7 +167,7 @@ private val LOCAL_DISPLAY_ITEMS = persistentListOf(
|
|||||||
),
|
),
|
||||||
subtitle = LOCAL_ITEMS[0].label,
|
subtitle = LOCAL_ITEMS[0].label,
|
||||||
favorite = false,
|
favorite = false,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
showMoveToBitwarden = true,
|
showMoveToBitwarden = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -77,7 +77,7 @@ class SharedVerificationCodesStateTest {
|
|||||||
title = "--",
|
title = "--",
|
||||||
subtitle = null,
|
subtitle = null,
|
||||||
favorite = false,
|
favorite = false,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
alertThresholdSeconds = ALERT_THRESHOLD,
|
alertThresholdSeconds = ALERT_THRESHOLD,
|
||||||
showMoveToBitwarden = false,
|
showMoveToBitwarden = false,
|
||||||
),
|
),
|
||||||
@ -100,7 +100,7 @@ class SharedVerificationCodesStateTest {
|
|||||||
title = "issuer",
|
title = "issuer",
|
||||||
subtitle = "accountName",
|
subtitle = "accountName",
|
||||||
favorite = false,
|
favorite = false,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
alertThresholdSeconds = ALERT_THRESHOLD,
|
alertThresholdSeconds = ALERT_THRESHOLD,
|
||||||
showMoveToBitwarden = false,
|
showMoveToBitwarden = false,
|
||||||
),
|
),
|
||||||
@ -169,7 +169,7 @@ class SharedVerificationCodesStateTest {
|
|||||||
title = "--",
|
title = "--",
|
||||||
subtitle = null,
|
subtitle = null,
|
||||||
favorite = false,
|
favorite = false,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
alertThresholdSeconds = ALERT_THRESHOLD,
|
alertThresholdSeconds = ALERT_THRESHOLD,
|
||||||
showMoveToBitwarden = false,
|
showMoveToBitwarden = false,
|
||||||
),
|
),
|
||||||
@ -192,7 +192,7 @@ class SharedVerificationCodesStateTest {
|
|||||||
title = "issuer",
|
title = "issuer",
|
||||||
subtitle = "accountName",
|
subtitle = "accountName",
|
||||||
favorite = false,
|
favorite = false,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
alertThresholdSeconds = ALERT_THRESHOLD,
|
alertThresholdSeconds = ALERT_THRESHOLD,
|
||||||
showMoveToBitwarden = false,
|
showMoveToBitwarden = false,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
authCode = favoriteItem.code,
|
authCode = favoriteItem.code,
|
||||||
favorite = (favoriteItem.source as AuthenticatorItem.Source.Local).isFavorite,
|
favorite = (favoriteItem.source as AuthenticatorItem.Source.Local).isFavorite,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
showMoveToBitwarden = false,
|
showMoveToBitwarden = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
authCode = nonFavoriteItem.code,
|
authCode = nonFavoriteItem.code,
|
||||||
favorite = (nonFavoriteItem.source as AuthenticatorItem.Source.Local).isFavorite,
|
favorite = (nonFavoriteItem.source as AuthenticatorItem.Source.Local).isFavorite,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
showMoveToBitwarden = false,
|
showMoveToBitwarden = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
favoriteItem.toDisplayItem(
|
favoriteItem.toDisplayItem(
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.Error,
|
sharedVerificationCodesState = SharedVerificationCodesState.Error,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@ -59,7 +59,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
nonFavoriteItem.toDisplayItem(
|
nonFavoriteItem.toDisplayItem(
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.Error,
|
sharedVerificationCodesState = SharedVerificationCodesState.Error,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
authCode = item.code,
|
authCode = item.code,
|
||||||
favorite = false,
|
favorite = false,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
showMoveToBitwarden = false,
|
showMoveToBitwarden = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
item.toDisplayItem(
|
item.toDisplayItem(
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.AppNotInstalled,
|
sharedVerificationCodesState = SharedVerificationCodesState.AppNotInstalled,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@ -96,7 +96,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
item.toDisplayItem(
|
item.toDisplayItem(
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.Error,
|
sharedVerificationCodesState = SharedVerificationCodesState.Error,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@ -104,7 +104,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
item.toDisplayItem(
|
item.toDisplayItem(
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.FeatureNotEnabled,
|
sharedVerificationCodesState = SharedVerificationCodesState.FeatureNotEnabled,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@ -112,7 +112,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
item.toDisplayItem(
|
item.toDisplayItem(
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.Loading,
|
sharedVerificationCodesState = SharedVerificationCodesState.Loading,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@ -120,7 +120,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
item.toDisplayItem(
|
item.toDisplayItem(
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.OsVersionNotSupported,
|
sharedVerificationCodesState = SharedVerificationCodesState.OsVersionNotSupported,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@ -128,7 +128,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
item.toDisplayItem(
|
item.toDisplayItem(
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.SyncNotEnabled,
|
sharedVerificationCodesState = SharedVerificationCodesState.SyncNotEnabled,
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
item.toDisplayItem(
|
item.toDisplayItem(
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.Success(emptyList()),
|
sharedVerificationCodesState = SharedVerificationCodesState.Success(emptyList()),
|
||||||
allowLongPressActions = true,
|
showOverflow = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
authCode = favoriteItem.code,
|
authCode = favoriteItem.code,
|
||||||
favorite = false,
|
favorite = false,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
showMoveToBitwarden = false,
|
showMoveToBitwarden = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ class VerificationCodeItemExtensionsTest {
|
|||||||
favoriteItem.toDisplayItem(
|
favoriteItem.toDisplayItem(
|
||||||
alertThresholdSeconds = alertThresholdSeconds,
|
alertThresholdSeconds = alertThresholdSeconds,
|
||||||
sharedVerificationCodesState = SharedVerificationCodesState.Error,
|
sharedVerificationCodesState = SharedVerificationCodesState.Error,
|
||||||
allowLongPressActions = false,
|
showOverflow = false,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user