Skip to content

Commit 5524ef1

Browse files
authored
Merge branch 'trunk' into woomob-1020-woo-possettings-add-ff-and-settings-button-to-the-menu
2 parents 5f3996f + a8c5399 commit 5524ef1

File tree

10 files changed

+35
-12
lines changed

10 files changed

+35
-12
lines changed

RELEASE-NOTES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
*** PLEASE FOLLOW THIS FORMAT: [<priority indicator, more stars = higher priority>] <description> [<PR URL>]
22
*** Use [*****] to indicate smoke tests of all critical flows should be run on the final APK before release (e.g. major library or targetSdk updates).
33
*** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too.
4-
54
23.1
65
-----
6+
- [*] You can now remove background from product images in the app. Just open the product image and click "Remove background" button. [https://github.com/woocommerce/woocommerce-android/pull/14445]
77
- [*] Fixed bug when an order was not selected when navigating from my store screen [https://github.com/woocommerce/woocommerce-android/pull/14436]
8-
8+
- [*] Updated behavior on the POS cash payment screen [https://github.com/woocommerce/woocommerce-android/pull/14449]
99

1010
23.0
1111
-----

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/images/ProductImageViewerFragment.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import com.woocommerce.android.ui.main.AppBarStatus
2424
import com.woocommerce.android.ui.main.MainActivity
2525
import com.woocommerce.android.ui.products.ConfirmRemoveProductImageDialog
2626
import com.woocommerce.android.ui.products.ImageViewerFragment
27-
import com.woocommerce.android.util.FeatureFlag
2827
import com.woocommerce.android.util.WooAnimUtils
2928
import com.woocommerce.android.util.setupTabletSecondPaneToolbar
3029
import com.woocommerce.android.viewmodel.fixedHiltNavGraphViewModels
@@ -93,8 +92,6 @@ class ProductImageViewerFragment :
9392
}
9493
toolbar.inflateMenu(R.menu.menu_product_image)
9594
toolbar.menu.findItem(R.id.menu_delete_image).isVisible = navArgs.isDeletingAllowed
96-
toolbar.menu.findItem(R.id.menu_remove_background).isVisible =
97-
FeatureFlag.AI_PRODUCT_IMAGE_BACKGROUND_REMOVAL.isEnabled(context)
9895
}
9996

10097
private fun onMenuItemSelected(item: MenuItem): Boolean =

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/cashpayment/WooPosCashPaymentScreen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ private fun Collecting(
149149
currencyPosition = state.currencyPosition,
150150
decimalSeparator = state.decimalSeparator,
151151
numberOfDecimals = state.numberOfDecimals,
152+
preselectText = true,
152153
)
153154

154155
Spacer(modifier = Modifier.height(WooPosSpacing.Small.value))

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/cashpayment/WooPosCashPaymentViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class WooPosCashPaymentViewModel @Inject constructor(
4444

4545
val order = repository.getOrderById(orderId)!!
4646
_state.value = WooPosCashPaymentState.Collecting(
47-
enteredAmount = null,
47+
enteredAmount = order.total,
4848
changeDueText = "",
4949
changeDue = null,
5050
total = order.total,
@@ -59,7 +59,7 @@ class WooPosCashPaymentViewModel @Inject constructor(
5959
numberOfDecimals = repository.getNumberOfDecimals(),
6060
button = WooPosCashPaymentState.Collecting.Button(
6161
text = resourceProvider.getString(R.string.woopos_complete_cash_order_button),
62-
status = WooPosCashPaymentState.Collecting.Button.Status.DISABLED
62+
status = WooPosCashPaymentState.Collecting.Button.Status.ENABLED
6363
)
6464
)
6565
}

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/common/composeui/component/WooPosInputFields.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fun WooPosMoneyInputField(
5656
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
5757
keyboardActions: KeyboardActions = KeyboardActions.Default,
5858
contentAlignment: Alignment = Alignment.CenterStart,
59+
preselectText: Boolean = false,
5960
) {
6061
val visualTransformation = remember {
6162
CurrencyVisualTransformation(
@@ -84,7 +85,12 @@ fun WooPosMoneyInputField(
8485
stateSaver = TextFieldValue.Saver,
8586
) {
8687
currentValue = value
87-
mutableStateOf(TextFieldValue(valueMapper.printValue(value)))
88+
mutableStateOf(
89+
TextFieldValue(
90+
text = valueMapper.printValue(value),
91+
selection = if (preselectText) TextRange(0, value.toString().length) else TextRange.Zero
92+
)
93+
)
8894
}
8995

9096
var labelWidth by remember { mutableIntStateOf(0) }

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/totals/WooPosTotalsAnalyticsTracker.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,8 @@ class WooPosTotalsAnalyticsTracker @Inject constructor(
9595
suspend fun trackCreateNewOrderTapped() {
9696
analyticsTracker.track(CreateNewOrderTapped)
9797
}
98+
99+
suspend fun trackCashPaymentTapped() {
100+
analyticsTracker.track(WooPosAnalyticsEvent.Event.CheckoutCashPaymentTapped)
101+
}
98102
}

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/totals/WooPosTotalsViewModel.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class WooPosTotalsViewModel @Inject constructor(
158158

159159
WooPosTotalsUIEvent.OnStartReceiptFlowClicked -> handleEmailReceiptClicked()
160160

161-
WooPosTotalsUIEvent.OnCashPaymentClicked -> informParentAboutNavigatingToCashPayment()
161+
WooPosTotalsUIEvent.OnCashPaymentClicked -> handleCashPaymentClicked()
162162

163163
WooPosTotalsUIEvent.GoBackToCheckoutAfterFailedPayment -> handleGoBackToCheckoutClickedWhenPaymentFailed()
164164

@@ -183,7 +183,8 @@ class WooPosTotalsViewModel @Inject constructor(
183183
}
184184
}
185185

186-
private fun informParentAboutNavigatingToCashPayment() = viewModelScope.launch {
186+
private fun handleCashPaymentClicked() = viewModelScope.launch {
187+
totalsAnalyticsTracker.trackCashPaymentTapped()
187188
childrenToParentEventSender.sendToParent(
188189
ToCashPayment(dataState.value.orderId)
189190
)

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/util/analytics/WooPosAnalyticsEvent.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ sealed class WooPosAnalyticsEvent : IAnalyticsEvent {
4747
data object CashCollectPaymentSuccess : Event() {
4848
override val name: String = "cash_collect_payment_success"
4949
}
50+
data object CheckoutCashPaymentTapped : Event() {
51+
override val name: String = "checkout_cash_payment_tapped"
52+
}
5053
data object CashPaymentTapped : Event() {
5154
override val name: String = "cash_payment_tapped"
5255
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ enum class FeatureFlag {
2626
WOO_POS_SETTINGS,
2727
WC_SHIPPING_BANNER,
2828
BETTER_CUSTOMER_SEARCH_M2,
29-
ORDER_CREATION_AUTO_TAX_RATE,
30-
AI_PRODUCT_IMAGE_BACKGROUND_REMOVAL -> PackageUtils.isDebugBuild()
29+
ORDER_CREATION_AUTO_TAX_RATE -> PackageUtils.isDebugBuild()
3130

3231
NEW_SHIPPING_SUPPORT,
3332
BULK_UPDATE_ORDERS_STATUS,

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/cashpayment/WooPosCashPaymentViewModelTest.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ class WooPosCashPaymentViewModelTest {
9494
assertThat(collectingState.numberOfDecimals).isEqualTo(2)
9595
}
9696

97+
@Test
98+
fun `when ViewModel initializes, then entered amount prefilled with total value and button is enabled`() = runTest {
99+
// WHEN
100+
val state = viewModel.state.first()
101+
102+
// THEN
103+
assertThat(state).isInstanceOf(WooPosCashPaymentState.Collecting::class.java)
104+
val collectingState = state as WooPosCashPaymentState.Collecting
105+
assertThat(collectingState.enteredAmount).isEqualTo(BigDecimal("100.00"))
106+
assertThat(collectingState.button.status).isEqualTo(WooPosCashPaymentState.Collecting.Button.Status.ENABLED)
107+
}
108+
97109
@Test
98110
fun `given valid amount,when onUIEvent AmountChanged , then button is enabled and changeDue is updated`() = runTest {
99111
// GIVEN

0 commit comments

Comments
 (0)