diff --git a/app/src/main/java/org/openobservatory/ooniprobe/fragment/dashboard/DashboardViewModel.kt b/app/src/main/java/org/openobservatory/ooniprobe/fragment/dashboard/DashboardViewModel.kt index 009a3cab0..99f814071 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/fragment/dashboard/DashboardViewModel.kt +++ b/app/src/main/java/org/openobservatory/ooniprobe/fragment/dashboard/DashboardViewModel.kt @@ -3,13 +3,14 @@ package org.openobservatory.ooniprobe.fragment.dashboard import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel +import org.openobservatory.ooniprobe.BuildConfig import org.openobservatory.ooniprobe.common.PreferenceManager import org.openobservatory.ooniprobe.test.TestAsyncTask import org.openobservatory.ooniprobe.test.suite.AbstractSuite import javax.inject.Inject class DashboardViewModel @Inject constructor(private val preferenceManager: PreferenceManager) : ViewModel() { - private val enabledTitle: String = "Enabled" + private val enabledTitle: String = "Enabled" private val groupedItemList = MutableLiveData>() val items = MutableLiveData>(TestAsyncTask.getSuites()) @@ -22,10 +23,12 @@ class DashboardViewModel @Inject constructor(private val preferenceManager: Pref private fun fetchItemList() { - val groupedItems = items.value!!.sortedBy { it.getTestList(preferenceManager).isEmpty() } + val groupedItems = items.value!!.filter {testSuite -> + return@filter testSuite.getTestList(preferenceManager).isNotEmpty() || BuildConfig.SHOW_DISABLED_CARDS + }.sortedBy { it.getTestList(preferenceManager).isEmpty() } .groupBy { return@groupBy if ((it.getTestList(preferenceManager).isNotEmpty())) { - enabledTitle + enabledTitle } else { "" } @@ -33,7 +36,7 @@ class DashboardViewModel @Inject constructor(private val preferenceManager: Pref val groupedItemList = mutableListOf() groupedItems.forEach { (status, itemList) -> - if (status != enabledTitle){ + if (status != enabledTitle) { groupedItemList.add(status) } groupedItemList.addAll(itemList)