Skip to content

Commit

Permalink
Merge branch 'trunk' into issue/revert-data-store-version
Browse files Browse the repository at this point in the history
  • Loading branch information
atorresveiga authored Nov 7, 2024
2 parents 5d935c2 + ac8f17c commit c68f285
Show file tree
Hide file tree
Showing 43 changed files with 1,126 additions and 368 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source 'https://rubygems.org'

gem 'danger-dangermattic', '~> 1.1'
gem 'danger-dangermattic', '~> 1.2'
gem 'fastlane', '~> 2.216'
gem 'nokogiri'
gem 'rubocop', '~> 1.65'
Expand Down
34 changes: 24 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ GEM
ast (2.4.2)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.999.0)
aws-partitions (1.1001.0)
aws-sdk-core (3.211.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
Expand Down Expand Up @@ -72,7 +72,7 @@ GEM
octokit (>= 4.0)
pstore (~> 0.1)
terminal-table (>= 1, < 4)
danger-dangermattic (1.1.2)
danger-dangermattic (1.2.1)
danger (~> 9.4)
danger-plugin-api (~> 1.0)
danger-rubocop (~> 0.13)
Expand Down Expand Up @@ -231,7 +231,7 @@ GEM
concurrent-ruby (~> 1.0)
java-properties (0.3.0)
jmespath (1.6.2)
json (2.7.5)
json (2.7.6)
jwt (2.9.3)
base64
kramdown (2.4.0)
Expand All @@ -242,16 +242,24 @@ GEM
logger (1.6.1)
mini_magick (4.13.2)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.25.1)
multi_json (1.15.0)
multipart-post (2.4.1)
nanaimo (0.4.0)
nap (1.1.0)
naturally (2.2.1)
nkf (0.2.0)
nokogiri (1.16.7)
mini_portile2 (~> 2.8.2)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86-linux)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
octokit (6.1.1)
faraday (>= 1, < 3)
Expand All @@ -261,7 +269,7 @@ GEM
optparse (0.5.0)
os (1.1.4)
parallel (1.26.3)
parser (3.3.5.0)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
plist (3.7.1)
Expand Down Expand Up @@ -295,7 +303,7 @@ GEM
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.33.0)
rubocop-ast (1.34.0)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
Expand Down Expand Up @@ -340,15 +348,21 @@ GEM
xcpretty (~> 0.2, >= 0.0.7)

PLATFORMS
aarch64-linux
arm-linux
arm64-darwin
ruby
x86-linux
x86_64-darwin
x86_64-linux

DEPENDENCIES
danger-dangermattic (~> 1.1)
danger-dangermattic (~> 1.2)
fastlane (~> 2.216)
fastlane-plugin-wpmreleasetoolkit (~> 12.3)
nokogiri
rmagick (~> 4.1)
rubocop (~> 1.65)

BUNDLED WITH
2.4.19
2.5.20
6 changes: 5 additions & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
*** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too.
21.1
-----

