Skip to content

Commit

Permalink
Updated rules for storing preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed Nov 3, 2023
1 parent 20a3160 commit 5fbc024
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,11 @@ class RunTestsViewModel() : ViewModel() {
}

fun disableTest(name: String) {
if (!ExperimentalSuite().getTestList(preferenceManager).map { it.name }.contains(name)) {
preferenceManager.disableTest(name)
}
preferenceManager.disableTest(name)
}

fun enableTest(name: String) {
if (!ExperimentalSuite().getTestList(preferenceManager).map { it.name }.contains(name)) {
preferenceManager.enableTest(name)
}
preferenceManager.enableTest(name)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ class RunTestsExpandableListViewAdapter(
}
} else {
groupSelectionIndicator.setImageResource(R.drawable.check_box_outline_blank)
if (groupItem.name == ExperimentalSuite.NAME) {
mViewModel.disableTest(ExperimentalSuite.NAME)
}
}
} else {
groupSelectionIndicator.setImageResource(R.drawable.check_box_outline_blank)
if (groupItem.name == ExperimentalSuite.NAME) {
mViewModel.disableTest(ExperimentalSuite.NAME)
}
}
groupSelectionIndicator.setOnClickListener {
if (groupItem.selected && isSelectAllChildItems(groupItem.nettests)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,31 @@ import org.openobservatory.ooniprobe.test.suite.ExperimentalSuite
import org.openobservatory.ooniprobe.test.test.*


fun PreferenceManager.enableTest(name: String) {
this.setValue(name, true)
private fun PreferenceManager.exclusionList(): MutableList<String> {
val exclusionList = mutableListOf<String>()
ExperimentalSuite().run {
exclusionList.addAll(getTestList(this@exclusionList).map { it.name })
exclusionList.addAll(longRunningTests().map { it.name })
}

return exclusionList

}

fun PreferenceManager.disableTest(name: String) {
this.setValue(name, false)
fun PreferenceManager.enableTest(name: String): Boolean {
if (!exclusionList().contains(name)) {
this.setValue(name, true)
return true
}
return false
}

fun PreferenceManager.disableTest(name: String): Boolean {
if (!exclusionList().contains(name)) {
this.setValue(name, false)
return true
}
return false
}

fun PreferenceManager.setValue(name: String, value: Boolean) {
Expand Down

0 comments on commit 5fbc024

Please sign in to comment.