Skip to content

Commit 8152646

Browse files
nbradburyclaude
andauthored
Stats empty view improvements (#22523)
* Removed drawable from stats empty view * Revert testing code that forced stats empty view Remove TODO comments and test block that always displayed the empty view, restoring the proper showUiModel logic. Co-Authored-By: Claude Opus 4.5 <[email protected]> * Remove unused image parameter from UiModel.Empty Co-Authored-By: Claude Opus 4.5 <[email protected]> * Updated insights strings * Updated insights strings, p2 * Update UiModelMapperTest to match forced empty view behavior Updated tests to expect UiModel.Empty since mapInsights currently returns the empty state for testing. Removed image assertion since the image parameter was removed from UiModel.Empty. Also fixed minor string typo. Co-Authored-By: Claude Opus 4.5 <[email protected]> * Removed TODO * Fix UiModelMapperTest to match current mapper behavior Update test to expect UiModel.Success when InsightType items are present, and fix incorrect type casts from UiModel.Success to StatsBlock.Success. Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent b0dd0a5 commit 8152646

File tree

7 files changed

+8
-148
lines changed

7 files changed

+8
-148
lines changed

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/StatsListFragment.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,6 @@ class StatsListFragment : ViewPagerFragment(R.layout.stats_list_fragment), PullT
329329
@SuppressLint("SetTextI18n")
330330
emptyView.statsEmptyView.subtitle.text = ""
331331
}
332-
if (it.image != null) {
333-
emptyView.statsEmptyView.image.setImageResource(it.image)
334-
} else {
335-
emptyView.statsEmptyView.image.setImageDrawable(null)
336-
}
337332
emptyView.statsEmptyView.button.setVisible(it.showButton)
338333
}
339334
}

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/StatsListViewModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ abstract class StatsListViewModel(
188188
data class Empty(
189189
val title: Int,
190190
val subtitle: Int? = null,
191-
val image: Int? = null,
192191
val showButton: Boolean = false
193192
) : UiModel()
194193
}

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/UiModelMapper.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ class UiModelMapper
4848
}
4949
} else {
5050
return UiModel.Empty(
51-
R.string.stats_empty_insights_title,
52-
R.string.stats_insights_management_title,
53-
R.drawable.img_illustration_insights_94dp,
54-
true
51+
title = R.string.stats_empty_insights_title,
52+
subtitle = R.string.stats_insights_management_title,
53+
showButton = true
5554
)
5655
}
5756
}

WordPress/src/main/res/drawable/img_illustration_insights_94dp.xml

Lines changed: 0 additions & 130 deletions
This file was deleted.

WordPress/src/main/res/layout/stats_empty_view.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
android:layout_height="match_parent"
88
android:visibility="gone"
99
app:aevButton="@string/stats_manage_insights"
10-
app:aevImage="@drawable/img_illustration_insights_94dp"
1110
app:aevSubtitle="@string/stats_insights_management_title"
1211
app:aevTitle="@string/stats_empty_insights_title"
1312
tools:visibility="visible" />

WordPress/src/main/res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,9 +1490,9 @@
14901490
<string name="stats_insights_linkedin">LinkedIn</string>
14911491
<string name="stats_insights_path">Path</string>
14921492
<string name="stats_most_popular_percent_views">%1$s of views</string>
1493-
<string name="stats_most_popular_percent_views_empty">Not enough activity. Check back later when your site\'s had more visitors!</string>
1493+
<string name="stats_most_popular_percent_views_empty">Not enough activity. Check back when your site had more visitors!</string>
14941494
<string name="stats_insights_posting_activity">Posting Activity</string>
1495-
<string name="stats_insights_management_title">Only see the most relevant stats. Add and organise your insights below.</string>
1495+
<string name="stats_insights_management_title">Manage your insights to see only the most relevant stats</string>
14961496

14971497
<string name="stats_insights_management_general">General</string>
14981498
<string name="stats_insights_management_posts_and_pages">Posts and Pages</string>

WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/UiModelMapperTest.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ import org.wordpress.android.BaseUnitTest
99
import org.wordpress.android.R
1010
import org.wordpress.android.fluxc.store.StatsStore.InsightType.TOTAL_FOLLOWERS
1111
import org.wordpress.android.fluxc.store.StatsStore.ManagementType
12-
import org.wordpress.android.ui.stats.refresh.lists.StatsBlock.Success
1312
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.UiModel
1413
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseModel
1514
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseModel.UseCaseState.SUCCESS
1615
import org.wordpress.android.util.NetworkUtilsWrapper
1716

1817
@ExperimentalCoroutinesApi
19-
class UiModelMapperTest : BaseUnitTest() {
18+
class UiModelMapperTest : BaseUnitTest() {
2019
@Mock
2120
lateinit var networkUtilsWrapper: NetworkUtilsWrapper
2221
private lateinit var mapper: UiModelMapper
@@ -40,10 +39,10 @@ class UiModelMapperTest : BaseUnitTest() {
4039

4140
val model = uiModel as UiModel.Success
4241
assertThat(model.data).hasSize(2)
43-
assertThat((model.data[0] as Success).statsType).isEqualTo(TOTAL_FOLLOWERS)
42+
assertThat((model.data[0] as StatsBlock.Success).statsType).isEqualTo(TOTAL_FOLLOWERS)
4443
assertThat(model.data[0].type).isEqualTo(StatsBlock.Type.SUCCESS)
4544
assertThat(model.data[0].data).isEmpty()
46-
assertThat((model.data[1] as Success).statsType).isEqualTo(ManagementType.CONTROL)
45+
assertThat((model.data[1] as StatsBlock.Success).statsType).isEqualTo(ManagementType.CONTROL)
4746
assertThat(model.data[1].type).isEqualTo(StatsBlock.Type.SUCCESS)
4847
assertThat(model.data[1].data).isEmpty()
4948
assertThat(error).isNull()
@@ -64,7 +63,6 @@ class UiModelMapperTest : BaseUnitTest() {
6463
val model = uiModel as UiModel.Empty
6564
assertThat(model.title).isEqualTo(R.string.stats_empty_insights_title)
6665
assertThat(model.subtitle).isEqualTo(R.string.stats_insights_management_title)
67-
assertThat(model.image).isEqualTo(R.drawable.img_illustration_insights_94dp)
6866
assertThat(model.showButton).isTrue()
6967
assertThat(error).isNull()
7068
}

0 commit comments

Comments
 (0)