diff --git a/app/src/main/kotlin/app/aaps/MainApp.kt b/app/src/main/kotlin/app/aaps/MainApp.kt index fb00915db60..b9ce7d309f3 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(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/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 a7780fa5919..5b0641659dd 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/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 3440f7ec21b..a8a78c61d45 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 1ce6dbcb856..8417bfe5f69 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", 400.0, 200, 400, showInNsClientMode = false), ApsLgsThreshold("lgsThreshold", 65.0, 60, 100, 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/core/ui/src/main/res/values-night/styles.xml b/core/ui/src/main/res/values-night/styles.xml index 5d80a20fcd4..1437aa9990f 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/attrs.xml b/core/ui/src/main/res/values/attrs.xml index b46603151d9..ecc009e4401 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 df4abdd40bf..45d700e310d 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/core/ui/src/main/res/values/styles.xml b/core/ui/src/main/res/values/styles.xml index dd8e587a8d8..4a0be309ec7 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 04db6298acd..5ca8202cb48 100644 --- a/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt +++ b/implementation/src/main/kotlin/app/aaps/implementation/overview/LastBgDataImpl.kt @@ -41,10 +41,16 @@ 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 { 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/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 6051d7cfdbf..864ce7564c7 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 @@ -148,6 +148,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/configuration/src/main/res/values/strings.xml b/plugins/configuration/src/main/res/values/strings.xml index d5bbf9d7c8a..3277ff475e4 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 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 c92e4bf97f8..a191994baca 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) @@ -260,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 d1d78301e54..c1ca3bce097 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. 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 f5ff2192175..b06318fd10e 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_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) } @@ -155,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) }