From 475d3ad527dc672be4fd5380edccfa6000fa39b7 Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 11:55:24 +0200 Subject: [PATCH 01/14] Adds new feedback module at the bottom of Blaze success sheet --- .../kotlin/com/woocommerce/android/AppUrls.kt | 3 + .../BlazeCampaignSuccessBottomSheet.kt | 61 +++++++++++++++++++ ...BlazeCampaignSuccessBottomSheetFragment.kt | 11 +++- WooCommerce/src/main/res/values/strings.xml | 1 + 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/AppUrls.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/AppUrls.kt index 12eb82081dc..224a9effb7f 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/AppUrls.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/AppUrls.kt @@ -143,4 +143,7 @@ object AppUrls { const val GOOGLE_ADMIN_DASHBOARD = "admin.php?page=wc-admin&path=%2Fgoogle%2Fdashboard" + + const val BLAZE_CAMPAIGN_CREATION_SURVEY_URL_I1 = + "https://wordpressdotcom.survey.fm/blaze-on-woo-mobile-survey-sept-2024-i1" } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt index 7c28e360b0d..88e27966163 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt @@ -1,23 +1,32 @@ package com.woocommerce.android.ui.blaze.creation.success +import androidx.annotation.StringRes import androidx.compose.foundation.Image +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Icon +import androidx.compose.material.IconButton import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import com.woocommerce.android.R import com.woocommerce.android.R.dimen import com.woocommerce.android.R.drawable import com.woocommerce.android.R.string @@ -28,6 +37,7 @@ import com.woocommerce.android.ui.compose.preview.LightDarkThemePreviews @Composable fun BlazeCampaignSuccessBottomSheet( onDoneTapped: () -> Unit, + onRequestFeedback: (Boolean) -> Unit, modifier: Modifier = Modifier ) { Surface( @@ -71,6 +81,57 @@ fun BlazeCampaignSuccessBottomSheet( Text(text = stringResource(id = string.blaze_campaign_created_success_done_button)) } Spacer(modifier = Modifier.height(16.dp)) + RequestFeedback( + onFeedbackReceived = onRequestFeedback, + feedbackRequestText = R.string.blaze_campaign_created_success_feedback_request, + modifier = Modifier.fillMaxWidth() + ) + } + } +} + +@Composable +fun RequestFeedback( + onFeedbackReceived: (Boolean) -> Unit, + @StringRes feedbackRequestText: Int, + modifier: Modifier = Modifier +) { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = modifier + .background( + color = colorResource(id = R.color.ai_product_suggestion_box_background), + shape = RoundedCornerShape(dimensionResource(id = R.dimen.minor_100)) + ) + .padding(dimensionResource(id = R.dimen.major_100)) + ) { + Text( + text = stringResource(id = feedbackRequestText), + color = colorResource(id = R.color.color_on_surface_medium), + modifier = Modifier.weight(1f) + ) + IconButton( + onClick = { onFeedbackReceived(true) }, + modifier = Modifier.size(dimensionResource(id = R.dimen.major_200)) + ) { + Icon( + painter = painterResource(id = R.drawable.ic_thumb_up), + contentDescription = stringResource(id = R.string.ai_feedback_form_positive_button), + tint = colorResource(id = R.color.color_on_surface_medium) + ) + } + + Spacer(modifier = Modifier.width(dimensionResource(id = R.dimen.minor_100))) + + IconButton( + onClick = { onFeedbackReceived(false) }, + modifier = Modifier.size(dimensionResource(id = R.dimen.major_200)) + ) { + Icon( + painter = painterResource(id = R.drawable.ic_thumb_down), + contentDescription = stringResource(id = R.string.ai_feedback_form_negative_button), + tint = colorResource(id = R.color.color_on_surface_medium) + ) } } } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt index 552e2c308a1..92c952a52c2 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt @@ -4,7 +4,9 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import com.woocommerce.android.AppUrls.BLAZE_CAMPAIGN_CREATION_SURVEY_URL_I1 import com.woocommerce.android.ui.compose.composeView +import com.woocommerce.android.util.ChromeCustomTabUtils import com.woocommerce.android.widgets.WCBottomSheetDialogFragment import dagger.hilt.android.AndroidEntryPoint @@ -12,11 +14,18 @@ import dagger.hilt.android.AndroidEntryPoint class BlazeCampaignSuccessBottomSheetFragment : WCBottomSheetDialogFragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { return composeView { - BlazeCampaignSuccessBottomSheet(::onDoneClicked) + BlazeCampaignSuccessBottomSheet( + ::onDoneClicked, + ::onFeedbackRequestTapped + ) } } private fun onDoneClicked() { dismiss() } + + private fun onFeedbackRequestTapped(isPositive: Boolean) { + ChromeCustomTabUtils.launchUrl(requireContext(), BLAZE_CAMPAIGN_CREATION_SURVEY_URL_I1) + } } diff --git a/WooCommerce/src/main/res/values/strings.xml b/WooCommerce/src/main/res/values/strings.xml index d8ec1060293..297279af88a 100644 --- a/WooCommerce/src/main/res/values/strings.xml +++ b/WooCommerce/src/main/res/values/strings.xml @@ -4014,6 +4014,7 @@ <string name="blaze_campaign_created_success_title">Ready to Go!</string> <string name="blaze_campaign_created_success_description">We\'re reviewing your campaign. It\'ll be live within 24 hours. Exciting times ahead for your sales!</string> <string name="blaze_campaign_created_success_done_button">Done</string> + <string name="blaze_campaign_created_success_feedback_request">How was the experience with Blaze</string> <string name="blaze_campaign_creation_loading">Creating your campaign</string> <string name="blaze_campaign_creation_error_title">Error creating campaign</string> <string name="blaze_campaign_creation_error_payment_hint">Error creating campaign</string> From bbcd326b20a7c244d6560a06ccea114253801b3a Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 14:48:36 +0200 Subject: [PATCH 02/14] Track tapping on positive or negative feedback --- .../android/analytics/AnalyticsEvent.kt | 2 +- .../BlazeCampaignSuccessBottomSheetFragment.kt | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt index 0867dde4c7c..49e18cb517c 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt @@ -1030,7 +1030,7 @@ enum class AnalyticsEvent(override val siteless: Boolean = false) : IAnalyticsEv BLAZE_CREATION_EDIT_INTEREST_SAVE_TAPPED, BLAZE_CREATION_EDIT_LOCATION_SAVE_TAPPED, BLAZE_CREATION_EDIT_DESTINATION_SAVE_TAPPED, - + BLAZE_CAMPAIGN_CREATION_FEEDBACK, // Hazmat Shipping Declaration CONTAINS_HAZMAT_CHECKED, HAZMAT_CATEGORY_SELECTOR_OPENED, diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt index 92c952a52c2..64cf0867f5a 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt @@ -5,13 +5,20 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.woocommerce.android.AppUrls.BLAZE_CAMPAIGN_CREATION_SURVEY_URL_I1 +import com.woocommerce.android.analytics.AnalyticsEvent +import com.woocommerce.android.analytics.AnalyticsTracker +import com.woocommerce.android.analytics.AnalyticsTrackerWrapper import com.woocommerce.android.ui.compose.composeView import com.woocommerce.android.util.ChromeCustomTabUtils import com.woocommerce.android.widgets.WCBottomSheetDialogFragment import dagger.hilt.android.AndroidEntryPoint +import javax.inject.Inject @AndroidEntryPoint class BlazeCampaignSuccessBottomSheetFragment : WCBottomSheetDialogFragment() { + @Inject + lateinit var analyticsTracker: AnalyticsTrackerWrapper + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { return composeView { BlazeCampaignSuccessBottomSheet( @@ -26,6 +33,13 @@ class BlazeCampaignSuccessBottomSheetFragment : WCBottomSheetDialogFragment() { } private fun onFeedbackRequestTapped(isPositive: Boolean) { + analyticsTracker.track( + stat = AnalyticsEvent.BLAZE_CAMPAIGN_CREATION_FEEDBACK, + properties = mapOf( + AnalyticsTracker.KEY_SOURCE to "satisfied", + AnalyticsTracker.KEY_IS_USEFUL to isPositive + ) + ) ChromeCustomTabUtils.launchUrl(requireContext(), BLAZE_CAMPAIGN_CREATION_SURVEY_URL_I1) } } From f42eb09681439d8ca69bce471d49441456cd07bd Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 17:00:35 +0200 Subject: [PATCH 03/14] Add logic to only show feedback request if user has at least 2 campaigns --- .../BlazeCampaignSuccessBottomSheet.kt | 24 ++++++++++++++++++- ...BlazeCampaignSuccessBottomSheetFragment.kt | 6 ++++- .../success/ShouldShowFeedbackRequest.kt | 17 +++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/ShouldShowFeedbackRequest.kt diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt index 88e27966163..1e6c7baeb09 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt @@ -18,6 +18,11 @@ import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +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.Modifier import androidx.compose.ui.res.colorResource @@ -34,6 +39,20 @@ import com.woocommerce.android.ui.compose.component.BottomSheetHandle import com.woocommerce.android.ui.compose.component.WCColoredButton import com.woocommerce.android.ui.compose.preview.LightDarkThemePreviews +@Composable +fun BlazeCampaignSuccessBottomSheet( + onDoneTapped: () -> Unit, + onRequestFeedback: (Boolean) -> Unit, + shouldShowFeedbackRequest: ShouldShowFeedbackRequest, +) { + var showFeedbackRequest by remember { mutableStateOf(false) } + LaunchedEffect(shouldShowFeedbackRequest) { + showFeedbackRequest = shouldShowFeedbackRequest() + } + + BlazeCampaignSuccessBottomSheet(onDoneTapped, onRequestFeedback) +} + @Composable fun BlazeCampaignSuccessBottomSheet( onDoneTapped: () -> Unit, @@ -139,5 +158,8 @@ fun RequestFeedback( @LightDarkThemePreviews @Composable private fun BlazeCampaignSuccessBottomSheetPreview() { - BlazeCampaignSuccessBottomSheet(onDoneTapped = {}) + BlazeCampaignSuccessBottomSheet( + onDoneTapped = {}, + onRequestFeedback = {} + ) } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt index 64cf0867f5a..6b562cace8a 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt @@ -19,11 +19,15 @@ class BlazeCampaignSuccessBottomSheetFragment : WCBottomSheetDialogFragment() { @Inject lateinit var analyticsTracker: AnalyticsTrackerWrapper + @Inject + lateinit var shouldShowFeedbackRequest: ShouldShowFeedbackRequest + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { return composeView { BlazeCampaignSuccessBottomSheet( ::onDoneClicked, - ::onFeedbackRequestTapped + ::onFeedbackRequestTapped, + shouldShowFeedbackRequest ) } } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/ShouldShowFeedbackRequest.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/ShouldShowFeedbackRequest.kt new file mode 100644 index 00000000000..c9e073f58bb --- /dev/null +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/ShouldShowFeedbackRequest.kt @@ -0,0 +1,17 @@ +package com.woocommerce.android.ui.blaze.creation.success + +import com.woocommerce.android.tools.SelectedSite +import org.wordpress.android.fluxc.store.blaze.BlazeCampaignsStore +import javax.inject.Inject + +class ShouldShowFeedbackRequest @Inject constructor( + private val selectedSite: SelectedSite, + private val blazeCampaignsStore: BlazeCampaignsStore +) { + companion object { + private const val MINIMUM_CAMPAIGNS_FOR_FEEDBACK_REQUEST = 2 + } + + suspend operator fun invoke(): Boolean = + blazeCampaignsStore.getBlazeCampaigns(selectedSite.get()).size >= MINIMUM_CAMPAIGNS_FOR_FEEDBACK_REQUEST +} From 3445f0facdeff116471ef38ec28b95c9e094a6a9 Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 17:20:13 +0200 Subject: [PATCH 04/14] Extract RequestFeedback composable to a reusable component --- .../BlazeCampaignSuccessBottomSheet.kt | 82 +++++-------------- .../android/ui/compose/component/Feedback.kt | 67 +++++++++++++++ 2 files changed, 86 insertions(+), 63 deletions(-) create mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/ui/compose/component/Feedback.kt diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt index 1e6c7baeb09..877d5608794 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheet.kt @@ -1,19 +1,12 @@ package com.woocommerce.android.ui.blaze.creation.success -import androidx.annotation.StringRes import androidx.compose.foundation.Image -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Icon -import androidx.compose.material.IconButton import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.material.Text @@ -25,7 +18,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource @@ -36,13 +28,14 @@ import com.woocommerce.android.R.dimen import com.woocommerce.android.R.drawable import com.woocommerce.android.R.string import com.woocommerce.android.ui.compose.component.BottomSheetHandle +import com.woocommerce.android.ui.compose.component.FeedbackRequest import com.woocommerce.android.ui.compose.component.WCColoredButton import com.woocommerce.android.ui.compose.preview.LightDarkThemePreviews @Composable fun BlazeCampaignSuccessBottomSheet( onDoneTapped: () -> Unit, - onRequestFeedback: (Boolean) -> Unit, + onFeedbackTapped: (Boolean) -> Unit, shouldShowFeedbackRequest: ShouldShowFeedbackRequest, ) { var showFeedbackRequest by remember { mutableStateOf(false) } @@ -50,13 +43,18 @@ fun BlazeCampaignSuccessBottomSheet( showFeedbackRequest = shouldShowFeedbackRequest() } - BlazeCampaignSuccessBottomSheet(onDoneTapped, onRequestFeedback) + BlazeCampaignSuccessBottomSheet( + onDoneTapped = onDoneTapped, + onFeedbackTapped = onFeedbackTapped, + showFeedbackRequest = showFeedbackRequest, + ) } @Composable fun BlazeCampaignSuccessBottomSheet( onDoneTapped: () -> Unit, - onRequestFeedback: (Boolean) -> Unit, + onFeedbackTapped: (Boolean) -> Unit, + showFeedbackRequest: Boolean, modifier: Modifier = Modifier ) { Surface( @@ -100,57 +98,14 @@ fun BlazeCampaignSuccessBottomSheet( Text(text = stringResource(id = string.blaze_campaign_created_success_done_button)) } Spacer(modifier = Modifier.height(16.dp)) - RequestFeedback( - onFeedbackReceived = onRequestFeedback, - feedbackRequestText = R.string.blaze_campaign_created_success_feedback_request, - modifier = Modifier.fillMaxWidth() - ) - } - } -} - -@Composable -fun RequestFeedback( - onFeedbackReceived: (Boolean) -> Unit, - @StringRes feedbackRequestText: Int, - modifier: Modifier = Modifier -) { - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = modifier - .background( - color = colorResource(id = R.color.ai_product_suggestion_box_background), - shape = RoundedCornerShape(dimensionResource(id = R.dimen.minor_100)) - ) - .padding(dimensionResource(id = R.dimen.major_100)) - ) { - Text( - text = stringResource(id = feedbackRequestText), - color = colorResource(id = R.color.color_on_surface_medium), - modifier = Modifier.weight(1f) - ) - IconButton( - onClick = { onFeedbackReceived(true) }, - modifier = Modifier.size(dimensionResource(id = R.dimen.major_200)) - ) { - Icon( - painter = painterResource(id = R.drawable.ic_thumb_up), - contentDescription = stringResource(id = R.string.ai_feedback_form_positive_button), - tint = colorResource(id = R.color.color_on_surface_medium) - ) - } - - Spacer(modifier = Modifier.width(dimensionResource(id = R.dimen.minor_100))) - - IconButton( - onClick = { onFeedbackReceived(false) }, - modifier = Modifier.size(dimensionResource(id = R.dimen.major_200)) - ) { - Icon( - painter = painterResource(id = R.drawable.ic_thumb_down), - contentDescription = stringResource(id = R.string.ai_feedback_form_negative_button), - tint = colorResource(id = R.color.color_on_surface_medium) - ) + if (showFeedbackRequest) { + FeedbackRequest( + onFeedbackReceived = onFeedbackTapped, + feedbackRequestText = R.string.blaze_campaign_created_success_feedback_request, + modifier = Modifier.fillMaxWidth() + ) + Spacer(modifier = Modifier.height(16.dp)) + } } } } @@ -160,6 +115,7 @@ fun RequestFeedback( private fun BlazeCampaignSuccessBottomSheetPreview() { BlazeCampaignSuccessBottomSheet( onDoneTapped = {}, - onRequestFeedback = {} + onFeedbackTapped = {}, + showFeedbackRequest = true ) } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/compose/component/Feedback.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/compose/component/Feedback.kt new file mode 100644 index 00000000000..ff15fe62a2e --- /dev/null +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/compose/component/Feedback.kt @@ -0,0 +1,67 @@ +package com.woocommerce.android.ui.compose.component + +import androidx.annotation.StringRes +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.colorResource +import androidx.compose.ui.res.dimensionResource +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import com.woocommerce.android.R + +@Composable +fun FeedbackRequest( + onFeedbackReceived: (Boolean) -> Unit, + @StringRes feedbackRequestText: Int, + modifier: Modifier = Modifier +) { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = modifier + .background( + color = colorResource(id = R.color.ai_product_suggestion_box_background), + shape = RoundedCornerShape(dimensionResource(id = R.dimen.minor_100)) + ) + .padding(dimensionResource(id = R.dimen.major_100)) + ) { + Text( + text = stringResource(id = feedbackRequestText), + color = colorResource(id = R.color.color_on_surface_medium), + modifier = Modifier.weight(1f) + ) + IconButton( + onClick = { onFeedbackReceived(true) }, + modifier = Modifier.size(dimensionResource(id = R.dimen.major_200)) + ) { + Icon( + painter = painterResource(id = R.drawable.ic_thumb_up), + contentDescription = stringResource(id = R.string.ai_feedback_form_positive_button), + tint = colorResource(id = R.color.color_on_surface_medium) + ) + } + + Spacer(modifier = Modifier.width(dimensionResource(id = R.dimen.minor_100))) + + IconButton( + onClick = { onFeedbackReceived(false) }, + modifier = Modifier.size(dimensionResource(id = R.dimen.major_200)) + ) { + Icon( + painter = painterResource(id = R.drawable.ic_thumb_down), + contentDescription = stringResource(id = R.string.ai_feedback_form_negative_button), + tint = colorResource(id = R.color.color_on_surface_medium) + ) + } + } +} From 1b80c167ea46659ae5859e30b82d4f8cc75e4bff Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 17:21:42 +0200 Subject: [PATCH 05/14] Use new generic compose component for feedback in AI product creation --- .../ui/products/ProductSharingBottomSheet.kt | 7 +- .../android/ui/products/ai/AiFeedbackForm.kt | 65 ------------------- .../ai/preview/AiProductPreviewScreen.kt | 7 +- 3 files changed, 9 insertions(+), 70 deletions(-) delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ai/AiFeedbackForm.kt diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductSharingBottomSheet.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductSharingBottomSheet.kt index df5e3c46a9d..af81039343c 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductSharingBottomSheet.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductSharingBottomSheet.kt @@ -35,6 +35,7 @@ import androidx.compose.ui.tooling.preview.Preview import com.woocommerce.android.AppConstants.FADE_ANIMATION_DELAY_MS import com.woocommerce.android.R import com.woocommerce.android.ui.compose.animations.SkeletonView +import com.woocommerce.android.ui.compose.component.FeedbackRequest import com.woocommerce.android.ui.compose.component.WCColoredButton import com.woocommerce.android.ui.compose.component.WCOutlinedButton import com.woocommerce.android.ui.compose.component.WCOutlinedTextField @@ -45,7 +46,6 @@ import com.woocommerce.android.ui.products.ProductSharingViewModel.AIButtonState import com.woocommerce.android.ui.products.ProductSharingViewModel.AIButtonState.Regenerate import com.woocommerce.android.ui.products.ProductSharingViewModel.AIButtonState.WriteWithAI import com.woocommerce.android.ui.products.ProductSharingViewModel.ProductSharingViewState -import com.woocommerce.android.ui.products.ai.AiFeedbackForm @Composable fun ProductSharingBottomSheet(viewModel: ProductSharingViewModel) { @@ -109,7 +109,10 @@ fun ProductShareWithAI( enter = fadeIn(animationSpec = tween(FADE_ANIMATION_DELAY_MS)), exit = fadeOut(animationSpec = tween(FADE_ANIMATION_DELAY_MS)) ) { - AiFeedbackForm(onDescriptionFeedbackReceived) + FeedbackRequest( + feedbackRequestText = R.string.ai_feedback_form_message, + onFeedbackReceived = onDescriptionFeedbackReceived + ) } } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ai/AiFeedbackForm.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ai/AiFeedbackForm.kt deleted file mode 100644 index fd20889529d..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ai/AiFeedbackForm.kt +++ /dev/null @@ -1,65 +0,0 @@ -package com.woocommerce.android.ui.products.ai - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.colorResource -import androidx.compose.ui.res.dimensionResource -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource -import com.woocommerce.android.R - -@Composable -fun AiFeedbackForm( - onFeedbackReceived: (Boolean) -> Unit, - modifier: Modifier = Modifier -) { - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = modifier - .background( - color = colorResource(id = R.color.ai_product_suggestion_box_background), - shape = RoundedCornerShape(dimensionResource(id = R.dimen.minor_100)) - ) - .padding(dimensionResource(id = R.dimen.major_100)) - ) { - Text( - text = stringResource(id = R.string.ai_feedback_form_message), - color = colorResource(id = R.color.color_on_surface_medium), - modifier = Modifier.weight(1f) - ) - IconButton( - onClick = { onFeedbackReceived(true) }, - modifier = Modifier.size(dimensionResource(id = R.dimen.major_200)) - ) { - Icon( - painter = painterResource(id = R.drawable.ic_thumb_up), - contentDescription = stringResource(id = R.string.ai_feedback_form_positive_button), - tint = colorResource(id = R.color.color_on_surface_medium) - ) - } - - Spacer(modifier = Modifier.width(dimensionResource(id = R.dimen.minor_100))) - - IconButton( - onClick = { onFeedbackReceived(false) }, - modifier = Modifier.size(dimensionResource(id = R.dimen.major_200)) - ) { - Icon( - painter = painterResource(id = R.drawable.ic_thumb_down), - contentDescription = stringResource(id = R.string.ai_feedback_form_negative_button), - tint = colorResource(id = R.color.color_on_surface_medium) - ) - } - } -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ai/preview/AiProductPreviewScreen.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ai/preview/AiProductPreviewScreen.kt index 5431b2a05b7..a192ff2ad2b 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ai/preview/AiProductPreviewScreen.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ai/preview/AiProductPreviewScreen.kt @@ -58,12 +58,12 @@ import androidx.compose.ui.window.DialogProperties import com.woocommerce.android.R import com.woocommerce.android.ui.compose.animations.SkeletonView import com.woocommerce.android.ui.compose.autoMirror +import com.woocommerce.android.ui.compose.component.FeedbackRequest import com.woocommerce.android.ui.compose.component.Toolbar import com.woocommerce.android.ui.compose.component.WCOutlinedButton import com.woocommerce.android.ui.compose.component.WCTextButton import com.woocommerce.android.ui.compose.theme.WooThemeWithBackground import com.woocommerce.android.ui.products.ai.AIProductModel -import com.woocommerce.android.ui.products.ai.AiFeedbackForm import com.woocommerce.android.ui.products.ai.ProductPropertyCard import com.woocommerce.android.ui.products.ai.components.FullScreenImageViewer import com.woocommerce.android.ui.products.ai.components.ImageAction @@ -283,8 +283,9 @@ private fun ProductPreviewContent( .fillMaxWidth() .padding(top = 16.dp) ) { - AiFeedbackForm( - onFeedbackReceived = onFeedbackReceived, + FeedbackRequest( + feedbackRequestText = R.string.ai_feedback_form_message, + onFeedbackReceived = onFeedbackReceived ) } From 7e6dae483ba6710bb3908aa12546aafc397ad39e Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 18:29:50 +0200 Subject: [PATCH 06/14] Fix detekt indentation issue --- .../kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt index 49e18cb517c..797df1e45c6 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt @@ -1031,6 +1031,7 @@ enum class AnalyticsEvent(override val siteless: Boolean = false) : IAnalyticsEv BLAZE_CREATION_EDIT_LOCATION_SAVE_TAPPED, BLAZE_CREATION_EDIT_DESTINATION_SAVE_TAPPED, BLAZE_CAMPAIGN_CREATION_FEEDBACK, + // Hazmat Shipping Declaration CONTAINS_HAZMAT_CHECKED, HAZMAT_CATEGORY_SELECTOR_OPENED, From c24bfbad0ba216ce633a385bb80b89cf3712bf2d Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 19:02:13 +0200 Subject: [PATCH 07/14] Send objective null to avoid making the API fail While objective feature is WIP we were sending objective = "" in the create campaign request. Empty values are not allowed for this field. So until the feature is finished we must avoid sending the objective value at all in the create campaign request. --- .../kotlin/com/woocommerce/android/ui/blaze/BlazeRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/BlazeRepository.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/BlazeRepository.kt index e1f4b3f3064..d6852a5523c 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/BlazeRepository.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/BlazeRepository.kt @@ -322,7 +322,7 @@ class BlazeRepository @Inject constructor( ) }, isEndlessCampaign = campaignDetails.budget.isEndlessCampaign, - objectiveId = campaignDetails.objectiveId + objectiveId = if (FeatureFlag.OBJECTIVE_SECTION.isEnabled()) campaignDetails.objectiveId else null ) ) From c1b26f57a79c893d230191006cc184873f93b500 Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 19:03:02 +0200 Subject: [PATCH 08/14] Update FluxC changeset --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0ec13e3cdc5..fb58c32bc4f 100644 --- a/build.gradle +++ b/build.gradle @@ -100,7 +100,7 @@ tasks.register("installGitHooks", Copy) { } ext { - fluxCVersion = 'trunk-373bc6d30f8d9da6b7750f3ddc38929611b50056' + fluxCVersion = '3105-70f34a7279c647424f0be61466abf2c17267ef8b' glideVersion = '4.16.0' coilVersion = '2.1.0' constraintLayoutVersion = '1.2.0' From e2a9561395f407355cef2486405db076555993b2 Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 19:07:16 +0200 Subject: [PATCH 09/14] Update FluxC changeset --- .../main/kotlin/com/woocommerce/android/util/FeatureFlag.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt index 12e807610cf..ba499308724 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt @@ -25,11 +25,11 @@ enum class FeatureFlag { PackageUtils.isDebugBuild() || context != null && PackageUtils.isBetaBuild(context) } + OBJECTIVE_SECTION -> false WC_SHIPPING_BANNER, BETTER_CUSTOMER_SEARCH_M2, ORDER_CREATION_AUTO_TAX_RATE, - REVAMP_WOO_SHIPPING, - OBJECTIVE_SECTION -> PackageUtils.isDebugBuild() + REVAMP_WOO_SHIPPING -> PackageUtils.isDebugBuild() NEW_SHIPPING_SUPPORT, INBOX, From b0353b68879c3740227fafcc0a8a48134c14a11a Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 19:07:39 +0200 Subject: [PATCH 10/14] Fix tracking property --- .../success/BlazeCampaignSuccessBottomSheetFragment.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt index 6b562cace8a..15acaa8a585 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt @@ -6,7 +6,6 @@ import android.view.View import android.view.ViewGroup import com.woocommerce.android.AppUrls.BLAZE_CAMPAIGN_CREATION_SURVEY_URL_I1 import com.woocommerce.android.analytics.AnalyticsEvent -import com.woocommerce.android.analytics.AnalyticsTracker import com.woocommerce.android.analytics.AnalyticsTrackerWrapper import com.woocommerce.android.ui.compose.composeView import com.woocommerce.android.util.ChromeCustomTabUtils @@ -39,10 +38,7 @@ class BlazeCampaignSuccessBottomSheetFragment : WCBottomSheetDialogFragment() { private fun onFeedbackRequestTapped(isPositive: Boolean) { analyticsTracker.track( stat = AnalyticsEvent.BLAZE_CAMPAIGN_CREATION_FEEDBACK, - properties = mapOf( - AnalyticsTracker.KEY_SOURCE to "satisfied", - AnalyticsTracker.KEY_IS_USEFUL to isPositive - ) + properties = mapOf("satisfied" to isPositive) ) ChromeCustomTabUtils.launchUrl(requireContext(), BLAZE_CAMPAIGN_CREATION_SURVEY_URL_I1) } From aa6d2bfd715559e056ce6e25887a53c341301ec0 Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 19:09:34 +0200 Subject: [PATCH 11/14] Updates release notes --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index cbbf110dcde..902dd14890f 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -11,6 +11,7 @@ - [*] Fixed incorrect instructions on "What is Tap to Pay" screen in the Payments section [https://github.com/woocommerce/woocommerce-android/pull/12709] - [***] Merchants can now view and edit custom fields of their products and orders from the app [https://github.com/woocommerce/woocommerce-android/issues/12207] - [*] Fix size of the whats new announcement dialog [https://github.com/woocommerce/woocommerce-android/pull/12692] +- [*] Enables Blaze survey [https://github.com/woocommerce/woocommerce-android/pull/12761] 20.6 ----- From 2bb1afa9638d855a08303bd385b74a3ce970a6c3 Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 19:12:39 +0200 Subject: [PATCH 12/14] Revert accidental change --- .../main/kotlin/com/woocommerce/android/util/FeatureFlag.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt index ba499308724..12e807610cf 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt @@ -25,11 +25,11 @@ enum class FeatureFlag { PackageUtils.isDebugBuild() || context != null && PackageUtils.isBetaBuild(context) } - OBJECTIVE_SECTION -> false WC_SHIPPING_BANNER, BETTER_CUSTOMER_SEARCH_M2, ORDER_CREATION_AUTO_TAX_RATE, - REVAMP_WOO_SHIPPING -> PackageUtils.isDebugBuild() + REVAMP_WOO_SHIPPING, + OBJECTIVE_SECTION -> PackageUtils.isDebugBuild() NEW_SHIPPING_SUPPORT, INBOX, From 687f52ea57df2546e558aa635c3a0b02a8173b04 Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 23:15:54 +0200 Subject: [PATCH 13/14] Update fluxC changeset --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index fb58c32bc4f..cf6ae22a421 100644 --- a/build.gradle +++ b/build.gradle @@ -100,7 +100,7 @@ tasks.register("installGitHooks", Copy) { } ext { - fluxCVersion = '3105-70f34a7279c647424f0be61466abf2c17267ef8b' + fluxCVersion = 'trunk-7ad6ce4c250ba435d8d8c7feb898bceb259fb007' glideVersion = '4.16.0' coilVersion = '2.1.0' constraintLayoutVersion = '1.2.0' From 7b6ab39543c8c399d1de1dd01a2f2887d6277df7 Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos <jorge.mucientes@automattic.com> Date: Thu, 3 Oct 2024 23:16:22 +0200 Subject: [PATCH 14/14] Dismiss bottom sheet when url is loaded --- .../creation/success/BlazeCampaignSuccessBottomSheetFragment.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt index 15acaa8a585..0d7cfd37c10 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/success/BlazeCampaignSuccessBottomSheetFragment.kt @@ -41,5 +41,6 @@ class BlazeCampaignSuccessBottomSheetFragment : WCBottomSheetDialogFragment() { properties = mapOf("satisfied" to isPositive) ) ChromeCustomTabUtils.launchUrl(requireContext(), BLAZE_CAMPAIGN_CREATION_SURVEY_URL_I1) + dismiss() } }