Skip to content

Commit

Permalink
Merge branch 'trunk' into dependabot/gradle/androidx.activity-activit…
Browse files Browse the repository at this point in the history
…y-ktx-1.9.3
  • Loading branch information
JorgeMucientes authored Dec 5, 2024
2 parents 260f7ca + 94898b9 commit 38f34d6
Show file tree
Hide file tree
Showing 18 changed files with 342 additions and 57 deletions.
3 changes: 3 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
21.3
-----
- [*] "One time shipping" label in Product Subscriptions now matches its availability state correctly. [https://github.com/woocommerce/woocommerce-android/pull/13021]
- [*] "One time shipping" label should not be shown in Simple product after conversion from Subscriptions product. [https://github.com/woocommerce/woocommerce-android/pull/13032]
- [*] Fixed a bug related to incorrect Shipping settings in Product details when converting from Subscriptions to Simple product. [https://github.com/woocommerce/woocommerce-android/pull/13035]
- [Internal] Refactored IPP Payment flow to allow customizing payment collection UI in POS [https://github.com/woocommerce/woocommerce-android/pull/13014]
- [*] Blaze Campaign Intro screen now offers creating a new product if the site has no products yet [https://github.com/woocommerce/woocommerce-android/pull/13001]
- [*] When entering a wrong WordPress.com account for login, retrying will bring the step back to the email input screen [https://github.com/woocommerce/woocommerce-android/pull/13024]


-----
21.2
- [Internal] Changed a way how authenticated web view opened in the IPP flows [https://github.com/woocommerce/woocommerce-android/pull/12908]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,14 @@ enum class AnalyticsEvent(override val siteless: Boolean = false) : IAnalyticsEv
DASHBOARD_SHARE_YOUR_STORE_BUTTON_TAPPED,
DASHBOARD_MAIN_STATS_DATE,
DASHBOARD_MAIN_STATS_LOADED,
DASHBOARD_TOP_PERFORMERS_DATE,
DASHBOARD_TOP_PERFORMERS_LOADED,
DASHBOARD_NEW_STATS_REVERTED_BANNER_DISMISS_TAPPED,
DASHBOARD_NEW_STATS_REVERTED_BANNER_LEARN_MORE_TAPPED,
DASHBOARD_WAITING_TIME_LOADED,
DASHBOARD_SEE_MORE_ANALYTICS_TAPPED,
DASHBOARD_STORE_TIMEZONE_DIFFER_FROM_DEVICE,
USED_ANALYTICS,
STATS_UNEXPECTED_FORMAT,
DASHBOARD_STATS_CUSTOM_RANGE_ADD_BUTTON_TAPPED,
DASHBOARD_STATS_CUSTOM_RANGE_CONFIRMED,
DASHBOARD_STATS_CUSTOM_RANGE_TAB_SELECTED,
DASHBOARD_STATS_CUSTOM_RANGE_EDIT_BUTTON_TAPPED,
DASHBOARD_STATS_CUSTOM_RANGE_INTERACTED,
DYNAMIC_DASHBOARD_EDIT_LAYOUT_BUTTON_TAPPED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.woocommerce.android.datastore
import android.content.Context
import androidx.datastore.core.DataStore
import androidx.datastore.core.DataStoreFactory
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
import androidx.datastore.dataStoreFile
import com.automattic.android.tracks.crashlogging.CrashLogging
import com.woocommerce.android.di.SiteComponent
import com.woocommerce.android.di.SiteCoroutineScope
import com.woocommerce.android.di.SiteScope
Expand All @@ -23,12 +25,17 @@ object DashboardDataStoreModule {
@SiteScope
fun provideDashboardDataStore(
appContext: Context,
crashLogging: CrashLogging,
@SiteCoroutineScope siteCoroutineScope: CoroutineScope,
site: SiteModel
): DataStore<DashboardDataModel> = DataStoreFactory.create(
produceFile = {
appContext.dataStoreFile("dashboard_configuration_${site.id}")
},
corruptionHandler = ReplaceFileCorruptionHandler {
crashLogging.recordEvent("Corrupted data store. DataStore Type: DASHBOARD")
DashboardDataModel.getDefaultInstance()
},
scope = CoroutineScope(siteCoroutineScope.coroutineContext + Dispatchers.IO),
serializer = DashboardSerializer
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ package com.woocommerce.android.datastore
import android.content.Context
import androidx.datastore.core.DataStore
import androidx.datastore.core.DataStoreFactory
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
import androidx.datastore.preferences.core.PreferenceDataStoreFactory
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.emptyPreferences
import androidx.datastore.preferences.preferencesDataStoreFile
import com.automattic.android.tracks.crashlogging.CrashLogging
import com.woocommerce.android.datastore.DataStoreType.ANALYTICS_CONFIGURATION
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.TOP_PERFORMER_PRODUCTS
import com.woocommerce.android.datastore.DataStoreType.TRACKER
import com.woocommerce.android.di.AppCoroutineScope
Expand All @@ -30,11 +35,16 @@ class DataStoreModule {
@DataStoreQualifier(TRACKER)
fun provideTrackerDataStore(
appContext: Context,
crashLogging: CrashLogging,
@AppCoroutineScope appCoroutineScope: CoroutineScope
): DataStore<Preferences> = PreferenceDataStoreFactory.create(
produceFile = {
appContext.preferencesDataStoreFile("tracker")
},
corruptionHandler = ReplaceFileCorruptionHandler {
crashLogging.recordEvent("Corrupted data store. DataStore Type: ${TRACKER.name}")
emptyPreferences()
},
scope = CoroutineScope(appCoroutineScope.coroutineContext + Dispatchers.IO)
)

Expand All @@ -43,11 +53,16 @@ class DataStoreModule {
@DataStoreQualifier(ANALYTICS_UI_CACHE)
fun provideAnalyticsDataStore(
appContext: Context,
crashLogging: CrashLogging,
@AppCoroutineScope appCoroutineScope: CoroutineScope
): DataStore<Preferences> = PreferenceDataStoreFactory.create(
produceFile = {
appContext.preferencesDataStoreFile("analytics")
},
corruptionHandler = ReplaceFileCorruptionHandler {
crashLogging.recordEvent("Corrupted data store. DataStore Type: ${ANALYTICS_UI_CACHE.name}")
emptyPreferences()
},
scope = CoroutineScope(appCoroutineScope.coroutineContext + Dispatchers.IO)
)

Expand All @@ -56,11 +71,16 @@ class DataStoreModule {
@DataStoreQualifier(ANALYTICS_CONFIGURATION)
fun provideAnalyticsConfigurationDataStore(
appContext: Context,
crashLogging: CrashLogging,
@AppCoroutineScope appCoroutineScope: CoroutineScope
): DataStore<Preferences> = PreferenceDataStoreFactory.create(
produceFile = {
appContext.preferencesDataStoreFile("analytics_configuration")
},
corruptionHandler = ReplaceFileCorruptionHandler {
crashLogging.recordEvent("Corrupted data store. DataStore Type: ${ANALYTICS_CONFIGURATION.name}")
emptyPreferences()
},
scope = CoroutineScope(appCoroutineScope.coroutineContext + Dispatchers.IO)
)

Expand All @@ -69,11 +89,16 @@ class DataStoreModule {
@DataStoreQualifier(DASHBOARD_STATS)
fun provideCustomDateRangeDataStore(
appContext: Context,
crashLogging: CrashLogging,
@AppCoroutineScope appCoroutineScope: CoroutineScope
): DataStore<CustomDateRange> = DataStoreFactory.create(
produceFile = {
appContext.preferencesDataStoreFile("custom_date_range_configuration")
},
corruptionHandler = ReplaceFileCorruptionHandler {
crashLogging.recordEvent("Corrupted data store. DataStore Type: ${DASHBOARD_STATS.name}")
CustomDateRange.getDefaultInstance()
},
scope = CoroutineScope(appCoroutineScope.coroutineContext + Dispatchers.IO),
serializer = CustomDateRangeSerializer
)
Expand All @@ -83,39 +108,54 @@ class DataStoreModule {
@DataStoreQualifier(TOP_PERFORMER_PRODUCTS)
fun provideTopPerformersCustomDateRangeDataStore(
appContext: Context,
crashLogging: CrashLogging,
@AppCoroutineScope appCoroutineScope: CoroutineScope
): DataStore<CustomDateRange> = DataStoreFactory.create(
produceFile = {
appContext.preferencesDataStoreFile("top_performers_custom_date_range_configuration")
},
corruptionHandler = ReplaceFileCorruptionHandler {
crashLogging.recordEvent("Corrupted data store. DataStore Type: ${TOP_PERFORMER_PRODUCTS.name}")
CustomDateRange.getDefaultInstance()
},
scope = CoroutineScope(appCoroutineScope.coroutineContext + Dispatchers.IO),
serializer = CustomDateRangeSerializer
)

@Provides
@Singleton
@DataStoreQualifier(DataStoreType.COUPONS)
@DataStoreQualifier(COUPONS)
fun provideCouponsCustomDateRangeDataStore(
appContext: Context,
crashLogging: CrashLogging,
@AppCoroutineScope appCoroutineScope: CoroutineScope
): DataStore<CustomDateRange> = DataStoreFactory.create(
produceFile = {
appContext.preferencesDataStoreFile("dashboard_coupons_custom_date_range_configuration")
},
corruptionHandler = ReplaceFileCorruptionHandler {
crashLogging.recordEvent("Corrupted data store. DataStore Type: ${COUPONS.name}")
CustomDateRange.getDefaultInstance()
},
scope = CoroutineScope(appCoroutineScope.coroutineContext + Dispatchers.IO),
serializer = CustomDateRangeSerializer
)

@Provides
@Singleton
@DataStoreQualifier(DataStoreType.LAST_UPDATE)
@DataStoreQualifier(LAST_UPDATE)
fun provideLastUpdateDataStore(
appContext: Context,
crashLogging: CrashLogging,
@AppCoroutineScope appCoroutineScope: CoroutineScope
) = PreferenceDataStoreFactory.create(
produceFile = {
appContext.preferencesDataStoreFile("update")
},
corruptionHandler = ReplaceFileCorruptionHandler {
crashLogging.recordEvent("Corrupted data store. DataStore Type: ${LAST_UPDATE.name}")
emptyPreferences()
},
scope = CoroutineScope(appCoroutineScope.coroutineContext + Dispatchers.IO)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fun DashboardStatsCard(
currencyFormatter = viewModel.currencyFormatter,
usageTracksEventEmitter = viewModel.usageTracksEventEmitter,
onAddCustomRangeClick = viewModel::onAddCustomRangeClicked,
onTabSelected = viewModel::onTabSelected,
onTabSelected = viewModel::onRangeChanged,
onChartDateSelected = viewModel::onChartDateSelected
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class DashboardStatsViewModel @AssistedInject constructor(
trackLocalTimezoneDifferenceFromStore()
}

fun onTabSelected(selectionType: SelectionType) {
fun onRangeChanged(selectionType: SelectionType) {
parentViewModel.trackCardInteracted(DashboardWidget.Type.STATS.trackingIdentifier)
usageTracksEventEmitter.interacted()
if (selectionType != SelectionType.CUSTOM) {
Expand All @@ -134,7 +134,7 @@ class DashboardStatsViewModel @AssistedInject constructor(
} else {
appPrefsWrapper.setActiveStatsTab(SelectionType.CUSTOM.name)
analyticsTrackerWrapper.track(
AnalyticsEvent.DASHBOARD_STATS_CUSTOM_RANGE_TAB_SELECTED
AnalyticsEvent.DASHBOARD_STATS_CUSTOM_RANGE_ADD_BUTTON_TAPPED
)
}
}
Expand All @@ -151,7 +151,7 @@ class DashboardStatsViewModel @AssistedInject constructor(
viewModelScope.launch {
customDateRangeDataStore.updateDateRange(range)
if (dateRangeState.value?.rangeSelection?.selectionType != SelectionType.CUSTOM) {
onTabSelected(SelectionType.CUSTOM)
onRangeChanged(SelectionType.CUSTOM)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class DashboardTopPerformersViewModel @AssistedInject constructor(
}
}

fun onTabSelected(selectionType: SelectionType) {
fun onRangeChanged(selectionType: SelectionType) {
parentViewModel.trackCardInteracted(DashboardWidget.Type.POPULAR_PRODUCTS.trackingIdentifier)
usageTracksEventEmitter.interacted()
if (selectionType != SelectionType.CUSTOM) {
Expand All @@ -150,7 +150,7 @@ class DashboardTopPerformersViewModel @AssistedInject constructor(
onEditCustomRangeTapped()
} else {
appPrefsWrapper.setActiveTopPerformersTab(SelectionType.CUSTOM.name)
analyticsTrackerWrapper.track(AnalyticsEvent.DASHBOARD_STATS_CUSTOM_RANGE_TAB_SELECTED)
analyticsTrackerWrapper.track(AnalyticsEvent.DASHBOARD_STATS_CUSTOM_RANGE_ADD_BUTTON_TAPPED)
}
}
}
Expand Down Expand Up @@ -287,7 +287,7 @@ class DashboardTopPerformersViewModel @AssistedInject constructor(
viewModelScope.launch {
customDateRangeDataStore.updateDateRange(statsTimeRange)
if (selectedDateRange.value?.rangeSelection?.selectionType != SelectionType.CUSTOM) {
onTabSelected(SelectionType.CUSTOM)
onRangeChanged(SelectionType.CUSTOM)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fun DashboardTopPerformersWidgetCard(
topPerformersState = topPerformersState,
selectedDateRange = selectedDateRange,
lastUpdateState = lastUpdateState,
onTabSelected = topPerformersViewModel::onTabSelected,
onTabSelected = topPerformersViewModel::onRangeChanged,
onEditCustomRangeTapped = topPerformersViewModel::onEditCustomRangeTapped
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import com.woocommerce.android.ui.orders.wooshippinglabels.packages.datasource.C
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.datasource.CarrierType.USPS
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking.CarrierPackageGroupDTO
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking.CarrierPredefinedPackagesDTO
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking.CustomPackageDTO
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking.PackageResponse
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking.PredefinedPackageDTO
import javax.inject.Inject

class WooShippingLabelPackageMapper @Inject constructor() {
operator fun invoke(response: PackageResponse): StorePackagesDAO {
val savedPackagesResponse = response.packages?.saved?.predefined ?: emptyList()
val savedPackagesResponse = response.packages?.saved?.custom ?: emptyList()

return StorePackagesDAO(
savedPackages = mapSavedPackages(savedPackagesResponse),
carrierPackages = mapCarrierPackages(response.packages?.predefined)
)
}

private fun mapSavedPackages(savedResponse: List<PredefinedPackageDTO>): List<PackageDAO> {
private fun mapSavedPackages(savedResponse: List<CustomPackageDTO>): List<PackageDAO> {
return savedResponse.map {
PackageDAO(
id = it.id.orEmpty(),
Expand Down Expand Up @@ -59,7 +59,7 @@ class WooShippingLabelPackageMapper @Inject constructor() {
PackageDAO(
id = it.id.orEmpty(),
name = it.name.orEmpty(),
dimensions = it.dimensions.orEmpty(),
dimensions = it.outerDimensions.orEmpty(),
isLetter = it.isLetter ?: false
)
} ?: emptyList()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
package com.woocommerce.android.ui.orders.wooshippinglabels.packages.networking

import com.google.gson.annotations.SerializedName

class CarrierPredefinedPackagesDTO {
val usps: USPSPackageDTO? = null

@SerializedName("dhlexpress")
val dhlExpress: DHLPackageDTO? = null
}

class USPSPackageDTO {
@SerializedName("pri_flat_boxes")
val flatBoxes: CarrierPackageGroupDTO? = null

@SerializedName("pri_boxes")
val boxes: CarrierPackageGroupDTO? = null

@SerializedName("pri_express_boxes")
val expressBoxes: CarrierPackageGroupDTO? = null

@SerializedName("pri_envelopes")
val envelopes: CarrierPackageGroupDTO? = null

@SerializedName("pri_express_envelopes")
val expressEnvelopes: CarrierPackageGroupDTO? = null
}

class DHLPackageDTO {
@SerializedName("domestic_and_international")
val domesticAndInternationalPackages: CarrierPackageGroupDTO? = null
}

Expand All @@ -23,15 +37,30 @@ class CarrierPackageGroupDTO {
}

class PredefinedPackageDTO {
val id: String? = null
val name: String? = null

@SerializedName("inner_dimensions")
val innerDimensions: String? = null

@SerializedName("outer_dimensions")
val outerDimensions: String? = null

@SerializedName("box_weight")
val boxWeight: Double? = null

@SerializedName("is_flat_rate")
val isFlatRate: Boolean? = null
val id: String? = null
val name: String? = null
val dimensions: String? = null

@SerializedName("max_weight")
val maxWeight: Double? = null

@SerializedName("is_letter")
val isLetter: Boolean? = null

@SerializedName("group_id")
val groupId: String? = null

@SerializedName("can_ship_international")
val canShipInternational: Boolean? = null
}
Loading

0 comments on commit 38f34d6

Please sign in to comment.