graphdata treatmentdata by attribut and final preperations

This commit is contained in:
osodebailar 2022-04-02 15:35:44 +02:00
parent 15e7aa59a2
commit d1e163988e
20 changed files with 168 additions and 81 deletions

View file

@ -205,7 +205,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
binding.bgGraph.gridLabelRenderer?.reloadStyles() binding.bgGraph.gridLabelRenderer?.reloadStyles()
binding.bgGraph.gridLabelRenderer?.labelVerticalWidth = axisWidth binding.bgGraph.gridLabelRenderer?.labelVerticalWidth = axisWidth
overviewMenus.setupChartMenu(binding.chartMenuButton) overviewMenus.setupChartMenu(context, binding.chartMenuButton)
prepareGraphsIfNeeded(overviewMenus.setting.size) prepareGraphsIfNeeded(overviewMenus.setting.size)
savedInstanceState?.let { bundle -> savedInstanceState?.let { bundle ->
rangeToDisplay = bundle.getInt("rangeToDisplay", 0) rangeToDisplay = bundle.getInt("rangeToDisplay", 0)

View file

@ -548,7 +548,7 @@ class OverviewData @Inject constructor(
// ProfileSwitch // ProfileSwitch
repository.getEffectiveProfileSwitchDataFromTimeToTime(fromTime, endTime, true).blockingGet() repository.getEffectiveProfileSwitchDataFromTimeToTime(fromTime, endTime, true).blockingGet()
.map { EffectiveProfileSwitchDataPoint(it) } .map { EffectiveProfileSwitchDataPoint(it,rh) }
.forEach(filteredTreatments::add) .forEach(filteredTreatments::add)
// OfflineEvent // OfflineEvent
@ -566,7 +566,7 @@ class OverviewData @Inject constructor(
// Extended bolus // Extended bolus
if (!activePlugin.activePump.isFakingTempsByExtendedBoluses) { if (!activePlugin.activePump.isFakingTempsByExtendedBoluses) {
repository.getExtendedBolusDataFromTimeToTime(fromTime, endTime, true).blockingGet() repository.getExtendedBolusDataFromTimeToTime(fromTime, endTime, true).blockingGet()
.map { ExtendedBolusDataPoint(it) } .map { ExtendedBolusDataPoint(it, rh) }
.filter { it.duration != 0L } .filter { it.duration != 0L }
.forEach { .forEach {
it.y = getNearestBg(it.x.toLong()) it.y = getNearestBg(it.x.toLong())

View file

@ -197,7 +197,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
false false
} }
prepareGraphsIfNeeded(overviewMenus.setting.size) prepareGraphsIfNeeded(overviewMenus.setting.size)
overviewMenus.setupChartMenu(binding.graphsLayout.chartMenuButton) context?.let { overviewMenus.setupChartMenu(it, binding.graphsLayout.chartMenuButton) }
binding.activeProfile.setOnClickListener(this) binding.activeProfile.setOnClickListener(this)
binding.activeProfile.setOnLongClickListener(this) binding.activeProfile.setOnLongClickListener(this)

View file

@ -1,10 +1,13 @@
package info.nightscout.androidaps.plugins.general.overview package info.nightscout.androidaps.plugins.general.overview
import android.content.Context
import android.text.SpannableString import android.text.SpannableString
import android.text.style.BackgroundColorSpan
import android.text.style.ForegroundColorSpan import android.text.style.ForegroundColorSpan
import android.view.Menu import android.view.Menu
import android.view.View import android.view.View
import android.widget.ImageButton import android.widget.ImageButton
import androidx.annotation.AttrRes
import androidx.annotation.ColorRes import androidx.annotation.ColorRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
@ -31,18 +34,17 @@ class OverviewMenus @Inject constructor(
private val loop: Loop, private val loop: Loop,
private val config: Config private val config: Config
) { ) {
enum class CharType(@StringRes val nameId: Int, @AttrRes val attrId: Int, val primary: Boolean, val secondary: Boolean, @StringRes val shortnameId: Int) {
enum class CharType(@StringRes val nameId: Int, @ColorRes val colorId: Int, val primary: Boolean, val secondary: Boolean, @StringRes val shortnameId: Int) { PRE(R.string.overview_show_predictions, R.attr.predictionColor, primary = true, secondary = false, shortnameId = R.string.prediction_shortname),
PRE(R.string.overview_show_predictions, R.color.prediction, primary = true, secondary = false, shortnameId = R.string.prediction_shortname), BAS(R.string.overview_show_basals, R.attr.basal, primary = true, secondary = false,shortnameId = R.string.basal_shortname),
BAS(R.string.overview_show_basals, R.color.basal, primary = true, secondary = false, shortnameId = R.string.basal_shortname), ABS(R.string.overview_show_absinsulin, R.attr.iobColor, primary = false, secondary = true,shortnameId = R.string.abs_insulin_shortname),
ABS(R.string.overview_show_absinsulin, R.color.iob, primary = false, secondary = true, shortnameId = R.string.abs_insulin_shortname), IOB(R.string.overview_show_iob, R.attr.iobColor, primary = false, secondary = true,shortnameId = R.string.iob),
IOB(R.string.overview_show_iob, R.color.iob, primary = false, secondary = true, shortnameId = R.string.iob), COB(R.string.overview_show_cob, R.attr.cobColor, primary = false, secondary = true,shortnameId = R.string.cob),
COB(R.string.overview_show_cob, R.color.cob, primary = false, secondary = true, shortnameId = R.string.cob), DEV(R.string.overview_show_deviations, R.attr.bgiColor, primary = false, secondary = true,shortnameId = R.string.deviation_shortname),
DEV(R.string.overview_show_deviations, R.color.bgi, primary = false, secondary = true, shortnameId = R.string.deviation_shortname), BGI(R.string.overview_show_bgi, R.attr.bgiColor, primary = false, secondary = true,shortnameId = R.string.bgi_shortname),
BGI(R.string.overview_show_bgi, R.color.bgi, primary = false, secondary = true, shortnameId = R.string.bgi_shortname), SEN(R.string.overview_show_sensitivity, R.attr.ratioColor, primary = false, secondary = true,shortnameId = R.string.sensitivity_shortname),
SEN(R.string.overview_show_sensitivity, R.color.ratio, primary = false, secondary = true, shortnameId = R.string.sensitivity_shortname), ACT(R.string.overview_show_activity, R.attr.activityColor, primary = true, secondary = false,shortnameId = R.string.activity_shortname),
ACT(R.string.overview_show_activity, R.color.activity, primary = true, secondary = false, shortnameId = R.string.activity_shortname), DEVSLOPE(R.string.overview_show_deviationslope, R.attr.devslopeposColor, primary = false, secondary = true,shortnameId = R.string.devslope_shortname)
DEVSLOPE(R.string.overview_show_deviationslope, R.color.devslopepos, primary = false, secondary = true, shortnameId = R.string.devslope_shortname)
} }
companion object { companion object {
@ -86,7 +88,7 @@ class OverviewMenus @Inject constructor(
} }
} }
fun setupChartMenu(chartButton: ImageButton) { fun setupChartMenu(context: Context, chartButton: ImageButton) {
val settingsCopy = setting val settingsCopy = setting
val numOfGraphs = settingsCopy.size // 1 main + x secondary val numOfGraphs = settingsCopy.size // 1 main + x secondary
@ -120,7 +122,8 @@ class OverviewMenus @Inject constructor(
val item = popup.menu.add(Menu.NONE, m.ordinal + 100 * (g + 1), Menu.NONE, rh.gs(m.nameId)) val item = popup.menu.add(Menu.NONE, m.ordinal + 100 * (g + 1), Menu.NONE, rh.gs(m.nameId))
val title = item.title val title = item.title
val s = SpannableString(title) val s = SpannableString(title)
s.setSpan(ForegroundColorSpan(rh.gc(m.colorId)), 0, s.length, 0) s.setSpan(ForegroundColorSpan(rh.gc(R.color.black)), 0, s.length, 0)
s.setSpan(BackgroundColorSpan(rh.gac(context, m.attrId)), 0, s.length, 0)
item.title = s item.title = s
item.isCheckable = true item.isCheckable = true
item.isChecked = settingsCopy[g][m.ordinal] item.isChecked = settingsCopy[g][m.ordinal]
@ -152,7 +155,7 @@ class OverviewMenus @Inject constructor(
} }
} }
storeGraphConfig() storeGraphConfig()
setupChartMenu(chartButton) setupChartMenu(context, chartButton)
rxBus.send(EventRefreshOverview("OnMenuItemClickListener", now = true)) rxBus.send(EventRefreshOverview("OnMenuItemClickListener", now = true))
return@setOnMenuItemClickListener true return@setOnMenuItemClickListener true
} }

View file

@ -66,7 +66,7 @@ class GraphData(
addSeries(AreaGraphSeries(inRangeAreaDataPoints).also { addSeries(AreaGraphSeries(inRangeAreaDataPoints).also {
it.color = 0 it.color = 0
it.isDrawBackground = true it.isDrawBackground = true
it.backgroundColor = rh.gc(R.color.inrangebackground) it.backgroundColor = rh.gac(graph.context,R.attr.inrangeBackground)
}) })
} }

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.androidaps.plugins.general.overview.graphExtensions
import android.content.Context
import android.graphics.Color import android.graphics.Color
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.entities.Bolus import info.nightscout.androidaps.database.entities.Bolus
@ -28,13 +29,11 @@ class BolusDataPoint @Inject constructor(
override val shape override val shape
get() = if (data.type == Bolus.Type.SMB) PointsWithLabelGraphSeries.Shape.SMB else PointsWithLabelGraphSeries.Shape.BOLUS get() = if (data.type == Bolus.Type.SMB) PointsWithLabelGraphSeries.Shape.SMB else PointsWithLabelGraphSeries.Shape.BOLUS
override val color override fun color(context: Context?): Int =
get() = if (data.type == Bolus.Type.SMB) rh.gac(context, R.attr.smbColor)
when { else if (data.isValid) rh.gac(context, R.attr.bolusDataPointColor)
data.type == Bolus.Type.SMB -> rh.gc(R.color.tempbasal) else rh.gac(context, R.attr.alarmColor)
data.isValid -> Color.CYAN
else -> rh.gc(android.R.color.holo_red_light)
}
override fun setY(y: Double) { override fun setY(y: Double) {
yValue = y yValue = y

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.androidaps.plugins.general.overview.graphExtensions
import android.content.Context
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.entities.Carbs import info.nightscout.androidaps.database.entities.Carbs
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -18,7 +19,10 @@ class CarbsDataPoint @Inject constructor(
override val duration = 0L override val duration = 0L
override val size = 2f override val size = 2f
override val shape = PointsWithLabelGraphSeries.Shape.CARBS override val shape = PointsWithLabelGraphSeries.Shape.CARBS
override val color get() = if (data.isValid) rh.gc(R.color.carbs) else rh.gc(android.R.color.holo_red_light)
override fun color(context: Context?): Int {
return if (data.isValid) rh.gac(context, R.attr.cobColor) else rh.gac(context, R.attr.alarmColor)
}
override fun setY(y: Double) { override fun setY(y: Double) {
yValue = y yValue = y

View file

@ -1,11 +1,15 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.androidaps.plugins.general.overview.graphExtensions
import android.content.Context
import android.graphics.Color import android.graphics.Color
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.entities.EffectiveProfileSwitch import info.nightscout.androidaps.database.entities.EffectiveProfileSwitch
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject import javax.inject.Inject
class EffectiveProfileSwitchDataPoint @Inject constructor( class EffectiveProfileSwitchDataPoint @Inject constructor(
val data: EffectiveProfileSwitch val data: EffectiveProfileSwitch,
private val rh: ResourceHelper
) : DataPointWithLabelInterface { ) : DataPointWithLabelInterface {
private var yValue = 0.0 private var yValue = 0.0
@ -21,5 +25,7 @@ class EffectiveProfileSwitchDataPoint @Inject constructor(
override val duration = 0L override val duration = 0L
override val shape = PointsWithLabelGraphSeries.Shape.PROFILE override val shape = PointsWithLabelGraphSeries.Shape.PROFILE
override val size = 10f override val size = 10f
override val color = Color.CYAN override fun color(context: Context?): Int {
return rh.gac(context, R.attr.profileSwitchColor)
}
} }

View file

@ -1,12 +1,16 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.androidaps.plugins.general.overview.graphExtensions
import android.content.Context
import android.graphics.Color import android.graphics.Color
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.entities.ExtendedBolus import info.nightscout.androidaps.database.entities.ExtendedBolus
import info.nightscout.androidaps.extensions.toStringTotal import info.nightscout.androidaps.extensions.toStringTotal
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject import javax.inject.Inject
class ExtendedBolusDataPoint @Inject constructor( class ExtendedBolusDataPoint @Inject constructor(
val data: ExtendedBolus val data: ExtendedBolus,
private val rh: ResourceHelper
) : DataPointWithLabelInterface { ) : DataPointWithLabelInterface {
private var yValue = 0.0 private var yValue = 0.0
@ -17,7 +21,9 @@ class ExtendedBolusDataPoint @Inject constructor(
override val duration get() = data.duration override val duration get() = data.duration
override val size = 10f override val size = 10f
override val shape = PointsWithLabelGraphSeries.Shape.EXTENDEDBOLUS override val shape = PointsWithLabelGraphSeries.Shape.EXTENDEDBOLUS
override val color = Color.CYAN override fun color(context: Context?): Int {
return rh.gac(context, R.attr.extBolusColor)
}
override fun setY(y: Double) { override fun setY(y: Double) {
yValue = y yValue = y

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.androidaps.plugins.general.overview.graphExtensions
import android.content.Context
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.entities.GlucoseValue import info.nightscout.androidaps.database.entities.GlucoseValue
@ -27,28 +28,26 @@ class GlucoseValueDataPoint @Inject constructor(
override val duration = 0L override val duration = 0L
override val shape get() = if (isPrediction) PointsWithLabelGraphSeries.Shape.PREDICTION else PointsWithLabelGraphSeries.Shape.BG override val shape get() = if (isPrediction) PointsWithLabelGraphSeries.Shape.PREDICTION else PointsWithLabelGraphSeries.Shape.BG
override val size = 1f override val size = 1f
override val color: Int override fun color(context: Context?): Int {
get() {
val units = profileFunction.getUnits() val units = profileFunction.getUnits()
val lowLine = defaultValueHelper.determineLowLine() val lowLine = defaultValueHelper.determineLowLine()
val highLine = defaultValueHelper.determineHighLine() val highLine = defaultValueHelper.determineHighLine()
return when { return when {
isPrediction -> predictionColor isPrediction -> predictionColor(context)
valueToUnits(units) < lowLine -> rh.gc(R.color.low) valueToUnits(units) < lowLine -> rh.gac(context, R.attr.bgLow)
valueToUnits(units) > highLine -> rh.gc(R.color.high) valueToUnits(units) > highLine -> rh.gac(context, R.attr.highColor)
else -> rh.gc(R.color.inrange) else -> rh.gac(context, R.attr.bgInRange)
} }
} }
val predictionColor: Int private fun predictionColor (context: Context?): Int {
get() {
return when (data.sourceSensor) { return when (data.sourceSensor) {
GlucoseValue.SourceSensor.IOB_PREDICTION -> rh.gc(R.color.iob) GlucoseValue.SourceSensor.IOB_PREDICTION -> rh.gac(context, R.attr.iobColor)
GlucoseValue.SourceSensor.COB_PREDICTION -> rh.gc(R.color.cob) GlucoseValue.SourceSensor.COB_PREDICTION -> rh.gac(context, R.attr.cobColor)
GlucoseValue.SourceSensor.A_COB_PREDICTION -> -0x7f000001 and rh.gc(R.color.cob) GlucoseValue.SourceSensor.A_COB_PREDICTION -> -0x7f000001 and rh.gac(context, R.attr.cobColor)
GlucoseValue.SourceSensor.UAM_PREDICTION -> rh.gc(R.color.uam) GlucoseValue.SourceSensor.UAM_PREDICTION -> rh.gac(context, R.attr.uamColor)
GlucoseValue.SourceSensor.ZT_PREDICTION -> rh.gc(R.color.zt) GlucoseValue.SourceSensor.ZT_PREDICTION -> rh.gac(context, R.attr.ztColor)
else -> R.color.white else -> rh.gac( context,R.attr.defaultTextColor)
} }
} }

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.androidaps.plugins.general.overview.graphExtensions
import android.content.Context
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.data.InMemoryGlucoseValue import info.nightscout.androidaps.data.InMemoryGlucoseValue
@ -24,5 +25,7 @@ class InMemoryGlucoseValueDataPoint @Inject constructor(
override val duration = 0L override val duration = 0L
override val shape = PointsWithLabelGraphSeries.Shape.BUCKETED_BG override val shape = PointsWithLabelGraphSeries.Shape.BUCKETED_BG
override val size = 0.3f override val size = 0.3f
override val color get() = rh.gc(R.color.white) override fun color(context: Context?): Int {
return rh.gac(context, R.attr.inMemoryColor)
}
} }

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.androidaps.plugins.general.overview.graphExtensions
import android.content.Context
import android.graphics.Color import android.graphics.Color
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
@ -59,14 +60,14 @@ class TherapyEventDataPoint @Inject constructor(
} }
override val size get() = if (rh.gb(R.bool.isTablet)) 12.0f else 10.0f override val size get() = if (rh.gb(R.bool.isTablet)) 12.0f else 10.0f
override val color override fun color(context: Context?): Int {
get() = return when (data.type) {
when (data.type) { TherapyEvent.Type.ANNOUNCEMENT -> rh.gac(context, R.attr.notificationAnnouncement)
TherapyEvent.Type.ANNOUNCEMENT -> rh.gc(R.color.notificationAnnouncement) TherapyEvent.Type.NS_MBG -> rh.gac(context, R.attr.therapyEvent_NS_MBG)
TherapyEvent.Type.NS_MBG -> Color.RED TherapyEvent.Type.FINGER_STICK_BG_VALUE -> rh.gac(context, R.attr.therapyEvent_FINGER_STICK_BG_VALUE)
TherapyEvent.Type.FINGER_STICK_BG_VALUE -> Color.RED TherapyEvent.Type.EXERCISE -> rh.gac(context, R.attr.therapyEvent_EXERCISE)
TherapyEvent.Type.EXERCISE -> Color.BLUE TherapyEvent.Type.APS_OFFLINE -> rh.gac(context, R.attr.therapyEvent_APS_OFFLINE) and -0x7f000001
TherapyEvent.Type.APS_OFFLINE -> Color.GRAY and -0x7f000001 else -> rh.gac(context, R.attr.therapyEvent_Default)
else -> Color.GRAY }
} }
} }

View file

@ -529,7 +529,8 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
if (!predArray.isEmpty()) { if (!predArray.isEmpty()) {
for (GlucoseValueDataPoint bg : predArray) { for (GlucoseValueDataPoint bg : predArray) {
if (bg.getData().getValue() < 40) continue; if (bg.getData().getValue() < 40) continue;
predictions.add(predictionMap(bg.getData().getTimestamp(), bg.getData().getValue(), bg.getPredictionColor())); predictions.add(predictionMap(bg.getData().getTimestamp(),
bg.getData().getValue(), bg.color(null)));
} }
} }
} }

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.data package info.nightscout.androidaps.data
import android.content.Context
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
@ -104,7 +105,7 @@ class IobTotal(val time: Long) : DataPointWithLabelInterface {
} }
// DataPoint interface // DataPoint interface
override var color = 0 private var color = 0
override fun getX(): Double = time.toDouble() override fun getX(): Double = time.toDouble()
override fun getY(): Double = iob override fun getY(): Double = iob
override fun setY(y: Double) {} override fun setY(y: Double) {}
@ -113,6 +114,11 @@ class IobTotal(val time: Long) : DataPointWithLabelInterface {
override val shape = PointsWithLabelGraphSeries.Shape.IOBPREDICTION override val shape = PointsWithLabelGraphSeries.Shape.IOBPREDICTION
override val size = 0.5f override val size = 0.5f
override fun color(context: Context?): Int {
return color
}
fun setColor(color: Int): IobTotal { fun setColor(color: Int): IobTotal {
this.color = color this.color = color
return this return this

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.androidaps.plugins.general.overview.graphExtensions
import android.content.Context
import com.jjoe64.graphview.series.DataPointInterface import com.jjoe64.graphview.series.DataPointInterface
interface DataPointWithLabelInterface : DataPointInterface { interface DataPointWithLabelInterface : DataPointInterface {
@ -12,5 +13,5 @@ interface DataPointWithLabelInterface : DataPointInterface {
val duration: Long val duration: Long
val shape: PointsWithLabelGraphSeries.Shape? val shape: PointsWithLabelGraphSeries.Shape?
val size: Float val size: Float
val color: Int fun color(context: Context?): Int
} }

View file

@ -152,7 +152,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
while (values.hasNext()) { while (values.hasNext()) {
E value = values.next(); E value = values.next();
mPaint.setColor(value.getColor()); mPaint.setColor(value.color(graphView.getContext()));
double valY = value.getY() - minY; double valY = value.getY() - minY;
double ratY = valY / diffY; double ratY = valY / diffY;
@ -200,12 +200,12 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, value.getSize() * scaledPxSize, mPaint); canvas.drawCircle(endX, endY, value.getSize() * scaledPxSize, mPaint);
} else if (value.getShape() == Shape.BG || value.getShape() == Shape.IOBPREDICTION || value.getShape() == Shape.BUCKETED_BG) { } else if (value.getShape() == Shape.BG || value.getShape() == Shape.IOBPREDICTION || value.getShape() == Shape.BUCKETED_BG) {
mPaint.setColor(value.getColor()); mPaint.setColor(value.color(graphView.getContext()));
mPaint.setStyle(Paint.Style.FILL); mPaint.setStyle(Paint.Style.FILL);
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, value.getSize() * scaledPxSize, mPaint); canvas.drawCircle(endX, endY, value.getSize() * scaledPxSize, mPaint);
} else if (value.getShape() == Shape.PREDICTION) { } else if (value.getShape() == Shape.PREDICTION) {
mPaint.setColor(value.getColor()); mPaint.setColor(value.color(graphView.getContext()));
mPaint.setStyle(Paint.Style.FILL); mPaint.setStyle(Paint.Style.FILL);
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, scaledPxSize, mPaint); canvas.drawCircle(endX, endY, scaledPxSize, mPaint);

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.iob.iobCobCalculator.data package info.nightscout.androidaps.plugins.iob.iobCobCalculator.data
import android.content.Context
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
@ -162,7 +163,9 @@ class AutosensData(injector: HasAndroidInjector) : DataPointWithLabelInterface {
override val duration = 0L override val duration = 0L
override val shape = PointsWithLabelGraphSeries.Shape.COBFAILOVER override val shape = PointsWithLabelGraphSeries.Shape.COBFAILOVER
override val size = 0.5f override val size = 0.5f
override val color get() = rh.gc(R.color.cob) override fun color(context: Context?): Int {
return rh.gac(context,R.attr.cobColor)
}
init { init {
injector.androidInjector().inject(this) injector.androidInjector().inject(this)

View file

@ -217,7 +217,12 @@
<item name="therapyEvent_APS_OFFLINE">@color/mdtp_line_dark</item> <item name="therapyEvent_APS_OFFLINE">@color/mdtp_line_dark</item>
<item name="therapyEvent_Default">@color/mdtp_line_dark</item> <item name="therapyEvent_Default">@color/mdtp_line_dark</item>
<!-- Graph specific colors --> <!-- Graph specific colors -->
<item name="inrangeBackground">@color/inrangebackground</item> <item name="inrangeBackground">@color/black_alpha_20</item>
<item name="devslopeposColor">@color/devslopepos</item>
<item name="predictionColor">@color/prediction</item>
<item name="bgiColor">@color/bgi</item>
<item name="ratioColor">@color/ratio</item>
<item name="activityColor">@color/activity</item>
</style> </style>
<style name="Theme.MaterialComponents.DayNight.DarkActionBar" parent="Theme.MaterialComponents.DayNight.Bridge"/> <style name="Theme.MaterialComponents.DayNight.DarkActionBar" parent="Theme.MaterialComponents.DayNight.Bridge"/>
@ -268,14 +273,37 @@
<style name="MaterialPickerTheme" parent="android:Theme.Material.Dialog.Alert"> <style name="MaterialPickerTheme" parent="android:Theme.Material.Dialog.Alert">
<item name="android:datePickerStyle">@style/MaterialDatePickerStyle</item>
<item name="android:timePickerStyle">@style/MaterialTimePickerStyle</item>
<item name="android:buttonBarPositiveButtonStyle">@style/PickerTextButton</item> <item name="android:buttonBarPositiveButtonStyle">@style/PickerTextButton</item>
<item name="android:buttonBarNegativeButtonStyle">@style/PickerTextButton</item> <item name="android:buttonBarNegativeButtonStyle">@style/PickerTextButton</item>
<item name="android:textColorPrimary">@color/okButtonText</item> <item name="colorAccent">@color/dialog_title_background</item>
<item name="android:colorPrimary">@color/okButtonText</item> <item name="colorSecondary">@color/dialog_title_background</item>
<item name="android:calendarTextColor">@color/okButtonText</item> <item name="android:textColorSecondary">@color/defaulttextcolor</item>
<item name="android:colorAccent">@color/okButtonText</item> <item name="android:textColorPrimary">@color/defaulttextcolor</item>
<item name="android:textColor">@color/defaulttextcolor</item>
<item name="backgroundColor">@color/dateTimePickerBackground</item>
<item name="android:dialogCornerRadius">12dp</item> <item name="android:dialogCornerRadius">12dp</item>
</style> </style>
<style name="MaterialDatePickerStyle" parent="Widget.MaterialComponents.MaterialCalendar">
<item name="android:calendarTextColor">@color/defaulttextcolor</item>
<item name="android:datePickerMode">calendar</item>
<item name="colorSecondary">@color/dialog_title_background</item>
<item name="android:background">@color/dateTimePickerBackground</item>
<item name="android:headerBackground">@color/dialog_title_background</item>
</style>
<style name="MaterialTimePickerStyle" parent="Widget.MaterialComponents.TimePicker">
<item name="android:numbersTextColor">@color/defaulttextcolor</item>
<item name="android:numbersSelectorColor">@color/white_alpha_40</item>
<item name="android:numbersBackgroundColor">@color/dialog_title_background</item>
<item name="android:background">@color/dateTimePickerBackground</item>
<item name="android:headerBackground">@color/dialog_title_background</item>
<item name="android:headerTimeTextAppearance">@color/defaulttextcolor</item>
<item name="android:timePickerMode">clock</item>
</style>
<style name="PickerTextButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog"> <style name="PickerTextButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">@color/okButtonText</item> <item name="android:textColor">@color/okButtonText</item>
</style> </style>

View file

@ -198,4 +198,9 @@
<attr name="graphVerticalLabelText" format="reference|color" /> <attr name="graphVerticalLabelText" format="reference|color" />
<attr name="inrangeBackground" format="reference|color" /> <attr name="inrangeBackground" format="reference|color" />
<attr name="graphGrid" format="reference|color" /> <attr name="graphGrid" format="reference|color" />
<attr name="devslopeposColor" format="reference|color" />
<attr name="predictionColor" format="reference|color" />
<attr name="bgiColor" format="reference|color" />
<attr name="ratioColor" format="reference|color" />
<attr name="activityColor" format="reference|color" />
</resources> </resources>

View file

@ -226,6 +226,11 @@
<item name="therapyEvent_Default">@color/mdtp_line_dark</item> <item name="therapyEvent_Default">@color/mdtp_line_dark</item>
<!-- Graph specific colors --> <!-- Graph specific colors -->
<item name="inrangeBackground">@color/black_alpha_20</item> <item name="inrangeBackground">@color/black_alpha_20</item>
<item name="devslopeposColor">@color/devslopepos</item>
<item name="predictionColor">@color/prediction</item>
<item name="bgiColor">@color/bgi</item>
<item name="ratioColor">@color/ratio</item>
<item name="activityColor">@color/activity</item>
</style> </style>
<style name="Theme.MaterialComponents.DayNight.DarkActionBar" parent="Theme.MaterialComponents.DayNight.Bridge"/> <style name="Theme.MaterialComponents.DayNight.DarkActionBar" parent="Theme.MaterialComponents.DayNight.Bridge"/>
@ -287,18 +292,35 @@
<item name="android:textAllCaps">true</item> <item name="android:textAllCaps">true</item>
</style> </style>
<style name="MaterialPickerTheme" parent="Theme.MaterialComponents.Light.Dialog.Alert"> <style name="MaterialPickerTheme" parent="Theme.MaterialComponents.Light.Dialog.Alert">
<item name="android:datePickerStyle">@style/MaterialDatePickerStyle</item>
<item name="android:timePickerStyle">@style/MaterialTimePickerStyle</item>
<item name="android:buttonBarPositiveButtonStyle">@style/PickerTextButton</item> <item name="android:buttonBarPositiveButtonStyle">@style/PickerTextButton</item>
<item name="android:buttonBarNegativeButtonStyle">@style/PickerTextButton</item> <item name="android:buttonBarNegativeButtonStyle">@style/PickerTextButton</item>
<item name="android:textColorPrimary">@color/black</item> <item name="colorAccent">@color/dialog_title_background</item>
<item name="android:colorPrimary">@color/colorPrimary</item> <item name="android:textColorSecondary">@color/defaulttextcolor</item>
<item name="android:calendarTextColor">@color/black</item> <item name="android:textColorPrimary">@color/defaulttextcolor</item>
<item name="android:colorAccent">@color/dialog_title_background</item> <item name="android:textColor">@color/defaulttextcolor</item>
<item name="colorSecondary">@color/dialog_title_background</item>
<item name="android:dialogCornerRadius">12dp</item> <item name="android:dialogCornerRadius">12dp</item>
</style> </style>
<style name="MaterialDatePickerStyle" parent="Widget.MaterialComponents.MaterialCalendar">
<item name="android:calendarTextColor">@color/defaulttextcolor</item>
<item name="android:datePickerMode">calendar</item>
<item name="android:background">@color/dateTimePickerBackground</item>
<item name="android:headerBackground">@color/dialog_title_background</item>
</style>
<style name="MaterialTimePickerStyle" parent="Widget.MaterialComponents.TimePicker">
<item name="android:numbersTextColor">@color/defaulttextcolor</item>
<item name="android:numbersSelectorColor">@color/white_alpha_40</item>
<item name="android:numbersBackgroundColor">@color/dialog_title_background</item>
<item name="android:background">@color/dateTimePickerBackground</item>
<item name="android:headerBackground">@color/dialog_title_background</item>
<item name="android:headerTimeTextAppearance">@color/defaulttextcolor</item>
<item name="android:timePickerMode">clock</item>
</style>
<style name="PickerTextButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog"> <style name="PickerTextButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">@color/okButtonText</item> <item name="android:textColor">@color/okButtonText</item>
</style> </style>