Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: (OONI Run v2) Web connectivity tests always appears selected, even if deselected #698

Merged
merged 1 commit into from
Mar 21, 2024
Merged
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 @@ -63,30 +63,14 @@ class DashboardAdapter(
if (item is InstalledDescriptor){
icon.setColorFilter(item.color)
}
} }
holder.itemView.tag = item
if (!item.isEnabled(preferenceManager)) {
holder.setIsRecyclable(false)
holder.itemView.apply {
elevation = 0f
isClickable = false
}
val resources: Resources = holder.itemView.context.resources
(holder.itemView as CardView).setCardBackgroundColor(resources.getColor(R.color.disabled_test_background))
holder.binding.apply {
title.setTextColor(resources.getColor(R.color.disabled_test_text))
desc.setTextColor(resources.getColor(R.color.disabled_test_text))
icon.setColorFilter(
resources.getColor(R.color.disabled_test_text),
PorterDuff.Mode.SRC_IN
)
}
} else {
holder.itemView.setOnClickListener(onClickListener)
}
holder.itemView.tag = item
holder.itemView.setOnClickListener(onClickListener)
}
}
}
holder.setIsRecyclable(false)
}

override fun getItemCount(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ abstract class AbstractDescriptor<T : BaseNettest>(
open fun isEnabled(preferenceManager: PreferenceManager): Boolean {
return when (name) {
OONITests.EXPERIMENTAL.label -> preferenceManager.isExperimentalOn
OONITests.WEBSITES.label -> preferenceManager.countEnabledCategory() > 0
else -> nettests.any {
preferenceManager.resolveStatus(
name = it.name,
Expand Down Expand Up @@ -120,7 +119,6 @@ abstract class AbstractDescriptor<T : BaseNettest>(
ChildItem(
selected = when (name) {
OONITests.EXPERIMENTAL.label -> preferenceManager.isExperimentalOn
OONITests.WEBSITES.label -> preferenceManager.countEnabledCategory() > 0
else -> preferenceManager.resolveStatus(
name = nettest.name,
prefix = preferencePrefix(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ fun PreferenceManager.resolveStatus(
name: String, prefix: String, autoRun: Boolean = false
): Boolean {
if (!autoRun) {
if (name == WebConnectivity.NAME) {
return true
} else if (experimentalTestList().contains(name)) {
if (experimentalTestList().contains(name)) {
return isExperimentalOn
}
}
Expand Down Expand Up @@ -79,7 +77,6 @@ private fun PreferenceManager.setValue(
if (experimentalTestList().contains(name) && !autoRun) {
return false
}
val key = getPreferenceKey(name = name, prefix = prefix, autoRun = autoRun)

return with(sp.edit()) {
putBoolean(getPreferenceKey(name = name, prefix = prefix, autoRun = autoRun), value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ class DashboardViewModel @Inject constructor(

private fun fetchItemList() {

val groupedItems = items.value!!.sortedBy { !it.isEnabled(preferenceManager) }
.groupBy {
val groupedItems = items.value!!.groupBy {
return@groupBy if (oonTests.contains(it)) {
oonTestsTitle
} else {
Expand Down
Loading