objective colors by attribut

This commit is contained in:
osodebailar 2022-04-14 15:19:38 +02:00
parent baf740fc6d
commit 967ca198fc
7 changed files with 34 additions and 13 deletions

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.constraints.objectives package info.nightscout.androidaps.plugins.constraints.objectives
import android.annotation.SuppressLint
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
@ -153,6 +154,7 @@ class ObjectivesFragment : DaggerFragment() {
return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.objectives_item, parent, false)) return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.objectives_item, parent, false))
} }
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val objective = objectivesPlugin.objectives[position] val objective = objectivesPlugin.objectives[position]
holder.binding.title.text = rh.gs(R.string.nth_objective, position + 1) holder.binding.title.text = rh.gs(R.string.nth_objective, position + 1)
@ -167,7 +169,7 @@ class ObjectivesFragment : DaggerFragment() {
} else } else
holder.binding.gate.visibility = View.GONE holder.binding.gate.visibility = View.GONE
if (!objective.isStarted) { 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.verify.visibility = View.GONE
holder.binding.progress.visibility = View.GONE holder.binding.progress.visibility = View.GONE
holder.binding.accomplished.visibility = View.GONE holder.binding.accomplished.visibility = View.GONE
@ -178,7 +180,7 @@ class ObjectivesFragment : DaggerFragment() {
else else
holder.binding.start.visibility = View.GONE holder.binding.start.visibility = View.GONE
} else if (objective.isAccomplished) { } 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.verify.visibility = View.GONE
holder.binding.progress.visibility = View.GONE holder.binding.progress.visibility = View.GONE
holder.binding.start.visibility = View.GONE holder.binding.start.visibility = View.GONE
@ -186,7 +188,7 @@ class ObjectivesFragment : DaggerFragment() {
holder.binding.unfinish.visibility = View.VISIBLE holder.binding.unfinish.visibility = View.VISIBLE
holder.binding.unstart.visibility = View.GONE holder.binding.unstart.visibility = View.GONE
} else if (objective.isStarted) { } 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.visibility = View.VISIBLE
holder.binding.verify.isEnabled = objective.isCompleted || binding.fake.isChecked holder.binding.verify.isEnabled = objective.isCompleted || binding.fake.isChecked
holder.binding.start.visibility = View.GONE holder.binding.start.visibility = View.GONE
@ -200,7 +202,7 @@ class ObjectivesFragment : DaggerFragment() {
// name // name
val name = TextView(holder.binding.progress.context) val name = TextView(holder.binding.progress.context)
name.text = "${rh.gs(task.task)}:" 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) holder.binding.progress.addView(name, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
// hint // hint
task.hints.forEach { h -> task.hints.forEach { h ->
@ -209,9 +211,9 @@ class ObjectivesFragment : DaggerFragment() {
} }
// state // state
val state = TextView(holder.binding.progress.context) val state = TextView(holder.binding.progress.context)
state.setTextColor(-0x1) state.setTextColor(rh.gac(context,R.attr.defaultTextColor))
val basicHTML = "<font color=\"%1\$s\"><b>%2\$s</b></font>" val basicHTML = "<font color=\"%1\$s\"><b>%2\$s</b></font>"
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.text = HtmlHelper.fromHtml(formattedHTML)
state.gravity = Gravity.END state.gravity = Gravity.END
holder.binding.progress.addView(state, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT) holder.binding.progress.addView(state, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
@ -228,7 +230,7 @@ class ObjectivesFragment : DaggerFragment() {
} }
// horizontal line // horizontal line
val separator = View(holder.binding.progress.context) 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) holder.binding.progress.addView(separator, LinearLayout.LayoutParams.MATCH_PARENT, 2)
} }
} }

View file

@ -176,7 +176,7 @@ abstract class Objective(injector: HasAndroidInjector, spName: String, @StringRe
textView.setText(hint) textView.setText(hint)
textView.autoLinkMask = Linkify.WEB_URLS textView.autoLinkMask = Linkify.WEB_URLS
textView.linksClickable = true textView.linksClickable = true
textView.setLinkTextColor(Color.YELLOW) textView.setLinkTextColor(rh.gac(context, R.attr.colorSecondary))
Linkify.addLinks(textView, Linkify.WEB_URLS) Linkify.addLinks(textView, Linkify.WEB_URLS)
return textView return textView
} }

View file

@ -183,8 +183,6 @@
<color name="action">#ffffbb33</color> <color name="action">#ffffbb33</color>
<color name="alarm">#ffff4444</color> <color name="alarm">#ffff4444</color>
<color name="cardObjectiveText">#779ECB</color>
<color name="colorAcceptTempButton">#f4d700</color> <color name="colorAcceptTempButton">#f4d700</color>
<color name="colorTreatmentButton">#67dfe8</color> <color name="colorTreatmentButton">#67dfe8</color>
<color name="colorInsulinButton">#67dfe8</color> <color name="colorInsulinButton">#67dfe8</color>
@ -196,7 +194,11 @@
<color name="colorSetExtendedButton">#FFDD7792</color> <color name="colorSetExtendedButton">#FFDD7792</color>
<color name="colorProfileSwitchButton">#ca77dd</color> <color name="colorProfileSwitchButton">#ca77dd</color>
<color name="cardObjectiveText">#779ECB</color>
<color name="colorObjectivesDisabledText">#FF5722</color> <color name="colorObjectivesDisabledText">#FF5722</color>
<color name="isAccomplished">#67e86a</color>
<color name="isCompleted">#4CAF50</color>
<color name="isNotCompleted">#FF9800</color>
<color name="colorScheduled">#de7550</color> <color name="colorScheduled">#de7550</color>
<color name="colorActive">#25912e</color> <color name="colorActive">#25912e</color>

