From e9c7bdc7f43bb2df1c88a5ec8821b0c013f360c7 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 31 Mar 2018 22:30:42 +0200 Subject: [PATCH] add necessity of profile switch to objectives --- .../ConstraintsObjectives/ObjectivesPlugin.java | 6 +++++- app/src/main/res/layout/nsprofile_fragment.xml | 11 ++++++----- app/src/main/res/values-cs/strings.xml | 2 +- app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java index 8973ba3ac8..291b06372f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java @@ -26,6 +26,7 @@ import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; +import info.nightscout.utils.DateUtil; import info.nightscout.utils.SP; /** @@ -129,7 +130,9 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginType.APS)) apsEnabled = true; - return new RequirementResult(hasBGData && bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginType.LOOP) && apsEnabled && vpUploadNeeded, + boolean profileSwitchExists = MainApp.getConfigBuilder().getProfileSwitchFromHistory(DateUtil.now()) != null; + + return new RequirementResult(hasBGData && bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginType.LOOP) && apsEnabled && vpUploadNeeded && profileSwitchExists, MainApp.gs(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS) + "\n" + MainApp.gs(R.string.nsclienthaswritepermission) + ": " + yesOrNo(NSClientPlugin.getPlugin().hasWritePermission()) + (isVirtualPump ? "\n" + MainApp.gs(R.string.virtualpump_uploadstatus_title) + ": " + yesOrNo(vpUploadEnabled) : "") @@ -137,6 +140,7 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface + "\n" + MainApp.gs(R.string.hasbgdata) + ": " + yesOrNo(hasBGData) + "\n" + MainApp.gs(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) + "\n" + MainApp.gs(R.string.apsselected) + ": " + yesOrNo(apsEnabled) + + "\n" + MainApp.gs(R.string.activate_profile) + ": " + yesOrNo(profileSwitchExists) ); case 1: return new RequirementResult(manualEnacts >= manualEnactsNeeded, diff --git a/app/src/main/res/layout/nsprofile_fragment.xml b/app/src/main/res/layout/nsprofile_fragment.xml index 0c1c40d1e4..6e9ca472d8 100644 --- a/app/src/main/res/layout/nsprofile_fragment.xml +++ b/app/src/main/res/layout/nsprofile_fragment.xml @@ -10,11 +10,6 @@ android:layout_gravity="center_horizontal" android:layout_marginBottom="5dp" /> - -