- [*] Fixed shipping lines being editable at all states [https://github.com/woocommerce/woocommerce-android/pull/12890]
- [*] Show web views on the payments hub screen in 3/4 of the screen [https://github.com/woocommerce/woocommerce-android/pull/12875]
- [*] Receipts can be shared via a google's sms application now [https://github.com/woocommerce/woocommerce-android/pull/12874]
- [*] Fixed a bug where picking date ranges (for Stats and Analytics) did not use the correct timezone [https://github.com/woocommerce/woocommerce-android/pull/12887]

21.0
-----
- [*] Fixed text formatting in the "Collect Payment has moved" rationale bottom sheet [https://github.com/woocommerce/woocommerce-android/pull/12815]
- [*] Added support for loading Product images using the AVIF format [https://github.com/woocommerce/woocommerce-android/pull/12835]
- [*] Updated Coupons UI in the order creation [https://github.com/woocommerce/woocommerce-android/pull/12855]

20.9
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import com.woocommerce.android.support.help.HelpOrigin
import com.woocommerce.android.ui.analytics.hub.AnalyticsHubFragment
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import java.time.Instant
import java.time.ZoneId
import java.time.ZonedDateTime
import kotlin.math.abs

/**
Expand Down Expand Up @@ -198,19 +201,38 @@ fun Fragment.showDateRangePicker(
toMillis: Long = System.currentTimeMillis(),
onCustomRangeSelected: (Long, Long) -> Unit
) {
val datePicker =
MaterialDatePicker.Builder.dateRangePicker()
.setTitleText(getString(R.string.orderfilters_date_range_picker_title))
.setSelection(androidx.core.util.Pair(fromMillis, toMillis))
.setCalendarConstraints(
CalendarConstraints.Builder()
.setEnd(MaterialDatePicker.todayInUtcMilliseconds())
.setValidator(DateValidatorPointBackward.now())
.build()
fun shiftTime(time: Long, originalZoneId: ZoneId, targetZoneId: ZoneId): Long {
// The timestamps returned by the MaterialDatePicker are in UTC timezone, if we use them directly
// we will get a shift in the selected range.
// To avoid this, we get the local date using UTC timestamps and then convert it to the selected timezone
// See: https://github.com/material-components/material-components-android/issues/882
val originalDateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(time), originalZoneId).toLocalDateTime()
val targetDateTime = ZonedDateTime.of(originalDateTime, targetZoneId)
return targetDateTime.toInstant().toEpochMilli()
}

val deviceZoneId = ZoneId.systemDefault()
val datePicker = MaterialDatePicker.Builder.dateRangePicker()
.setTitleText(getString(R.string.orderfilters_date_range_picker_title))
.setSelection(
androidx.core.util.Pair(
shiftTime(fromMillis, deviceZoneId, ZoneId.of("UTC")),
shiftTime(toMillis, deviceZoneId, ZoneId.of("UTC"))
)
.build()
)
.setCalendarConstraints(
CalendarConstraints.Builder()
.setEnd(MaterialDatePicker.todayInUtcMilliseconds())
.setValidator(DateValidatorPointBackward.now())
.build()
)
.build()

datePicker.show(parentFragmentManager, AnalyticsHubFragment.DATE_PICKER_FRAGMENT_TAG)
datePicker.addOnPositiveButtonClickListener {
onCustomRangeSelected(it?.first ?: 0L, it.second ?: 0L)
val start = shiftTime(it.first ?: 0, ZoneId.of("UTC"), deviceZoneId)
val end = shiftTime(it.second ?: 0, ZoneId.of("UTC"), deviceZoneId)

onCustomRangeSelected(start, end)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import com.woocommerce.android.ui.orders.creation.OrderCreateEditViewModel.Mode.
import com.woocommerce.android.ui.orders.creation.OrderCreateEditViewModel.Mode.Edit
import com.woocommerce.android.ui.orders.creation.configuration.EditProductConfigurationResult
import com.woocommerce.android.ui.orders.creation.configuration.ProductConfigurationFragment
import com.woocommerce.android.ui.orders.creation.coupon.CouponLineFormSection
import com.woocommerce.android.ui.orders.creation.coupon.edit.OrderCreateCouponDetailsViewModel
import com.woocommerce.android.ui.orders.creation.coupon.edit.OrderCreateCouponEditFragment.Companion.KEY_COUPON_EDIT_RESULT
import com.woocommerce.android.ui.orders.creation.customerlist.OrderCustomerListFragment
Expand Down Expand Up @@ -167,7 +168,7 @@ class OrderCreateEditFormFragment :
handleCouponEditResult()
handleProductDetailsEditResult()
handleResult<String>(KEY_COUPON_SELECTOR_RESULT) {
viewModel.onCouponAdded(it)
viewModel.addCoupon(it)
}
handleTaxRateSelectionResult()
viewModel.onDeviceConfigurationChanged(requireContext().windowSizeClass)
Expand Down Expand Up @@ -224,6 +225,7 @@ class OrderCreateEditFormFragment :
initAdditionalInfoCollectionSection()
initTaxRateSelectorSection()
initTotalsSection()
initShippingLinesSection()
adjustUIForScreenSize()
}

Expand Down Expand Up @@ -377,7 +379,7 @@ class OrderCreateEditFormFragment :

private fun FragmentOrderCreateEditFormBinding.initAdditionalInfoCollectionSection() {
additionalInfoCollectionSection.addShippingButton.setOnClickListener {
viewModel.onAddOrEditShipping()
viewModel.onAddOrEditShippingClicked()
}
}

Expand Down Expand Up @@ -408,26 +410,47 @@ class OrderCreateEditFormFragment :
bindCustomAmountsSection(binding.customAmountsSection, it)
}

bindShippingLinesSection(binding)
bindCouponsLinesSection(binding)

bindFeedbackSection(binding)

observeViewStateChanges(binding)

viewModel.event.observe(viewLifecycleOwner) { handleViewModelEvents(it, binding) }
}
private fun bindShippingLinesSection(binding: FragmentOrderCreateEditFormBinding) {
binding.shippingLines.apply {

private fun FragmentOrderCreateEditFormBinding.initShippingLinesSection() {
shippingLines.apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
viewModel.shippingLineList.observeAsState().value?.let { shippingLines ->
viewModel.shippingLineSection.observeAsState().value?.let { shippingLineSection ->
WooThemeWithBackground {
ShippingLineFormSection(
shippingLineDetails = shippingLines,
shippingLineDetails = shippingLineSection.shippingLines,
isEnabled = shippingLineSection.isEnabled,
formatCurrency = { amount -> currencyFormatter.formatCurrency(amount) },
modifier = Modifier.padding(bottom = 1.dp),
onAdd = { viewModel.onAddOrEditShipping() },
onEdit = { id -> viewModel.onAddOrEditShipping(id) }
onAddClicked = { viewModel.onAddOrEditShippingClicked() },
onEditClicked = { id -> viewModel.onAddOrEditShippingClicked(id) }
)
}
}
}
}
}

private fun bindCouponsLinesSection(binding: FragmentOrderCreateEditFormBinding) {
binding.couponLines.apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
viewModel.couponLinesLiveData.observeAsState().value?.let { couponSection ->
WooThemeWithBackground {
CouponLineFormSection(
couponLineDetails = couponSection.couponLines,
isEnabled = couponSection.isEnabled,
modifier = Modifier.padding(bottom = 1.dp),
onAddClicked = { viewModel.onAddCouponButtonClicked() },
onRemoveClicked = { code -> viewModel.removeCoupon(code) }
)
}
}
Expand Down Expand Up @@ -738,6 +761,22 @@ class OrderCreateEditFormFragment :
} else {
additionalInfoCollectionSection.addShippingButtonGroup.show()
}

if (newOrderData.couponLines.isNotEmpty()) {
additionalInfoCollectionSection.addCouponButtonGroup.hide()
} else {
additionalInfoCollectionSection.addCouponButtonGroup.show()
}

// Hide the whole section when all children are invisible
if (!additionalInfoCollectionSection.addGiftCardButtonGroup.isVisible &&
!additionalInfoCollectionSection.addCouponButtonGroup.isVisible &&
!additionalInfoCollectionSection.addShippingButtonGroup.isVisible
) {
additionalInfoCollectionSection.root.isVisible = false
} else {
additionalInfoCollectionSection.root.isVisible = true
}
}

private fun OrderCreationAdditionalInfoCollectionSectionBinding.bindGiftCardSubSection(newOrderData: Order) {
Expand Down
Loading

0 comments on commit c68f285

Please sign in to comment.