Skip to content

Commit

Permalink
Merge branch 'trunk' into task/bulk-order-update-unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hafizrahman authored Jan 7, 2025
2 parents ee03135 + 4708660 commit 2626048
Show file tree
Hide file tree
Showing 56 changed files with 669 additions and 552 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 @@ -215,6 +215,12 @@ enum class AnalyticsEvent(override val siteless: Boolean = false) : IAnalyticsEv
FILTER_ORDERS_BY_STATUS_DIALOG_OPTION_SELECTED,
ORDER_FILTER_LIST_CLEAR_MENU_BUTTON_TAPPED,

ORDERS_LIST_BULK_UPDATE_SELECTION_ENABLED,
ORDERS_LIST_BULK_UPDATE_REQUESTED,
ORDERS_LIST_BULK_UPDATE_CONFIRMED,
ORDERS_LIST_BULK_UPDATE_SUCCESS,
ORDERS_LIST_BULK_UPDATE_FAILURE,

// -- Payments
PAYMENTS_FLOW_ORDER_COLLECT_PAYMENT_TAPPED,
PAYMENTS_FLOW_COMPLETED,
Expand Down Expand Up @@ -533,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 @@ -258,6 +258,8 @@ class AnalyticsTracker private constructor(
const val VALUE_SORT_DATE_ASC = "date,ascending"
const val VALUE_SORT_DATE_DESC = "date,descending"

const val KEY_SELECTED_ORDERS_COUNT = "selected_orders_count"

const val VALUE_API_SUCCESS = "success"
const val VALUE_API_FAILED = "failed"
const val VALUE_SHIPMENT_TRACK = "track"
Expand Down Expand Up @@ -366,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 @@ -30,12 +30,3 @@ class DefaultOrderItemDetailsLookup(
override fun getPosition() = position
override fun getSelectionKey() = orderId
}

class SelectableOrderItemDetailsLookup(
private val position: Int,
private val orderId: Long
) : ItemDetailsLookup.ItemDetails<Long>() {
override fun getPosition() = position
override fun getSelectionKey() = orderId
override fun inSelectionHotspot(e: MotionEvent) = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ class OrderSelectionItemKeyProvider(private val recyclerView: RecyclerView) :
}
}

override fun getPosition(key: Long): Int {
return (recyclerView.adapter as? OrderListAdapter)?.currentList
?.indexOfFirst { item ->
item is OrderListItemUIType.OrderListItemUI && item.orderId == key
} ?: RecyclerView.NO_POSITION
}
override fun getPosition(key: Long): Int =
(recyclerView.adapter as? OrderListAdapter)?.orderIdAndPosition[key] ?: RecyclerView.NO_POSITION
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.woocommerce.android.ui.orders.list.OrderListItemUIType.SectionHeader
import com.woocommerce.android.util.CurrencyFormatter
import com.woocommerce.android.widgets.tags.TagView
import org.wordpress.android.fluxc.model.WCOrderStatusModel

class OrderListAdapter(
val listener: OrderListListener,
val currencyFormatter: CurrencyFormatter
Expand All @@ -38,6 +39,7 @@ class OrderListAdapter(
var activeOrderStatusMap: Map<String, WCOrderStatusModel> = emptyMap()
var allOrderIds: List<Long> = listOf()
var tracker: SelectionTracker<Long>? = null
var orderIdAndPosition = mutableMapOf<Long, Int>()

override fun getItemViewType(position: Int): Int {
return when (getItem(position)) {
Expand All @@ -61,10 +63,12 @@ class OrderListAdapter(
)
)
}

VIEW_TYPE_LOADING -> {
val view = inflater.inflate(R.layout.skeleton_order_list_item_auto, parent, false)
LoadingViewHolder(view)
}

VIEW_TYPE_SECTION_HEADER -> {
SectionHeaderViewHolder(
OrderListHeaderBinding.inflate(
Expand All @@ -74,6 +78,7 @@ class OrderListAdapter(
)
)
}

else -> {
// Fail fast if a new view type is added so we can handle it
throw IllegalStateException("The view type '$viewType' needs to be handled")
Expand All @@ -97,7 +102,9 @@ class OrderListAdapter(
allOrderIds,
isActivated = tracker?.isSelected(item.orderId) ?: false
)
orderIdAndPosition[item.orderId] = position
}

is SectionHeaderViewHolder -> {
if (BuildConfig.DEBUG && item !is SectionHeader) {
error(
Expand All @@ -107,6 +114,7 @@ class OrderListAdapter(
}
holder.onBind((item as SectionHeader))
}

else -> {}
}
}
Expand All @@ -126,7 +134,11 @@ class OrderListAdapter(
fun setOrderStatusOptions(orderStatusOptions: Map<String, WCOrderStatusModel>) {
if (orderStatusOptions.keys != activeOrderStatusMap.keys) {
this.activeOrderStatusMap = orderStatusOptions
notifyDataSetChanged()
for (position in 0 until itemCount) {
if (getItem(position) is OrderListItemUI) {
notifyItemChanged(position)
}
}
}
}

Expand Down Expand Up @@ -184,6 +196,7 @@ class OrderListAdapter(
viewBinding.root.context.getColor(R.color.color_item_selected)
)
}

else -> {
viewBinding.orderItemLayout.setBackgroundColor(Color.TRANSPARENT)
}
Expand All @@ -209,6 +222,7 @@ class OrderListAdapter(
extras[SwipeToComplete.OLD_STATUS] = orderItemUI.status

this.itemView.setOnClickListener {
if (shouldPreventDetailNavigation(orderId)) return@setOnClickListener
listener.openOrderDetail(
orderId = orderItemUI.orderId,
allOrderIds = allOrderIds,
Expand All @@ -218,6 +232,23 @@ class OrderListAdapter(
}
}

// Some edge cases in order selection mode, like tapping the screen with 4 fingers or using TalkBack,
// cause the order's onClick listener to gain focus over the selection tracker.
// This quick fix will prevent the app from entering an unexpected status when the app is in selection mode.
private fun shouldPreventDetailNavigation(orderId: Long): Boolean {
if (tracker?.selection?.size() != 0) {
tracker?.let { selectionTracker ->
if (selectionTracker.isSelected(orderId)) {
selectionTracker.deselect(orderId)
} else {
selectionTracker.select(orderId)
}
}
return true
}
return false
}

/**
* Converts the order status label into an [OrderStatusTag], creates the associated [TagView],
* and add it to the holder. No need to trim the label text since this is done in [OrderStatusTag]
Expand Down
Loading

0 comments on commit 2626048

Please sign in to comment.