Skip to content

Commit

Permalink
Merge branch 'issue/13222-site-visibility-tracking' of https://github…
Browse files Browse the repository at this point in the history
….com/woocommerce/woocommerce-android into issue/13222-site-visibility-tracking
  • Loading branch information
JorgeMucientes committed Dec 31, 2024
2 parents 0620818 + d040d8a commit 74bcad7
Show file tree
Hide file tree
Showing 26 changed files with 851 additions and 234 deletions.
3 changes: 2 additions & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
*** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too.
21.4
-----
- [*] 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]
- [**] 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]


21.3
-----
- [*] "One time shipping" label in Product Subscriptions now matches its availability state correctly. [https://github.com/woocommerce/woocommerce-android/pull/13021]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import com.woocommerce.android.datastore.DataStoreType.ANALYTICS_UI_CACHE
import com.woocommerce.android.datastore.DataStoreType.COUPONS
import com.woocommerce.android.datastore.DataStoreType.DASHBOARD_STATS
import com.woocommerce.android.datastore.DataStoreType.LAST_UPDATE
import com.woocommerce.android.datastore.DataStoreType.SITE_PICKER_HIDDEN_SITES
import com.woocommerce.android.datastore.DataStoreType.SHIPPING_LABEL_ADDRESS
import com.woocommerce.android.datastore.DataStoreType.SHIPPING_LABEL_CONFIGURATION
import com.woocommerce.android.datastore.DataStoreType.SITE_PICKER_WOO_VISIBLE_SITES
import com.woocommerce.android.datastore.DataStoreType.TOP_PERFORMER_PRODUCTS
import com.woocommerce.android.datastore.DataStoreType.TRACKER
import com.woocommerce.android.di.AppCoroutineScope
Expand Down Expand Up @@ -162,7 +164,7 @@ class DataStoreModule {

@Provides
@Singleton
@DataStoreQualifier(SITE_PICKER_HIDDEN_SITES)
@DataStoreQualifier(SITE_PICKER_WOO_VISIBLE_SITES)
fun provideWooVisibleSitesDataStore(
appContext: Context,
crashLogging: CrashLogging,
Expand All @@ -172,7 +174,47 @@ class DataStoreModule {
appContext.preferencesDataStoreFile("site_picker_visible_sites")
},
corruptionHandler = ReplaceFileCorruptionHandler {
crashLogging.recordEvent("Corrupted data store. DataStore Type: ${SITE_PICKER_HIDDEN_SITES.name}")
crashLogging.recordEvent("Corrupted data store. DataStore Type: ${SITE_PICKER_WOO_VISIBLE_SITES.name}")
emptyPreferences()
},
scope = CoroutineScope(appCoroutineScope.coroutineContext + Dispatchers.IO)
)

@Provides
@Singleton
@DataStoreQualifier(SHIPPING_LABEL_CONFIGURATION)
fun provideShippingLabelConfigurationDataStore(
appContext: Context,
crashLogging: CrashLogging,
@AppCoroutineScope appCoroutineScope: CoroutineScope
) = PreferenceDataStoreFactory.create(
produceFile = {
appContext.preferencesDataStoreFile("shipping_label_configuration")
},
corruptionHandler = ReplaceFileCorruptionHandler {
crashLogging.recordEvent(
"Corrupted data store. DataStore Type: ${SHIPPING_LABEL_CONFIGURATION.name}"
)
emptyPreferences()
},
scope = CoroutineScope(appCoroutineScope.coroutineContext + Dispatchers.IO)
)

@Provides
@Singleton
@DataStoreQualifier(SHIPPING_LABEL_ADDRESS)
fun provideShippingLabelAddressDataStore(
appContext: Context,
crashLogging: CrashLogging,
@AppCoroutineScope appCoroutineScope: CoroutineScope
) = PreferenceDataStoreFactory.create(
produceFile = {
appContext.preferencesDataStoreFile("shipping_label_address")
},
corruptionHandler = ReplaceFileCorruptionHandler {
crashLogging.recordEvent(
"Corrupted data store. DataStore Type: ${SHIPPING_LABEL_ADDRESS.name}"
)
emptyPreferences()
},
scope = CoroutineScope(appCoroutineScope.coroutineContext + Dispatchers.IO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ enum class DataStoreType {
TOP_PERFORMER_PRODUCTS,
COUPONS,
LAST_UPDATE,
SITE_PICKER_HIDDEN_SITES,
SITE_PICKER_WOO_VISIBLE_SITES,
SHIPPING_LABEL_CONFIGURATION,
SHIPPING_LABEL_ADDRESS
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ fun <T> WCOverflowMenu(
) {
items.forEachIndexed { index, item ->
DropdownMenuItem(
modifier = Modifier.height(dimensionResource(id = dimen.major_175)),
onClick = {
showMenu = false
onSelected(item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import android.widget.FrameLayout
import androidx.appcompat.content.res.AppCompatResources
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.res.stringResource
Expand All @@ -20,6 +23,7 @@ import androidx.core.view.isVisible
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import androidx.lifecycle.LiveData
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import androidx.transition.TransitionManager
Expand Down Expand Up @@ -101,6 +105,7 @@ import com.woocommerce.android.viewmodel.fixedHiltNavGraphViewModels
import com.woocommerce.android.widgets.SkeletonView
import com.woocommerce.android.widgets.WCEmptyView
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import org.wordpress.android.fluxc.model.OrderAttributionInfo
import org.wordpress.android.util.DisplayUtils
import javax.inject.Inject
Expand Down Expand Up @@ -352,6 +357,7 @@ class OrderDetailFragment :
viewModel.onNextOrderClicked()
true
}

else -> {
false
}
Expand Down Expand Up @@ -434,23 +440,31 @@ class OrderDetailFragment :
showOrderNotes(it)
}
viewModel.orderRefunds.observe(viewLifecycleOwner) {
showOrderRefunds(it, viewModel.order)
lifecycleScope.launch {
showOrderRefunds(it, viewModel.awaitOrder())
}
}
viewModel.productList.observe(viewLifecycleOwner) {
showOrderProducts(it, viewModel.order.currency)
lifecycleScope.launch {
showOrderProducts(it, viewModel.awaitOrder().currency)
}
}
showCustomAmounts(viewModel.feeLineList)
viewModel.shipmentTrackings.observe(viewLifecycleOwner) {
showShipmentTrackings(it)
}
viewModel.shippingLabels.observe(viewLifecycleOwner) {
showShippingLabels(it, viewModel.order.currency)
lifecycleScope.launch {
showShippingLabels(it, viewModel.awaitOrder().currency)
}
}
viewModel.subscriptions.observe(viewLifecycleOwner) {
showSubscriptions(it)
}
viewModel.giftCards.observe(viewLifecycleOwner) {
showGiftCards(it, viewModel.order.currency)
lifecycleScope.launch {
showGiftCards(it, viewModel.awaitOrder().currency)
}
}
showShippingLines(viewModel.shippingLineList)

Expand All @@ -465,9 +479,11 @@ class OrderDetailFragment :
uiMessageResolver.showSnack(event.message)
}
}

is ShowUndoSnackbar -> {
displayUndoSnackbar(event.message, event.undoAction, event.dismissAction)
}

is OrderNavigationTarget -> navigator.navigate(this, event)
is InstallWCShippingViewModel.InstallWcShipping -> navigateToInstallWcShippingFlow()
is OrderDetailViewModel.TrashOrder -> {
Expand All @@ -477,6 +493,7 @@ class OrderDetailFragment :

communicationViewModel.trashOrder(event.orderId)
}

is MultiLiveEvent.Event.ShowDialog -> event.showDialog()
else -> event.isHandled = false
}
Expand All @@ -488,14 +505,19 @@ class OrderDetailFragment :
binding.orderDetailShippingLines.apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
val orderCurrency = remember { mutableStateOf<String>("") }
LaunchedEffect(Unit) {
orderCurrency.value = viewModel.awaitOrder().currency
}

shippingLineList.observeAsState().value?.let { shippingLines ->
WooThemeWithBackground {
ShippingLineSection(
shippingLineDetails = shippingLines,
formatCurrency = { amount ->
currencyFormatter.formatCurrency(
amount,
currencyCode = viewModel.order.currency
currencyCode = orderCurrency.value
)
},
modifier = Modifier.padding(bottom = 1.dp)
Expand Down
Loading

0 comments on commit 74bcad7

Please sign in to comment.