From 967ca198fcfb1f8756878853784e402d7001e10a Mon Sep 17 00:00:00 2001 From: osodebailar Date: Thu, 14 Apr 2022 15:19:38 +0200 Subject: [PATCH] objective colors by attribut --- .../constraints/objectives/ObjectivesFragment.kt | 16 +++++++++------- .../objectives/objectives/Objective.kt | 2 +- core/src/main/res/values-night/colors.xml | 6 ++++-- core/src/main/res/values-night/styles.xml | 5 +++++ core/src/main/res/values/attrs.xml | 5 +++++ core/src/main/res/values/colors.xml | 8 +++++--- core/src/main/res/values/styles.xml | 5 +++++ 7 files changed, 34 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index 5b412076b5..7b254e4f72 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.constraints.objectives +import android.annotation.SuppressLint import android.graphics.Color import android.os.Bundle import android.os.Handler @@ -153,6 +154,7 @@ class ObjectivesFragment : DaggerFragment() { return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.objectives_item, parent, false)) } + @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: ViewHolder, position: Int) { val objective = objectivesPlugin.objectives[position] holder.binding.title.text = rh.gs(R.string.nth_objective, position + 1) @@ -167,7 +169,7 @@ class ObjectivesFragment : DaggerFragment() { } else holder.binding.gate.visibility = View.GONE if (!objective.isStarted) { - holder.binding.gate.setTextColor(-0x1) + holder.binding.gate.setTextColor(rh.gac(context, R.attr.defaultTextColor)) holder.binding.verify.visibility = View.GONE holder.binding.progress.visibility = View.GONE holder.binding.accomplished.visibility = View.GONE @@ -178,7 +180,7 @@ class ObjectivesFragment : DaggerFragment() { else holder.binding.start.visibility = View.GONE } else if (objective.isAccomplished) { - holder.binding.gate.setTextColor(-0xb350b0) + holder.binding.gate.setTextColor(rh.gac(context, R.attr.isAccomplishedColor)) holder.binding.verify.visibility = View.GONE holder.binding.progress.visibility = View.GONE holder.binding.start.visibility = View.GONE @@ -186,7 +188,7 @@ class ObjectivesFragment : DaggerFragment() { holder.binding.unfinish.visibility = View.VISIBLE holder.binding.unstart.visibility = View.GONE } else if (objective.isStarted) { - holder.binding.gate.setTextColor(-0x1) + holder.binding.gate.setTextColor(rh.gac(context,R.attr.defaultTextColor)) holder.binding.verify.visibility = View.VISIBLE holder.binding.verify.isEnabled = objective.isCompleted || binding.fake.isChecked holder.binding.start.visibility = View.GONE @@ -200,7 +202,7 @@ class ObjectivesFragment : DaggerFragment() { // name val name = TextView(holder.binding.progress.context) name.text = "${rh.gs(task.task)}:" - name.setTextColor(-0x1) + name.setTextColor(rh.gac(context,R.attr.defaultTextColor) ) holder.binding.progress.addView(name, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT) // hint task.hints.forEach { h -> @@ -209,9 +211,9 @@ class ObjectivesFragment : DaggerFragment() { } // state val state = TextView(holder.binding.progress.context) - state.setTextColor(-0x1) + state.setTextColor(rh.gac(context,R.attr.defaultTextColor)) val basicHTML = "%2\$s" - val formattedHTML = String.format(basicHTML, if (task.isCompleted()) "#4CAF50" else "#FF9800", task.progress) + val formattedHTML = String.format(basicHTML, if (task.isCompleted()) rh.gac(context, R.attr.isCompletedColor) else rh.gac(context, R.attr.isNotCompletedColor), task.progress) state.text = HtmlHelper.fromHtml(formattedHTML) state.gravity = Gravity.END holder.binding.progress.addView(state, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT) @@ -228,7 +230,7 @@ class ObjectivesFragment : DaggerFragment() { } // horizontal line val separator = View(holder.binding.progress.context) - separator.setBackgroundColor(Color.DKGRAY) + separator.setBackgroundColor(rh.gac(context, R.attr.seperatorColor)) holder.binding.progress.addView(separator, LinearLayout.LayoutParams.MATCH_PARENT, 2) } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.kt index 0da7daa37c..9faa974d1f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.kt @@ -176,7 +176,7 @@ abstract class Objective(injector: HasAndroidInjector, spName: String, @StringRe textView.setText(hint) textView.autoLinkMask = Linkify.WEB_URLS textView.linksClickable = true - textView.setLinkTextColor(Color.YELLOW) + textView.setLinkTextColor(rh.gac(context, R.attr.colorSecondary)) Linkify.addLinks(textView, Linkify.WEB_URLS) return textView } diff --git a/core/src/main/res/values-night/colors.xml b/core/src/main/res/values-night/colors.xml index a75dfe6902..ff02e8002f 100644 --- a/core/src/main/res/values-night/colors.xml +++ b/core/src/main/res/values-night/colors.xml @@ -183,8 +183,6 @@ #ffffbb33 #ffff4444 - #779ECB - #f4d700 #67dfe8 #67dfe8 @@ -196,7 +194,11 @@ #FFDD7792 #ca77dd + #779ECB #FF5722 + #67e86a + #4CAF50 + #FF9800 #de7550 #25912e diff --git a/core/src/main/res/values-night/styles.xml b/core/src/main/res/values-night/styles.xml index f7b6521c01..83e203d0ae 100644 --- a/core/src/main/res/values-night/styles.xml +++ b/core/src/main/res/values-night/styles.xml @@ -239,6 +239,11 @@ @color/textAppearancemediumDark @style/Aaps_ActionBarStyle + + @color/isAccomplished + @color/sphere_plastic_grey + @color/isCompleted + @color/isNotCompleted