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/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..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 @@ -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, @@ -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/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) } 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 { "" 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" /> Total Likes Total Comments Total Subscribers - Subscribers + Subscriber Growth Subscribers Emails + Subscriber + Subscribers seconds ago