From 464490e68f5e321ea6dcc766c9188980a7cd5511 Mon Sep 17 00:00:00 2001 From: Caleb Derosier <125901828+caleb-livefront@users.noreply.github.com> Date: Thu, 4 Apr 2024 11:25:21 -0600 Subject: [PATCH] BIT-2207: Move Give Feedback form to About screen (#1227) --- .../feature/settings/about/AboutScreen.kt | 14 ++++++++++++++ .../feature/settings/about/AboutViewModel.kt | 15 +++++++++++++++ .../feature/settings/other/OtherScreen.kt | 15 --------------- .../feature/settings/other/OtherViewModel.kt | 15 --------------- .../feature/settings/about/AboutScreenTest.kt | 16 ++++++++++++++++ .../feature/settings/about/AboutViewModelTest.kt | 9 +++++++++ .../feature/settings/other/OtherScreenTest.kt | 16 ---------------- .../feature/settings/other/OtherViewModelTest.kt | 9 --------- 8 files changed, 54 insertions(+), 55 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutScreen.kt index dd4483d6849..35b3895a39a 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutScreen.kt @@ -71,6 +71,10 @@ fun AboutScreen( AboutEvent.NavigateBack -> onNavigateBack.invoke() + AboutEvent.NavigateToFeedbackForm -> { + intentManager.launchUri("https://livefrontinc.typeform.com/to/irgrRu4a".toUri()) + } + AboutEvent.NavigateToHelpCenter -> { intentManager.launchUri("https://bitwarden.com/help".toUri()) } @@ -126,6 +130,9 @@ fun AboutScreen( onRateTheAppClick = remember(viewModel) { { viewModel.trySendAction(AboutAction.RateAppClick) } }, + onGiveFeedbackClick = remember(viewModel) { + { viewModel.trySendAction(AboutAction.GiveFeedbackClick) } + }, onSubmitCrashLogsCheckedChange = remember(viewModel) { { viewModel.trySendAction(AboutAction.SubmitCrashLogsClick(it)) } }, @@ -147,6 +154,7 @@ private fun ContentColumn( onPrivacyPolicyClick: () -> Unit, onLearnAboutOrgsClick: () -> Unit, onRateTheAppClick: () -> Unit, + onGiveFeedbackClick: () -> Unit, onSubmitCrashLogsCheckedChange: (Boolean) -> Unit, onVersionClick: () -> Unit, onWebVaultClick: () -> Unit, @@ -208,6 +216,12 @@ private fun ContentColumn( dialogTitle = stringResource(id = R.string.continue_to_app_store), dialogMessage = stringResource(id = R.string.rate_app_description_long), ) + BitwardenExternalLinkRow( + text = stringResource(R.string.give_feedback), + onConfirmClick = onGiveFeedbackClick, + dialogTitle = stringResource(R.string.continue_to_give_feedback), + dialogMessage = stringResource(R.string.continue_to_provide_feedback), + ) CopyRow( text = state.version, onClick = onVersionClick, diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutViewModel.kt index 34ba869ecbc..a06c969a7cd 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutViewModel.kt @@ -49,6 +49,7 @@ class AboutViewModel @Inject constructor( override fun handleAction(action: AboutAction): Unit = when (action) { AboutAction.BackClick -> handleBackClick() + AboutAction.GiveFeedbackClick -> handleGiveFeedbackClick() AboutAction.HelpCenterClick -> handleHelpCenterClick() AboutAction.PrivacyPolicyClick -> handlePrivacyPolicyClick() AboutAction.LearnAboutOrganizationsClick -> handleLearnAboutOrganizationsClick() @@ -66,6 +67,10 @@ class AboutViewModel @Inject constructor( sendEvent(AboutEvent.NavigateToHelpCenter) } + private fun handleGiveFeedbackClick() { + sendEvent(AboutEvent.NavigateToFeedbackForm) + } + private fun handlePrivacyPolicyClick() { sendEvent(AboutEvent.NavigateToPrivacyPolicy) } @@ -139,6 +144,11 @@ sealed class AboutEvent { */ data object NavigateBack : AboutEvent() + /** + * Navigate to the feedback form. + */ + data object NavigateToFeedbackForm : AboutEvent() + /** * Navigates to the help center. */ @@ -174,6 +184,11 @@ sealed class AboutAction { */ data object BackClick : AboutAction() + /** + * User clicked the give feedback row. + */ + data object GiveFeedbackClick : AboutAction() + /** * User clicked the helper center row. */ diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherScreen.kt index 151514db0df..5a84c196e31 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherScreen.kt @@ -29,7 +29,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.semantics import androidx.compose.ui.semantics.testTag import androidx.compose.ui.unit.dp -import androidx.core.net.toUri import androidx.hilt.navigation.compose.hiltViewModel import com.x8bit.bitwarden.R import com.x8bit.bitwarden.data.platform.repository.model.ClearClipboardFrequency @@ -42,7 +41,6 @@ import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenSelectionDialo import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState import com.x8bit.bitwarden.ui.platform.components.dialog.row.BitwardenSelectionRow -import com.x8bit.bitwarden.ui.platform.components.row.BitwardenExternalLinkRow import com.x8bit.bitwarden.ui.platform.components.row.BitwardenTextRow import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenWideSwitch @@ -64,9 +62,6 @@ fun OtherScreen( EventsEffect(viewModel = viewModel) { event -> when (event) { OtherEvent.NavigateBack -> onNavigateBack.invoke() - OtherEvent.NavigateToFeedbackForm -> { - intentManager.launchUri("https://livefrontinc.typeform.com/to/irgrRu4a".toUri()) - } } } @@ -166,16 +161,6 @@ fun OtherScreen( .semantics { testTag = "AllowScreenCaptureSwitch" } .padding(horizontal = 16.dp), ) - - BitwardenExternalLinkRow( - text = stringResource(R.string.give_feedback), - onConfirmClick = remember(viewModel) { - { viewModel.trySendAction(OtherAction.GiveFeedbackClick) } - }, - dialogTitle = stringResource(R.string.continue_to_give_feedback), - dialogMessage = stringResource(R.string.continue_to_provide_feedback), - withDivider = false, - ) } } } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherViewModel.kt index 057c4b79c43..a19f32a010d 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherViewModel.kt @@ -60,7 +60,6 @@ class OtherViewModel @Inject constructor( is OtherAction.AllowSyncToggle -> handleAllowSyncToggled(action) OtherAction.BackClick -> handleBackClicked() is OtherAction.ClearClipboardFrequencyChange -> handleClearClipboardFrequencyChanged(action) - OtherAction.GiveFeedbackClick -> handleGiveFeedbackClicked() OtherAction.SyncNowButtonClick -> handleSyncNowButtonClicked() is OtherAction.Internal -> handleInternalAction(action) } @@ -88,10 +87,6 @@ class OtherViewModel @Inject constructor( settingsRepo.clearClipboardFrequency = action.clearClipboardFrequency } - private fun handleGiveFeedbackClicked() { - sendEvent(OtherEvent.NavigateToFeedbackForm) - } - private fun handleSyncNowButtonClicked() { mutableStateFlow.update { it.copy(dialogState = OtherState.DialogState.Loading(R.string.syncing.asText())) @@ -151,11 +146,6 @@ sealed class OtherEvent { * Navigate back. */ data object NavigateBack : OtherEvent() - - /** - * Navigate to the feedback form. - */ - data object NavigateToFeedbackForm : OtherEvent() } /** @@ -188,11 +178,6 @@ sealed class OtherAction { val clearClipboardFrequency: ClearClipboardFrequency, ) : OtherAction() - /** - * Indicates that the user clicked the Give feedback button. - */ - data object GiveFeedbackClick : OtherAction() - /** * Indicates that the user clicked the Sync Now button. */ diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutScreenTest.kt index 0d858d3d3d2..74eaba680b8 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutScreenTest.kt @@ -72,6 +72,22 @@ class AboutScreenTest : BaseComposeTest() { verify { viewModel.trySendAction(AboutAction.BackClick) } } + @Suppress("MaxLineLength") + @Test + fun `on give feedback click should display confirmation dialog and confirm click should emit GiveFeedbackClick`() { + composeTestRule.onNode(isDialog()).assertDoesNotExist() + composeTestRule.onNodeWithText("Give Feedback").performScrollTo().performClick() + composeTestRule.onNode(isDialog()).assertExists() + composeTestRule + .onAllNodesWithText("Continue") + .filterToOne(hasAnyAncestor(isDialog())) + .performClick() + composeTestRule.onNode(isDialog()).assertDoesNotExist() + verify { + viewModel.trySendAction(AboutAction.GiveFeedbackClick) + } + } + @Suppress("MaxLineLength") @Test fun `on bitwarden help center click should display confirmation dialog and confirm click should emit HelpCenterClick`() { diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutViewModelTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutViewModelTest.kt index 69d9bf2e853..f0f04271971 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutViewModelTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/about/AboutViewModelTest.kt @@ -44,6 +44,15 @@ class AboutViewModelTest : BaseViewModelTest() { } } + @Test + fun `on GiveFeedbackClick should emit NavigateToFeedbackForm`() = runTest { + val viewModel = createViewModel() + viewModel.eventFlow.test { + viewModel.trySendAction(AboutAction.GiveFeedbackClick) + assertEquals(AboutEvent.NavigateToFeedbackForm, awaitItem()) + } + } + @Test fun `on HelpCenterClick should emit NavigateToHelpCenter`() = runTest { val viewModel = createViewModel(DEFAULT_ABOUT_STATE) diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherScreenTest.kt index 1680310ada7..4c345dc0b0b 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherScreenTest.kt @@ -149,22 +149,6 @@ class OtherScreenTest : BaseComposeTest() { .assertIsDisplayed() .assert(hasAnyAncestor(isDialog())) } - - @Suppress("MaxLineLength") - @Test - fun `on give feedback click should display confirmation dialog and confirm click should emit GiveFeedbackClick`() { - composeTestRule.onNode(isDialog()).assertDoesNotExist() - composeTestRule.onNodeWithText("Give Feedback").performClick() - composeTestRule.onNode(isDialog()).assertExists() - composeTestRule - .onAllNodesWithText("Continue") - .filterToOne(hasAnyAncestor(isDialog())) - .performClick() - composeTestRule.onNode(isDialog()).assertDoesNotExist() - verify { - viewModel.trySendAction(OtherAction.GiveFeedbackClick) - } - } } private val DEFAULT_STATE = OtherState( diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherViewModelTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherViewModelTest.kt index 1555694994a..d85f2d97405 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherViewModelTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/other/OtherViewModelTest.kt @@ -108,15 +108,6 @@ class OtherViewModelTest : BaseViewModelTest() { } } - @Test - fun `on GiveFeedbackClick should emit NavigateToFeedbackForm`() = runTest { - val viewModel = createViewModel() - viewModel.eventFlow.test { - viewModel.trySendAction(OtherAction.GiveFeedbackClick) - assertEquals(OtherEvent.NavigateToFeedbackForm, awaitItem()) - } - } - @Test fun `on ClearClipboardFrequencyChange should update state`() = runTest { val viewModel = createViewModel()