Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,6 @@ class StatsListFragment : ViewPagerFragment(R.layout.stats_list_fragment), PullT
@SuppressLint("SetTextI18n")
emptyView.statsEmptyView.subtitle.text = ""
}
if (it.image != null) {
emptyView.statsEmptyView.image.setImageResource(it.image)
} else {
emptyView.statsEmptyView.image.setImageDrawable(null)
}
emptyView.statsEmptyView.button.setVisible(it.showButton)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ abstract class StatsListViewModel(
data class Empty(
val title: Int,
val subtitle: Int? = null,
val image: Int? = null,
val showButton: Boolean = false
) : UiModel()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import javax.inject.Inject
class UiModelMapper
@Inject constructor(private val networkUtilsWrapper: NetworkUtilsWrapper) {
fun mapInsights(useCaseModels: List<UseCaseModel>, showError: (Int) -> Unit): UiModel {
// TODO remove this before merging
return UiModel.Empty(
title = R.string.stats_empty_insights_title,
subtitle = R.string.stats_insights_management_title,
showButton = true
)
val insightUseCaseModels = useCaseModels.filter { it.type is InsightType }
if (insightUseCaseModels.isNotEmpty()) {
val allFailing = allFailing(insightUseCaseModels)
Expand Down Expand Up @@ -48,10 +54,9 @@ class UiModelMapper
}
} else {
return UiModel.Empty(
R.string.stats_empty_insights_title,
R.string.stats_insights_management_title,
R.drawable.img_illustration_insights_94dp,
true
title = R.string.stats_empty_insights_title,
subtitle = R.string.stats_insights_management_title,
showButton = true
)
}
}
Expand Down
1 change: 0 additions & 1 deletion WordPress/src/main/res/layout/stats_empty_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
android:layout_height="match_parent"
android:visibility="gone"
app:aevButton="@string/stats_manage_insights"
app:aevImage="@drawable/img_illustration_insights_94dp"
app:aevSubtitle="@string/stats_insights_management_title"
app:aevTitle="@string/stats_empty_insights_title"
tools:visibility="visible" />
4 changes: 2 additions & 2 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1490,9 +1490,9 @@
<string name="stats_insights_linkedin">LinkedIn</string>
<string name="stats_insights_path">Path</string>
<string name="stats_most_popular_percent_views">%1$s of views</string>
<string name="stats_most_popular_percent_views_empty">Not enough activity. Check back later when your site\'s had more visitors!</string>
<string name="stats_most_popular_percent_views_empty">Not enough activity. Check back when your site had more visitors!</string>
<string name="stats_insights_posting_activity">Posting Activity</string>
<string name="stats_insights_management_title">Only see the most relevant stats. Add and organise your insights below.</string>
<string name="stats_insights_management_title">Manage your insights to see only the most relevant stats</string>

<string name="stats_insights_management_general">General</string>
<string name="stats_insights_management_posts_and_pages">Posts and Pages</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.wordpress.android.BaseUnitTest
import org.wordpress.android.R
import org.wordpress.android.fluxc.store.StatsStore.InsightType.TOTAL_FOLLOWERS
import org.wordpress.android.fluxc.store.StatsStore.ManagementType
import org.wordpress.android.ui.stats.refresh.lists.StatsBlock.Success
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.UiModel
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseModel
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseModel.UseCaseState.SUCCESS
Expand All @@ -26,8 +25,9 @@ class UiModelMapperTest : BaseUnitTest() {
mapper = UiModelMapper(networkUtilsWrapper)
}

// TODO restore this test when removing the forced empty view in UiModelMapper.mapInsights
@Test
fun `mapInsights returns success ui model when all the inputs are successful`() {
fun `mapInsights returns empty ui model`() {
var error: Int? = null
val uiModel = mapper.mapInsights(
listOf(
Expand All @@ -38,14 +38,10 @@ class UiModelMapperTest : BaseUnitTest() {
error = it
}

val model = uiModel as UiModel.Success
assertThat(model.data).hasSize(2)
assertThat((model.data[0] as Success).statsType).isEqualTo(TOTAL_FOLLOWERS)
assertThat(model.data[0].type).isEqualTo(StatsBlock.Type.SUCCESS)
assertThat(model.data[0].data).isEmpty()
assertThat((model.data[1] as Success).statsType).isEqualTo(ManagementType.CONTROL)
assertThat(model.data[1].type).isEqualTo(StatsBlock.Type.SUCCESS)
assertThat(model.data[1].data).isEmpty()
val model = uiModel as UiModel.Empty
assertThat(model.title).isEqualTo(R.string.stats_empty_insights_title)
assertThat(model.subtitle).isEqualTo(R.string.stats_insights_management_title)
assertThat(model.showButton).isTrue()
assertThat(error).isNull()
}

Expand All @@ -64,7 +60,6 @@ class UiModelMapperTest : BaseUnitTest() {
val model = uiModel as UiModel.Empty
assertThat(model.title).isEqualTo(R.string.stats_empty_insights_title)
assertThat(model.subtitle).isEqualTo(R.string.stats_insights_management_title)
assertThat(model.image).isEqualTo(R.drawable.img_illustration_insights_94dp)
assertThat(model.showButton).isTrue()
assertThat(error).isNull()
}
Expand Down