Skip to content

Commit

Permalink
Merge branch 'trunk' into update-screenshot-mockup
Browse files Browse the repository at this point in the history
  • Loading branch information
irfano authored Jan 6, 2025
2 parents 2ebed2a + 4708660 commit 4e7fb1e
Show file tree
Hide file tree
Showing 37 changed files with 73 additions and 310 deletions.
4 changes: 3 additions & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
-----
- [*] Fix Dashboard card menu sizing to fit bigger font sizes and longer text. [https://github.com/woocommerce/woocommerce-android/pull/13184]
- [*] Fixed overlap issue in Settings > WooCommerce Version [https://github.com/woocommerce/woocommerce-android/pull/13183]
- [*] Fixed a crash on the order details [https://github.com/woocommerce/woocommerce-android/pull/13191]
- [*] Removed Tap To Pay usage survey [https://github.com/woocommerce/woocommerce-android/pull/13207]
- [**] Fixed a crash when a shop manager was trying to install or activate plugin in the POS onboarding [https://github.com/woocommerce/woocommerce-android/pull/13203]
- [*] Fixed a crash on the order details [https://github.com/woocommerce/woocommerce-android/pull/13191]
- [**] Introduced fallback logic for the barcode scanner to use the front-facing camera when a back-facing camera is unavailable [https://github.com/woocommerce/woocommerce-android/pull/13230]

21.3
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,18 +492,6 @@ class AppPrefsTest {
).isFalse
}

@Test
fun givenTTPWasUsedAtLeastOnceNeverInvokedThenIsTTPWasUsedAtLeastOnceReturnsFalse() {
assertThat(AppPrefs.isTTPWasUsedAtLeastOnce()).isFalse
}

@Test
fun givenTTPWasUsedAtLeastOnceInvokedThenIsTTPWasUsedAtLeastOnceReturnsTrue() {
AppPrefs.setTTPWasUsedAtLeastOnce()

assertThat(AppPrefs.isTTPWasUsedAtLeastOnce()).isTrue
}

@Test
fun givenIppWasNotUsedWhenGetCardReaderLastSuccessfulPaymentThenTimeReturnedZero() {
assertThat(AppPrefs.getCardReaderLastSuccessfulPaymentTime()).isEqualTo(0L)
Expand Down
10 changes: 0 additions & 10 deletions WooCommerce/src/main/kotlin/com/woocommerce/android/AppPrefs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ object AppPrefs {
// Was the IPP feedback survey banner dismissed forever
IPP_FEEDBACK_SURVEY_BANNER_DISMISSED_FOREVER,

// Was the Tap To Pay used at least once
TTP_WAS_USED_AT_LEAST_ONCE,

// Whether onboarding tasks have been completed or not for a given site
STORE_ONBOARDING_TASKS_COMPLETED,

Expand Down Expand Up @@ -941,13 +938,6 @@ object AppPrefs {
setBoolean(UndeletablePrefKey.IPP_FEEDBACK_SURVEY_BANNER_DISMISSED_FOREVER, dismissedForever)
}

fun isTTPWasUsedAtLeastOnce() =
getBoolean(UndeletablePrefKey.TTP_WAS_USED_AT_LEAST_ONCE, false)

fun setTTPWasUsedAtLeastOnce() {
setBoolean(UndeletablePrefKey.TTP_WAS_USED_AT_LEAST_ONCE, true)
}

fun updateOnboardingCompletedStatus(siteId: Int, completed: Boolean) {
setBoolean(
key = getStoreOnboardingKeyFor(siteId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ object AppUrls {
const val CROWDSIGNAL_STORE_SETUP_SURVEY =
"https://automattic.survey.fm/woo-mobile-%E2%80%93-store-setup-survey-2022"

const val CROWDSIGNAL_TAP_TO_PAY_SURVEY = "https://automattic.survey.fm/woo-app-%E2%80%93-first-ttp-survey"
val CROWDSIGNAL_PRODCUT_CREATION_WITH_AI_SURVEY =
if (BuildConfig.DEBUG) {
"https://automattic.survey.fm/testing-debug-product-creation-with-ai-dec-2023"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,6 @@ enum class AnalyticsEvent(override val siteless: Boolean = false) : IAnalyticsEv
PAYMENTS_HUB_CASH_ON_DELIVERY_TOGGLED_LEARN_MORE_TAPPED,
IN_PERSON_PAYMENTS_LEARN_MORE_TAPPED,
PAYMENTS_HUB_TAP_TO_PAY_TAPPED,
PAYMENTS_HUB_TAP_TO_PAY_FEEDBACK_TAPPED,
PAYMENTS_HUB_TAP_TO_PAY_ABOUT_TAPPED,

// -- Payments Hub - Payout Summary (Previously called Deposit summary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ class AnalyticsTracker private constructor(

const val VALUE_SIMPLE_PAYMENTS_FLOW = "simple_payment"
const val VALUE_SIMPLE_PAYMENTS_FEEDBACK = "simple_payments"
const val VALUE_TAP_TO_PAY_FEEDBACK = "tap_to_pay"
const val VALUE_SIMPLE_PAYMENTS_COLLECT_CARD = "card"
const val VALUE_SIMPLE_PAYMENTS_COLLECT_CASH = "cash"
const val VALUE_SIMPLE_PAYMENTS_COLLECT_LINK = "payment_link"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ data class FeatureFeedbackSettings(
PRODUCT_ADDONS,
SIMPLE_PAYMENTS_AND_ORDER_CREATION,
ANALYTICS_HUB,
TAP_TO_PAY,
ORDER_SHIPPING_LINES
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ fun BarcodeScanner(
}
}
val selector = remember {
CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build()
val cameraProvider = cameraProviderFuture.get()
val hasBackCamera = cameraProvider.hasCamera(CameraSelector.DEFAULT_BACK_CAMERA)
val hasFrontCamera = cameraProvider.hasCamera(CameraSelector.DEFAULT_FRONT_CAMERA)

when {
hasBackCamera -> CameraSelector.DEFAULT_BACK_CAMERA
hasFrontCamera -> CameraSelector.DEFAULT_FRONT_CAMERA
else -> error(IllegalStateException("No available camera"))
}
}

DisposableEffect(lifecycleOwner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_ORDER_
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_PRODUCT_ADDONS_FEEDBACK
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_SHIPPING_LABELS_M4_FEEDBACK
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_SIMPLE_PAYMENTS_FEEDBACK
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_TAP_TO_PAY_FEEDBACK
import com.woocommerce.android.databinding.FragmentFeedbackSurveyBinding
import com.woocommerce.android.extensions.navigateSafely
import com.woocommerce.android.ui.base.BaseFragment
Expand Down Expand Up @@ -56,7 +55,6 @@ class FeedbackSurveyFragment : BaseFragment(R.layout.fragment_feedback_survey) {
SurveyType.SHIPPING_LABELS -> VALUE_SHIPPING_LABELS_M4_FEEDBACK
SurveyType.ADDONS -> VALUE_PRODUCT_ADDONS_FEEDBACK
SurveyType.ANALYTICS_HUB -> VALUE_ANALYTICS_HUB_FEEDBACK
SurveyType.PAYMENTS_HUB_TAP_TO_PAY -> VALUE_TAP_TO_PAY_FEEDBACK
SurveyType.ORDER_SHIPPING_LINES -> VALUE_ORDER_SHIPPING_LINES_FEEDBACK
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ enum class SurveyType(private val untaggedUrl: String, private val milestone: In
ADDONS(AppUrls.ADDONS_SURVEY),
STORE_ONBOARDING(AppUrls.CROWDSIGNAL_STORE_SETUP_SURVEY),
ANALYTICS_HUB(AppUrls.CROWDSIGNAL_ANALYTICS_HUB_SURVEY),
PAYMENTS_HUB_TAP_TO_PAY(AppUrls.CROWDSIGNAL_TAP_TO_PAY_SURVEY),
ORDER_SHIPPING_LINES(AppUrls.CROWDSIGNAL_ORDER_SHIPPING_LINES_SURVEY);

val url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ class OrderListFragment :

private var tracker: SelectionTracker<Long>? = null
private var actionMode: ActionMode? = null
private val selectionPredicate = MutableMultipleSelectionPredicate<Long>()
private val selectionPredicate = MutableMultipleSelectionPredicate<Long>(
maxSelectionCount = OrderListViewModel.BULK_UPDATE_COUNT_LIMIT
)
private val viewModel: OrderListViewModel by viewModels()
private val communicationViewModel: OrdersCommunicationViewModel by activityViewModels()
private var snackBar: Snackbar? = null
Expand Down Expand Up @@ -275,6 +277,8 @@ class OrderListFragment :
object : SelectionTracker.SelectionObserver<Long>() {
override fun onSelectionChanged() {
val selectionCount = tracker?.selection?.size() ?: 0
selectionPredicate.currentSelectionCount = selectionCount

viewModel.onSelectionChanged(selectionCount)
}
}
Expand Down Expand Up @@ -640,6 +644,7 @@ class OrderListFragment :
showBulkUpdateStatusDialog(event.currentStatus, event.orderStatusList)
}

is OrderListViewModel.OrderListEvent.ShowSnackbarString -> uiMessageResolver.showSnack(event.message)
is MultiLiveEvent.Event.ShowSnackbar -> uiMessageResolver.showSnack(event.message)

else -> event.isHandled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class OrderListViewModel @Inject constructor(
) : ScopedViewModel(savedState), LifecycleOwner {
private val navArgs: OrderListFragmentArgs by savedState.navArgs()

companion object {
const val BULK_UPDATE_COUNT_LIMIT = 100
}

private val lifecycleRegistry: LifecycleRegistry by lazy {
LifecycleRegistry(this)
}
Expand Down Expand Up @@ -915,11 +919,23 @@ class OrderListViewModel @Inject constructor(
fun onSelectionChanged(count: Int) {
when {
count == 0 -> exitSelectionMode()
count >= BULK_UPDATE_COUNT_LIMIT -> {
viewState = viewState.copy(selectionCount = count)
showMaximumBulkSelectionNotice()
}
count > 0 && !isSelecting() -> enterSelectionMode(count)
count > 0 -> viewState = viewState.copy(selectionCount = count)
}
}

private fun showMaximumBulkSelectionNotice() {
val message = resourceProvider.getString(
R.string.orderlist_bulk_update_maximum_reached,
BULK_UPDATE_COUNT_LIMIT
)
triggerEvent(OrderListEvent.ShowSnackbarString(message))
}

private fun enterSelectionMode(count: Int) {
analyticsTracker.track(AnalyticsEvent.ORDERS_LIST_BULK_UPDATE_SELECTION_ENABLED)
viewState = viewState.copy(
Expand Down Expand Up @@ -1021,6 +1037,7 @@ class OrderListViewModel @Inject constructor(

sealed class OrderListEvent : Event() {
data class ShowErrorSnack(@StringRes val messageRes: Int) : OrderListEvent()
data class ShowSnackbarString(val message: String) : OrderListEvent()
object ShowOrderFilters : OrderListEvent()
data class OpenPurchaseCardReaderLink(
val url: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.transition.Slide
import androidx.transition.TransitionManager
import com.google.android.material.textview.MaterialTextView
import com.woocommerce.android.NavGraphMainDirections
import com.woocommerce.android.NavGraphPaymentFlowDirections
import com.woocommerce.android.R
import com.woocommerce.android.analytics.AnalyticsTracker
import com.woocommerce.android.databinding.FragmentPaymentsHubBinding
import com.woocommerce.android.extensions.navigateSafely
import com.woocommerce.android.ui.base.BaseFragment
import com.woocommerce.android.ui.base.UIMessageResolver
import com.woocommerce.android.ui.feedback.SurveyType
import com.woocommerce.android.ui.main.AppBarStatus
import com.woocommerce.android.ui.orders.list.OrderListViewModel
import com.woocommerce.android.ui.payments.cardreader.onboarding.CardReaderFlowParam
import com.woocommerce.android.ui.payments.cardreader.onboarding.CardReaderOnboardingParams
import com.woocommerce.android.ui.payments.hub.PaymentsHubViewModel.PaymentsHubEvents.NavigateToTapToPaySummaryScreen
import com.woocommerce.android.ui.payments.hub.PaymentsHubViewModel.PaymentsHubEvents.NavigateToTapToPaySurveyScreen
import com.woocommerce.android.ui.payments.taptopay.summary.TapToPaySummaryFragment
import com.woocommerce.android.util.ChromeCustomTabUtils
import com.woocommerce.android.util.UiHelpers
Expand Down Expand Up @@ -143,12 +140,6 @@ class PaymentsHubFragment : BaseFragment(R.layout.fragment_payments_hub) {
)
)
}
is NavigateToTapToPaySurveyScreen -> {
NavGraphMainDirections.actionGlobalFeedbackSurveyFragment(SurveyType.PAYMENTS_HUB_TAP_TO_PAY)
.apply {
findNavController().navigateSafely(this)
}
}
is MultiLiveEvent.Event.ShowDialog -> {
event.showDialog()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.map
import com.woocommerce.android.AppPrefs
import com.woocommerce.android.AppPrefsWrapper
import com.woocommerce.android.AppUrls
import com.woocommerce.android.AppUrls.STRIPE_TAP_TO_PAY_DEVICE_REQUIREMENTS
Expand All @@ -17,10 +16,8 @@ import com.woocommerce.android.cardreader.CardReaderManager
import com.woocommerce.android.cardreader.config.CardReaderConfigForSupportedCountry
import com.woocommerce.android.cardreader.connection.CardReaderStatus
import com.woocommerce.android.cardreader.connection.event.SoftwareUpdateAvailability
import com.woocommerce.android.model.FeatureFeedbackSettings
import com.woocommerce.android.model.UiString.UiStringRes
import com.woocommerce.android.tools.SelectedSite
import com.woocommerce.android.ui.feedback.FeedbackRepository
import com.woocommerce.android.ui.payments.cardreader.CardReaderCountryConfigProvider
import com.woocommerce.android.ui.payments.cardreader.CashOnDeliverySettingsRepository
import com.woocommerce.android.ui.payments.cardreader.ClearCardReaderDataAction
Expand Down Expand Up @@ -74,8 +71,6 @@ class PaymentsHubViewModel @Inject constructor(
private val paymentsFlowTracker: PaymentsFlowTracker,
@Named("payment-menu") private val paymentMenuUtmProvider: UtmProvider,
private val tapToPayAvailabilityStatus: TapToPayAvailabilityStatus,
private val appPrefs: AppPrefs,
private val feedbackRepository: FeedbackRepository,
private val tapToPayUnavailableHandler: PaymentsHubTapToPayUnavailableHandler,
private val cardReaderDataAction: ClearCardReaderDataAction,
private val cardReaderManager: CardReaderManager,
Expand Down Expand Up @@ -203,19 +198,19 @@ class PaymentsHubViewModel @Inject constructor(
cashOnDeliveryItem,
HeaderItem(
label = UiStringRes(R.string.card_reader_card_readers_header),
index = 10,
index = 9,
),
NonToggleableListItem(
icon = R.drawable.ic_shopping_cart,
label = UiStringRes(R.string.card_reader_purchase_card_reader),
index = 11,
index = 10,
onClick = ::onPurchaseCardReaderClicked
),
NonToggleableListItem(
icon = R.drawable.ic_manage_card_reader,
label = UiStringRes(R.string.card_reader_manage_card_reader),
isEnabled = isOnboardingComplete,
index = 12,
index = 11,
onClick = ::onManageCardReaderClicked
)
).apply {
Expand Down Expand Up @@ -250,16 +245,6 @@ class PaymentsHubViewModel @Inject constructor(
onClick = { onAboutTTPClicked(countryConfig as CardReaderConfigForSupportedCountry) },
)
)
if (shouldShowTTPFeedbackRequest) {
add(
NonToggleableListItem(
icon = R.drawable.ic_feedback_banner_logo,
label = UiStringRes(R.string.card_reader_tap_to_pay_share_feedback),
index = 9,
onClick = ::onTapToPayFeedbackClicked
)
)
}
}
}

Expand All @@ -269,7 +254,7 @@ class PaymentsHubViewModel @Inject constructor(
NonToggleableListItem(
icon = R.drawable.ic_card_reader_manual,
label = UiStringRes(R.string.settings_card_reader_manuals),
index = 13,
index = 12,
onClick = { onCardReaderManualsClicked(countryConfig) }
)
)
Expand All @@ -281,7 +266,7 @@ class PaymentsHubViewModel @Inject constructor(
LearnMoreListItem(
icon = R.drawable.ic_info_outline_20dp,
label = UiStringRes(R.string.card_reader_detail_learn_more, containsHtml = true),
index = 14,
index = 13,
onClick = ::onLearnMoreIppClicked
)
)
Expand Down Expand Up @@ -389,15 +374,6 @@ class PaymentsHubViewModel @Inject constructor(
triggerEvent(PaymentsHubEvents.NavigateToTapToPaySummaryScreen)
}

private fun onTapToPayFeedbackClicked() {
trackEvent(AnalyticsEvent.PAYMENTS_HUB_TAP_TO_PAY_FEEDBACK_TAPPED)
feedbackRepository.saveFeatureFeedback(
FeatureFeedbackSettings.Feature.TAP_TO_PAY,
FeatureFeedbackSettings.FeedbackState.GIVEN
)
triggerEvent(PaymentsHubEvents.NavigateToTapToPaySurveyScreen)
}

private fun onAboutTTPClicked(countryConfig: CardReaderConfigForSupportedCountry) {
trackEvent(AnalyticsEvent.PAYMENTS_HUB_TAP_TO_PAY_ABOUT_TAPPED)
triggerEvent(PaymentsHubEvents.NavigateToAboutTapToPay(countryConfig))
Expand Down Expand Up @@ -548,17 +524,6 @@ class PaymentsHubViewModel @Inject constructor(
selfHostedSiteId = selectedSite.get().selfHostedSiteId,
)

private val shouldShowTTPFeedbackRequest: Boolean
get() {
val featureFeedbackSetting = feedbackRepository.getFeatureFeedbackSetting(
FeatureFeedbackSettings.Feature.TAP_TO_PAY
)
return appPrefs.isTTPWasUsedAtLeastOnce() && (
featureFeedbackSetting.feedbackState == FeatureFeedbackSettings.FeedbackState.UNANSWERED ||
!featureFeedbackSetting.isFeedbackGivenMoreThanDaysAgo(SHOW_FEEDBACK_AFTER_USAGE_DAYS)
)
}

sealed class PaymentsHubEvents : MultiLiveEvent.Event() {
data class NavigateToCardReaderDetail(val cardReaderFlowParam: CardReaderFlowParam) : PaymentsHubEvents()
data class NavigateToPurchaseCardReaderFlow(
Expand All @@ -568,7 +533,6 @@ class PaymentsHubViewModel @Inject constructor(

data object NavigateToOrderCreationScreen : PaymentsHubEvents()
data object NavigateToTapToPaySummaryScreen : PaymentsHubEvents()
data object NavigateToTapToPaySurveyScreen : PaymentsHubEvents()
data class NavigateToCardReaderManualsScreen(
val countryConfig: CardReaderConfigForSupportedCountry
) : PaymentsHubEvents()
Expand Down Expand Up @@ -601,7 +565,5 @@ class PaymentsHubViewModel @Inject constructor(
const val UTM_CAMPAIGN = "payments_menu_item"
const val UTM_SOURCE = "payments_menu"
private const val SOURCE = "payments_menu"

private const val SHOW_FEEDBACK_AFTER_USAGE_DAYS = 30
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.woocommerce.android.ui.payments.methodselection
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.SavedStateHandle
import com.woocommerce.android.AppPrefs
import com.woocommerce.android.R
import com.woocommerce.android.analytics.AnalyticsTracker
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_CARD_READER_TYPE_BUILT_IN
Expand Down Expand Up @@ -77,7 +76,6 @@ class SelectPaymentMethodViewModel @Inject constructor(
private val paymentsFlowTracker: PaymentsFlowTracker,
private val tapToPayAvailabilityStatus: TapToPayAvailabilityStatus,
private val cardReaderTrackingInfoKeeper: CardReaderTrackingInfoKeeper,
private val appPrefs: AppPrefs = AppPrefs,
private val paymentsUtils: PaymentUtils,
private val logOrderCurrencyMismatchWithSiteSettings: SelectPaymentMethodCurrencyMissMatchLog,
) : ScopedViewModel(savedState) {
Expand Down Expand Up @@ -309,7 +307,6 @@ class SelectPaymentMethodViewModel @Inject constructor(
fun onTapToPayClicked() {
launch {
trackPaymentMethodSelection(VALUE_SIMPLE_PAYMENTS_COLLECT_CARD, VALUE_CARD_READER_TYPE_BUILT_IN)
appPrefs.setTTPWasUsedAtLeastOnce()
triggerEvent(NavigateToCardReaderPaymentFlow(cardReaderPaymentFlowParam, BUILT_IN))
}
}
Expand Down
Loading

0 comments on commit 4e7fb1e

Please sign in to comment.