From cb25b418c202d799fb7fc3d07a275879798e2a65 Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Tue, 7 May 2024 15:01:59 +0300 Subject: [PATCH 1/7] Add title to the loading state of the subscribers chart card --- .../sections/subscribers/usecases/SubscribersChartUseCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersChartUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersChartUseCase.kt index 18681b3ba6b0..bcafffd01940 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersChartUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersChartUseCase.kt @@ -31,7 +31,7 @@ class SubscribersChartUseCase @Inject constructor( @Named(BG_THREAD) private val backgroundDispatcher: CoroutineDispatcher, private val analyticsTracker: AnalyticsTrackerWrapper ) : StatelessUseCase(SUBSCRIBERS_CHART, mainDispatcher, backgroundDispatcher) { - override fun buildLoadingItem(): List = listOf() + override fun buildLoadingItem(): List = listOf(Title(R.string.stats_view_subscribers)) override suspend fun loadCachedData() = subscribersStore.getSubscribers( statsSiteProvider.siteModel, From 6166f5cfa3130d897e565b896df4cbfe2d6b2397 Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Tue, 7 May 2024 17:52:00 +0300 Subject: [PATCH 2/7] Update FluxC PR to trunk --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index cd674f8dbf6b..ad876cb014af 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ ext { automatticTracksVersion = '5.0.0' gutenbergMobileVersion = 'v1.118.0' wordPressAztecVersion = 'v2.1.3' - wordPressFluxCVersion = 'trunk-eceaa9130d4307fc213d7acdad334104b8e57b16' + wordPressFluxCVersion = '3005-d455ac39c1805965df2f32f0ada4cc7768a094c1' wordPressLoginVersion = '1.15.0' wordPressPersistentEditTextVersion = '1.0.2' wordPressUtilsVersion = '3.14.0' From 68b8e2b56b4bc98299bfbce262b6c08d4d73512e Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Wed, 8 May 2024 22:11:37 +0300 Subject: [PATCH 3/7] Add singular-plural options for the marker view of subscribers chart --- .../ui/stats/refresh/SubscribersChartMarkerView.kt | 9 ++++++++- .../main/res/layout/stats_subscribers_chart_marker.xml | 5 +++-- WordPress/src/main/res/values/strings.xml | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/SubscribersChartMarkerView.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/SubscribersChartMarkerView.kt index e884490654d5..22821ee61c3f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/SubscribersChartMarkerView.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/SubscribersChartMarkerView.kt @@ -33,7 +33,8 @@ class SubscribersChartMarkerView @Inject constructor( @Inject lateinit var statsDateFormatter: StatsDateFormatter private val countView = findViewById(R.id.marker_text1) - private val dateView = findViewById(R.id.marker_text2) + private val labelView = findViewById(R.id.marker_text2) + private val dateView = findViewById(R.id.marker_text3) override fun refreshContent(e: Entry?, highlight: Highlight?) { val lineChart = chartView as? LineChart ?: return @@ -46,6 +47,12 @@ class SubscribersChartMarkerView @Inject constructor( val count = yValue.toLong() countView.text = count.toString() + val label = if (count > 1) { + R.string.stats_subscribers_marker_view_plural + } else { + R.string.stats_subscribers_marker_view_singular + } + labelView.setText(label) val date = statsDateFormatter.getStatsDateFromPeriodDay(e.data.toString()) dateView.text = date diff --git a/WordPress/src/main/res/layout/stats_subscribers_chart_marker.xml b/WordPress/src/main/res/layout/stats_subscribers_chart_marker.xml index d79c2f7e52a6..973f504fc18b 100644 --- a/WordPress/src/main/res/layout/stats_subscribers_chart_marker.xml +++ b/WordPress/src/main/res/layout/stats_subscribers_chart_marker.xml @@ -19,14 +19,15 @@ tools:text="6500" /> Subscribers Subscribers Emails + Subscriber + Subscribers seconds ago From fc4fcf1ca750d9818f6959842dde443eb351fc5d Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Wed, 8 May 2024 22:11:54 +0300 Subject: [PATCH 4/7] Rename the title of chart card to "Subscriber Growth" --- .../sections/subscribers/usecases/SubscribersChartUseCase.kt | 2 +- .../lists/sections/subscribers/usecases/SubscribersMapper.kt | 2 +- WordPress/src/main/res/values/strings.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersChartUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersChartUseCase.kt index bcafffd01940..821eb0cf906f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersChartUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersChartUseCase.kt @@ -68,7 +68,7 @@ class SubscribersChartUseCase @Inject constructor( return items } - private fun buildTitle() = Title(R.string.stats_view_subscribers_chart) + private fun buildTitle() = Title(R.string.stats_view_subscriber_growth) private fun onLineSelected() { analyticsTracker.track(AnalyticsTracker.Stat.STATS_SUBSCRIBERS_CHART_TAPPED) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersMapper.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersMapper.kt index cfae96d0f75c..f557c1016275 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersMapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/subscribers/usecases/SubscribersMapper.kt @@ -19,7 +19,7 @@ class SubscribersMapper @Inject constructor( } val contentDescriptions = statsUtils.getSubscribersChartEntryContentDescriptions( - R.string.stats_view_subscribers_chart, + R.string.stats_subscribers_marker_view_plural, chartItems ) diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index c45248696e20..ae7676f3f2b5 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -1327,7 +1327,7 @@ Total Comments Total Followers Total Subscribers - Subscribers + Subscriber Growth Subscribers Emails Subscriber From 408c8f1c2bde4f687520cb27c25005cc94efa13c Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Fri, 10 May 2024 14:54:34 +0300 Subject: [PATCH 5/7] Update FluxC reference to the trunk --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ad876cb014af..94ad2667e406 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ ext { automatticTracksVersion = '5.0.0' gutenbergMobileVersion = 'v1.118.0' wordPressAztecVersion = 'v2.1.3' - wordPressFluxCVersion = '3005-d455ac39c1805965df2f32f0ada4cc7768a094c1' + wordPressFluxCVersion = 'trunk-6fc2cb7dd5f122c494bff981bf865dd8a22c9fbb' wordPressLoginVersion = '1.15.0' wordPressPersistentEditTextVersion = '1.0.2' wordPressUtilsVersion = '3.14.0' From 9c581d37d962ca5f5435e809f0fec6e1d9a997cc Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Fri, 10 May 2024 15:22:24 +0300 Subject: [PATCH 6/7] Fix 0 subscriber crash on the markerview of the subscriber growth card --- .../lists/sections/viewholders/SubscribersChartViewHolder.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/viewholders/SubscribersChartViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/viewholders/SubscribersChartViewHolder.kt index fcef4266088d..3ed7b5a8eb5c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/viewholders/SubscribersChartViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/viewholders/SubscribersChartViewHolder.kt @@ -82,7 +82,7 @@ class SubscribersChartViewHolder(parent: ViewGroup) : BlockListItemViewHolder( } private fun getData(item: SubscribersChartItem): List { - val data = if (item.entries.isEmpty() || item.entries.all { it.value == 0 }) { + val data = if (item.entries.isEmpty()) { buildEmptyDataSet(item.entries.size) } else { val mappedEntries = item.entries.mapIndexed { index, pair -> toLineEntry(pair, index) } From e31a090ff9f88cbdc3bb6f8f55ecdda86437c342 Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Wed, 22 May 2024 16:46:20 +0300 Subject: [PATCH 7/7] Fix checking the index of lists in chart label formatter classes --- .../android/ui/stats/refresh/utils/LineChartLabelFormatter.kt | 2 +- .../ui/stats/refresh/utils/SubscribersChartLabelFormatter.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/LineChartLabelFormatter.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/LineChartLabelFormatter.kt index ec3b54ae47e2..6b85e0bdd5f0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/LineChartLabelFormatter.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/LineChartLabelFormatter.kt @@ -10,7 +10,7 @@ class LineChartLabelFormatter @Inject constructor( ) : ValueFormatter() { override fun getAxisLabel(value: Float, axis: AxisBase?): String { val index = value.toInt() - return if (entries.isNotEmpty() && index in 0..entries.size) { + return if (entries.isNotEmpty() && index in entries.indices) { entries[index].label } else { "" diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/SubscribersChartLabelFormatter.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/SubscribersChartLabelFormatter.kt index 6a153a7708bc..aa4599c211fb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/SubscribersChartLabelFormatter.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/SubscribersChartLabelFormatter.kt @@ -10,7 +10,7 @@ class SubscribersChartLabelFormatter @Inject constructor( ) : ValueFormatter() { override fun getAxisLabel(value: Float, axis: AxisBase?): String { val index = value.toInt() - return if (entries.isNotEmpty() && index in 0..entries.size) { + return if (entries.isNotEmpty() && index in entries.indices) { entries[index].label } else { ""