Skip to content

Commit

Permalink
Merge branch 'trunk' into pos-cash-card-payment-collection-alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
samiuelson authored Jan 9, 2025
2 parents 33dc451 + 9218fa9 commit 4a506d8
Show file tree
Hide file tree
Showing 17 changed files with 590 additions and 113 deletions.
2 changes: 2 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
- [***] Orders: Merchants can now bulk update the status of their orders [https://github.com/woocommerce/woocommerce-android/pull/13245]
- [*] 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]
- [*] It possible to quickly open plugins page from the plugins list in the up to update an outdated plugin [https://github.com/woocommerce/woocommerce-android/pull/13246]
- [**] Fixed a bug when refunded items were displayed on the refund screen [https://github.com/woocommerce/woocommerce-android/pull/13212]
- [**] Enable hiding and disabling push notification for sites from site picker [https://github.com/woocommerce/woocommerce-android/issues/13107]

21.3
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ class OrderSelectionItemKeyProvider(private val recyclerView: RecyclerView) :
}

override fun getPosition(key: Long): Int =
(recyclerView.adapter as? OrderListAdapter)?.orderIdAndPosition[key] ?: RecyclerView.NO_POSITION
(recyclerView.adapter as? OrderListAdapter)?.orderIdAndPosition?.get(key) ?: RecyclerView.NO_POSITION
}
Original file line number Diff line number Diff line change
Expand Up @@ -415,24 +415,36 @@ class OrderListFragment :
}
}
tracker?.onSaveInstanceState(outState)
viewModel.orderIdAndPositionBackup =
((binding.orderListView.ordersList.adapter as? OrderListAdapter)?.orderIdAndPosition ?: emptyMap())
as MutableMap<Long, Int>

_binding?.let { binding ->
val adapter = binding.orderListView.ordersList.adapter as? OrderListAdapter
adapter?.let {
viewModel.orderIdAndPositionBackup = it.orderIdAndPosition
}
}
}

override fun onViewStateRestored(savedInstanceState: Bundle?) {
tracker?.run {
onRestoreInstanceState(savedInstanceState)
(binding.orderListView.ordersList.adapter as? OrderListAdapter)?.orderIdAndPosition =
viewModel.orderIdAndPositionBackup
if (hasSelection()) {
setItemsSelected(selection.toList(), true)
_binding?.let { binding ->
restoreAdapterBulkSelectionState(binding)
if (hasSelection()) {
setItemsSelected(selection.toList(), true)
}
}
}

super.onViewStateRestored(savedInstanceState)
}

private fun restoreAdapterBulkSelectionState(binding: FragmentOrderListBinding) {
val adapter = binding.orderListView.ordersList.adapter as? OrderListAdapter
if (adapter != null) {
adapter.orderIdAndPosition = viewModel.orderIdAndPositionBackup
}
}

override fun onDestroyView() {
disableSearchListeners()
handler.removeCallbacksAndMessages(null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.woocommerce.android.ui.orders.wooshippinglabels.address

import android.content.Context
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
Expand All @@ -10,6 +11,8 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Divider
import androidx.compose.material.Icon
Expand All @@ -26,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
Expand Down Expand Up @@ -364,20 +368,22 @@ fun AddressSelection(
bottom = dimensionResource(id = R.dimen.minor_100)
)
)
originAddresses.forEach { option ->
val isSelected = option == shipFrom
AddressSelectionItem(
address = option,
isSelected = isSelected,
onClick = {
onShippingFromAddressChange(option)
},
modifier = Modifier.padding(
top = dimensionResource(id = R.dimen.minor_100),
start = dimensionResource(id = R.dimen.major_100),
end = dimensionResource(id = R.dimen.major_100)
LazyColumn {
items(originAddresses) { option ->
val isSelected = option == shipFrom
AddressSelectionItem(
address = option,
isSelected = isSelected,
onClick = {
onShippingFromAddressChange(option)
},
modifier = Modifier.padding(
top = dimensionResource(id = R.dimen.minor_100),
start = dimensionResource(id = R.dimen.major_100),
end = dimensionResource(id = R.dimen.major_100)
)
)
)
}
}
Spacer(modifier = Modifier.height(dimensionResource(id = R.dimen.major_100)))
},
Expand Down Expand Up @@ -422,7 +428,7 @@ fun AddressSelectionItem(
Row {
Column(modifier = Modifier.weight(1f)) {
Text(
text = "Address Name",
text = address.getFormattedName(LocalContext.current),
fontWeight = FontWeight.Bold,
modifier = Modifier
)
Expand Down Expand Up @@ -492,3 +498,18 @@ internal fun getShipTo() = Address(
country = Location("US", "USA"),
state = AmbiguousLocation.Defined(Location("CA", "California", "USA"))
)

fun OriginShippingAddress.getFormattedName(context: Context): String {
val name = when {
!firstName.isNullOrEmpty() && !lastName.isNullOrEmpty() -> "$firstName $lastName"
!firstName.isNullOrEmpty() -> firstName
!lastName.isNullOrEmpty() -> lastName
!company.isNullOrEmpty() -> company
else -> context.getString(R.string.shipping_label_select_origin_address)
}
return if (this.isDefault) {
context.getString(R.string.shipping_label_select_origin_default_address, name)
} else {
name
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.woocommerce.android.ui.prefs.plugins

import com.woocommerce.android.viewmodel.MultiLiveEvent

sealed class PluginsEvent : MultiLiveEvent.Event() {
data class NavigateToPluginsWeb(val url: String) : PluginsEvent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.ViewGroup
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.woocommerce.android.NavGraphSettingsDirections
import com.woocommerce.android.analytics.AnalyticsTracker
import com.woocommerce.android.ui.base.BaseFragment
import com.woocommerce.android.ui.compose.theme.WooThemeWithBackground
Expand Down Expand Up @@ -46,6 +47,10 @@ class PluginsFragment : BaseFragment() {
viewModel.event.observe(viewLifecycleOwner) { event ->
when (event) {
is MultiLiveEvent.Event.Exit -> findNavController().navigateUp()
is PluginsEvent.NavigateToPluginsWeb -> {
findNavController()
.navigate(NavGraphSettingsDirections.actionGlobalWPComWebViewFragment(event.url))
}
}
}
}
Expand Down
Loading

0 comments on commit 4a506d8

Please sign in to comment.