From 673ae12d206e02168a8a86e394105952879d3608 Mon Sep 17 00:00:00 2001 From: Friedel van Megen Date: Tue, 31 Dec 2024 14:53:11 +0100 Subject: [PATCH 01/12] very high --- .../kotlin/app/aaps/core/interfaces/overview/LastBgData.kt | 7 +++++++ .../src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt | 1 + .../app/aaps/implementation/overview/LastBgDataImpl.kt | 5 +++++ ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt | 1 + 4 files changed, 14 insertions(+) diff --git a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/overview/LastBgData.kt b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/overview/LastBgData.kt index 3440f7ec21bf..a8a78c61d45c 100644 --- a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/overview/LastBgData.kt +++ b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/overview/LastBgData.kt @@ -34,6 +34,13 @@ interface LastBgData { */ fun isHigh(): Boolean + /** + * Is last value above display high very target? + * + * @return true if above + */ + fun isVeryHigh(): Boolean + /** * Evaluate color based on low - in - high * diff --git a/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt b/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt index 75d12c03211d..1a44b936e4fd 100644 --- a/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt +++ b/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt @@ -19,6 +19,7 @@ enum class UnitDoubleKey( OverviewHypoTarget("hypo_target", 160.0, 108, 180, defaultedBySM = true), OverviewLowMark("low_mark", 72.0, 25, 160, showInNsClientMode = false, hideParentScreenIfHidden = true), OverviewHighMark("high_mark", 180.0, 90, 250, showInNsClientMode = false), + OverviewVeryHighMark("very_high_mark", 240.0, 200, 300, showInNsClientMode = false), ApsLgsThreshold("lgsThreshold", 65.0, 65, 120, defaultedBySM = true, dependency = BooleanKey.ApsUseDynamicSensitivity), ApsAutoIsfSmbDeliveryRatioBgRange("openapsama_smb_delivery_ratio_bg_range", 0.0, 0, 100, defaultedBySM = true) } \ No newline at end of file diff --git a/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt b/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt index 04db6298acd0..c1b6a169c917 100644 --- a/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt +++ b/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt @@ -41,6 +41,11 @@ class LastBgDataImpl @Inject constructor( lastBg.valueToUnits(profileFunction.getUnits()) > preferences.get(UnitDoubleKey.OverviewHighMark) } == true + override fun isVeryHigh(): Boolean = + lastBg()?.let { lastBg -> + lastBg.valueToUnits(profileFunction.getUnits()) > preferences.get(UnitDoubleKey.OverviewVeryHighMark) + } == true + @ColorInt override fun lastBgColor(context: Context?): Int = when { diff --git a/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt b/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt index f5ff21921758..624ed4598f3e 100644 --- a/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt +++ b/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt @@ -144,6 +144,7 @@ class Widget : AppWidgetProvider() { views.setTextColor( R.id.bg, when { lastBgData.isLow() -> rh.gc(app.aaps.core.ui.R.color.widget_low) + lastBgData.isVeryHigh() -> rh.gc(app.aaps.core.ui.R.color.widget_low) lastBgData.isHigh() -> rh.gc(app.aaps.core.ui.R.color.widget_high) else -> rh.gc(app.aaps.core.ui.R.color.widget_inrange) } From 9ef344f41c65c9da2a62e07700e50a249ea2bf94 Mon Sep 17 00:00:00 2001 From: Friedel van Megen Date: Tue, 31 Dec 2024 15:03:53 +0100 Subject: [PATCH 02/12] veryHighColor --- .../app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt | 2 ++ core/ui/src/main/res/values/attrs.xml | 1 + core/ui/src/main/res/values/colors.xml | 1 + ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt | 3 ++- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt b/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt index a7780fa5919e..5b0641659dd5 100644 --- a/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt +++ b/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt @@ -36,8 +36,10 @@ class InMemoryGlucoseValueDataPoint( val units = profileFunction.getUnits() val lowLine = preferences.get(UnitDoubleKey.OverviewLowMark) val highLine = preferences.get(UnitDoubleKey.OverviewHighMark) + val veryHighLine = preferences.get(UnitDoubleKey.OverviewVeryHighMark) val color = when { valueToUnits(units) < lowLine -> rh.gac(context, app.aaps.core.ui.R.attr.bgLow) + valueToUnits(units) > veryHighLine -> rh.gac(context, app.aaps.core.ui.R.attr.veryHighColor) valueToUnits(units) > highLine -> rh.gac(context, app.aaps.core.ui.R.attr.highColor) else -> rh.gac(context, app.aaps.core.ui.R.attr.bgInRange) } diff --git a/core/ui/src/main/res/values/attrs.xml b/core/ui/src/main/res/values/attrs.xml index b46603151d98..ecc009e4401e 100644 --- a/core/ui/src/main/res/values/attrs.xml +++ b/core/ui/src/main/res/values/attrs.xml @@ -89,6 +89,7 @@ + diff --git a/core/ui/src/main/res/values/colors.xml b/core/ui/src/main/res/values/colors.xml index df4abdd40bf1..45d700e310d8 100644 --- a/core/ui/src/main/res/values/colors.xml +++ b/core/ui/src/main/res/values/colors.xml @@ -360,6 +360,7 @@ #00FF00 #FF0000 #FFFF00 + #FF0000 #f4d700 #FFFFFF #ff0400 diff --git a/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt b/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt index 624ed4598f3e..b06318fd10e0 100644 --- a/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt +++ b/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt @@ -144,7 +144,7 @@ class Widget : AppWidgetProvider() { views.setTextColor( R.id.bg, when { lastBgData.isLow() -> rh.gc(app.aaps.core.ui.R.color.widget_low) - lastBgData.isVeryHigh() -> rh.gc(app.aaps.core.ui.R.color.widget_low) + lastBgData.isVeryHigh() -> rh.gc(app.aaps.core.ui.R.color.widget_very_high) lastBgData.isHigh() -> rh.gc(app.aaps.core.ui.R.color.widget_high) else -> rh.gc(app.aaps.core.ui.R.color.widget_inrange) } @@ -156,6 +156,7 @@ class Widget : AppWidgetProvider() { views.setInt( R.id.arrow, "setColorFilter", when { lastBgData.isLow() -> rh.gc(app.aaps.core.ui.R.color.widget_low) + lastBgData.isVeryHigh() -> rh.gc(app.aaps.core.ui.R.color.widget_very_high) lastBgData.isHigh() -> rh.gc(app.aaps.core.ui.R.color.widget_high) else -> rh.gc(app.aaps.core.ui.R.color.widget_inrange) } From 7908f98be02dd452ad74c91d2273ffe633c561eb Mon Sep 17 00:00:00 2001 From: Friedel van Megen Date: Tue, 31 Dec 2024 15:46:30 +0100 Subject: [PATCH 03/12] very --- core/ui/src/main/res/values-night/styles.xml | 1 + core/ui/src/main/res/values/styles.xml | 1 + .../kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt | 1 + .../src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt | 1 + 4 files changed, 4 insertions(+) diff --git a/core/ui/src/main/res/values-night/styles.xml b/core/ui/src/main/res/values-night/styles.xml index 5d80a20fcd46..1437aa9990f8 100644 --- a/core/ui/src/main/res/values-night/styles.xml +++ b/core/ui/src/main/res/values-night/styles.xml @@ -113,6 +113,7 @@ @color/low @color/high + @color/low @color/inRange @color/helperProfile diff --git a/core/ui/src/main/res/values/styles.xml b/core/ui/src/main/res/values/styles.xml index dd8e587a8d84..4a0be309ec70 100644 --- a/core/ui/src/main/res/values/styles.xml +++ b/core/ui/src/main/res/values/styles.xml @@ -116,6 +116,7 @@ @color/low @color/high + @color/low @color/tempTargetConfirmation @color/helperProfile diff --git a/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt b/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt index c1b6a169c917..5ca8202cb485 100644 --- a/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt +++ b/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt @@ -50,6 +50,7 @@ class LastBgDataImpl @Inject constructor( override fun lastBgColor(context: Context?): Int = when { isLow() -> rh.gac(context, app.aaps.core.ui.R.attr.bgLow) + isVeryHigh() -> rh.gac(context, app.aaps.core.ui.R.attr.veryHighColor) isHigh() -> rh.gac(context, app.aaps.core.ui.R.attr.highColor) else -> rh.gac(context, app.aaps.core.ui.R.attr.bgInRange) } diff --git a/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt b/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt index a2475be56d26..2e18a2439dce 100644 --- a/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt +++ b/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt @@ -4,6 +4,7 @@ enum class JsonKeys(val key: String) { METADATA("metadata"), ENABLESECOND("enableSecond"), HIGHCOLOR("highColor"), + VERYHIGHCOLOR("veryHighColor"), MIDCOLOR("midColor"), LOWCOLOR("lowColor"), LOWBATCOLOR("lowBatColor"), From 5c4b0eaac9ff5bdb9b48d581c3d41d4ad525e6eb Mon Sep 17 00:00:00 2001 From: Friedel van Megen Date: Tue, 31 Dec 2024 15:54:51 +0100 Subject: [PATCH 04/12] m --- .../app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt | 2 +- plugins/configuration/src/main/res/values/strings.xml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt b/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt index 5b0641659dd5..e1fc088c6078 100644 --- a/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt +++ b/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt @@ -39,7 +39,7 @@ class InMemoryGlucoseValueDataPoint( val veryHighLine = preferences.get(UnitDoubleKey.OverviewVeryHighMark) val color = when { valueToUnits(units) < lowLine -> rh.gac(context, app.aaps.core.ui.R.attr.bgLow) - valueToUnits(units) > veryHighLine -> rh.gac(context, app.aaps.core.ui.R.attr.veryHighColor) + veryHighLine > 0 && valueToUnits(units) > veryHighLine -> rh.gac(context, app.aaps.core.ui.R.attr.veryHighColor) valueToUnits(units) > highLine -> rh.gac(context, app.aaps.core.ui.R.attr.highColor) else -> rh.gac(context, app.aaps.core.ui.R.attr.bgInRange) } diff --git a/plugins/configuration/src/main/res/values/strings.xml b/plugins/configuration/src/main/res/values/strings.xml index 4f74b4085b3d..4d591722063f 100644 --- a/plugins/configuration/src/main/res/values/strings.xml +++ b/plugins/configuration/src/main/res/values/strings.xml @@ -16,8 +16,10 @@ Display Settings LOW mark HIGH mark + VERY HIGH mark Lower value of in range area (display only) Higher value of in range area (display only) + Even Higher value of in range area (display only) Permission Application needs system window permission for notifications Application needs location permission for BT scan and WiFi identification From c803d1c792a6d9f01ec0eb20ba5e2334c0b9bddf Mon Sep 17 00:00:00 2001 From: Friedel van Megen Date: Tue, 31 Dec 2024 16:02:16 +0100 Subject: [PATCH 05/12] nd --- app/src/main/kotlin/app/aaps/MainApp.kt | 1 + .../app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/app/aaps/MainApp.kt b/app/src/main/kotlin/app/aaps/MainApp.kt index 6c993b95eac2..8f1d6d58e354 100644 --- a/app/src/main/kotlin/app/aaps/MainApp.kt +++ b/app/src/main/kotlin/app/aaps/MainApp.kt @@ -197,6 +197,7 @@ class MainApp : DaggerApplication() { if (preferences.get(IntKey.OverviewEatingSoonDuration) == 0) preferences.remove(IntKey.OverviewEatingSoonDuration) if (preferences.get(UnitDoubleKey.OverviewEatingSoonTarget) == 0.0) preferences.remove(UnitDoubleKey.OverviewEatingSoonTarget) if (preferences.get(IntKey.OverviewActivityDuration) == 0) preferences.remove(IntKey.OverviewActivityDuration) + if (preferences.get(UnitDoubleKey.OverviewVeryHighMark) == 0.0) preferences.remove(UnitDoubleKey.OverviewVeryHighMark) if (preferences.get(UnitDoubleKey.OverviewActivityTarget) == 0.0) preferences.remove(UnitDoubleKey.OverviewActivityTarget) if (preferences.get(IntKey.OverviewHypoDuration) == 0) preferences.remove(IntKey.OverviewHypoDuration) if (preferences.get(UnitDoubleKey.OverviewHypoTarget) == 0.0) preferences.remove(UnitDoubleKey.OverviewHypoTarget) diff --git a/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt b/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt index e1fc088c6078..5b0641659dd5 100644 --- a/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt +++ b/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt @@ -39,7 +39,7 @@ class InMemoryGlucoseValueDataPoint( val veryHighLine = preferences.get(UnitDoubleKey.OverviewVeryHighMark) val color = when { valueToUnits(units) < lowLine -> rh.gac(context, app.aaps.core.ui.R.attr.bgLow) - veryHighLine > 0 && valueToUnits(units) > veryHighLine -> rh.gac(context, app.aaps.core.ui.R.attr.veryHighColor) + valueToUnits(units) > veryHighLine -> rh.gac(context, app.aaps.core.ui.R.attr.veryHighColor) valueToUnits(units) > highLine -> rh.gac(context, app.aaps.core.ui.R.attr.highColor) else -> rh.gac(context, app.aaps.core.ui.R.attr.bgInRange) } From 6ba5479d83eec5ff9438519cae9cb3b543875626 Mon Sep 17 00:00:00 2001 From: Friedel van Megen Date: Wed, 1 Jan 2025 14:30:12 +0100 Subject: [PATCH 06/12] add gui --- app/src/main/kotlin/app/aaps/MainApp.kt | 2 +- .../src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt | 2 +- .../plugins/configuration/setupwizard/SWDefinition.kt | 8 ++++++++ .../aaps/plugins/main/general/overview/OverviewPlugin.kt | 2 ++ .../kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/app/aaps/MainApp.kt b/app/src/main/kotlin/app/aaps/MainApp.kt index 8f1d6d58e354..ce2321029fda 100644 --- a/app/src/main/kotlin/app/aaps/MainApp.kt +++ b/app/src/main/kotlin/app/aaps/MainApp.kt @@ -197,12 +197,12 @@ class MainApp : DaggerApplication() { if (preferences.get(IntKey.OverviewEatingSoonDuration) == 0) preferences.remove(IntKey.OverviewEatingSoonDuration) if (preferences.get(UnitDoubleKey.OverviewEatingSoonTarget) == 0.0) preferences.remove(UnitDoubleKey.OverviewEatingSoonTarget) if (preferences.get(IntKey.OverviewActivityDuration) == 0) preferences.remove(IntKey.OverviewActivityDuration) - if (preferences.get(UnitDoubleKey.OverviewVeryHighMark) == 0.0) preferences.remove(UnitDoubleKey.OverviewVeryHighMark) if (preferences.get(UnitDoubleKey.OverviewActivityTarget) == 0.0) preferences.remove(UnitDoubleKey.OverviewActivityTarget) if (preferences.get(IntKey.OverviewHypoDuration) == 0) preferences.remove(IntKey.OverviewHypoDuration) if (preferences.get(UnitDoubleKey.OverviewHypoTarget) == 0.0) preferences.remove(UnitDoubleKey.OverviewHypoTarget) if (preferences.get(UnitDoubleKey.OverviewLowMark) == 0.0) preferences.remove(UnitDoubleKey.OverviewLowMark) if (preferences.get(UnitDoubleKey.OverviewHighMark) == 0.0) preferences.remove(UnitDoubleKey.OverviewHighMark) + if (preferences.get(UnitDoubleKey.OverviewVeryHighMark) == 0.0) preferences.remove(UnitDoubleKey.OverviewVeryHighMark) if (preferences.getIfExists(BooleanKey.GeneralSimpleMode) == null) preferences.put(BooleanKey.GeneralSimpleMode, !preferences.get(BooleanKey.GeneralSetupWizardProcessed)) // Migrate from OpenAPSSMBDynamicISFPlugin diff --git a/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt b/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt index 1a44b936e4fd..b0a87a749c8a 100644 --- a/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt +++ b/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt @@ -19,7 +19,7 @@ enum class UnitDoubleKey( OverviewHypoTarget("hypo_target", 160.0, 108, 180, defaultedBySM = true), OverviewLowMark("low_mark", 72.0, 25, 160, showInNsClientMode = false, hideParentScreenIfHidden = true), OverviewHighMark("high_mark", 180.0, 90, 250, showInNsClientMode = false), - OverviewVeryHighMark("very_high_mark", 240.0, 200, 300, showInNsClientMode = false), + OverviewVeryHighMark("very_high_mark", 400.0, 200, 400, showInNsClientMode = false), ApsLgsThreshold("lgsThreshold", 65.0, 65, 120, defaultedBySM = true, dependency = BooleanKey.ApsUseDynamicSensitivity), ApsAutoIsfSmbDeliveryRatioBgRange("openapsama_smb_delivery_ratio_bg_range", 0.0, 0, 100, defaultedBySM = true) } \ No newline at end of file diff --git a/plugins/configuration/src/main/kotlin/app/aaps/plugins/configuration/setupwizard/SWDefinition.kt b/plugins/configuration/src/main/kotlin/app/aaps/plugins/configuration/setupwizard/SWDefinition.kt index 9d78daa7e8ea..87ea681ad5ea 100644 --- a/plugins/configuration/src/main/kotlin/app/aaps/plugins/configuration/setupwizard/SWDefinition.kt +++ b/plugins/configuration/src/main/kotlin/app/aaps/plugins/configuration/setupwizard/SWDefinition.kt @@ -146,6 +146,14 @@ class SWDefinition @Inject constructor( .label(R.string.high_mark) .comment(R.string.high_mark_comment) ) + .add(SWBreak(injector)) + .add( + SWEditNumberWithUnits(injector, UnitDoubleKey.OverviewVeryHighMark.defaultValue * Constants.MGDL_TO_MMOLL, 5.0, 23.0) + .preference(UnitDoubleKey.OverviewVeryHighMark) + .updateDelay(5) + .label(R.string.very_high_mark) + .comment(R.string.very_high_mark_comment) + ) private val screenPermissionWindow get() = SWScreen(injector, R.string.permission) diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt index c92e4bf97f8d..0a7fac2e9686 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt +++ b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt @@ -150,6 +150,7 @@ class OverviewPlugin @Inject constructor( .put(UnitDoubleKey.OverviewHypoTarget, preferences) .put(UnitDoubleKey.OverviewLowMark, preferences) .put(UnitDoubleKey.OverviewHighMark, preferences) + .put(UnitDoubleKey.OverviewVeryHighMark, preferences) .put(IntKey.OverviewCageWarning, preferences) .put(IntKey.OverviewCageCritical, preferences) .put(IntKey.OverviewIageWarning, preferences) @@ -180,6 +181,7 @@ class OverviewPlugin @Inject constructor( .store(UnitDoubleKey.OverviewHypoTarget, preferences) .store(UnitDoubleKey.OverviewLowMark, preferences) .store(UnitDoubleKey.OverviewHighMark, preferences) + .store(UnitDoubleKey.OverviewVeryHighMark, preferences) .store(IntKey.OverviewCageWarning, preferences) .store(IntKey.OverviewCageCritical, preferences) .store(IntKey.OverviewIageWarning, preferences) diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt index e261cceb120c..b0a6156065c1 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt @@ -126,6 +126,7 @@ class TizenPlugin @Inject constructor( bundle.putDouble("deltaMgdl", glucoseStatus.delta) // bg delta in mgdl bundle.putDouble("avgDeltaMgdl", glucoseStatus.shortAvgDelta) // average bg delta bundle.putDouble("high", preferences.get(UnitDoubleKey.OverviewHighMark)) // predefined top value of in range (green area) + bundle.putDouble("veryHigh", preferences.get(UnitDoubleKey.OverviewVeryHighMark)) // predefined very top value of in range (above yellow area) bundle.putDouble("low", preferences.get(UnitDoubleKey.OverviewLowMark)) // predefined bottom value of in range } From b145a33507e18ad7b401ed957b99fc1dfc829fac Mon Sep 17 00:00:00 2001 From: Friedel van Megen Date: Wed, 1 Jan 2025 14:39:16 +0100 Subject: [PATCH 07/12] very high mark --- .../app/aaps/plugins/main/general/overview/OverviewPlugin.kt | 1 + plugins/main/src/main/res/values/strings.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt index 0a7fac2e9686..a191994bacaf 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt +++ b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt @@ -262,6 +262,7 @@ class OverviewPlugin @Inject constructor( title = rh.gs(R.string.prefs_range_title) addPreference(AdaptiveUnitPreference(ctx = context, unitKey = UnitDoubleKey.OverviewLowMark, title = R.string.low_mark)) addPreference(AdaptiveUnitPreference(ctx = context, unitKey = UnitDoubleKey.OverviewHighMark, title = R.string.high_mark)) + addPreference(AdaptiveUnitPreference(ctx = context, unitKey = UnitDoubleKey.OverviewVeryHighMark, title = R.string.very_high_mark)) }) addPreference(AdaptiveSwitchPreference(ctx = context, booleanKey = BooleanKey.OverviewShortTabTitles, title = R.string.short_tabtitles)) addPreference(AdaptiveSwitchPreference(ctx = context, booleanKey = BooleanKey.OverviewShowNotesInDialogs, title = R.string.overview_show_notes_field_in_dialogs_title)) diff --git a/plugins/main/src/main/res/values/strings.xml b/plugins/main/src/main/res/values/strings.xml index d1d78301e548..c1ca3bce097d 100644 --- a/plugins/main/src/main/res/values/strings.xml +++ b/plugins/main/src/main/res/values/strings.xml @@ -265,6 +265,7 @@ High and low mark for the charts in Overview and Smartwatch LOW mark HIGH mark + VERY HIGH mark Shorten tab titles Show notes field in treatment dialogs Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm. From 6a44a3cbdaf03f8afc4ebdf05d6f19fe5fe42802 Mon Sep 17 00:00:00 2001 From: Friedel van Megen Date: Thu, 2 Jan 2025 12:57:21 +0100 Subject: [PATCH 08/12] remove wear related data --- .../src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt | 1 - .../src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt index b0a6156065c1..e261cceb120c 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt @@ -126,7 +126,6 @@ class TizenPlugin @Inject constructor( bundle.putDouble("deltaMgdl", glucoseStatus.delta) // bg delta in mgdl bundle.putDouble("avgDeltaMgdl", glucoseStatus.shortAvgDelta) // average bg delta bundle.putDouble("high", preferences.get(UnitDoubleKey.OverviewHighMark)) // predefined top value of in range (green area) - bundle.putDouble("veryHigh", preferences.get(UnitDoubleKey.OverviewVeryHighMark)) // predefined very top value of in range (above yellow area) bundle.putDouble("low", preferences.get(UnitDoubleKey.OverviewLowMark)) // predefined bottom value of in range } diff --git a/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt b/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt index 2e18a2439dce..a2475be56d26 100644 --- a/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt +++ b/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt @@ -4,7 +4,6 @@ enum class JsonKeys(val key: String) { METADATA("metadata"), ENABLESECOND("enableSecond"), HIGHCOLOR("highColor"), - VERYHIGHCOLOR("veryHighColor"), MIDCOLOR("midColor"), LOWCOLOR("lowColor"), LOWBATCOLOR("lowBatColor"), From a1fdc27c12638bc089eab648b9d390b904a07c82 Mon Sep 17 00:00:00 2001 From: Friedel van Megen Date: Tue, 18 Feb 2025 00:14:50 +0100 Subject: [PATCH 09/12] VERY LOW setting added # Conflicts: # core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt --- app/src/main/kotlin/app/aaps/MainApp.kt | 1 + .../aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt | 2 ++ .../app/aaps/core/interfaces/overview/LastBgData.kt | 7 +++++++ .../src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt | 1 + core/ui/src/main/res/values-night/styles.xml | 3 ++- core/ui/src/main/res/values/attrs.xml | 1 + core/ui/src/main/res/values/colors.xml | 3 ++- core/ui/src/main/res/values/styles.xml | 3 ++- .../app/aaps/implementation/overview/LastBgDataImpl.kt | 6 ++++++ .../plugins/configuration/setupwizard/SWDefinition.kt | 8 ++++++++ plugins/configuration/src/main/res/values/strings.xml | 2 ++ .../aaps/plugins/main/general/overview/OverviewPlugin.kt | 3 +++ plugins/main/src/main/res/values/strings.xml | 1 + ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt | 2 ++ 14 files changed, 40 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/app/aaps/MainApp.kt b/app/src/main/kotlin/app/aaps/MainApp.kt index f6d5522954f9..5c0d89c080a8 100644 --- a/app/src/main/kotlin/app/aaps/MainApp.kt +++ b/app/src/main/kotlin/app/aaps/MainApp.kt @@ -195,6 +195,7 @@ class MainApp : DaggerApplication() { if (preferences.get(UnitDoubleKey.OverviewActivityTarget) == 0.0) preferences.remove(UnitDoubleKey.OverviewActivityTarget) if (preferences.get(IntKey.OverviewHypoDuration) == 0) preferences.remove(IntKey.OverviewHypoDuration) if (preferences.get(UnitDoubleKey.OverviewHypoTarget) == 0.0) preferences.remove(UnitDoubleKey.OverviewHypoTarget) + if (preferences.get(UnitDoubleKey.OverviewVeryLowMark) == 0.0) preferences.remove(UnitDoubleKey.OverviewVeryLowMark) if (preferences.get(UnitDoubleKey.OverviewLowMark) == 0.0) preferences.remove(UnitDoubleKey.OverviewLowMark) if (preferences.get(UnitDoubleKey.OverviewHighMark) == 0.0) preferences.remove(UnitDoubleKey.OverviewHighMark) if (preferences.get(UnitDoubleKey.OverviewVeryHighMark) == 0.0) preferences.remove(UnitDoubleKey.OverviewVeryHighMark) diff --git a/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt b/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt index 5b0641659dd5..02fc049a0526 100644 --- a/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt +++ b/core/graph/src/main/kotlin/app/aaps/core/graph/data/InMemoryGlucoseValueDataPoint.kt @@ -34,10 +34,12 @@ class InMemoryGlucoseValueDataPoint( @ColorInt override fun color(context: Context?): Int { val units = profileFunction.getUnits() + val veryLowLine = preferences.get(UnitDoubleKey.OverviewVeryLowMark) val lowLine = preferences.get(UnitDoubleKey.OverviewLowMark) val highLine = preferences.get(UnitDoubleKey.OverviewHighMark) val veryHighLine = preferences.get(UnitDoubleKey.OverviewVeryHighMark) val color = when { + valueToUnits(units) < veryLowLine -> rh.gac(context, app.aaps.core.ui.R.attr.bgVeryLow) valueToUnits(units) < lowLine -> rh.gac(context, app.aaps.core.ui.R.attr.bgLow) valueToUnits(units) > veryHighLine -> rh.gac(context, app.aaps.core.ui.R.attr.veryHighColor) valueToUnits(units) > highLine -> rh.gac(context, app.aaps.core.ui.R.attr.highColor) diff --git a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/overview/LastBgData.kt b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/overview/LastBgData.kt index a8a78c61d45c..6e24df2aeab0 100644 --- a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/overview/LastBgData.kt +++ b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/overview/LastBgData.kt @@ -20,6 +20,13 @@ interface LastBgData { */ fun lastBg(): InMemoryGlucoseValue? + /** + * Is last value below display very low target? + * + * @return true if below + */ + fun isVeryLow(): Boolean + /** * Is last value below display low target? * diff --git a/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt b/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt index 4a7187c2a0eb..17b053f298e9 100644 --- a/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt +++ b/core/keys/src/main/kotlin/app/aaps/core/keys/UnitDoubleKey.kt @@ -17,6 +17,7 @@ enum class UnitDoubleKey( OverviewEatingSoonTarget("eatingsoon_target", 90.0, 72, 160, defaultedBySM = true), OverviewActivityTarget("activity_target", 140.0, 108, 180, defaultedBySM = true), OverviewHypoTarget("hypo_target", 160.0, 108, 180, defaultedBySM = true), + OverviewVeryLowMark("very_low_mark", 55.0, 40, 80, showInNsClientMode = false), OverviewLowMark("low_mark", 72.0, 25, 160, showInNsClientMode = false, hideParentScreenIfHidden = true), OverviewHighMark("high_mark", 180.0, 90, 250, showInNsClientMode = false), OverviewVeryHighMark("very_high_mark", 400.0, 200, 400, showInNsClientMode = false), diff --git a/core/ui/src/main/res/values-night/styles.xml b/core/ui/src/main/res/values-night/styles.xml index 73fb5cc1c05a..6d3d193bdd32 100644 --- a/core/ui/src/main/res/values-night/styles.xml +++ b/core/ui/src/main/res/values-night/styles.xml @@ -111,7 +111,8 @@ @color/byodaGray @color/colorCalibrationButton - @color/low + @color/low + @color/high @color/high @color/low @color/inRange diff --git a/core/ui/src/main/res/values/attrs.xml b/core/ui/src/main/res/values/attrs.xml index 14032d86bcfd..09c1e1124c25 100644 --- a/core/ui/src/main/res/values/attrs.xml +++ b/core/ui/src/main/res/values/attrs.xml @@ -87,6 +87,7 @@ + diff --git a/core/ui/src/main/res/values/colors.xml b/core/ui/src/main/res/values/colors.xml index a111c61302a4..09965ebd532e 100644 --- a/core/ui/src/main/res/values/colors.xml +++ b/core/ui/src/main/res/values/colors.xml @@ -358,7 +358,8 @@ we generate extra colornames only used for the widget Colors for the widget are always taken from the default color.xml--> #00FF00 - #FF0000 + #FF0000 + #FFFF00 #FFFF00 #FF0000 #f4d700 diff --git a/core/ui/src/main/res/values/styles.xml b/core/ui/src/main/res/values/styles.xml index acbd98ecb741..422c4a84d589 100644 --- a/core/ui/src/main/res/values/styles.xml +++ b/core/ui/src/main/res/values/styles.xml @@ -114,7 +114,8 @@ @color/byodaGray @color/colorCalibrationButton - @color/low + @color/low + @color/high @color/high @color/low @color/tempTargetConfirmation diff --git a/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt b/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt index 5ca8202cb485..c39e7df1a90d 100644 --- a/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt +++ b/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt @@ -31,6 +31,11 @@ class LastBgDataImpl @Inject constructor( iobCobCalculator.ads.bucketedData?.firstOrNull() ?: persistenceLayer.getLastGlucoseValue()?.let { InMemoryGlucoseValue.fromGv(it) } + override fun isVeryLow(): Boolean = + lastBg()?.let { lastBg -> + lastBg.valueToUnits(profileFunction.getUnits()) < preferences.get(UnitDoubleKey.OverviewVeryLowMark) + } == true + override fun isLow(): Boolean = lastBg()?.let { lastBg -> lastBg.valueToUnits(profileFunction.getUnits()) < preferences.get(UnitDoubleKey.OverviewLowMark) @@ -49,6 +54,7 @@ class LastBgDataImpl @Inject constructor( @ColorInt override fun lastBgColor(context: Context?): Int = when { + isVeryLow() -> rh.gac(context, app.aaps.core.ui.R.attr.bgVeryLow) isLow() -> rh.gac(context, app.aaps.core.ui.R.attr.bgLow) isVeryHigh() -> rh.gac(context, app.aaps.core.ui.R.attr.veryHighColor) isHigh() -> rh.gac(context, app.aaps.core.ui.R.attr.highColor) diff --git a/plugins/configuration/src/main/kotlin/app/aaps/plugins/configuration/setupwizard/SWDefinition.kt b/plugins/configuration/src/main/kotlin/app/aaps/plugins/configuration/setupwizard/SWDefinition.kt index 83524ad7ae40..512579e2feef 100644 --- a/plugins/configuration/src/main/kotlin/app/aaps/plugins/configuration/setupwizard/SWDefinition.kt +++ b/plugins/configuration/src/main/kotlin/app/aaps/plugins/configuration/setupwizard/SWDefinition.kt @@ -133,6 +133,14 @@ class SWDefinition @Inject constructor( private val displaySettings get() = SWScreen(injector, R.string.display_settings) .skippable(false) + .add( + SWEditNumberWithUnits(injector, UnitDoubleKey.OverviewVeryLowMark.defaultValue * Constants.MGDL_TO_MMOLL, 3.0, 8.0) + .preference(UnitDoubleKey.OverviewVeryLowMark) + .updateDelay(5) + .label(R.string.very_low_mark) + .comment(R.string.very_low_mark_comment) + ) + .add(SWBreak(injector)) .add( SWEditNumberWithUnits(injector, UnitDoubleKey.OverviewLowMark.defaultValue * Constants.MGDL_TO_MMOLL, 3.0, 8.0) .preference(UnitDoubleKey.OverviewLowMark) diff --git a/plugins/configuration/src/main/res/values/strings.xml b/plugins/configuration/src/main/res/values/strings.xml index 3277ff475e4c..d32a95dda3f1 100644 --- a/plugins/configuration/src/main/res/values/strings.xml +++ b/plugins/configuration/src/main/res/values/strings.xml @@ -14,9 +14,11 @@ MUST NOT BE USED TO MAKE MEDICAL DECISIONS. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. I UNDERSTAND AND AGREE Display Settings + VERY LOW mark LOW mark HIGH mark VERY HIGH mark + Very Low value of in range area (display only) Lower value of in range area (display only) Higher value of in range area (display only) Even Higher value of in range area (display only) diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt index 3177c4e448ba..26631ed42059 100644 --- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt +++ b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt @@ -148,6 +148,7 @@ class OverviewPlugin @Inject constructor( .put(UnitDoubleKey.OverviewActivityTarget, preferences) .put(IntKey.OverviewHypoDuration, preferences) .put(UnitDoubleKey.OverviewHypoTarget, preferences) + .put(UnitDoubleKey.OverviewVeryLowMark, preferences) .put(UnitDoubleKey.OverviewLowMark, preferences) .put(UnitDoubleKey.OverviewHighMark, preferences) .put(UnitDoubleKey.OverviewVeryHighMark, preferences) @@ -179,6 +180,7 @@ class OverviewPlugin @Inject constructor( .store(UnitDoubleKey.OverviewActivityTarget, preferences) .store(IntKey.OverviewHypoDuration, preferences) .store(UnitDoubleKey.OverviewHypoTarget, preferences) + .store(UnitDoubleKey.OverviewVeryLowMark, preferences) .store(UnitDoubleKey.OverviewLowMark, preferences) .store(UnitDoubleKey.OverviewHighMark, preferences) .store(UnitDoubleKey.OverviewVeryHighMark, preferences) @@ -260,6 +262,7 @@ class OverviewPlugin @Inject constructor( key = "range_settings" summary = rh.gs(R.string.prefs_range_summary) title = rh.gs(R.string.prefs_range_title) + addPreference(AdaptiveUnitPreference(ctx = context, unitKey = UnitDoubleKey.OverviewVeryLowMark, title = R.string.very_low_mark)) addPreference(AdaptiveUnitPreference(ctx = context, unitKey = UnitDoubleKey.OverviewLowMark, title = R.string.low_mark)) addPreference(AdaptiveUnitPreference(ctx = context, unitKey = UnitDoubleKey.OverviewHighMark, title = R.string.high_mark)) addPreference(AdaptiveUnitPreference(ctx = context, unitKey = UnitDoubleKey.OverviewVeryHighMark, title = R.string.very_high_mark)) diff --git a/plugins/main/src/main/res/values/strings.xml b/plugins/main/src/main/res/values/strings.xml index 04e280c07da8..bb9cb6f6828b 100644 --- a/plugins/main/src/main/res/values/strings.xml +++ b/plugins/main/src/main/res/values/strings.xml @@ -262,6 +262,7 @@ Button 3 Range for visualization High and low mark for the charts in Overview and Smartwatch + VERY LOW mark LOW mark HIGH mark VERY HIGH mark diff --git a/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt b/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt index b805ceb17832..624c53aa74b7 100644 --- a/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt +++ b/ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt @@ -149,6 +149,7 @@ class Widget : AppWidgetProvider() { lastBgData.lastBg()?.let { profileUtil.fromMgdlToStringInUnits(it.recalculated) } ?: rh.gs(app.aaps.core.ui.R.string.value_unavailable_short)) views.setTextColor( R.id.bg, when { + lastBgData.isVeryLow() -> rh.gc(app.aaps.core.ui.R.color.widget_very_low) lastBgData.isLow() -> rh.gc(app.aaps.core.ui.R.color.widget_low) lastBgData.isVeryHigh() -> rh.gc(app.aaps.core.ui.R.color.widget_very_high) lastBgData.isHigh() -> rh.gc(app.aaps.core.ui.R.color.widget_high) @@ -161,6 +162,7 @@ class Widget : AppWidgetProvider() { views.setViewVisibility(R.id.arrow, (trendCalculator.getTrendArrow(iobCobCalculator.ads) != null).toVisibilityKeepSpace()) views.setInt( R.id.arrow, "setColorFilter", when { + lastBgData.isVeryLow() -> rh.gc(app.aaps.core.ui.R.color.widget_very_low) lastBgData.isLow() -> rh.gc(app.aaps.core.ui.R.color.widget_low) lastBgData.isVeryHigh() -> rh.gc(app.aaps.core.ui.R.color.widget_very_high) lastBgData.isHigh() -> rh.gc(app.aaps.core.ui.R.color.widget_high) From d0aaa690c8d04104e3dcdd3c5ae3ca8913d46023 Mon Sep 17 00:00:00 2001 From: Friedel van Megen Date: Fri, 28 Feb 2025 00:18:16 +0100 Subject: [PATCH 10/12] prepare for wear --- .../core/interfaces/rx/weardata/EventData.kt | 2 + .../interfaces/rx/weardata/EventDataTest.kt | 6 +- .../aaps/plugins/sync/tizen/TizenPlugin.kt | 2 + .../wear/wearintegration/DataHandlerMobile.kt | 6 ++ .../plugins/sync/tizen/TizenPluginTest.kt | 2 + .../app/aaps/wear/data/RawDisplayData.kt | 6 ++ .../aaps/wear/watchfaces/CircleWatchface.kt | 29 ++++++-- .../aaps/wear/watchfaces/CustomWatchface.kt | 9 +-- .../wear/watchfaces/DigitalStyleWatchface.kt | 11 +-- .../wear/watchfaces/utils/BaseWatchFace.kt | 12 ++-- .../wear/watchfaces/utils/BgGraphBuilder.kt | 72 ++++++++++++++++--- wear/src/main/res/values/colors.xml | 4 +- .../wear/testing/mockers/RawDataMocker.kt | 6 +- 13 files changed, 135 insertions(+), 32 deletions(-) diff --git a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/EventData.kt b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/EventData.kt index 4f006f74b306..e7e6a4d6af44 100644 --- a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/EventData.kt +++ b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/EventData.kt @@ -255,8 +255,10 @@ 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, diff --git a/core/interfaces/src/test/kotlin/app/aaps/core/interfaces/rx/weardata/EventDataTest.kt b/core/interfaces/src/test/kotlin/app/aaps/core/interfaces/rx/weardata/EventDataTest.kt index 27be941de858..7f6dacfa6f70 100644 --- a/core/interfaces/src/test/kotlin/app/aaps/core/interfaces/rx/weardata/EventDataTest.kt +++ b/core/interfaces/src/test/kotlin/app/aaps/core/interfaces/rx/weardata/EventDataTest.kt @@ -140,11 +140,11 @@ class EventDataTest { assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } - EventData.SingleBg(dataset = 0, 1, sgv = 2.0, high = 3.0, low = 4.0).let { + EventData.SingleBg(dataset = 0, 1, sgv = 2.0, veryHigh = 5.0, high = 3.0, low = 4.0, veryLow = 6.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, high = 3.0, low = 4.0))).let { + EventData.GraphData(arrayListOf(EventData.SingleBg(dataset = 0, 1, sgv = 2.0, veryHigh = 5.0, high = 3.0, low = 4.0, veryLow = 6.0))).let { assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) } @@ -152,7 +152,7 @@ class EventDataTest { 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, high = 3.0, low = 4.0)) + arrayListOf(EventData.SingleBg(dataset = 0, 1, sgv = 2.0, veryHigh = 5.0, high = 3.0, low = 4.0, veryLow = 6.0)) ).let { assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it) assertThat(EventData.deserialize(it.serialize())).isEqualTo(it) diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt index e261cceb120c..3b00c18be623 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/tizen/TizenPlugin.kt @@ -125,8 +125,10 @@ 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) { diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt index c4228a97deec..88ff274d8fce 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt @@ -1331,8 +1331,10 @@ 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) ) ) @@ -1466,8 +1468,10 @@ 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, @@ -1481,8 +1485,10 @@ 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 diff --git a/plugins/sync/src/test/kotlin/app/aaps/plugins/sync/tizen/TizenPluginTest.kt b/plugins/sync/src/test/kotlin/app/aaps/plugins/sync/tizen/TizenPluginTest.kt index 84430b44ea52..9d411bf0265e 100644 --- a/plugins/sync/src/test/kotlin/app/aaps/plugins/sync/tizen/TizenPluginTest.kt +++ b/plugins/sync/src/test/kotlin/app/aaps/plugins/sync/tizen/TizenPluginTest.kt @@ -82,8 +82,10 @@ 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() diff --git a/wear/src/main/kotlin/app/aaps/wear/data/RawDisplayData.kt b/wear/src/main/kotlin/app/aaps/wear/data/RawDisplayData.kt index 5696d8218bc1..4a386c7de717 100644 --- a/wear/src/main/kotlin/app/aaps/wear/data/RawDisplayData.kt +++ b/wear/src/main/kotlin/app/aaps/wear/data/RawDisplayData.kt @@ -27,8 +27,10 @@ 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 @@ -44,8 +46,10 @@ 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, @@ -61,8 +65,10 @@ 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, diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt index fcadf1080113..4acd81714028 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt @@ -253,11 +253,16 @@ 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 - when (singleBg[0].sgvLevel.toInt()) { - -1 -> color = lowColor - 0 -> color = inRangeColor - 1 -> color = highColor + + 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 } + circlePaint.shader = null circlePaint.style = Paint.Style.STROKE circlePaint.strokeWidth = CIRCLE_WIDTH @@ -292,12 +297,16 @@ class CircleWatchface : WatchFace() { } // defining color for dark and bright - private val lowColor: Int + 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) 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 @@ -309,8 +318,10 @@ 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) @@ -406,9 +417,15 @@ class CircleWatchface : WatchFace() { indicatorColor = Color.LTGRAY } var barColor = Color.GRAY - if (entry.sgv >= entry.high) { + if (entry.sgv >= entry.veryHigh) { + indicatorColor = veryHighColor + barColor = darken(veryHighColor) + } else 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) diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt index 6955d6d9d5c6..4c3e11a2594b 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt @@ -71,10 +71,11 @@ class CustomWatchface : BaseWatchFace() { private var json = JSONObject() private var jsonString = "" - private fun bgColor(dataSet: Int): Int = when (singleBg[dataSet].sgvLevel) { - 1L -> highColor - 0L -> midColor - -1L -> lowColor + 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 else -> midColor } diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt index 0c9410d0ad6b..399ab024143e 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt @@ -36,12 +36,15 @@ class DigitalStyleWatchface : BaseWatchFace() { } override fun setColorDark() { - val color = when (singleBg[0].sgvLevel) { - 1L -> R.color.dark_highColor - 0L -> R.color.dark_midColor - -1L -> R.color.dark_lowColor + 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 else -> R.color.dark_midColor } + binding.sgv.setTextColor(ContextCompat.getColor(this, color)) binding.direction.setTextColor(ContextCompat.getColor(this, color)) diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BaseWatchFace.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BaseWatchFace.kt index d3f7700d934b..0e2579c92051 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BaseWatchFace.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BaseWatchFace.kt @@ -73,8 +73,10 @@ abstract class BaseWatchFace : WatchFace() { var loopLevelExt2 = -1 var enableExt1 = false var enableExt2 = false + var veryHighColor = Color.RED var highColor = Color.YELLOW - var lowColor = Color.RED + var lowColor = Color.YELLOW + var veryLowColor = Color.RED var midColor = Color.WHITE var gridColor = Color.WHITE var basalBackgroundColor = Color.BLUE @@ -552,12 +554,14 @@ 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, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, carbColor, timeframe + sp, dateUtil, graphData.entries, treatmentData.predictions, treatmentData.temps, treatmentData.basals, treatmentData.boluses, pointSize, + veryHighColor, highColor, lowColor, veryLowColor, midColor, gridColor, + basalBackgroundColor, basalCenterColor, bolusColor, carbColor, timeframe ) binding.chart?.lineChartData = bgGraphBuilder.lineData() binding.chart?.isViewportCalculationEnabled = true diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BgGraphBuilder.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BgGraphBuilder.kt index c488257a45cd..546d7d8849dd 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BgGraphBuilder.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BgGraphBuilder.kt @@ -28,8 +28,10 @@ class BgGraphBuilder( private val basalWatchDataList: ArrayList, private val bolusWatchDataList: ArrayList, private val pointSize: Int, + private val veryHighColor: Int, private val highColor: Int, private val lowColor: Int, + private val veryLowColor: Int, private val midColor: Int, private val gridColour: Int, private val basalBackgroundColor: Int, @@ -42,11 +44,15 @@ class BgGraphBuilder( private var endingTime: Long = System.currentTimeMillis() + 1000L * 60 * 6 * timeSpan private var startingTime: Long = System.currentTimeMillis() - 1000L * 60 * 60 * timeSpan private var fuzzyTimeDiv = (1000 * 60 * 1).toDouble() + private var veryHighMark: Double = bgDataList[bgDataList.size - 1].veryHigh private var highMark: Double = bgDataList[bgDataList.size - 1].high private var lowMark: Double = bgDataList[bgDataList.size - 1].low + private var veryLowMark: Double = bgDataList[bgDataList.size - 1].veryLow private val inRangeValues: MutableList = ArrayList() + private val veryHighValues: MutableList = ArrayList() private val highValues: MutableList = ArrayList() private val lowValues: MutableList = ArrayList() + private val veryLowValues: MutableList = ArrayList() private val predictionEndTime: Long get() { @@ -72,11 +78,17 @@ class BgGraphBuilder( tempWatchDataList: List, basalWatchDataList: ArrayList, bolusWatchDataList: ArrayList, - aPointSize: Int, aMidColor: Int, gridColour: Int, basalBackgroundColor: Int, basalCenterColor: Int, bolusInvalidColor: Int, carbsColor: Int, timeSpan: Int + aPointSize: Int, + aMidColor: Int, + gridColour: Int, + basalBackgroundColor: Int, + basalCenterColor: Int, + bolusInvalidColor: Int, + carbsColor: Int, + timeSpan: Int ) : this( - sp, dateUtil, - aBgList, predictionsList, tempWatchDataList, basalWatchDataList, - bolusWatchDataList, aPointSize, aMidColor, aMidColor, aMidColor, gridColour, + sp, dateUtil, aBgList, predictionsList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, aPointSize, + aMidColor, aMidColor, aMidColor, aMidColor, aMidColor, gridColour, basalBackgroundColor, basalCenterColor, bolusInvalidColor, carbsColor, timeSpan ) @@ -92,11 +104,15 @@ class BgGraphBuilder( private fun defaultLines(): List { addBgReadingValues() val lines: MutableList = ArrayList() + lines.add(veryHighLine()) lines.add(highLine()) lines.add(lowLine()) + lines.add(veryLowLine()) lines.add(inRangeValuesLine()) + lines.add(veryLowValuesLine()) lines.add(lowValuesLine()) lines.add(highValuesLine()) + lines.add(veryHighValuesLine()) var minChart = lowMark var maxChart = highMark for ((_, _, _, _, _, _, _, _, _, _, sgv) in bgDataList) { @@ -215,7 +231,7 @@ class BgGraphBuilder( private fun addPredictionLines(lines: MutableList) { val values: MutableMap> = HashMap() - for ((_, timeStamp, _, _, _, _, _, _, _, _, sgv, _, _, color) in predictionsList) { + for ((_, timeStamp, _, _, _, _, _, _, _, _, _, _, sgv, _, _, color) in predictionsList) { if (timeStamp <= predictionEndTime) { val value = min(sgv, UPPER_CUTOFF_SGV) if (!values.containsKey(color)) { @@ -236,6 +252,14 @@ class BgGraphBuilder( } } + private fun veryHighValuesLine(): Line = + Line(veryHighValues).also { veryHighValuesLine -> + veryHighValuesLine.color = veryHighColor + veryHighValuesLine.setHasLines(false) + veryHighValuesLine.pointRadius = pointSize + veryHighValuesLine.setHasPoints(true) + } + private fun highValuesLine(): Line = Line(highValues).also { highValuesLine -> highValuesLine.color = highColor @@ -252,6 +276,14 @@ class BgGraphBuilder( lowValuesLine.setHasPoints(true) } + private fun veryLowValuesLine(): Line = + Line(veryLowValues).also { veryLowValuesLine -> + veryLowValuesLine.color = veryLowColor + veryLowValuesLine.setHasLines(false) + veryLowValuesLine.pointRadius = pointSize + veryLowValuesLine.setHasPoints(true) + } + private fun inRangeValuesLine(): Line = Line(inRangeValues).also { inRangeValuesLine -> inRangeValuesLine.color = midColor @@ -283,11 +315,13 @@ class BgGraphBuilder( for ((_, timeStamp, _, _, _, _, _, _, _, _, sgv) in bgDataList) { if (timeStamp > startingTime) { when { - sgv >= 450 -> highValues.add(PointValue(fuzz(timeStamp), 450.toFloat())) + sgv >= 450 -> veryHighValues.add(PointValue(fuzz(timeStamp), 450.toFloat())) + sgv >= veryHighMark -> veryHighValues.add(PointValue(fuzz(timeStamp), sgv.toFloat())) sgv >= highMark -> highValues.add(PointValue(fuzz(timeStamp), sgv.toFloat())) sgv >= lowMark -> inRangeValues.add(PointValue(fuzz(timeStamp), sgv.toFloat())) - sgv >= 40 -> lowValues.add(PointValue(fuzz(timeStamp), sgv.toFloat())) - sgv >= 11 -> lowValues.add(PointValue(fuzz(timeStamp), 40.toFloat())) + sgv >= veryLowMark -> veryLowValues.add(PointValue(fuzz(timeStamp), sgv.toFloat())) + sgv >= 40 -> veryLowValues.add(PointValue(fuzz(timeStamp), sgv.toFloat())) + sgv >= 11 -> veryLowValues.add(PointValue(fuzz(timeStamp), 40.toFloat())) } } } @@ -304,6 +338,17 @@ class BgGraphBuilder( } } + private fun veryHighLine(): Line { + val veryHighLineValues: MutableList = ArrayList() + veryHighLineValues.add(PointValue(fuzz(startingTime), highMark.toFloat())) + veryHighLineValues.add(PointValue(fuzz(endingTime), highMark.toFloat())) + return Line(veryHighLineValues).also { veryHighLine -> + veryHighLine.setHasPoints(false) + veryHighLine.strokeWidth = 1 + veryHighLine.color = veryHighColor + } + } + private fun lowLine(): Line { val lowLineValues: MutableList = ArrayList() lowLineValues.add(PointValue(fuzz(startingTime), lowMark.toFloat())) @@ -315,6 +360,17 @@ class BgGraphBuilder( } } + private fun veryLowLine(): Line { + val veryLowLineValues: MutableList = ArrayList() + veryLowLineValues.add(PointValue(fuzz(startingTime), lowMark.toFloat())) + veryLowLineValues.add(PointValue(fuzz(endingTime), lowMark.toFloat())) + return Line(veryLowLineValues).also { veryLowLine -> + veryLowLine.setHasPoints(false) + veryLowLine.color = veryLowColor + veryLowLine.strokeWidth = 1 + } + } + /////////AXIS RELATED////////////// private fun yAxis(): Axis = Axis().also { yAxis -> diff --git a/wear/src/main/res/values/colors.xml b/wear/src/main/res/values/colors.xml index c5d0cd2368e0..3591fe723220 100644 --- a/wear/src/main/res/values/colors.xml +++ b/wear/src/main/res/values/colors.xml @@ -31,8 +31,10 @@ #ffff00 #ff4444 + @color/RED @color/yellow_A200 - @color/RED + @color/yellow_A200 + @color/RED @color/grey_50 @color/grey_50 diff --git a/wear/src/test/kotlin/app/aaps/wear/testing/mockers/RawDataMocker.kt b/wear/src/test/kotlin/app/aaps/wear/testing/mockers/RawDataMocker.kt index 0890c0fa12fb..30447277092b 100644 --- a/wear/src/test/kotlin/app/aaps/wear/testing/mockers/RawDataMocker.kt +++ b/wear/src/test/kotlin/app/aaps/wear/testing/mockers/RawDataMocker.kt @@ -38,7 +38,8 @@ class RawDataMocker { 0.0, 0.0, 0.0, - 0 + 0.0, + 0.0 ) ) return raw @@ -61,7 +62,8 @@ class RawDataMocker { 0.0, 0.0, 0.0, - 0 + 0.0, + 0.0 ) ) return raw From 45a6416a08253b61482947a0d386f5d1dfdb09d8 Mon Sep 17 00:00:00 2001 From: Friedel van Megen Date: Mon, 3 Mar 2025 13:31:29 +0100 Subject: [PATCH 11/12] adressing comments --- .../wear/wearintegration/DataHandlerMobile.kt | 8 ++++++- .../app/aaps/shared/impl/weardata/JsonKeys.kt | 2 ++ .../aaps/wear/watchfaces/CircleWatchface.kt | 13 ++++++------ .../aaps/wear/watchfaces/CustomWatchface.kt | 21 ++++++++++++------- .../wear/watchfaces/DigitalStyleWatchface.kt | 12 +++++------ .../wear/watchfaces/utils/BgGraphBuilder.kt | 8 +++---- wear/src/main/res/values/colors.xml | 3 ++- 7 files changed, 41 insertions(+), 26 deletions(-) diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt index 88ff274d8fce..8430ee696150 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt @@ -1483,7 +1483,13 @@ class DataHandlerMobile @Inject constructor( deltaDetailed = glucoseStatus?.let { deltaStringDetailed(it.delta, it.delta * Constants.MGDL_TO_MMOLL, units) } ?: "--", avgDelta = glucoseStatus?.let { deltaString(it.shortAvgDelta, it.shortAvgDelta * Constants.MGDL_TO_MMOLL, units) } ?: "--", 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, + sgvLevel = when { + glucoseValue.recalculated > veryHighLine -> 2L + glucoseValue.recalculated > highLine -> 1L + glucoseValue.recalculated < veryLowLine -> -2L + glucoseValue.recalculated < lowLine -> -1L + else -> 0L + }, sgv = glucoseValue.recalculated, veryHigh = veryHighLine, high = highLine, diff --git a/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt b/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt index a2475be56d26..e5a036636037 100644 --- a/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt +++ b/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt @@ -3,9 +3,11 @@ package app.aaps.shared.impl.weardata enum class JsonKeys(val key: String) { METADATA("metadata"), ENABLESECOND("enableSecond"), + VERYHIGHCOLOR("veryhighColor"), HIGHCOLOR("highColor"), MIDCOLOR("midColor"), LOWCOLOR("lowColor"), + VERYLOWCOLOR("veryLowColor"), LOWBATCOLOR("lowBatColor"), CARBCOLOR("carbColor"), BASALBACKGROUNDCOLOR("basalBackgroundColor"), diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt index 4acd81714028..bec8f162dcca 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt @@ -254,13 +254,12 @@ class CircleWatchface : WatchFace() { 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()) { + -2 -> color = veryLowColor + -1 -> color = lowColor + 0 -> color = inRangeColor + 1 -> color = highColor + 2 -> color = veryHighColor } circlePaint.shader = null diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt index 4c3e11a2594b..9a40c196b2a2 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt @@ -71,11 +71,12 @@ 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) { + 2L -> veryHighColor + 1L -> highColor + 0L -> midColor + -1L -> lowColor + -2L -> veryLowColor else -> midColor } @@ -240,9 +241,11 @@ class CustomWatchface : BaseWatchFace() { binding.dayName.text = dateUtil.dayNameString(dayNameFormat).substringBeforeLast(".") // Update dayName and month according to format on cwf loading binding.month.text = dateUtil.monthString(monthFormat).substringBeforeLast(".") val jsonColor = dynPref[json.optString(JsonKeys.DYNPREFCOLOR.key)] ?: json + veryHighColor = getColor(jsonColor.optString(JsonKeys.VERYHIGHCOLOR.key), ContextCompat.getColor(this, R.color.dark_veryHighColor)) highColor = getColor(jsonColor.optString(JsonKeys.HIGHCOLOR.key), ContextCompat.getColor(this, R.color.dark_highColor)) midColor = getColor(jsonColor.optString(JsonKeys.MIDCOLOR.key), ContextCompat.getColor(this, R.color.inrange)) lowColor = getColor(jsonColor.optString(JsonKeys.LOWCOLOR.key), ContextCompat.getColor(this, R.color.low)) + veryLowColor = getColor(jsonColor.optString(JsonKeys.VERYLOWCOLOR.key), ContextCompat.getColor(this, R.color.veryLow)) lowBatColor = getColor(jsonColor.optString(JsonKeys.LOWBATCOLOR.key), ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)) carbColor = getColor(jsonColor.optString(JsonKeys.CARBCOLOR.key), ContextCompat.getColor(this, R.color.carbs)) basalBackgroundColor = getColor(jsonColor.optString(JsonKeys.BASALBACKGROUNDCOLOR.key), ContextCompat.getColor(this, R.color.basal_dark)) @@ -362,9 +365,11 @@ class CustomWatchface : BaseWatchFace() { } private fun setDefaultColors() { + veryHighColor = Color.parseColor("#FF0000") highColor = Color.parseColor("#FFFF00") midColor = Color.parseColor("#00FF00") - lowColor = Color.parseColor("#FF0000") + lowColor = Color.parseColor("#FFFF00") + veryLowColor = Color.parseColor("#FF0000") carbColor = ContextCompat.getColor(this, R.color.carbs) basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) basalCenterColor = ContextCompat.getColor(this, R.color.basal_light) @@ -608,8 +613,10 @@ class CustomWatchface : BaseWatchFace() { var textDrawable: Drawable? = null val drawable: Drawable? get() = dynData?.getDrawable() ?: when (cwf.singleBg[0].sgvLevel) { + 2L -> highCustom ?: rangeCustom 1L -> highCustom ?: rangeCustom 0L -> rangeCustom + -2L -> lowCustom ?: rangeCustom -1L -> lowCustom ?: rangeCustom else -> rangeCustom } @@ -853,7 +860,7 @@ class CustomWatchface : BaseWatchFace() { private enum class ValueMap(val key: String, val min: Double, val max: Double) { NONE("", 0.0, 0.0), SGV(ViewKeys.SGV.key, 39.0, 400.0), - SGV_LEVEL(JsonKeyValues.SGV_LEVEL.key, -1.0, 1.0), + SGV_LEVEL(JsonKeyValues.SGV_LEVEL.key, -2.0, 2.0), DIRECTION(ViewKeys.DIRECTION.key, 1.0, 7.0), DELTA(ViewKeys.DELTA.key, -25.0, 25.0), AVG_DELTA(ViewKeys.AVG_DELTA.key, -25.0, 25.0), diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt index 399ab024143e..d1421d24eb0a 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt @@ -36,12 +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) { + 2L -> R.color.dark_veryHighColor + 1L -> R.color.dark_highColor + 0L -> R.color.dark_midColor + -1L -> R.color.dark_lowColor + -2L -> R.color.dark_veryLowColor else -> R.color.dark_midColor } diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BgGraphBuilder.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BgGraphBuilder.kt index 546d7d8849dd..710206c936f1 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BgGraphBuilder.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/utils/BgGraphBuilder.kt @@ -340,8 +340,8 @@ class BgGraphBuilder( private fun veryHighLine(): Line { val veryHighLineValues: MutableList = ArrayList() - veryHighLineValues.add(PointValue(fuzz(startingTime), highMark.toFloat())) - veryHighLineValues.add(PointValue(fuzz(endingTime), highMark.toFloat())) + veryHighLineValues.add(PointValue(fuzz(startingTime), veryHighMark.toFloat())) + veryHighLineValues.add(PointValue(fuzz(endingTime), veryHighMark.toFloat())) return Line(veryHighLineValues).also { veryHighLine -> veryHighLine.setHasPoints(false) veryHighLine.strokeWidth = 1 @@ -362,8 +362,8 @@ class BgGraphBuilder( private fun veryLowLine(): Line { val veryLowLineValues: MutableList = ArrayList() - veryLowLineValues.add(PointValue(fuzz(startingTime), lowMark.toFloat())) - veryLowLineValues.add(PointValue(fuzz(endingTime), lowMark.toFloat())) + veryLowLineValues.add(PointValue(fuzz(startingTime), veryLowMark.toFloat())) + veryLowLineValues.add(PointValue(fuzz(endingTime), veryLowMark.toFloat())) return Line(veryLowLineValues).also { veryLowLine -> veryLowLine.setHasPoints(false) veryLowLine.color = veryLowColor diff --git a/wear/src/main/res/values/colors.xml b/wear/src/main/res/values/colors.xml index 3591fe723220..fa68a0a29a67 100644 --- a/wear/src/main/res/values/colors.xml +++ b/wear/src/main/res/values/colors.xml @@ -54,7 +54,8 @@ #00FF00 #67DFE8 #FFFB8C00 - #FF0000 + #FFFF00 + #FF0000 #77dd77 From b1105409d87b4703c0f80c7fe298c8bb17d0e302 Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 3 Mar 2025 21:38:46 +0100 Subject: [PATCH 12/12] Update CustomWatchface for VeryLow and VeryHigh --- .../core/interfaces/rx/weardata/ResFormat.kt | 2 +- .../wear/wearintegration/DataHandlerMobile.kt | 9 ++- .../app/aaps/shared/impl/weardata/JsonKeys.kt | 2 + .../aaps/shared/impl/weardata/ResFileMap.kt | 12 ++++ .../aaps/wear/watchfaces/CircleWatchface.kt | 14 ++--- .../aaps/wear/watchfaces/CustomWatchface.kt | 57 ++++++++++++++----- .../wear/watchfaces/DigitalStyleWatchface.kt | 13 ++--- 7 files changed, 76 insertions(+), 33 deletions(-) diff --git a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/ResFormat.kt b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/ResFormat.kt index 51a53aed39cf..8fc8c0817474 100644 --- a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/ResFormat.kt +++ b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/ResFormat.kt @@ -1,6 +1,6 @@ package app.aaps.core.interfaces.rx.weardata -const val CUSTOM_VERSION = "2.0" +const val CUSTOM_VERSION = "2.1" enum class ResFormat(val extension: String) { UNKNOWN(""), diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt index 88ff274d8fce..39177b8fee67 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/wearintegration/DataHandlerMobile.kt @@ -1472,6 +1472,13 @@ class DataHandlerMobile @Inject constructor( 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) + val sgvLevel = when { + glucoseValue.recalculated > veryHighLine -> 2L + glucoseValue.recalculated > highLine -> 1L + glucoseValue.recalculated < veryLowLine -> -2L + glucoseValue.recalculated < lowLine -> -1L + else -> 0L + } return EventData.SingleBg( dataset = 0, @@ -1483,7 +1490,7 @@ class DataHandlerMobile @Inject constructor( deltaDetailed = glucoseStatus?.let { deltaStringDetailed(it.delta, it.delta * Constants.MGDL_TO_MMOLL, units) } ?: "--", avgDelta = glucoseStatus?.let { deltaString(it.shortAvgDelta, it.shortAvgDelta * Constants.MGDL_TO_MMOLL, units) } ?: "--", 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, + sgvLevel = sgvLevel, sgv = glucoseValue.recalculated, veryHigh = veryHighLine, high = highLine, diff --git a/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt b/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt index a2475be56d26..b4f58a003de8 100644 --- a/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt +++ b/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/JsonKeys.kt @@ -3,9 +3,11 @@ package app.aaps.shared.impl.weardata enum class JsonKeys(val key: String) { METADATA("metadata"), ENABLESECOND("enableSecond"), + VERYHIGHCOLOR("veryHighColor"), HIGHCOLOR("highColor"), MIDCOLOR("midColor"), LOWCOLOR("lowColor"), + VERYLOWCOLOR("veryLowColor"), LOWBATCOLOR("lowBatColor"), CARBCOLOR("carbColor"), BASALBACKGROUNDCOLOR("basalBackgroundColor"), diff --git a/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/ResFileMap.kt b/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/ResFileMap.kt index d79c6b93d0a3..0161f91b65b7 100644 --- a/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/ResFileMap.kt +++ b/shared/impl/src/main/kotlin/app/aaps/shared/impl/weardata/ResFileMap.kt @@ -6,21 +6,33 @@ enum class ResFileMap(val fileName: String) { BACKGROUND("Background"), BACKGROUND_HIGH("BackgroundHigh"), BACKGROUND_LOW("BackgroundLow"), + BACKGROUND_VERY_HIGH("BackgroundVeryHigh"), + BACKGROUND_VERY_LOW("BackgroundVeryLow"), COVER_CHART("CoverChart"), COVER_CHART_HIGH("CoverChartHigh"), COVER_CHART_LOW("CoverChartLow"), + COVER_CHART_VERY_HIGH("CoverChartVeryHigh"), + COVER_CHART_VERY_LOW("CoverChartVeryLow"), COVER_PLATE("CoverPlate"), COVER_PLATE_HIGH("CoverPlateHigh"), COVER_PLATE_LOW("CoverPlateLow"), + COVER_PLATE_VERY_HIGH("CoverPlateVeryHigh"), + COVER_PLATE_VERY_LOW("CoverPlateVeryLow"), HOUR_HAND("HourHand"), HOUR_HAND_HIGH("HourHandHigh"), HOUR_HAND_LOW("HourHandLow"), + HOUR_HAND_VERY_HIGH("HourHandVeryHigh"), + HOUR_HAND_VERY_LOW("HourHandVeryLow"), MINUTE_HAND("MinuteHand"), MINUTE_HAND_HIGH("MinuteHandHigh"), MINUTE_HAND_LOW("MinuteHandLow"), + MINUTE_HAND_VERY_HIGH("MinuteHandVeryHigh"), + MINUTE_HAND_VERY_LOW("MinuteHandVeryLow"), SECOND_HAND("SecondHand"), SECOND_HAND_HIGH("SecondHandHigh"), SECOND_HAND_LOW("SecondHandLow"), + SECOND_HAND_VERY_HIGH("SecondHandVeryHigh"), + SECOND_HAND_VERY_LOW("SecondHandVeryLow"), ARROW_NONE("ArrowNone"), ARROW_DOUBLE_UP("ArrowDoubleUp"), ARROW_SINGLE_UP("ArrowSingleUp"), diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt index 4acd81714028..60e2279b35fe 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CircleWatchface.kt @@ -252,17 +252,13 @@ class CircleWatchface : WatchFace() { val minute = Calendar.getInstance()[Calendar.MINUTE] 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 + color = when (singleBg[0].sgvLevel.toInt()) { + -2 -> veryLowColor + -1 -> lowColor + 1 -> highColor + 2 -> veryHighColor else -> inRangeColor } - circlePaint.shader = null circlePaint.style = Paint.Style.STROKE circlePaint.strokeWidth = CIRCLE_WIDTH diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt index 4c3e11a2594b..2aaede75a03a 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt @@ -71,11 +71,12 @@ 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) { + 2L -> veryHighColor + 1L -> highColor + 0L -> midColor + -1L -> lowColor + -2L -> veryLowColor else -> midColor } @@ -241,8 +242,10 @@ class CustomWatchface : BaseWatchFace() { binding.month.text = dateUtil.monthString(monthFormat).substringBeforeLast(".") val jsonColor = dynPref[json.optString(JsonKeys.DYNPREFCOLOR.key)] ?: json highColor = getColor(jsonColor.optString(JsonKeys.HIGHCOLOR.key), ContextCompat.getColor(this, R.color.dark_highColor)) + veryHighColor = getColor(jsonColor.optString(JsonKeys.VERYHIGHCOLOR.key), highColor) midColor = getColor(jsonColor.optString(JsonKeys.MIDCOLOR.key), ContextCompat.getColor(this, R.color.inrange)) lowColor = getColor(jsonColor.optString(JsonKeys.LOWCOLOR.key), ContextCompat.getColor(this, R.color.low)) + veryLowColor = getColor(jsonColor.optString(JsonKeys.VERYLOWCOLOR.key), lowColor) lowBatColor = getColor(jsonColor.optString(JsonKeys.LOWBATCOLOR.key), ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)) carbColor = getColor(jsonColor.optString(JsonKeys.CARBCOLOR.key), ContextCompat.getColor(this, R.color.carbs)) basalBackgroundColor = getColor(jsonColor.optString(JsonKeys.BASALBACKGROUNDCOLOR.key), ContextCompat.getColor(this, R.color.basal_dark)) @@ -301,9 +304,11 @@ class CustomWatchface : BaseWatchFace() { .put(CwfMetadataKey.CWF_COMMENT.key, if (externalViews) getString(app.aaps.core.interfaces.R.string.default_custom_watchface_external_comment) else getString(app.aaps.core.interfaces.R.string.default_custom_watchface_comment)) val json = JSONObject() .put(JsonKeys.METADATA.key, metadata) + .put(JsonKeys.VERYHIGHCOLOR.key, String.format("#%06X", 0xFFFFFF and veryHighColor)) .put(JsonKeys.HIGHCOLOR.key, String.format("#%06X", 0xFFFFFF and highColor)) .put(JsonKeys.MIDCOLOR.key, String.format("#%06X", 0xFFFFFF and midColor)) .put(JsonKeys.LOWCOLOR.key, String.format("#%06X", 0xFFFFFF and lowColor)) + .put(JsonKeys.VERYLOWCOLOR.key, String.format("#%06X", 0xFFFFFF and veryLowColor)) .put(JsonKeys.LOWBATCOLOR.key, String.format("#%06X", 0xFFFFFF and lowBatColor)) .put(JsonKeys.CARBCOLOR.key, String.format("#%06X", 0xFFFFFF and carbColor)) .put(JsonKeys.BASALBACKGROUNDCOLOR.key, String.format("#%06X", 0xFFFFFF and basalBackgroundColor)) @@ -362,9 +367,11 @@ class CustomWatchface : BaseWatchFace() { } private fun setDefaultColors() { + veryHighColor = Color.parseColor("#FF0000") highColor = Color.parseColor("#FFFF00") midColor = Color.parseColor("#00FF00") - lowColor = Color.parseColor("#FF0000") + lowColor = Color.parseColor("#FFFF00") + veryLowColor = Color.parseColor("#FF0000") carbColor = ContextCompat.getColor(this, R.color.carbs) basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) basalCenterColor = ContextCompat.getColor(this, R.color.basal_light) @@ -453,6 +460,8 @@ class CustomWatchface : BaseWatchFace() { val customDrawable: ResFileMap? = null, val customHigh: ResFileMap? = null, val customLow: ResFileMap? = null, + val customVeryHigh: ResFileMap? = null, + val customVeryLow: ResFileMap? = null, val external: Int = 0 ) { @@ -462,7 +471,9 @@ class CustomWatchface : BaseWatchFace() { defaultDrawable = R.drawable.background, customDrawable = ResFileMap.BACKGROUND, customHigh = ResFileMap.BACKGROUND_HIGH, - customLow = ResFileMap.BACKGROUND_LOW + customLow = ResFileMap.BACKGROUND_LOW, + customVeryHigh = ResFileMap.BACKGROUND_VERY_HIGH, + customVeryLow = ResFileMap.BACKGROUND_VERY_LOW ), CHART(ViewKeys.CHART.key, R.id.chart), COVER_CHART( @@ -470,7 +481,9 @@ class CustomWatchface : BaseWatchFace() { id = R.id.cover_chart, customDrawable = ResFileMap.COVER_CHART, customHigh = ResFileMap.COVER_CHART_HIGH, - customLow = ResFileMap.COVER_CHART_LOW + customLow = ResFileMap.COVER_CHART_LOW, + customVeryHigh = ResFileMap.COVER_CHART_VERY_HIGH, + customVeryLow = ResFileMap.COVER_CHART_VERY_LOW ), FREETEXT1(ViewKeys.FREETEXT1.key, R.id.freetext1), FREETEXT2(ViewKeys.FREETEXT2.key, R.id.freetext2), @@ -543,7 +556,9 @@ class CustomWatchface : BaseWatchFace() { defaultDrawable = R.drawable.simplified_dial, customDrawable = ResFileMap.COVER_PLATE, customHigh = ResFileMap.COVER_PLATE_HIGH, - customLow = ResFileMap.COVER_PLATE_LOW + customLow = ResFileMap.COVER_PLATE_LOW, + customVeryHigh = ResFileMap.COVER_PLATE_VERY_HIGH, + customVeryLow = ResFileMap.COVER_PLATE_VERY_LOW ), HOUR_HAND( key = ViewKeys.HOUR_HAND.key, @@ -551,7 +566,9 @@ class CustomWatchface : BaseWatchFace() { defaultDrawable = R.drawable.hour_hand, customDrawable = ResFileMap.HOUR_HAND, customHigh = ResFileMap.HOUR_HAND_HIGH, - customLow = ResFileMap.HOUR_HAND_LOW + customLow = ResFileMap.HOUR_HAND_LOW, + customVeryHigh = ResFileMap.HOUR_HAND_VERY_HIGH, + customVeryLow = ResFileMap.HOUR_HAND_VERY_LOW ), MINUTE_HAND( key = ViewKeys.MINUTE_HAND.key, @@ -559,7 +576,9 @@ class CustomWatchface : BaseWatchFace() { defaultDrawable = R.drawable.minute_hand, customDrawable = ResFileMap.MINUTE_HAND, customHigh = ResFileMap.MINUTE_HAND_HIGH, - customLow = ResFileMap.MINUTE_HAND_LOW + customLow = ResFileMap.MINUTE_HAND_LOW, + customVeryHigh = ResFileMap.MINUTE_HAND_VERY_HIGH, + customVeryLow = ResFileMap.MINUTE_HAND_VERY_LOW ), SECOND_HAND( key = ViewKeys.SECOND_HAND.key, @@ -568,7 +587,9 @@ class CustomWatchface : BaseWatchFace() { defaultDrawable = R.drawable.second_hand, customDrawable = ResFileMap.SECOND_HAND, customHigh = ResFileMap.SECOND_HAND_HIGH, - customLow = ResFileMap.SECOND_HAND_LOW + customLow = ResFileMap.SECOND_HAND_LOW, + customVeryHigh = ResFileMap.SECOND_HAND_VERY_HIGH, + customVeryLow = ResFileMap.SECOND_HAND_VERY_LOW ); companion object { @@ -605,12 +626,18 @@ class CustomWatchface : BaseWatchFace() { get() = field ?: customHigh?.let { cd -> cwf.resDataMap[cd.fileName]?.toDrawable(cwf.resources).also { highCustom = it } } var lowCustom: Drawable? = null get() = field ?: customLow?.let { cd -> cwf.resDataMap[cd.fileName]?.toDrawable(cwf.resources).also { lowCustom = it } } + var veryHighCustom: Drawable? = null + get() = field ?: customVeryHigh?.let { cd -> cwf.resDataMap[cd.fileName]?.toDrawable(cwf.resources).also { highCustom = it } } + var veryLowCustom: Drawable? = null + get() = field ?: customVeryLow?.let { cd -> cwf.resDataMap[cd.fileName]?.toDrawable(cwf.resources).also { lowCustom = it } } var textDrawable: Drawable? = null val drawable: Drawable? get() = dynData?.getDrawable() ?: when (cwf.singleBg[0].sgvLevel) { + 2L -> veryHighCustom ?: highCustom ?: rangeCustom 1L -> highCustom ?: rangeCustom 0L -> rangeCustom -1L -> lowCustom ?: rangeCustom + -2L -> veryLowCustom ?: lowCustom ?: rangeCustom else -> rangeCustom } var twinView: ViewMap? = null @@ -853,7 +880,7 @@ class CustomWatchface : BaseWatchFace() { private enum class ValueMap(val key: String, val min: Double, val max: Double) { NONE("", 0.0, 0.0), SGV(ViewKeys.SGV.key, 39.0, 400.0), - SGV_LEVEL(JsonKeyValues.SGV_LEVEL.key, -1.0, 1.0), + SGV_LEVEL(JsonKeyValues.SGV_LEVEL.key, -2.0, 2.0), DIRECTION(ViewKeys.DIRECTION.key, 1.0, 7.0), DELTA(ViewKeys.DELTA.key, -25.0, 25.0), AVG_DELTA(ViewKeys.AVG_DELTA.key, -25.0, 25.0), @@ -869,7 +896,7 @@ class CustomWatchface : BaseWatchFace() { MONTH(ViewKeys.MONTH.key, 1.0, 12.0), WEEK_NUMBER(ViewKeys.WEEK_NUMBER.key, 1.0, 53.0), SGV_EXT1(ViewKeys.SGV_EXT1.key, 39.0, 400.0), - SGV_LEVEL_EXT1(JsonKeyValues.SGV_LEVEL_EXT1.key, -1.0, 1.0), + SGV_LEVEL_EXT1(JsonKeyValues.SGV_LEVEL_EXT1.key, -2.0, 2.0), DIRECTION_EXT1(ViewKeys.DIRECTION_EXT1.key, 1.0, 7.0), DELTA_EXT1(ViewKeys.DELTA_EXT1.key, -25.0, 25.0), AVG_DELTA_EXT1(ViewKeys.AVG_DELTA_EXT1.key, -25.0, 25.0), @@ -880,7 +907,7 @@ class CustomWatchface : BaseWatchFace() { TIMESTAMP_EXT1(ViewKeys.TIMESTAMP_EXT1.key, 0.0, 60.0), LOOP_EXT1(ViewKeys.LOOP_EXT1.key, 0.0, 28.0), SGV_EXT2(ViewKeys.SGV_EXT2.key, 39.0, 400.0), - SGV_LEVEL_EXT2(JsonKeyValues.SGV_LEVEL_EXT2.key, -1.0, 1.0), + SGV_LEVEL_EXT2(JsonKeyValues.SGV_LEVEL_EXT2.key, -2.0, 2.0), DIRECTION_EXT2(ViewKeys.DIRECTION_EXT2.key, 1.0, 7.0), DELTA_EXT2(ViewKeys.DELTA_EXT2.key, -25.0, 25.0), AVG_DELTA_EXT2(ViewKeys.AVG_DELTA_EXT2.key, -25.0, 25.0), diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt index 399ab024143e..012c28fd1790 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/DigitalStyleWatchface.kt @@ -36,15 +36,14 @@ 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.toInt()) { + -2 -> R.color.dark_veryLowColor + -1 -> R.color.dark_lowColor + 0 -> R.color.dark_midColor + 1 -> R.color.dark_highColor + 2 -> R.color.dark_veryHighColor else -> R.color.dark_midColor } - binding.sgv.setTextColor(ContextCompat.getColor(this, color)) binding.direction.setTextColor(ContextCompat.getColor(this, color))