From 37bd7495fd10d3da12044e8ce38ff86a83442475 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 23 May 2021 10:50:37 +0200 Subject: [PATCH 1/5] Convert status Message to Kotlin (+ associated null management in localInsightPlugin) --- .../androidaps/plugins/general/overview/OverviewData.kt | 2 +- .../plugins/general/overview/graphData/GraphData.kt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt index d5f64cc96e..b14a819844 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt @@ -268,7 +268,7 @@ class OverviewData @Inject constructor( var maxRatioValueFound = 5.0 //even if sens data equals 0 for all the period, minimum scale is between 95% and 105% var minRatioValueFound = -maxRatioValueFound - val ratioScale = Scale() + var ratioScale = Scale() var ratioSeries: LineGraphSeries = LineGraphSeries() var maxFromMaxValueFound = Double.MIN_VALUE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt index c2055e61e8..498f98ee7f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt @@ -15,6 +15,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.general.overview.OverviewData import info.nightscout.androidaps.plugins.general.overview.graphExtensions.AreaGraphSeries import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DoubleDataPoint +import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Scale import info.nightscout.androidaps.plugins.general.overview.graphExtensions.TimeAsXAxisLabelFormatter import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.Round @@ -153,9 +154,12 @@ class GraphData( if (useForScale) { maxY = 100.0 + max(overviewData.maxRatioValueFound, abs(overviewData.minRatioValueFound)) minY = 100.0 - max(overviewData.maxRatioValueFound, abs(overviewData.minRatioValueFound)) + overviewData.ratioScale = Scale(100.0) overviewData.ratioScale.setMultiplier(1.0) - } else + } else { + overviewData.ratioScale = Scale() overviewData.ratioScale.setMultiplier(maxY * scale / max(overviewData.maxRatioValueFound, abs(overviewData.minRatioValueFound))) + } addSeries(overviewData.ratioSeries) } From 62c063a5bc0d8693c06a3d94097549239d8864ee Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 23 May 2021 14:37:18 +0200 Subject: [PATCH 2/5] Fix Sens curve scale if alone on a graph => I also fix deviation slope curve if secondary behind Sens curve --- .../plugins/general/overview/OverviewData.kt | 4 ++-- .../plugins/general/overview/OverviewFragment.kt | 2 +- .../general/overview/graphData/GraphData.kt | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt index b14a819844..1346374246 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt @@ -273,8 +273,8 @@ class OverviewData @Inject constructor( var maxFromMaxValueFound = Double.MIN_VALUE var maxFromMinValueFound = Double.MIN_VALUE - val dsMaxScale = Scale() - val dsMinScale = Scale() + var dsMaxScale = Scale() + var dsMinScale = Scale() var dsMaxSeries: LineGraphSeries = LineGraphSeries() var dsMinSeries: LineGraphSeries = LineGraphSeries() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index d4b9d90774..9217164710 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -780,7 +780,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList if (menuChartSettings[g + 1][OverviewMenus.CharType.DEV.ordinal]) secondGraphData.addDeviations(useDevForScale, 1.0) if (menuChartSettings[g + 1][OverviewMenus.CharType.BGI.ordinal]) secondGraphData.addMinusBGI(useBGIForScale, if (alignDevBgiScale) 1.0 else 0.8) if (menuChartSettings[g + 1][OverviewMenus.CharType.SEN.ordinal]) secondGraphData.addRatio(useRatioForScale, if (useRatioForScale) 1.0 else 0.8) - if (menuChartSettings[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] && buildHelper.isDev()) secondGraphData.addDeviationSlope(useDSForScale, 1.0) + if (menuChartSettings[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] && buildHelper.isDev()) secondGraphData.addDeviationSlope(useDSForScale, if(useDSForScale) 1.0 else 0.8, useRatioForScale) // set manual x bounds to have nice steps secondGraphData.formatAxis(overviewData.fromTime, overviewData.endTime) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt index 498f98ee7f..cbc021b421 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt @@ -164,13 +164,22 @@ class GraphData( } // scale in % of vertical size (like 0.3) - fun addDeviationSlope(useForScale: Boolean, scale: Double) { + fun addDeviationSlope(useForScale: Boolean, scale: Double, isRatioScale: Boolean = false) { if (useForScale) { maxY = max(overviewData.maxFromMaxValueFound, overviewData.maxFromMinValueFound) minY = -maxY } - overviewData.dsMaxScale.setMultiplier(maxY * scale / overviewData.maxFromMaxValueFound) - overviewData.dsMinScale.setMultiplier(maxY * scale / overviewData.maxFromMinValueFound) + var graphMaxY = maxY + if (isRatioScale) { + graphMaxY = maxY - 100.0 + overviewData.dsMinScale = Scale(100.0) + overviewData.dsMaxScale = Scale(100.0) + } else { + overviewData.dsMinScale = Scale() + overviewData.dsMaxScale = Scale() + } + overviewData.dsMaxScale.setMultiplier(graphMaxY * scale / overviewData.maxFromMaxValueFound) + overviewData.dsMinScale.setMultiplier(graphMaxY * scale / overviewData.maxFromMinValueFound) addSeries(overviewData.dsMaxSeries) addSeries(overviewData.dsMinSeries) } From 6532d9111eb307e0d319babf1dbe6a90df0b1a6e Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 23 May 2021 15:28:33 +0200 Subject: [PATCH 3/5] Fix same curve on different graphs --- .../androidaps/plugins/general/overview/OverviewMenus.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt index 70fa9ef620..6f7f464d5e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt @@ -113,6 +113,9 @@ class OverviewMenus @Inject constructor( if (m == CharType.PRE) insert = predictionsAvailable if (m == CharType.DEVSLOPE) insert = buildHelper.isDev() if (used.contains(m.ordinal)) insert = false + for (g2 in g + 1 until numOfGraphs) { + if (settingsCopy[g2][m.ordinal]) insert = false + } if (insert) { val item = popup.menu.add(Menu.NONE, m.ordinal + 100 * (g + 1), Menu.NONE, resourceHelper.gs(m.nameId)) val title = item.title From ede1468bbbc4e792f1f98ceb2cc883fff112c312 Mon Sep 17 00:00:00 2001 From: Philoul Date: Wed, 26 May 2021 22:04:42 +0200 Subject: [PATCH 4/5] Modify shift --- .../plugins/general/overview/graphData/GraphData.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt index b080eaa400..3fcc046cbd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt @@ -174,11 +174,11 @@ class GraphData( overviewData.dsMinScale.shift = 100.0 overviewData.dsMaxScale.shift = 100.0 } else { - overviewData.dsMinScale.shift = 0 - overviewData.dsMaxScale.shift = 0 + overviewData.dsMinScale.shift = 0.0 + overviewData.dsMaxScale.shift = 0.0 } - overviewData.dsMaxScale.setMultiplier = graphMaxY * scale / overviewData.maxFromMaxValueFound - overviewData.dsMinScale.setMultiplier = graphMaxY * scale / overviewData.maxFromMinValueFound + overviewData.dsMaxScale.multiplier = graphMaxY * scale / overviewData.maxFromMaxValueFound + overviewData.dsMinScale.multiplier = graphMaxY * scale / overviewData.maxFromMinValueFound addSeries(overviewData.dsMaxSeries) addSeries(overviewData.dsMinSeries) } From 93046d0354c4b51eca437c08c348d3131676c4c3 Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 27 May 2021 08:43:45 +0200 Subject: [PATCH 5/5] Revert to val for ratio and dev slope Scale --- .../androidaps/plugins/general/overview/OverviewData.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt index 9db9f1b5fa..11a1ff2203 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt @@ -286,13 +286,13 @@ class OverviewData @Inject constructor( var maxRatioValueFound = 5.0 //even if sens data equals 0 for all the period, minimum scale is between 95% and 105% var minRatioValueFound = -maxRatioValueFound - var ratioScale = Scale() + val ratioScale = Scale() var ratioSeries: LineGraphSeries = LineGraphSeries() var maxFromMaxValueFound = Double.MIN_VALUE var maxFromMinValueFound = Double.MIN_VALUE - var dsMaxScale = Scale() - var dsMinScale = Scale() + val dsMaxScale = Scale() + val dsMinScale = Scale() var dsMaxSeries: LineGraphSeries = LineGraphSeries() var dsMinSeries: LineGraphSeries = LineGraphSeries()