Skip to content

Commit e404477

Browse files
PM-34499: bug: Add appropriate external link callouts for attachments (#6752)
1 parent fb65c3b commit e404477

5 files changed

Lines changed: 34 additions & 6 deletions

File tree

app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/attachments/preview/PreviewAttachmentScreen.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ fun PreviewAttachmentScreen(
8787
onClick = {
8888
viewModel.trySendAction(PreviewAttachmentAction.DownloadClick)
8989
},
90+
isExternalLink = true,
9091
modifier = Modifier.testTag("ToolbarDownloadButton"),
9192
)
9293
},
@@ -119,6 +120,7 @@ fun PreviewAttachmentScreen(
119120
label = BitwardenString.download_file.asText(),
120121
icon = rememberVectorPainter(id = BitwardenDrawable.ic_download),
121122
onClick = { viewModel.trySendAction(PreviewAttachmentAction.DownloadClick) },
123+
isExternalLink = true,
122124
testTag = "ErrorStateDownloadButton",
123125
),
124126
modifier = Modifier.fillMaxSize(),

app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/item/component/VaultItemAttachment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ fun VaultItemAttachment(
100100
BitwardenStandardIconButton(
101101
vectorIconRes = BitwardenDrawable.ic_download,
102102
contentDescription = stringResource(id = BitwardenString.download),
103+
isExternalLink = true,
103104
onClick = {
104105
if (!attachmentItem.isDownloadAllowed) {
105106
shouldShowPremiumWarningDialog = true

app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/attachments/preview/PreviewAttachmentScreenTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class PreviewAttachmentScreenTest : BitwardenComposeTest() {
6363

6464
@Test
6565
fun `download button click should send DownloadClick`() {
66-
composeTestRule.onNodeWithContentDescription("Download").performClick()
66+
composeTestRule.onNodeWithContentDescription("Download, External link").performClick()
6767
verify(exactly = 1) {
6868
viewModel.trySendAction(PreviewAttachmentAction.DownloadClick)
6969
}

app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/item/VaultItemScreenTest.kt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,9 @@ class VaultItemScreenTest : BitwardenComposeTest() {
780780
}
781781

782782
composeTestRule.assertNoDialogExists()
783-
composeTestRule.onNodeWithContentDescriptionAfterScroll("Download").performClick()
783+
composeTestRule
784+
.onNodeWithContentDescriptionAfterScroll("Download, External link")
785+
.performClick()
784786

785787
composeTestRule
786788
.onAllNodesWithText(
@@ -824,7 +826,9 @@ class VaultItemScreenTest : BitwardenComposeTest() {
824826
}
825827

826828
composeTestRule.assertNoDialogExists()
827-
composeTestRule.onNodeWithContentDescriptionAfterScroll("Download").performClick()
829+
composeTestRule
830+
.onNodeWithContentDescriptionAfterScroll("Download, External link")
831+
.performClick()
828832

829833
composeTestRule
830834
.onAllNodesWithText(
@@ -864,7 +868,9 @@ class VaultItemScreenTest : BitwardenComposeTest() {
864868
}
865869

866870
composeTestRule.assertNoDialogExists()
867-
composeTestRule.onNodeWithContentDescriptionAfterScroll("Download").performClick()
871+
composeTestRule
872+
.onNodeWithContentDescriptionAfterScroll("Download, External link")
873+
.performClick()
868874

869875
composeTestRule
870876
.onAllNodesWithText(
@@ -907,7 +913,9 @@ class VaultItemScreenTest : BitwardenComposeTest() {
907913
}
908914

909915
composeTestRule.assertNoDialogExists()
910-
composeTestRule.onNodeWithContentDescriptionAfterScroll("Download").performClick()
916+
composeTestRule
917+
.onNodeWithContentDescriptionAfterScroll("Download, External link")
918+
.performClick()
911919

912920
composeTestRule.assertNoDialogExists()
913921

ui/src/main/kotlin/com/bitwarden/ui/platform/components/button/BitwardenStandardIconButton.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import androidx.compose.runtime.Composable
77
import androidx.compose.ui.Modifier
88
import androidx.compose.ui.graphics.Color
99
import androidx.compose.ui.graphics.painter.Painter
10+
import androidx.compose.ui.res.stringResource
1011
import androidx.compose.ui.semantics.contentDescription
1112
import androidx.compose.ui.semantics.semantics
1213
import androidx.compose.ui.tooling.preview.Preview
1314
import com.bitwarden.ui.platform.components.button.color.bitwardenStandardIconButtonColors
1415
import com.bitwarden.ui.platform.components.util.rememberVectorPainter
1516
import com.bitwarden.ui.platform.resource.BitwardenDrawable
17+
import com.bitwarden.ui.platform.resource.BitwardenString
1618
import com.bitwarden.ui.platform.theme.BitwardenTheme
1719

1820
/**
@@ -23,6 +25,8 @@ import com.bitwarden.ui.platform.theme.BitwardenTheme
2325
* @param onClick Callback for when the icon button is clicked.
2426
* @param modifier A [Modifier] for the composable.
2527
* @param isEnabled Whether the button should be enabled.
28+
* @param isExternalLink Whether the icon button is an external link.
29+
* @param contentColor The color applied to the icon.
2630
*/
2731
@Composable
2832
fun BitwardenStandardIconButton(
@@ -31,6 +35,7 @@ fun BitwardenStandardIconButton(
3135
onClick: () -> Unit,
3236
modifier: Modifier = Modifier,
3337
isEnabled: Boolean = true,
38+
isExternalLink: Boolean = false,
3439
contentColor: Color = BitwardenTheme.colorScheme.icon.primary,
3540
) {
3641
BitwardenStandardIconButton(
@@ -39,6 +44,7 @@ fun BitwardenStandardIconButton(
3944
onClick = onClick,
4045
modifier = modifier,
4146
isEnabled = isEnabled,
47+
isExternalLink = isExternalLink,
4248
contentColor = contentColor,
4349
)
4450
}
@@ -51,6 +57,8 @@ fun BitwardenStandardIconButton(
5157
* @param onClick Callback for when the icon button is clicked.
5258
* @param modifier A [Modifier] for the composable.
5359
* @param isEnabled Whether the button should be enabled.
60+
* @param isExternalLink Whether the icon button is an external link.
61+
* @param contentColor The color applied to the icon.
5462
*/
5563
@Composable
5664
fun BitwardenStandardIconButton(
@@ -59,11 +67,20 @@ fun BitwardenStandardIconButton(
5967
onClick: () -> Unit,
6068
modifier: Modifier = Modifier,
6169
isEnabled: Boolean = true,
70+
isExternalLink: Boolean = false,
6271
contentColor: Color = BitwardenTheme.colorScheme.icon.primary,
6372
) {
73+
val formattedContentDescription = if (isExternalLink) {
74+
stringResource(
75+
id = BitwardenString.external_link_format,
76+
formatArgs = arrayOf(contentDescription),
77+
)
78+
} else {
79+
contentDescription
80+
}
6481
IconButton(
6582
modifier = modifier.semantics(mergeDescendants = true) {
66-
this.contentDescription = contentDescription
83+
this.contentDescription = formattedContentDescription
6784
},
6885
onClick = onClick,
6986
colors = bitwardenStandardIconButtonColors(contentColor = contentColor),

0 commit comments

Comments
 (0)