From 00c07b91e77bd6d6d4226fe1aca47a8a636571c4 Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 17 Aug 2021 08:30:10 +0200 Subject: [PATCH 01/11] Fix Overview LoopDialog trial --- .../androidaps/dialogs/LoopDialog.kt | 50 +++++++++++-------- app/src/main/res/layout/dialog_loop.xml | 1 + 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index 6c335de9ad..f248445112 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -158,8 +158,24 @@ class LoopDialog : DaggerDialogFragment() { val closedLoopAllowed = constraintChecker.isClosedLoopAllowed(Constraint(true)) val lgsEnabled = constraintChecker.isLgsAllowed(Constraint(true)) val apsMode = sp.getString(R.string.key_aps_mode, "open") + val pump = activePlugin.activePump if (profileFunction.isProfileValid("LoopDialogUpdateGUI")) { + binding.overviewLoop.visibility = View.VISIBLE + binding.overviewEnable.visibility = View.VISIBLE + binding.overviewDisable.visibility = View.VISIBLE + + binding.overviewSuspend.visibility = View.VISIBLE + binding.overviewResume.visibility = View.VISIBLE + binding.overviewSuspendButtons.visibility = View.VISIBLE + + binding.overviewPump.visibility = View.VISIBLE + binding.overviewReconnect.visibility = View.VISIBLE + binding.overviewDisconnectButtons.visibility = View.VISIBLE + binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility() + binding.overviewDisconnect30m.visibility = pumpDescription.tempDurationStep30mAllowed.toVisibility() + if (loopPlugin.isEnabled(PluginType.LOOP)) { + binding.overviewEnable.visibility = View.GONE when { closedLoopAllowed.value() -> { binding.overviewCloseloop.visibility = (apsMode != "closed").toVisibility() @@ -179,39 +195,31 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewOpenloop.visibility = View.GONE } } - binding.overviewEnable.visibility = View.GONE - binding.overviewDisable.visibility = View.VISIBLE - if (!loopPlugin.isSuspended) { - binding.overviewSuspendHeader.text = resourceHelper.gs(R.string.suspendloop) - binding.overviewResume.visibility = View.GONE - binding.overviewSuspendButtons.visibility = View.VISIBLE - binding.overviewSuspend.visibility = View.VISIBLE - } else { - if (!loopPlugin.isDisconnected) { - binding.overviewSuspendHeader.text = resourceHelper.gs(R.string.resumeloop) - binding.overviewResume.visibility = View.VISIBLE - binding.overviewSuspendButtons.visibility = View.GONE - binding.overviewSuspend.visibility = View.VISIBLE - } else - binding.overviewSuspend.visibility = View.GONE - } } else { - binding.overviewEnable.visibility = View.VISIBLE binding.overviewDisable.visibility = View.GONE binding.overviewSuspend.visibility = View.GONE } if (!loopPlugin.isDisconnected) { binding.overviewPumpHeader.text = resourceHelper.gs(R.string.disconnectpump) - binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility() - binding.overviewDisconnect30m.visibility = pumpDescription.tempDurationStep30mAllowed.toVisibility() - binding.overviewDisconnectButtons.visibility = View.VISIBLE binding.overviewReconnect.visibility = View.GONE } else { binding.overviewPumpHeader.text = resourceHelper.gs(R.string.reconnect) binding.overviewDisconnectButtons.visibility = View.GONE binding.overviewReconnect.visibility = View.VISIBLE + binding.overviewSuspend.visibility = View.GONE + if (loopPlugin.isEnabled(PluginType.LOOP)) binding.overviewLoop.visibility = View.GONE + binding.overviewResume.visibility = View.GONE + } + if (!loopPlugin.isSuspended) { + binding.overviewSuspendHeader.text = resourceHelper.gs(R.string.suspendloop) + binding.overviewResume.visibility = View.GONE + } else { + binding.overviewSuspendHeader.text = resourceHelper.gs(R.string.resumeloop) + if (loopPlugin.isEnabled(PluginType.LOOP)) binding.overviewLoop.visibility = View.GONE + if (!loopPlugin.isDisconnected) binding.overviewPump.visibility = View.GONE + binding.overviewSuspendButtons.visibility = View.GONE + binding.overviewResume.visibility = View.VISIBLE } - binding.overviewLoop.visibility = (!loopPlugin.isSuspended && !loopPlugin.isDisconnected).toVisibility() } val profile = profileFunction.getProfile() val profileStore = activePlugin.activeProfileSource.profile diff --git a/app/src/main/res/layout/dialog_loop.xml b/app/src/main/res/layout/dialog_loop.xml index 594d1855e3..fa1d97105e 100644 --- a/app/src/main/res/layout/dialog_loop.xml +++ b/app/src/main/res/layout/dialog_loop.xml @@ -275,6 +275,7 @@ From a28be52faa9735d04dacb49086983923be99fa6b Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 19 Aug 2021 01:01:12 +0200 Subject: [PATCH 02/11] Simplify Overview code --- .../androidaps/dialogs/LoopDialog.kt | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index f248445112..5c03efcd20 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -159,6 +159,85 @@ class LoopDialog : DaggerDialogFragment() { val lgsEnabled = constraintChecker.isLgsAllowed(Constraint(true)) val apsMode = sp.getString(R.string.key_aps_mode, "open") val pump = activePlugin.activePump + + when { + pump.isSuspended() -> { + binding.overviewLoop.visibility = View.GONE + binding.overviewSuspend.visibility = View.GONE + binding.overviewPump.visibility = View.GONE + } + + !profileFunction.isProfileValid("LoopDialogUpdateGUI") -> { + binding.overviewLoop.visibility = View.GONE + binding.overviewSuspend.visibility = View.GONE + binding.overviewPump.visibility = View.GONE + } + + !loopPlugin.isEnabled(PluginType.LOOP) -> { + binding.overviewLoop.visibility = View.VISIBLE + binding.overviewEnable.visibility = View.VISIBLE + binding.overviewDisable.visibility = View.GONE + binding.overviewSuspend.visibility = View.GONE + binding.overviewPump.visibility = View.GONE + } + + loopPlugin.isDisconnected -> { + binding.overviewLoop.visibility = View.GONE + binding.overviewSuspend.visibility = View.GONE + binding.overviewPump.visibility = View.VISIBLE + binding.overviewPumpHeader.text = resourceHelper.gs(R.string.reconnect) + binding.overviewDisconnectButtons.visibility = View.GONE + binding.overviewReconnect.visibility = View.VISIBLE + } + + loopPlugin.isSuspended -> { + binding.overviewLoop.visibility = View.GONE + binding.overviewSuspend.visibility = View.VISIBLE + binding.overviewSuspendHeader.text = resourceHelper.gs(R.string.resumeloop) + binding.overviewSuspendButtons.visibility = View.GONE + binding.overviewResume.visibility = View.VISIBLE + binding.overviewPump.visibility = View.GONE + } + + else -> { + binding.overviewLoop.visibility = View.VISIBLE + binding.overviewEnable.visibility = View.GONE + when { + closedLoopAllowed.value() -> { + binding.overviewCloseloop.visibility = (apsMode != "closed").toVisibility() + binding.overviewLgsloop.visibility = (apsMode != "lgs").toVisibility() + binding.overviewOpenloop.visibility = (apsMode != "open").toVisibility() + } + + lgsEnabled.value() -> { + binding.overviewCloseloop.visibility = View.GONE + binding.overviewLgsloop.visibility = (apsMode != "lgs").toVisibility() + binding.overviewOpenloop.visibility = (apsMode != "open").toVisibility() + } + + else -> { + binding.overviewCloseloop.visibility = View.GONE + binding.overviewLgsloop.visibility = View.GONE + binding.overviewOpenloop.visibility = View.GONE + } + } + binding.overviewSuspend.visibility = View.VISIBLE + binding.overviewSuspendHeader.text = resourceHelper.gs(R.string.suspendloop) + binding.overviewSuspendButtons.visibility = View.VISIBLE + binding.overviewResume.visibility = View.GONE + + binding.overviewPump.visibility = View.VISIBLE + binding.overviewPumpHeader.text = resourceHelper.gs(R.string.disconnectpump) + binding.overviewDisconnectButtons.visibility = View.VISIBLE + binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility() + binding.overviewDisconnect30m.visibility = pumpDescription.tempDurationStep30mAllowed.toVisibility() + binding.overviewReconnect.visibility = View.GONE + + } + } + + + /************************************************************************************************** if (profileFunction.isProfileValid("LoopDialogUpdateGUI")) { binding.overviewLoop.visibility = View.VISIBLE binding.overviewEnable.visibility = View.VISIBLE @@ -229,6 +308,7 @@ class LoopDialog : DaggerDialogFragment() { dismiss() return } + **************************************************************************************************/ } From 226e968bfd7d6037a71c26b2e5d1e9425cf0e9ef Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 19 Aug 2021 01:03:34 +0200 Subject: [PATCH 03/11] Clean previous code --- .../androidaps/dialogs/LoopDialog.kt | 62 ------------------- 1 file changed, 62 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index 5c03efcd20..6320d6087d 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -238,68 +238,6 @@ class LoopDialog : DaggerDialogFragment() { /************************************************************************************************** - if (profileFunction.isProfileValid("LoopDialogUpdateGUI")) { - binding.overviewLoop.visibility = View.VISIBLE - binding.overviewEnable.visibility = View.VISIBLE - binding.overviewDisable.visibility = View.VISIBLE - - binding.overviewSuspend.visibility = View.VISIBLE - binding.overviewResume.visibility = View.VISIBLE - binding.overviewSuspendButtons.visibility = View.VISIBLE - - binding.overviewPump.visibility = View.VISIBLE - binding.overviewReconnect.visibility = View.VISIBLE - binding.overviewDisconnectButtons.visibility = View.VISIBLE - binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility() - binding.overviewDisconnect30m.visibility = pumpDescription.tempDurationStep30mAllowed.toVisibility() - - if (loopPlugin.isEnabled(PluginType.LOOP)) { - binding.overviewEnable.visibility = View.GONE - when { - closedLoopAllowed.value() -> { - binding.overviewCloseloop.visibility = (apsMode != "closed").toVisibility() - binding.overviewLgsloop.visibility = (apsMode != "lgs").toVisibility() - binding.overviewOpenloop.visibility = (apsMode != "open").toVisibility() - } - - lgsEnabled.value() -> { - binding.overviewCloseloop.visibility = View.GONE - binding.overviewLgsloop.visibility = (apsMode != "lgs").toVisibility() - binding.overviewOpenloop.visibility = (apsMode != "open").toVisibility() - } - - else -> { - binding.overviewCloseloop.visibility = View.GONE - binding.overviewLgsloop.visibility = View.GONE - binding.overviewOpenloop.visibility = View.GONE - } - } - } else { - binding.overviewDisable.visibility = View.GONE - binding.overviewSuspend.visibility = View.GONE - } - if (!loopPlugin.isDisconnected) { - binding.overviewPumpHeader.text = resourceHelper.gs(R.string.disconnectpump) - binding.overviewReconnect.visibility = View.GONE - } else { - binding.overviewPumpHeader.text = resourceHelper.gs(R.string.reconnect) - binding.overviewDisconnectButtons.visibility = View.GONE - binding.overviewReconnect.visibility = View.VISIBLE - binding.overviewSuspend.visibility = View.GONE - if (loopPlugin.isEnabled(PluginType.LOOP)) binding.overviewLoop.visibility = View.GONE - binding.overviewResume.visibility = View.GONE - } - if (!loopPlugin.isSuspended) { - binding.overviewSuspendHeader.text = resourceHelper.gs(R.string.suspendloop) - binding.overviewResume.visibility = View.GONE - } else { - binding.overviewSuspendHeader.text = resourceHelper.gs(R.string.resumeloop) - if (loopPlugin.isEnabled(PluginType.LOOP)) binding.overviewLoop.visibility = View.GONE - if (!loopPlugin.isDisconnected) binding.overviewPump.visibility = View.GONE - binding.overviewSuspendButtons.visibility = View.GONE - binding.overviewResume.visibility = View.VISIBLE - } - } val profile = profileFunction.getProfile() val profileStore = activePlugin.activeProfileSource.profile From 0918880415165749c629d7a8f7fceb984b2de13c Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 19 Aug 2021 22:16:38 +0200 Subject: [PATCH 04/11] Allow direct modification of duration of suspend loop or disconnect pump --- .../java/info/nightscout/androidaps/dialogs/LoopDialog.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index 6320d6087d..432e8e20cb 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -186,7 +186,9 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewSuspend.visibility = View.GONE binding.overviewPump.visibility = View.VISIBLE binding.overviewPumpHeader.text = resourceHelper.gs(R.string.reconnect) - binding.overviewDisconnectButtons.visibility = View.GONE + binding.overviewDisconnectButtons.visibility = View.VISIBLE + binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility() + binding.overviewDisconnect30m.visibility = pumpDescription.tempDurationStep30mAllowed.toVisibility() binding.overviewReconnect.visibility = View.VISIBLE } @@ -194,7 +196,7 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewLoop.visibility = View.GONE binding.overviewSuspend.visibility = View.VISIBLE binding.overviewSuspendHeader.text = resourceHelper.gs(R.string.resumeloop) - binding.overviewSuspendButtons.visibility = View.GONE + binding.overviewSuspendButtons.visibility = View.VISIBLE binding.overviewResume.visibility = View.VISIBLE binding.overviewPump.visibility = View.GONE } From 69839b53951f66f9a1a2bd9fd5e06ab0aa1226f1 Mon Sep 17 00:00:00 2001 From: Philoul Date: Wed, 25 Aug 2021 09:00:13 +0200 Subject: [PATCH 05/11] Add Disconnect Bloc when Loop is suspended or disabled --- .../info/nightscout/androidaps/dialogs/LoopDialog.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index 432e8e20cb..8fb262c452 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -160,6 +160,8 @@ class LoopDialog : DaggerDialogFragment() { val apsMode = sp.getString(R.string.key_aps_mode, "open") val pump = activePlugin.activePump + binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility() + binding.overviewDisconnect30m.visibility = pumpDescription.tempDurationStep30mAllowed.toVisibility() when { pump.isSuspended() -> { binding.overviewLoop.visibility = View.GONE @@ -178,7 +180,8 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewEnable.visibility = View.VISIBLE binding.overviewDisable.visibility = View.GONE binding.overviewSuspend.visibility = View.GONE - binding.overviewPump.visibility = View.GONE + binding.overviewPump.visibility = View.VISIBLE + binding.overviewReconnect.visibility = View.GONE } loopPlugin.isDisconnected -> { @@ -187,8 +190,6 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewPump.visibility = View.VISIBLE binding.overviewPumpHeader.text = resourceHelper.gs(R.string.reconnect) binding.overviewDisconnectButtons.visibility = View.VISIBLE - binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility() - binding.overviewDisconnect30m.visibility = pumpDescription.tempDurationStep30mAllowed.toVisibility() binding.overviewReconnect.visibility = View.VISIBLE } @@ -198,7 +199,8 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewSuspendHeader.text = resourceHelper.gs(R.string.resumeloop) binding.overviewSuspendButtons.visibility = View.VISIBLE binding.overviewResume.visibility = View.VISIBLE - binding.overviewPump.visibility = View.GONE + binding.overviewPump.visibility = View.VISIBLE + binding.overviewReconnect.visibility = View.GONE } else -> { @@ -231,8 +233,6 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewPump.visibility = View.VISIBLE binding.overviewPumpHeader.text = resourceHelper.gs(R.string.disconnectpump) binding.overviewDisconnectButtons.visibility = View.VISIBLE - binding.overviewDisconnect15m.visibility = pumpDescription.tempDurationStep15mAllowed.toVisibility() - binding.overviewDisconnect30m.visibility = pumpDescription.tempDurationStep30mAllowed.toVisibility() binding.overviewReconnect.visibility = View.GONE } From c00000e07984fe658f5ecbb1506eca20ed2b760a Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 29 Aug 2021 22:24:52 +0200 Subject: [PATCH 06/11] Simplify a bit more LoopPlugin --- .../androidaps/dialogs/LoopDialog.kt | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index 284bd1cbaf..e82cb790d5 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -35,6 +35,7 @@ import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -60,6 +61,7 @@ class LoopDialog : DaggerDialogFragment() { @Inject lateinit var uel: UserEntryLogger @Inject lateinit var dateUtil: DateUtil @Inject lateinit var repository: AppRepository + @Inject lateinit var objectivePlugin: ObjectivesPlugin private var showOkCancel: Boolean = true private var _binding: DialogLoopBinding? = null @@ -159,6 +161,7 @@ class LoopDialog : DaggerDialogFragment() { aapsLogger.debug("UpdateGUI from $from") val pumpDescription: PumpDescription = activePlugin.activePump.pumpDescription val closedLoopAllowed = constraintChecker.isClosedLoopAllowed(Constraint(true)) + val closedLoopAllowed2 = objectivePlugin.objectives[ObjectivesPlugin.MAXIOB_OBJECTIVE].isCompleted val lgsEnabled = constraintChecker.isLgsAllowed(Constraint(true)) val apsMode = sp.getString(R.string.key_aps_mode, "open") val pump = activePlugin.activePump @@ -178,15 +181,6 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewPump.visibility = View.GONE } - !loopPlugin.isEnabled(PluginType.LOOP) -> { - binding.overviewLoop.visibility = View.VISIBLE - binding.overviewEnable.visibility = View.VISIBLE - binding.overviewDisable.visibility = View.GONE - binding.overviewSuspend.visibility = View.GONE - binding.overviewPump.visibility = View.VISIBLE - binding.overviewReconnect.visibility = View.GONE - } - loopPlugin.isDisconnected -> { binding.overviewLoop.visibility = View.GONE binding.overviewSuspend.visibility = View.GONE @@ -196,6 +190,15 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewReconnect.visibility = View.VISIBLE } + !loopPlugin.isEnabled(PluginType.LOOP) -> { + binding.overviewLoop.visibility = View.VISIBLE + binding.overviewEnable.visibility = View.VISIBLE + binding.overviewDisable.visibility = View.GONE + binding.overviewSuspend.visibility = View.GONE + binding.overviewPump.visibility = View.VISIBLE + binding.overviewReconnect.visibility = View.GONE + } + loopPlugin.isSuspended -> { binding.overviewLoop.visibility = View.GONE binding.overviewSuspend.visibility = View.VISIBLE @@ -210,24 +213,24 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewLoop.visibility = View.VISIBLE binding.overviewEnable.visibility = View.GONE when { - closedLoopAllowed.value() -> { - binding.overviewCloseloop.visibility = (apsMode != "closed").toVisibility() - binding.overviewLgsloop.visibility = (apsMode != "lgs").toVisibility() - binding.overviewOpenloop.visibility = (apsMode != "open").toVisibility() + apsMode == "closed" -> { + binding.overviewCloseloop.visibility = View.GONE + binding.overviewLgsloop.visibility = View.VISIBLE + binding.overviewOpenloop.visibility = View.VISIBLE + } + + apsMode == "lgs" -> { + binding.overviewCloseloop.visibility = closedLoopAllowed.value().toVisibility() //show Close loop button only if Close loop allowed + binding.overviewLgsloop.visibility = View.GONE + binding.overviewOpenloop.visibility = View.VISIBLE } apsMode == "open" -> { - binding.overviewCloseloop.visibility = View.VISIBLE - binding.overviewLgsloop.visibility = View.GONE + binding.overviewCloseloop.visibility = closedLoopAllowed2.toVisibility() //show CloseLoop button only if Objective 6 is completed (closedLoopAllowed always false in open loop mode) + binding.overviewLgsloop.visibility = lgsEnabled.value().toVisibility() binding.overviewOpenloop.visibility = View.GONE } - lgsEnabled.value() -> { - binding.overviewCloseloop.visibility = View.GONE - binding.overviewLgsloop.visibility = (apsMode != "lgs").toVisibility() - binding.overviewOpenloop.visibility = (apsMode != "open").toVisibility() - } - else -> { binding.overviewCloseloop.visibility = View.GONE binding.overviewLgsloop.visibility = View.GONE @@ -247,7 +250,6 @@ class LoopDialog : DaggerDialogFragment() { } } - /************************************************************************************************** val profile = profileFunction.getProfile() val profileStore = activePlugin.activeProfileSource.profile @@ -258,7 +260,6 @@ class LoopDialog : DaggerDialogFragment() { return } **************************************************************************************************/ - } private fun onClickOkCancelEnabled(v: View): Boolean { From fc83e41148a3db0af0af8d38953bbdf199db023d Mon Sep 17 00:00:00 2001 From: Philoul Date: Fri, 10 Sep 2021 00:34:17 +0200 Subject: [PATCH 07/11] Avoid disconect pump during suspend --- .../nightscout/androidaps/dialogs/LoopDialog.kt | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index e82cb790d5..7833a836cd 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -205,7 +205,7 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewSuspendHeader.text = resourceHelper.gs(R.string.resumeloop) binding.overviewSuspendButtons.visibility = View.VISIBLE binding.overviewResume.visibility = View.VISIBLE - binding.overviewPump.visibility = View.VISIBLE + binding.overviewPump.visibility = View.GONE binding.overviewReconnect.visibility = View.GONE } @@ -249,17 +249,6 @@ class LoopDialog : DaggerDialogFragment() { } } - - /************************************************************************************************** - val profile = profileFunction.getProfile() - val profileStore = activePlugin.activeProfileSource.profile - - if (profile == null || profileStore == null) { - ToastUtils.showToastInUiThread(ctx, resourceHelper.gs(R.string.noprofile)) - dismiss() - return - } - **************************************************************************************************/ } private fun onClickOkCancelEnabled(v: View): Boolean { From 444915ebf732dc3e7dbce1f7e4f93bf48cc3e3ce Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 15 Sep 2021 23:19:25 +0200 Subject: [PATCH 08/11] fix displaying bg data on range change --- .../androidaps/plugins/general/overview/OverviewFragment.kt | 2 ++ 1 file changed, 2 insertions(+) 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 bddee95f50..e000c9ff44 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 @@ -178,6 +178,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList overviewData.rangeToDisplay = if (overviewData.rangeToDisplay > 24) 6 else overviewData.rangeToDisplay sp.putInt(R.string.key_rangetodisplay, overviewData.rangeToDisplay) overviewData.initRange() + overviewData.prepareBucketedData("EventBucketedDataCreated") + overviewData.prepareBgData("EventBucketedDataCreated") updateGUI("rangeChange", OverviewData.Property.GRAPH) rxBus.send(EventPreferenceChange(resourceHelper, R.string.key_rangetodisplay)) sp.putBoolean(R.string.key_objectiveusescale, true) From 5e9b03cffd7f5a0b92aa4b4f2d2f113daa9d67e6 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 15 Sep 2021 23:49:34 +0200 Subject: [PATCH 09/11] fix tests --- .../java/info/nightscout/androidaps/data/ProfileSealed.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt b/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt index 93d863aaee..1dbba939d6 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt +++ b/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt @@ -162,7 +162,7 @@ sealed class ProfileSealed( } for (target in targetBlocks) { if (!hardLimits.isInRange( - Round.roundTo(target.lowTarget, 0.1), + Profile.toMgdl(target.lowTarget, units), HardLimits.VERY_HARD_LIMIT_MIN_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_MIN_BG[1].toDouble() ) @@ -172,7 +172,7 @@ sealed class ProfileSealed( break } if (!hardLimits.isInRange( - Round.roundTo(target.highTarget, 0.1), + Profile.toMgdl(target.highTarget, units), HardLimits.VERY_HARD_LIMIT_MAX_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_MAX_BG[1].toDouble() ) From c611674b3b1e240a7f5e587725815c2e74426817 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 16 Sep 2021 00:02:27 +0200 Subject: [PATCH 10/11] show only valid data --- .../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 bf9803796d..076c4de02e 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 @@ -548,14 +548,14 @@ class OverviewData @Inject constructor( // val start = dateUtil.now() maxTreatmentsValue = 0.0 val filteredTreatments: MutableList = java.util.ArrayList() - repository.getBolusesIncludingInvalidFromTimeToTime(fromTime, endTime, true).blockingGet() + repository.getBolusesDataFromTimeToTime(fromTime, endTime, true).blockingGet() .map { BolusDataPoint(it, resourceHelper, activePlugin, defaultValueHelper) } - .filter { it.data.type != Bolus.Type.SMB || it.data.isValid } + .filter { it.data.type == Bolus.Type.NORMAL || it.data.type == Bolus.Type.SMB } .forEach { it.y = getNearestBg(it.x.toLong()) filteredTreatments.add(it) } - repository.getCarbsIncludingInvalidFromTimeToTimeExpanded(fromTime, endTime, true).blockingGet() + repository.getCarbsDataFromTimeToTimeExpanded(fromTime, endTime, true).blockingGet() .map { CarbsDataPoint(it, resourceHelper) } .forEach { it.y = getNearestBg(it.x.toLong()) From a448efe09cfeb7c54e28c5d4c67783d30fc6d918 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 16 Sep 2021 00:18:02 +0200 Subject: [PATCH 11/11] fix profile editor (ISF limits) --- .../androidaps/plugins/profile/local/LocalProfilePlugin.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index a474bb86c8..8b74f760cc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -106,16 +106,17 @@ class LocalProfilePlugin @Inject constructor( if (dia < hardLimits.minDia() || dia > hardLimits.maxDia()) return false if (name.isNullOrEmpty()) return false if (blockFromJsonArray(ic, dateUtil)?.any { it.amount < hardLimits.minIC() || it.amount > hardLimits.maxIC() } != false) return false - if (blockFromJsonArray(isf, dateUtil)?.any { it.amount < HardLimits.MIN_ISF || it.amount > HardLimits.MAX_ISF } != false) return false if (blockFromJsonArray(basal, dateUtil)?.any { it.amount < pumpDescription.basalMinimumRate || it.amount > 10.0 } != false) return false val low = blockFromJsonArray(targetLow, dateUtil) val high = blockFromJsonArray(targetHigh, dateUtil) if (profileFunction.getUnits() == GlucoseUnit.MGDL) { if (low?.any { it.amount < HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble() || it.amount > HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble() } != false) return false if (high?.any { it.amount < HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble() || it.amount > HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble() } != false) return false + if (blockFromJsonArray(isf, dateUtil)?.any { it.amount < HardLimits.MIN_ISF || it.amount > HardLimits.MAX_ISF } != false) return false } else { if (low?.any { it.amount < Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), GlucoseUnit.MMOL) || it.amount > Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), GlucoseUnit.MMOL) } != false) return false if (high?.any { it.amount < Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), GlucoseUnit.MMOL) || it.amount > Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), GlucoseUnit.MMOL) } != false) return false + if (blockFromJsonArray(isf, dateUtil)?.any { it.amount < Profile.fromMgdlToUnits(HardLimits.MIN_ISF, GlucoseUnit.MMOL) || it.amount > Profile.fromMgdlToUnits(HardLimits.MAX_ISF, GlucoseUnit.MMOL) } != false) return false } for (i in low.indices) if (low[i].amount > high[i].amount) return false }