mirror of
https://github.com/bitwarden/android.git
synced 2025-12-12 00:08:00 -06:00
PM-19776: Change 'Move to Bitwarden' to 'Copy to Bitwarden vault' (#5435)
This commit is contained in:
parent
288efb3611
commit
3ee74d3ec5
@ -119,7 +119,7 @@ class ItemListingViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
is ItemListingAction.ItemClick -> {
|
||||
handleCopyItemClick(action.authCode)
|
||||
handleCopyCodeClick(action.authCode)
|
||||
}
|
||||
|
||||
is ItemListingAction.DialogDismiss -> {
|
||||
@ -164,7 +164,7 @@ class ItemListingViewModel @Inject constructor(
|
||||
sendEvent(ItemListingEvent.NavigateToAppSettings)
|
||||
}
|
||||
|
||||
private fun handleCopyItemClick(authCode: String) {
|
||||
private fun handleCopyCodeClick(authCode: String) {
|
||||
clipboardManager.setText(authCode)
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ class ItemListingViewModel @Inject constructor(
|
||||
sendEvent(ItemListingEvent.NavigateToEditItem(itemId))
|
||||
}
|
||||
|
||||
private fun handleMoveToBitwardenClick(itemId: String) {
|
||||
private fun handleCopyToBitwardenClick(itemId: String) {
|
||||
viewModelScope.launch {
|
||||
val item = authenticatorRepository
|
||||
.getItemStateFlow(itemId)
|
||||
@ -521,9 +521,9 @@ class ItemListingViewModel @Inject constructor(
|
||||
|
||||
private fun handleDropdownMenuClick(action: ItemListingAction.DropdownMenuClick) {
|
||||
when (action.menuAction) {
|
||||
VaultDropdownMenuAction.COPY -> handleCopyItemClick(action.item.authCode)
|
||||
VaultDropdownMenuAction.COPY_CODE -> handleCopyCodeClick(action.item.authCode)
|
||||
VaultDropdownMenuAction.EDIT -> handleEditItemClick(action.item.id)
|
||||
VaultDropdownMenuAction.MOVE -> handleMoveToBitwardenClick(action.item.id)
|
||||
VaultDropdownMenuAction.COPY_TO_BITWARDEN -> handleCopyToBitwardenClick(action.item.id)
|
||||
VaultDropdownMenuAction.DELETE -> handleDeleteItemClick(action.item.id)
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ fun VaultVerificationCodeItem(
|
||||
},
|
||||
onClick = {
|
||||
shouldShowDropdownMenu = false
|
||||
onDropdownMenuClick(VaultDropdownMenuAction.COPY)
|
||||
onDropdownMenuClick(VaultDropdownMenuAction.COPY_CODE)
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
@ -190,16 +190,18 @@ fun VaultVerificationCodeItem(
|
||||
HorizontalDivider()
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(text = stringResource(id = R.string.move_to_bitwarden))
|
||||
Text(text = stringResource(id = R.string.copy_to_bitwarden_vault))
|
||||
},
|
||||
onClick = {
|
||||
shouldShowDropdownMenu = false
|
||||
onDropdownMenuClick(VaultDropdownMenuAction.MOVE)
|
||||
onDropdownMenuClick(VaultDropdownMenuAction.COPY_TO_BITWARDEN)
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_arrow_right),
|
||||
contentDescription = stringResource(id = R.string.move_to_bitwarden),
|
||||
contentDescription = stringResource(
|
||||
id = R.string.copy_to_bitwarden_vault,
|
||||
),
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
@ -4,8 +4,8 @@ package com.bitwarden.authenticator.ui.authenticator.feature.itemlisting.model
|
||||
* Enum representing the available actions in the Vault dropdown menu.
|
||||
*/
|
||||
enum class VaultDropdownMenuAction {
|
||||
COPY,
|
||||
COPY_CODE,
|
||||
COPY_TO_BITWARDEN,
|
||||
EDIT,
|
||||
MOVE,
|
||||
DELETE,
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ fun SharedVerificationCodesState.Success.toSharedCodesDisplayState(
|
||||
it.toDisplayItem(
|
||||
alertThresholdSeconds = alertThresholdSeconds,
|
||||
// Always map based on Error state, because shared codes will never
|
||||
// show "Move to Bitwarden" action.
|
||||
// show "Copy to Bitwarden vault" action.
|
||||
sharedVerificationCodesState = SharedVerificationCodesState.Error,
|
||||
),
|
||||
)
|
||||
|
||||
@ -30,10 +30,10 @@ fun VerificationCodeItem.toDisplayItem(
|
||||
},
|
||||
favorite = (source as? AuthenticatorItem.Source.Local)?.isFavorite ?: false,
|
||||
showMoveToBitwarden = when (source) {
|
||||
// Shared items should never show Move to Bitwarden action:
|
||||
// Shared items should never show "Copy to Bitwarden vault" action:
|
||||
is AuthenticatorItem.Source.Shared -> false
|
||||
|
||||
// Local items should only show Move to Bitwarden if we are successfully syncing: =
|
||||
// Local items should only show "Copy to Bitwarden vault" if we are successfully syncing: =
|
||||
is AuthenticatorItem.Source.Local -> when (sharedVerificationCodesState) {
|
||||
SharedVerificationCodesState.AppNotInstalled,
|
||||
SharedVerificationCodesState.Error,
|
||||
|
||||
@ -124,7 +124,7 @@
|
||||
<string name="take_me_to_app_settings">Take me to the app settings</string>
|
||||
<string name="something_went_wrong">Something went wrong</string>
|
||||
<string name="please_try_again">Please try again</string>
|
||||
<string name="move_to_bitwarden">Move to Bitwarden</string>
|
||||
<string name="copy_to_bitwarden_vault">Copy to Bitwarden vault</string>
|
||||
<string name="default_save_option">Default save option</string>
|
||||
<string name="save_to_bitwarden">Save to Bitwarden</string>
|
||||
<string name="save_here">Save here</string>
|
||||
|
||||
@ -346,7 +346,7 @@ class ItemListingScreenTest : AuthenticatorComposeTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `clicking Move to Bitwarden should send MoveToBitwardenClick`() {
|
||||
fun `clicking Copy to Bitwarden vault should send DropdownMenuClick with COPY_TO_BITWARDEN`() {
|
||||
mutableStateFlow.value = DEFAULT_STATE.copy(
|
||||
viewState = ItemListingState.ViewState.Content(
|
||||
actionCard = ItemListingState.ActionCardState.None,
|
||||
@ -360,21 +360,22 @@ class ItemListingScreenTest : AuthenticatorComposeTest() {
|
||||
.performTouchInput { longClick() }
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText("Move to Bitwarden")
|
||||
.onNodeWithText(text = "Copy to Bitwarden vault")
|
||||
.performClick()
|
||||
|
||||
verify {
|
||||
viewModel.trySendAction(
|
||||
ItemListingAction.DropdownMenuClick(
|
||||
menuAction = VaultDropdownMenuAction.MOVE,
|
||||
menuAction = VaultDropdownMenuAction.COPY_TO_BITWARDEN,
|
||||
item = LOCAL_CODE,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `Move to Bitwarden long press action should not show when showMoveToBitwarden is false`() {
|
||||
fun `Copy to Bitwarden vault long press action should not show when showMoveToBitwarden is false`() {
|
||||
mutableStateFlow.value = DEFAULT_STATE.copy(
|
||||
viewState = ItemListingState.ViewState.Content(
|
||||
actionCard = ItemListingState.ActionCardState.None,
|
||||
@ -388,7 +389,7 @@ class ItemListingScreenTest : AuthenticatorComposeTest() {
|
||||
.performTouchInput { longClick() }
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText("Move to Bitwarden")
|
||||
.onNodeWithText(text = "Copy to Bitwarden vault")
|
||||
.assertDoesNotExist()
|
||||
}
|
||||
|
||||
|
||||
@ -378,7 +378,7 @@ class ItemListingViewModelTest : BaseViewModelTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on MoveToBitwardenClick receive should call startAddTotpLoginItemFlow`() {
|
||||
fun `on CopyToBitwardenClick receive should call startAddTotpLoginItemFlow`() {
|
||||
val expectedUriString = "expectedUriString"
|
||||
val entity: AuthenticatorItemEntity = mockk {
|
||||
every { toOtpAuthUriString() } returns expectedUriString
|
||||
@ -394,7 +394,7 @@ class ItemListingViewModelTest : BaseViewModelTest() {
|
||||
|
||||
viewModel.trySendAction(
|
||||
ItemListingAction.DropdownMenuClick(
|
||||
menuAction = VaultDropdownMenuAction.MOVE,
|
||||
menuAction = VaultDropdownMenuAction.COPY_TO_BITWARDEN,
|
||||
item = LOCAL_CODE,
|
||||
),
|
||||
)
|
||||
@ -403,7 +403,7 @@ class ItemListingViewModelTest : BaseViewModelTest() {
|
||||
|
||||
@Test
|
||||
@Suppress("MaxLineLength")
|
||||
fun `on MoveToBitwardenClick should show error dialog when startAddTotpLoginItemFlow returns false`() {
|
||||
fun `on CopyToBitwardenClick should show error dialog when startAddTotpLoginItemFlow returns false`() {
|
||||
val expectedState = DEFAULT_STATE.copy(
|
||||
dialog = ItemListingState.DialogState.Error(
|
||||
title = R.string.something_went_wrong.asText(),
|
||||
@ -423,7 +423,10 @@ class ItemListingViewModelTest : BaseViewModelTest() {
|
||||
|
||||
val viewModel = createViewModel()
|
||||
viewModel.trySendAction(
|
||||
ItemListingAction.DropdownMenuClick(VaultDropdownMenuAction.MOVE, LOCAL_CODE),
|
||||
ItemListingAction.DropdownMenuClick(
|
||||
menuAction = VaultDropdownMenuAction.COPY_TO_BITWARDEN,
|
||||
item = LOCAL_CODE,
|
||||
),
|
||||
)
|
||||
assertEquals(
|
||||
expectedState,
|
||||
@ -442,7 +445,7 @@ class ItemListingViewModelTest : BaseViewModelTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should copy text to clipboard when DropdownMenuClick COPY is triggered`() = runTest {
|
||||
fun `should copy text to clipboard when DropdownMenuClick COPY_CODE is triggered`() = runTest {
|
||||
val viewModel = createViewModel()
|
||||
|
||||
every { clipboardManager.setText(text = LOCAL_CODE.authCode) } just runs
|
||||
@ -450,7 +453,7 @@ class ItemListingViewModelTest : BaseViewModelTest() {
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(
|
||||
ItemListingAction.DropdownMenuClick(
|
||||
menuAction = VaultDropdownMenuAction.COPY,
|
||||
menuAction = VaultDropdownMenuAction.COPY_CODE,
|
||||
item = LOCAL_CODE,
|
||||
),
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user