Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fmegen/3.3.0.0 - Adding VeryHigh Overview Display Option #3678

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/kotlin/app/aaps/MainApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
1 change: 1 addition & 0 deletions core/ui/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<!---BG color-->
<item name="bgLow">@color/low</item>
<item name="highColor">@color/high</item>
<item name="veryHighColor">@color/low</item>
<item name="bgInRange">@color/inRange</item>
<!---Profile Helper -->
<item name="helperProfileColor">@color/helperProfile</item>
Expand Down
1 change: 1 addition & 0 deletions core/ui/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<!---BG color-->
<attr name="bgLow" format="reference|color" />
<attr name="highColor" format="reference|color" />
<attr name="veryHighColor" format="reference|color" />
<attr name="bgInRange" format="reference|color" />
<!---Profile Helper -->
<attr name="helperProfileColor" format="reference|color" />
Expand Down
1 change: 1 addition & 0 deletions core/ui/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@
<color name="widget_inrange">#00FF00</color>
<color name="widget_low">#FF0000</color>
<color name="widget_high">#FFFF00</color>
<color name="widget_very_high">#FF0000</color>
<color name="widget_ribbonWarning">#f4d700</color>
<color name="widget_ribbonTextDefault">#FFFFFF</color>
<color name="widget_ribbonCritical">#ff0400</color>
Expand Down
1 change: 1 addition & 0 deletions core/ui/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<!---BG color-->
<item name="bgLow">@color/low</item>
<item name="highColor">@color/high</item>
<item name="veryHighColor">@color/low</item>
<item name="bgInRange">@color/tempTargetConfirmation</item>
<!---Profile Helper -->
<item name="helperProfileColor">@color/helperProfile</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions plugins/configuration/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
<string name="display_settings">Display Settings</string>
<string name="low_mark">LOW mark</string>
<string name="high_mark">HIGH mark</string>
<string name="very_high_mark">VERY HIGH mark</string>
<string name="low_mark_comment">Lower value of in range area (display only)</string>
<string name="high_mark_comment">Higher value of in range area (display only)</string>
<string name="very_high_mark_comment">Even Higher value of in range area (display only)</string>
<string name="permission">Permission</string>
<string name="need_system_window_permission">Application needs system window permission for notifications</string>
<string name="need_location_permission">Application needs location permission for BT scan and WiFi identification</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions plugins/main/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
<string name="prefs_range_summary">High and low mark for the charts in Overview and Smartwatch</string>
<string name="low_mark">LOW mark</string>
<string name="high_mark">HIGH mark</string>
<string name="very_high_mark">VERY HIGH mark</string>
<string name="short_tabtitles">Shorten tab titles</string>
<string name="overview_show_notes_field_in_dialogs_title">Show notes field in treatment dialogs</string>
<string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string>
Expand Down
2 changes: 2 additions & 0 deletions ui/src/main/kotlin/app/aaps/ui/widget/Widget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down