From 60db89fb91c31a4657109d0478be540e711c0b92 Mon Sep 17 00:00:00 2001 From: Norbel AMBANUMBEN Date: Mon, 19 Feb 2024 14:11:03 +0100 Subject: [PATCH 1/2] Updated `ResultDetailActivity` --- .../ooniprobe/activity/ResultDetailActivity.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/openobservatory/ooniprobe/activity/ResultDetailActivity.kt b/app/src/main/java/org/openobservatory/ooniprobe/activity/ResultDetailActivity.kt index d2f51f73b..a6ef2de56 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/activity/ResultDetailActivity.kt +++ b/app/src/main/java/org/openobservatory/ooniprobe/activity/ResultDetailActivity.kt @@ -203,13 +203,10 @@ class ResultDetailActivity : AbstractActivity(), View.OnClickListener, OnConfirm */ private fun setThemeFromDescriptor() { result.getDescriptor(this).get().let { desriptor -> - if (desriptor is OONIDescriptor<*>) { - val color = ContextCompat.getColor(this@ResultDetailActivity, desriptor.color) - binding.toolbar.setBackgroundColor(color) - binding.appBar.setBackgroundColor(color) - binding.tabLayout.setBackgroundColor(color) - window.statusBarColor = color - } + binding.toolbar.setBackgroundColor(desriptor.color) + binding.appBar.setBackgroundColor(desriptor.color) + binding.tabLayout.setBackgroundColor(desriptor.color) + window.statusBarColor = desriptor.color } } From 00f9abbb1d25d568099f128724dbe57ecacc7f46 Mon Sep 17 00:00:00 2001 From: Norbel AMBANUMBEN Date: Mon, 19 Feb 2024 14:16:28 +0100 Subject: [PATCH 2/2] Updated support for colors in test results fragment and add prefix when fetching preferences in `RunTestsActivity` --- .../ooniprobe/activity/runtests/RunTestsActivity.kt | 4 ++-- .../ooniprobe/adapters/DashboardAdapter.kt | 8 ++++++-- .../java/org/openobservatory/ooniprobe/item/RunItem.kt | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/openobservatory/ooniprobe/activity/runtests/RunTestsActivity.kt b/app/src/main/java/org/openobservatory/ooniprobe/activity/runtests/RunTestsActivity.kt index b7a33f03d..219b01e0f 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/activity/runtests/RunTestsActivity.kt +++ b/app/src/main/java/org/openobservatory/ooniprobe/activity/runtests/RunTestsActivity.kt @@ -145,8 +145,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()) } } } diff --git a/app/src/main/java/org/openobservatory/ooniprobe/adapters/DashboardAdapter.kt b/app/src/main/java/org/openobservatory/ooniprobe/adapters/DashboardAdapter.kt index c01ce9a16..a731b0cff 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/adapters/DashboardAdapter.kt +++ b/app/src/main/java/org/openobservatory/ooniprobe/adapters/DashboardAdapter.kt @@ -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, @@ -58,8 +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)) { holder.setIsRecyclable(false) diff --git a/app/src/main/java/org/openobservatory/ooniprobe/item/RunItem.kt b/app/src/main/java/org/openobservatory/ooniprobe/item/RunItem.kt index 67090104b..864644702 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/item/RunItem.kt +++ b/app/src/main/java/org/openobservatory/ooniprobe/item/RunItem.kt @@ -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) } } } -} \ No newline at end of file +}