View file

@ -239,6 +239,11 @@
<item name="textAppearancemediumColor">@color/textAppearancemediumDark</item> <item name="textAppearancemediumColor">@color/textAppearancemediumDark</item>
<!-- Actionbar --> <!-- Actionbar -->
<item name="actionBarStyle">@style/Aaps_ActionBarStyle</item> <item name="actionBarStyle">@style/Aaps_ActionBarStyle</item>
<!-- Objectives specific colors -->
<item name="isAccomplishedColor">@color/isAccomplished</item>
<item name="seperatorColor">@color/sphere_plastic_grey</item>
<item name="isCompletedColor">@color/isCompleted</item>
<item name="isNotCompletedColor">@color/isNotCompleted</item>
</style> </style>
<style name="Aaps_ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar"> <style name="Aaps_ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">

View file

@ -216,4 +216,9 @@
<!-- CardView specific colors --> <!-- CardView specific colors -->
<attr name="strokeColor" format="reference|color" /> <attr name="strokeColor" format="reference|color" />
<attr name="textAppearancemediumColor" format="reference|color" /> <attr name="textAppearancemediumColor" format="reference|color" />
<!-- Objectives specific colors -->
<attr name="isAccomplishedColor" format="reference|color" />
<attr name="seperatorColor" format="reference|color" />
<attr name="isCompletedColor" format="reference|color" />
<attr name="isNotCompletedColor" format="reference|color" />
</resources> </resources>

View file

@ -168,7 +168,7 @@
<color name="bgi">#00EEEE</color> <color name="bgi">#00EEEE</color>
<color name="devslopepos">#FFFFFF00</color> <color name="devslopepos">#FFFFFF00</color>
<color name="devslopeneg">#FFFF00FF</color> <color name="devslopeneg">#FFFF00FF</color>
<color name="actionsConfirm">#FFFF00</color> <color name="actionsConfirm">#F6CE22</color>
<color name="deviations">#FF0000</color> <color name="deviations">#FF0000</color>
<color name="cobAlert">#7484E2</color> <color name="cobAlert">#7484E2</color>
<color name="inrangebackground">#2800FF00</color> <color name="inrangebackground">#2800FF00</color>
@ -186,8 +186,6 @@
<color name="action">#ffffbb33</color> <color name="action">#ffffbb33</color>
<color name="alarm">#ffff4444</color> <color name="alarm">#ffff4444</color>
<color name="cardObjectiveText">#779ECB</color>
<color name="colorAcceptTempButton">#E19701</color> <color name="colorAcceptTempButton">#E19701</color>
<color name="colorTreatmentButton">#006493</color> <color name="colorTreatmentButton">#006493</color>
<color name="colorInsulinButton">#67dfe8</color> <color name="colorInsulinButton">#67dfe8</color>
@ -199,7 +197,11 @@
<color name="colorSetExtendedButton">#FFDD7792</color> <color name="colorSetExtendedButton">#FFDD7792</color>
<color name="colorProfileSwitchButton">#ca77dd</color> <color name="colorProfileSwitchButton">#ca77dd</color>
<color name="cardObjectiveText">#779ECB</color>
<color name="colorObjectivesDisabledText">#FF5722</color> <color name="colorObjectivesDisabledText">#FF5722</color>
<color name="isAccomplished">#25912e</color>
<color name="isCompleted">#4CAF50</color>
<color name="isNotCompleted">#FF9800</color>
<color name="colorScheduled">#de7550</color> <color name="colorScheduled">#de7550</color>
<color name="colorActive">#25912e</color> <color name="colorActive">#25912e</color>

View file

@ -242,6 +242,11 @@
<item name="textAppearancemediumColor">@color/textAppearancemediumLight</item> <item name="textAppearancemediumColor">@color/textAppearancemediumLight</item>
<!-- Actionbar --> <!-- Actionbar -->
<item name="actionBarStyle">@style/Aaps_ActionBarStyle</item> <item name="actionBarStyle">@style/Aaps_ActionBarStyle</item>
<!-- Objectives specific colors -->
<item name="isAccomplishedColor">@color/isAccomplished</item>
<item name="seperatorColor">@color/sphere_plastic_grey</item>
<item name="isCompletedColor">@color/isCompleted</item>
<item name="isNotCompletedColor">@color/isNotCompleted</item>
</style> </style>
<style name="Aaps_ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar"> <style name="Aaps_ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">