Skip to content

Commit 3e41172

Browse files
authored
Merge branch 'trunk' into woomob-1573-woo-poslocal-catalog-getfrommemoryincache-uses-store
2 parents afb600e + 3692a44 commit 3e41172

File tree

9 files changed

+57
-31
lines changed

9 files changed

+57
-31
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too.
44
23.7
55
-----
6+
- [Internal][Woo POS] Survey for potential and current users of the POS delivered via local push notification. [https://github.com/woocommerce/woocommerce-android/pull/14751]
67
- [Internal] Handle BLUETOOTH_PEER_REMOVED_PAIRING_INFORMATION disconnect reason from Stripe SDK [https://github.com/woocommerce/woocommerce-android/pull/14886]
78

89
23.6

WooCommerce/src/main/kotlin/com/woocommerce/android/notifications/local/LocalNotificationType.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package com.woocommerce.android.notifications.local
33
enum class LocalNotificationType(val value: String) {
44
BLAZE_NO_CAMPAIGN_REMINDER("blaze_no_campaign_reminder"),
55
BLAZE_ABANDONED_CAMPAIGN_REMINDER("blaze_abandoned_campaign_reminder"),
6-
WOO_POS_SURVEY_POTENTIAL_USER_REMINDER("woo_pos_survey_potential_user_reminder"),
7-
WOO_POS_SURVEY_CURRENT_USER_REMINDER("woo_pos_survey_current_user_reminder");
6+
WOO_POS_SURVEY_POTENTIAL_USER_REMINDER("woo_pos_survey_potential_user_survey"),
7+
WOO_POS_SURVEY_CURRENT_USER_REMINDER("woo_pos_survey_current_user_survey");
88
override fun toString() = value
99

1010
companion object {

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/bookings/filter/BookingFilterListScreen.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import com.woocommerce.android.ui.bookings.filter.type.BookingTypeFilterRoute
3333
import com.woocommerce.android.ui.compose.Render
3434
import com.woocommerce.android.ui.compose.component.Toolbar
3535
import com.woocommerce.android.ui.compose.component.WCColoredButton
36+
import com.woocommerce.android.ui.compose.component.getText
3637
import com.woocommerce.android.ui.compose.preview.LightDarkThemePreviews
3738
import com.woocommerce.android.ui.compose.theme.WooThemeWithBackground
3839
import org.wordpress.android.fluxc.network.rest.wpcom.wc.bookings.BookingsFilterOption
@@ -43,7 +44,7 @@ fun BookingFilterListScreen(state: BookingFilterListUiState) {
4344
topBar = {
4445
Column {
4546
Toolbar(
46-
title = stringResource(state.currentPage.titleRes),
47+
title = state.title.getText(),
4748
onNavigationButtonClick = state.onClose,
4849
navigationIcon = ImageVector.vectorResource(id = state.navigationIcon)
4950
)

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/bookings/filter/BookingFilterListUiState.kt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ data class BookingFilterListUiState(
4545
initialBookingFilters?.bookingType
4646
) ?: BookingsFilterOption.BookingType(BookingsFilterOption.BookingType.Type.ANY)
4747

48+
val updatedBookingFilters: BookingFilters
49+
get() {
50+
val initial = initialBookingFilters ?: BookingFilters()
51+
return BookingFilters(
52+
dateRange = newBookingFilters.getOrDefault(initial.dateRange),
53+
customer = newBookingFilters.getOrDefault(initial.customer),
54+
teamMember = newBookingFilters.getOrDefault(initial.teamMember),
55+
attendanceStatus = newBookingFilters.getOrDefault(initial.attendanceStatus),
56+
paymentStatus = newBookingFilters.getOrDefault(initial.paymentStatus),
57+
bookingType = newBookingFilters.getOrDefault(initial.bookingType),
58+
location = newBookingFilters.getOrDefault(initial.location),
59+
serviceEvent = newBookingFilters.getOrDefault(initial.serviceEvent),
60+
)
61+
}
62+
63+
val updatedBookingFiltersCount = updatedBookingFilters.enabledFiltersCount
64+
4865
@DrawableRes
4966
val navigationIcon: Int = when (currentPage) {
5067
BookingFilterPage.List -> R.drawable.ic_gridicons_cross_24dp
@@ -73,6 +90,18 @@ data class BookingFilterListUiState(
7390
BookingFilterPage.TeamMember,
7491
BookingFilterPage.List -> null
7592
}
93+
94+
val title: UiString
95+
get() = if (currentPage != BookingFilterPage.List) {
96+
UiString.UiStringRes(currentPage.titleRes)
97+
} else if (updatedBookingFiltersCount > 0) {
98+
UiString.UiStringRes(
99+
stringRes = R.string.bookings_filters_title_with_count,
100+
params = listOf(UiString.UiStringText(updatedBookingFiltersCount.toString()))
101+
)
102+
} else {
103+
UiString.UiStringRes(R.string.bookings_filters_default_title)
104+
}
76105
}
77106

78107
val BookingFilterPage.titleRes: Int

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/bookings/filter/BookingFilterListViewModel.kt

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,3 @@ class BookingFilterListViewModel @Inject constructor(
114114
return updated != initial
115115
}
116116
}
117-
118-
private val BookingFilterListUiState.updatedBookingFilters: BookingFilters
119-
get() {
120-
val initial = initialBookingFilters ?: BookingFilters()
121-
val updates = this@updatedBookingFilters.newBookingFilters
122-
123-
return BookingFilters(
124-
dateRange = updates.getOrDefault(initial.dateRange),
125-
customer = updates.getOrDefault(initial.customer),
126-
teamMember = updates.getOrDefault(
127-
initial.teamMember
128-
),
129-
attendanceStatus = updates.getOrDefault(initial.attendanceStatus),
130-
paymentStatus = updates.getOrDefault(initial.paymentStatus),
131-
bookingType = updates.getOrDefault(initial.bookingType),
132-
location = updates.getOrDefault(initial.location),
133-
serviceEvent = updates.getOrDefault(initial.serviceEvent),
134-
)
135-
}

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/feedback/FeedbackSurveyFragment.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.webkit.WebResourceRequest
77
import android.webkit.WebSettings
88
import android.webkit.WebView
99
import android.webkit.WebViewClient
10+
import androidx.activity.OnBackPressedCallback
1011
import androidx.appcompat.app.AppCompatActivity
1112
import androidx.navigation.fragment.findNavController
1213
import androidx.navigation.fragment.navArgs
@@ -56,6 +57,7 @@ class FeedbackSurveyFragment : BaseFragment(R.layout.fragment_feedback_survey) {
5657
private var progressDialog: CustomProgressDialog? = null
5758
private var surveyCompleted: Boolean = false
5859
private val surveyWebViewClient = SurveyWebViewClient()
60+
private var backPressedCallback: OnBackPressedCallback? = null
5961
private val arguments: FeedbackSurveyFragmentArgs by navArgs()
6062
private val feedbackContext by lazy {
6163
when (arguments.surveyType) {
@@ -77,6 +79,7 @@ class FeedbackSurveyFragment : BaseFragment(R.layout.fragment_feedback_survey) {
7779
_binding = FragmentFeedbackSurveyBinding.bind(view)
7880

7981
setupToolbar(binding.toolbar)
82+
setupBackPressHandling()
8083

8184
configureWebView()
8285
savedInstanceState?.let {
@@ -95,6 +98,21 @@ class FeedbackSurveyFragment : BaseFragment(R.layout.fragment_feedback_survey) {
9598
activity?.invalidateOptionsMenu()
9699
}
97100

101+
private fun setupBackPressHandling() {
102+
backPressedCallback = object : OnBackPressedCallback(true) {
103+
override fun handleOnBackPressed() {
104+
if (binding.webView.canGoBack()) {
105+
binding.webView.goBack()
106+
} else {
107+
isEnabled = false
108+
requireActivity().onBackPressedDispatcher.onBackPressed()
109+
}
110+
}
111+
}.also {
112+
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, it)
113+
}
114+
}
115+
98116
private fun getSurveyUrlFromArguments(): String = arguments.customUrl ?: arguments.surveyType.url
99117

100118
private fun addCrowdSignalTagsTo(url: String): String {
@@ -112,6 +130,8 @@ class FeedbackSurveyFragment : BaseFragment(R.layout.fragment_feedback_survey) {
112130

113131
override fun onDestroyView() {
114132
super.onDestroyView()
133+
backPressedCallback?.remove()
134+
backPressedCallback = null
115135
_binding = null
116136
}
117137

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/common/util/WooPosSurveysNotificationScheduler.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import com.woocommerce.android.notifications.local.LocalNotification
55
import com.woocommerce.android.notifications.local.LocalNotificationScheduler
66
import com.woocommerce.android.tools.SelectedSite
77
import com.woocommerce.android.ui.woopos.util.datastore.WooPosPreferencesRepository
8-
import com.woocommerce.android.util.FeatureFlag
98
import kotlinx.coroutines.flow.first
109
import org.wordpress.android.fluxc.store.WooCommerceStore
1110
import java.util.concurrent.TimeUnit
@@ -26,7 +25,7 @@ class WooPosSurveysNotificationScheduler @Inject constructor(
2625
suspend fun schedulePotentialUserSurveyNotification() {
2726
if (!appPrefs.isWooPosSurveyNotificationPotentialUserShown &&
2827
!wooPosPreferencesRepository.wasOpenedOnce.first() &&
29-
areNotificationsAllowed()
28+
isAllowedCountry()
3029
) {
3130
localNotificationScheduler.scheduleNotification(
3231
LocalNotification.WooPosSurveyPotentialUserNotification(
@@ -39,7 +38,7 @@ class WooPosSurveysNotificationScheduler @Inject constructor(
3938
suspend fun scheduleCurrentUserSurveyNotification() {
4039
if (!appPrefs.isWooPosSurveyNotificationCurrentUserShown &&
4140
wooPosPreferencesRepository.wasOpenedOnce.first() &&
42-
areNotificationsAllowed()
41+
isAllowedCountry()
4342
) {
4443
localNotificationScheduler.scheduleNotification(
4544
LocalNotification.WooPosSurveyCurrentUserNotification(
@@ -50,9 +49,6 @@ class WooPosSurveysNotificationScheduler @Inject constructor(
5049
}
5150
}
5251

53-
private suspend fun areNotificationsAllowed(): Boolean =
54-
isAllowedCountry() && FeatureFlag.WOO_POS_SURVEYS.isEnabled()
55-
5652
private suspend fun isAllowedCountry(): Boolean {
5753
val countryCode = wooCommerceStore.getSiteSettingsAsync(selectedSite.get())?.countryCode
5854
return countryCode?.lowercase() in ALLOWED_COUNTRIES

WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ enum class FeatureFlag {
1010
WC_SHIPPING_BANNER,
1111
BETTER_CUSTOMER_SEARCH_M2,
1212
ORDER_CREATION_AUTO_TAX_RATE,
13-
WOO_POS_SURVEYS,
1413
WOO_POS_LOCAL_CATALOG_M1,
1514
BOOKINGS_MVP;
1615

@@ -21,7 +20,6 @@ enum class FeatureFlag {
2120
}
2221

2322
WC_SHIPPING_BANNER,
24-
WOO_POS_SURVEYS,
2523
BETTER_CUSTOMER_SEARCH_M2,
2624
ORDER_CREATION_AUTO_TAX_RATE,
2725
WOO_POS_LOCAL_CATALOG_M1,

WooCommerce/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4236,7 +4236,7 @@
42364236
<string name="bookings_empty_state_clear_filters_button">Clear filters</string>
42374237
<string name="bookings_filters_default_title">Filters</string>
42384238
<string name="bookings_filters_enabled_title">Filters • %d</string>
4239-
<string name="bookings_filters_count_title">Filters (%d)</string>
4239+
<string name="bookings_filters_title_with_count">Filters (%s)</string>
42404240
<string name="bookings_filters_show_bookings">Show bookings</string>
42414241
<string name="bookings_filter_title_team_member">Assigned team member</string>
42424242
<string name="bookings_filter_title_attendance_status">Attendance status</string>

0 commit comments

Comments
 (0)