Skip to content

Commit

Permalink
Updated support for colors in test results fragment and add prefix wh…
Browse files Browse the repository at this point in the history
…en fetching preferences in `RunTestsActivity`
  • Loading branch information
aanorbel committed Feb 15, 2024
1 parent b78e42f commit 01d76d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ class RunTestsActivity : AbstractActivity() {
}
else -> group.nettests.forEach { nettest ->
when(nettest.selected) {
true -> preferenceManager.enableTest(nettest.name)
false -> preferenceManager.disableTest(nettest.name)
true -> preferenceManager.enableTest(nettest.name, group.preferencePrefix())
false -> preferenceManager.disableTest(nettest.name, group.preferencePrefix())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.openobservatory.ooniprobe.common.AbstractDescriptor
import org.openobservatory.ooniprobe.common.PreferenceManager
import org.openobservatory.ooniprobe.databinding.ItemSeperatorBinding
import org.openobservatory.ooniprobe.databinding.ItemTestsuiteBinding
import org.openobservatory.ooniprobe.model.database.InstalledDescriptor

class DashboardAdapter(
private val items: List<Any>,
Expand Down Expand Up @@ -58,7 +59,11 @@ class DashboardAdapter(
cardHolder.binding.apply {
title.setText(item.title)
desc.setText(item.shortDescription)
icon.setImageResource(item.getDisplayIcon(holder.itemView.context))
icon.setImageResource(item.getDisplayIcon(holder.itemView.context)).also {
if (item is InstalledDescriptor){
icon.setColorFilter(item.color)
}
}
}
holder.itemView.tag = item
if (!item.isEnabled(preferenceManager)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class RunItem(
viewHolder?.itemView?.context?.let { context ->
extra.getDescriptor(context).get().let { descriptor ->
viewHolder.binding?.icon?.setImageResource(descriptor.getDisplayIcon(context))
viewHolder.binding?.icon?.setColorFilter(descriptor.color)
viewHolder.binding?.name?.text = descriptor.title
viewHolder.binding?.name?.setTextColor(descriptor.color)
}
}
}
}
}

0 comments on commit 01d76d5

Please sign in to comment.