Skip to content

Commit

Permalink
Revert "prepare for wear"
Browse files Browse the repository at this point in the history
This reverts commit d0aaa69.
  • Loading branch information
fmegen committed Mar 3, 2025
1 parent 2ca7d24 commit 6b12921
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,8 @@ sealed class EventData : Event() {
val avgDeltaDetailed: String = "--",
val sgvLevel: Long = 0,
val sgv: Double,
val veryHigh: Double, // veryHighLine
val high: Double, // highLine
val low: Double, // lowLine
val veryLow: Double, // veryLowLine
val color: Int = 0,
val deltaMgdl: Double? = null,
val avgDeltaMgdl: Double? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,19 @@ class EventDataTest {
assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it)
assertThat(EventData.deserialize(it.serialize())).isEqualTo(it)
}
EventData.SingleBg(dataset = 0, 1, sgv = 2.0, veryHigh = 5.0, high = 3.0, low = 4.0, veryLow = 6.0).let {
EventData.SingleBg(dataset = 0, 1, sgv = 2.0, high = 3.0, low = 4.0).let {
assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it)
assertThat(EventData.deserialize(it.serialize())).isEqualTo(it)
}
EventData.GraphData(arrayListOf(EventData.SingleBg(dataset = 0, 1, sgv = 2.0, veryHigh = 5.0, high = 3.0, low = 4.0, veryLow = 6.0))).let {
EventData.GraphData(arrayListOf(EventData.SingleBg(dataset = 0, 1, sgv = 2.0, high = 3.0, low = 4.0))).let {
assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it)
assertThat(EventData.deserialize(it.serialize())).isEqualTo(it)
}
EventData.TreatmentData(
arrayListOf(EventData.TreatmentData.TempBasal(1, 2.0, 3, 4.0, 5.0)),
arrayListOf(EventData.TreatmentData.Basal(1, 2, 3.0)),
arrayListOf(EventData.TreatmentData.Treatment(1, 2.0, 3.0, true, isValid = true)),
arrayListOf(EventData.SingleBg(dataset = 0, 1, sgv = 2.0, veryHigh = 5.0, high = 3.0, low = 4.0, veryLow = 6.0))
arrayListOf(EventData.SingleBg(dataset = 0, 1, sgv = 2.0, high = 3.0, low = 4.0))
).let {
assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it)
assertThat(EventData.deserialize(it.serialize())).isEqualTo(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,8 @@ class TizenPlugin @Inject constructor(
bundle.putString("slopeArrow", lastBG.trendArrow.text) // direction arrow as string
bundle.putDouble("deltaMgdl", glucoseStatus.delta) // bg delta in mgdl
bundle.putDouble("avgDeltaMgdl", glucoseStatus.shortAvgDelta) // average bg delta
bundle.putDouble("veryHigh", preferences.get(UnitDoubleKey.OverviewVeryHighMark)) // predefined topmost value of in range (yellow area)
bundle.putDouble("high", preferences.get(UnitDoubleKey.OverviewHighMark)) // predefined top value of in range (green area)
bundle.putDouble("low", preferences.get(UnitDoubleKey.OverviewLowMark)) // predefined bottom value of in range
bundle.putDouble("veryLow", preferences.get(UnitDoubleKey.OverviewVeryLowMark)) // predefined very bottom value of in range
}

private fun iobCob(bundle: Bundle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1331,10 +1331,8 @@ class DataHandlerMobile @Inject constructor(
timeStamp = bg.timestamp,
glucoseUnits = GlucoseUnit.MGDL.asText,
sgv = bg.value,
veryHigh = 0.0,
high = 0.0,
low = 0.0,
veryLow = 0.0,
color = predictionColor(context, bg)
)
)
Expand Down Expand Up @@ -1468,10 +1466,8 @@ class DataHandlerMobile @Inject constructor(
private fun getSingleBG(glucoseValue: InMemoryGlucoseValue): EventData.SingleBg {
val glucoseStatus = glucoseStatusProvider.getGlucoseStatusData(true)
val units = profileFunction.getUnits()
val veryLowLine = profileUtil.convertToMgdl(preferences.get(UnitDoubleKey.OverviewVeryLowMark), units)
val lowLine = profileUtil.convertToMgdl(preferences.get(UnitDoubleKey.OverviewLowMark), units)
val highLine = profileUtil.convertToMgdl(preferences.get(UnitDoubleKey.OverviewHighMark), units)
val veryHighLine = profileUtil.convertToMgdl(preferences.get(UnitDoubleKey.OverviewVeryHighMark), units)

return EventData.SingleBg(
dataset = 0,
Expand All @@ -1485,10 +1481,8 @@ class DataHandlerMobile @Inject constructor(
avgDeltaDetailed = glucoseStatus?.let { deltaStringDetailed(it.shortAvgDelta, it.shortAvgDelta * Constants.MGDL_TO_MMOLL, units) } ?: "--",
sgvLevel = if (glucoseValue.recalculated > highLine) 1L else if (glucoseValue.recalculated < lowLine) -1L else 0L,
sgv = glucoseValue.recalculated,
veryHigh = veryHighLine,
high = highLine,
low = lowLine,
veryLow = veryLowLine,
color = 0,
deltaMgdl = glucoseStatus?.delta,
avgDeltaMgdl = glucoseStatus?.shortAvgDelta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ internal class TizenPluginTest : TestBaseWithProfile() {
assertThat(bundle.containsKey("slopeArrow")).isTrue()
assertThat(bundle.containsKey("deltaMgdl")).isTrue()
assertThat(bundle.containsKey("avgDeltaMgdl")).isTrue()
assertThat(bundle.containsKey("veryHigh")).isTrue()
assertThat(bundle.containsKey("high")).isTrue()
assertThat(bundle.containsKey("low")).isTrue()
assertThat(bundle.containsKey("veryLow")).isTrue()
assertThat(bundle.containsKey("bolusIob")).isTrue()
assertThat(bundle.containsKey("basalIob")).isTrue()
assertThat(bundle.containsKey("iob")).isTrue()
Expand Down
6 changes: 0 additions & 6 deletions wear/src/main/kotlin/app/aaps/wear/data/RawDisplayData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ class RawDisplayData {
avgDeltaDetailed = "--",
sgvLevel = 0,
sgv = 0.0,
veryHigh = 0.0,
high = 0.0,
low = 0.0,
veryLow = 0.0,
color = 0,
deltaMgdl = null,
avgDeltaMgdl = null
Expand All @@ -46,10 +44,8 @@ class RawDisplayData {
avgDeltaDetailed = "--",
sgvLevel = 0,
sgv = 0.0,
veryHigh = 0.0,
high = 0.0,
low = 0.0,
veryLow = 0.0,
color = 0,
deltaMgdl = null,
avgDeltaMgdl = null,
Expand All @@ -65,10 +61,8 @@ class RawDisplayData {
avgDeltaDetailed = "--",
sgvLevel = 0,
sgv = 0.0,
veryHigh = 0.0,
high = 0.0,
low = 0.0,
veryLow = 0.0,
color = 0,
deltaMgdl = null,
avgDeltaMgdl = null,
Expand Down
29 changes: 6 additions & 23 deletions wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,11 @@ class CircleWatchface : WatchFace() {
angleBig = ((hour + minute / 60f) / 12f * 360 - 90 - BIG_HAND_WIDTH / 2f + 360) % 360
angleSMALL = (minute / 60f * 360 - 90 - SMALL_HAND_WIDTH / 2f + 360) % 360
color = 0

val entry = singleBg[0];
color = when {
entry.sgv >= entry.veryHigh -> veryHighColor
entry.sgv >= entry.high -> highColor
entry.sgv <= entry.veryLow -> veryLowColor
entry.sgv <= entry.low -> lowColor
else -> inRangeColor
when (singleBg[0].sgvLevel.toInt()) {
-1 -> color = lowColor
0 -> color = inRangeColor
1 -> color = highColor
}

circlePaint.shader = null
circlePaint.style = Paint.Style.STROKE
circlePaint.strokeWidth = CIRCLE_WIDTH
Expand Down Expand Up @@ -297,16 +292,12 @@ class CircleWatchface : WatchFace() {
}

// defining color for dark and bright
private val veryLowColor: Int
get() = if (sp.getBoolean(R.string.key_dark, true)) Color.argb(255, 255, 120, 120) else Color.argb(255, 255, 80, 80)
private val lowColor: Int
get() = if (sp.getBoolean(R.string.key_dark, true)) Color.argb(255, 255, 255, 120) else Color.argb(255, 255, 80, 80)
get() = if (sp.getBoolean(R.string.key_dark, true)) Color.argb(255, 255, 120, 120) else Color.argb(255, 255, 80, 80)
private val inRangeColor: Int
get() = if (sp.getBoolean(R.string.key_dark, true)) Color.argb(255, 120, 255, 120) else Color.argb(255, 0, 240, 0)
private val highColor: Int
get() = if (sp.getBoolean(R.string.key_dark, true)) Color.argb(255, 255, 255, 120) else Color.argb(255, 255, 200, 0)
private val veryHighColor: Int
get() = if (sp.getBoolean(R.string.key_dark, true)) Color.argb(255, 255, 120, 120) else Color.argb(255, 255, 200, 0)
private val backgroundColor: Int
get() = if (sp.getBoolean(R.string.key_dark, true)) Color.BLACK else Color.WHITE
val textColor: Int
Expand All @@ -318,10 +309,8 @@ class CircleWatchface : WatchFace() {
//Perfect low and High indicators
if (bgDataList.isNotEmpty()) {
addIndicator(canvas, 100f, Color.LTGRAY)
addIndicator(canvas, bgDataList.iterator().next().veryLow.toFloat(), veryLowColor)
addIndicator(canvas, bgDataList.iterator().next().low.toFloat(), lowColor)
addIndicator(canvas, bgDataList.iterator().next().high.toFloat(), highColor)
addIndicator(canvas, bgDataList.iterator().next().veryHigh.toFloat(), veryHighColor)
if (sp.getBoolean("softRingHistory", true)) {
for (data in bgDataList) {
addReadingSoft(canvas, data)
Expand Down Expand Up @@ -417,15 +406,9 @@ class CircleWatchface : WatchFace() {
indicatorColor = Color.LTGRAY
}
var barColor = Color.GRAY
if (entry.sgv >= entry.veryHigh) {
indicatorColor = veryHighColor
barColor = darken(veryHighColor)
} else if (entry.sgv >= entry.high) {
if (entry.sgv >= entry.high) {
indicatorColor = highColor
barColor = darken(highColor)
} else if (entry.sgv <= entry.veryLow) {
indicatorColor = veryLowColor
barColor = darken(veryLowColor)
} else if (entry.sgv <= entry.low) {
indicatorColor = lowColor
barColor = darken(lowColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ class CustomWatchface : BaseWatchFace() {
private var json = JSONObject()
private var jsonString = ""

private fun bgColor(dataSet: Int): Int = when {
singleBg[dataSet].sgv >= singleBg[dataSet].veryHigh -> veryHighColor
singleBg[dataSet].sgv >= singleBg[dataSet].high -> highColor
singleBg[dataSet].sgv <= singleBg[dataSet].veryLow -> veryLowColor
singleBg[dataSet].sgv <= singleBg[dataSet].low -> lowColor
private fun bgColor(dataSet: Int): Int = when (singleBg[dataSet].sgvLevel) {
1L -> highColor
0L -> midColor
-1L -> lowColor
else -> midColor
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,12 @@ class DigitalStyleWatchface : BaseWatchFace() {
}

override fun setColorDark() {
val entry = singleBg[0]
val color = when {
entry.sgv >= entry.veryHigh -> R.color.dark_veryHighColor
entry.sgv >= entry.high -> R.color.dark_highColor
entry.sgv <= entry.veryLow -> R.color.dark_veryLowColor
entry.sgv <= entry.low -> R.color.dark_lowColor
val color = when (singleBg[0].sgvLevel) {
1L -> R.color.dark_highColor
0L -> R.color.dark_midColor
-1L -> R.color.dark_lowColor
else -> R.color.dark_midColor
}

binding.sgv.setTextColor(ContextCompat.getColor(this, color))
binding.direction.setTextColor(ContextCompat.getColor(this, color))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@ abstract class BaseWatchFace : WatchFace() {
var loopLevelExt2 = -1
var enableExt1 = false
var enableExt2 = false
var veryHighColor = Color.RED
var highColor = Color.YELLOW
var lowColor = Color.YELLOW
var veryLowColor = Color.RED
var lowColor = Color.RED
var midColor = Color.WHITE
var gridColor = Color.WHITE
var basalBackgroundColor = Color.BLUE
Expand Down Expand Up @@ -554,14 +552,12 @@ abstract class BaseWatchFace : WatchFace() {
if (lowResMode)
BgGraphBuilder(
sp, dateUtil, graphData.entries, treatmentData.predictions, treatmentData.temps, treatmentData.basals, treatmentData.boluses, pointSize,
midColor, gridColor,
basalBackgroundColor, basalCenterColor, bolusColor, carbColor, timeframe
midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, carbColor, timeframe
)
else
BgGraphBuilder(
sp, dateUtil, graphData.entries, treatmentData.predictions, treatmentData.temps, treatmentData.basals, treatmentData.boluses, pointSize,
veryHighColor, highColor, lowColor, veryLowColor, midColor, gridColor,
basalBackgroundColor, basalCenterColor, bolusColor, carbColor, timeframe
sp, dateUtil, graphData.entries, treatmentData.predictions, treatmentData.temps, treatmentData.basals, treatmentData.boluses,
pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, carbColor, timeframe
)
binding.chart?.lineChartData = bgGraphBuilder.lineData()
binding.chart?.isViewportCalculationEnabled = true
Expand Down
Loading

0 comments on commit 6b12921

Please sign in to comment.