diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsPlugin.java index d591f67556..df283bac13 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsPlugin.java @@ -30,12 +30,12 @@ public class ActionsPlugin implements PluginBase { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == GENERAL && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == GENERAL && fragmentVisible; } @Override @@ -45,12 +45,12 @@ public class ActionsPlugin implements PluginBase { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - this.fragmentEnabled = fragmentEnabled; + if (type == GENERAL) this.fragmentEnabled = fragmentEnabled; } @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - this.fragmentVisible = fragmentVisible; + if (type == GENERAL) this.fragmentVisible = fragmentVisible; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java index adc9ae0d4f..87f9f0f817 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java @@ -26,12 +26,12 @@ public class CareportalPlugin implements PluginBase { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == GENERAL && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == GENERAL && fragmentVisible; } @Override @@ -41,12 +41,12 @@ public class CareportalPlugin implements PluginBase { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - this.fragmentEnabled = fragmentEnabled; + if (type == GENERAL) this.fragmentEnabled = fragmentEnabled; } @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - this.fragmentVisible = fragmentVisible; + if (type == GENERAL) this.fragmentVisible = fragmentVisible; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java index 094ae157c8..03598d10f2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java @@ -69,12 +69,12 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == PROFILE && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == PROFILE && fragmentVisible; } @Override @@ -84,12 +84,12 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - this.fragmentEnabled = fragmentEnabled; + if (type == PROFILE) this.fragmentEnabled = fragmentEnabled; } @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - this.fragmentVisible = fragmentVisible; + if (type == PROFILE) this.fragmentVisible = fragmentVisible; } void storeSettings() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java index 588aeec7b6..5ac59dcaee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java @@ -21,6 +21,7 @@ import android.widget.ListView; import android.widget.TextView; import java.util.ArrayList; + import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventRefreshGui; @@ -34,6 +35,8 @@ import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.TempBasalsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.plugins.Loop.LoopFragment; +import info.nightscout.androidaps.plugins.NSProfileViewer.NSProfileViewerPlugin; +import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpPlugin; public class ConfigBuilderFragment extends Fragment implements FragmentBase { @@ -93,7 +96,8 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase { nsclientVerView.setText(ConfigBuilderPlugin.nsClientVersionName); nightscoutVerView.setText(ConfigBuilderPlugin.nightscoutVersionName); if (ConfigBuilderPlugin.nsClientVersionCode < 117) nsclientVerView.setTextColor(Color.RED); - if (ConfigBuilderPlugin.nightscoutVersionCode < 900) nightscoutVerView.setTextColor(Color.RED); + if (ConfigBuilderPlugin.nightscoutVersionCode < 900) + nightscoutVerView.setTextColor(Color.RED); setViews(); return view; } @@ -179,6 +183,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase { onEnabledCategoryChanged(plugin, type); configBuilderPlugin.storeSettings(); MainApp.bus().post(new EventRefreshGui(true)); + getPlugin().logPluginStatus(); } }); @@ -189,6 +194,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase { plugin.setFragmentVisible(type, cb.isChecked()); configBuilderPlugin.storeSettings(); MainApp.bus().post(new EventRefreshGui(true)); + getPlugin().logPluginStatus(); } }); } else { @@ -213,6 +219,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase { if (pluginList.size() < 2) { holder.checkboxEnabled.setEnabled(false); plugin.setFragmentEnabled(type, true); + getPlugin().storeSettings(); } // Constraints cannot be disabled @@ -246,9 +253,8 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase { } void onEnabledCategoryChanged(PluginBase changedPlugin, int type) { - int category = changedPlugin.getType(); ArrayList pluginsInCategory = null; - switch (category) { + switch (type) { // Multiple selection allowed case PluginBase.GENERAL: case PluginBase.CONSTRAINTS: @@ -267,7 +273,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase { case PluginBase.TEMPBASAL: case PluginBase.TREATMENT: case PluginBase.PUMP: - pluginsInCategory = MainApp.getSpecificPluginsList(category); + pluginsInCategory = MainApp.getSpecificPluginsListByInterface(PumpInterface.class); break; } if (pluginsInCategory != null) { @@ -282,7 +288,12 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase { } } } else { // enable first plugin in list - pluginsInCategory.get(0).setFragmentEnabled(type, true); + if (type == PluginBase.PUMP) + MainApp.getSpecificPlugin(VirtualPumpPlugin.class).setFragmentEnabled(type, true); + else if (type == PluginBase.PROFILE) + MainApp.getSpecificPlugin(NSProfileViewerPlugin.class).setFragmentEnabled(type, true); + else + pluginsInCategory.get(0).setFragmentEnabled(type, true); } setViews(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index f8a311e0c0..25d2bde3e0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -98,12 +98,12 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain @Override public boolean isEnabled(int type) { - return true; + return type == GENERAL && true; } @Override public boolean isVisibleInTabs(int type) { - return true; + return type == GENERAL && true; } @Override @@ -192,6 +192,22 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain return activeLoop; } + public void logPluginStatus() { + for (PluginBase p : pluginList) { + log.debug(p.getName() + ":" + + (p.isEnabled(1) ? " GENERAL" : "") + + (p.isEnabled(2) ? " TREATMENT" : "") + + (p.isEnabled(3) ? " TEMPBASAL" : "") + + (p.isEnabled(4) ? " PROFILE" : "") + + (p.isEnabled(5) ? " APS" : "") + + (p.isEnabled(6) ? " PUMP" : "") + + (p.isEnabled(7) ? " CONSTRAINTS" : "") + + (p.isEnabled(8) ? " LOOP" : "") + + (p.isEnabled(9) ? " BGSOURCE" : "") + ); + } + } + private void verifySelectionInCategories() { ArrayList pluginsInCategory; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java index b039a84f94..a94ae44e8c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java @@ -36,6 +36,7 @@ import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService; +import info.nightscout.androidaps.plugins.NSProfileViewer.NSProfileViewerPlugin; import info.nightscout.client.data.NSProfile; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; @@ -173,8 +174,17 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - if (type == PluginBase.PROFILE) this.fragmentProfileEnabled = fragmentEnabled; - else if (type == PluginBase.PUMP) this.fragmentPumpEnabled = fragmentEnabled; + if (type == PluginBase.PROFILE) + this.fragmentProfileEnabled = fragmentEnabled; + else if (type == PluginBase.PUMP) + this.fragmentPumpEnabled = fragmentEnabled; + // if pump profile was enabled need to switch to another too + if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) { + setFragmentEnabled(PluginBase.PROFILE, false); + setFragmentVisible(PluginBase.PROFILE, false); + MainApp.getSpecificPlugin(NSProfileViewerPlugin.class).setFragmentEnabled(PluginBase.PROFILE, true); + MainApp.getSpecificPlugin(NSProfileViewerPlugin.class).setFragmentVisible(PluginBase.PROFILE, true); + } } @Override @@ -648,7 +658,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf extended.put("BaseBasalRate", getBaseBasalRate()); try { extended.put("ActiveProfile", MainApp.getConfigBuilder().getActiveProfile().getProfile().getActiveProfile()); - } catch (Exception e) {} + } catch (Exception e) { + } pump.put("battery", battery); pump.put("status", status); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java index 67ee8d3ad2..831909cfab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java @@ -36,6 +36,7 @@ import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService; +import info.nightscout.androidaps.plugins.NSProfileViewer.NSProfileViewerPlugin; import info.nightscout.client.data.NSProfile; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; @@ -173,8 +174,17 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - if (type == PluginBase.PROFILE) this.fragmentProfileEnabled = fragmentEnabled; - else if (type == PluginBase.PUMP) this.fragmentPumpEnabled = fragmentEnabled; + if (type == PluginBase.PROFILE) + this.fragmentProfileEnabled = fragmentEnabled; + else if (type == PluginBase.PUMP) + this.fragmentPumpEnabled = fragmentEnabled; + // if pump profile was enabled need to switch to another too + if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) { + setFragmentEnabled(PluginBase.PROFILE, false); + setFragmentVisible(PluginBase.PROFILE, false); + MainApp.getSpecificPlugin(NSProfileViewerPlugin.class).setFragmentEnabled(PluginBase.PROFILE, true); + MainApp.getSpecificPlugin(NSProfileViewerPlugin.class).setFragmentVisible(PluginBase.PROFILE, true); + } } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java index 3051bf3138..886470538f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java @@ -83,12 +83,12 @@ public class LoopPlugin implements PluginBase { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == LOOP && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == LOOP && fragmentVisible; } @Override @@ -98,12 +98,12 @@ public class LoopPlugin implements PluginBase { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - this.fragmentEnabled = fragmentEnabled; + if (type == LOOP) this.fragmentEnabled = fragmentEnabled; } @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - this.fragmentVisible = fragmentVisible; + if (type == LOOP) this.fragmentVisible = fragmentVisible; } @Subscribe diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSProfileViewer/NSProfileViewerPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSProfileViewer/NSProfileViewerPlugin.java index f957b46fce..25e389a414 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSProfileViewer/NSProfileViewerPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSProfileViewer/NSProfileViewerPlugin.java @@ -51,12 +51,12 @@ public class NSProfileViewerPlugin implements PluginBase, ProfileInterface { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == PROFILE && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == PROFILE && fragmentVisible; } @Override @@ -66,12 +66,12 @@ public class NSProfileViewerPlugin implements PluginBase, ProfileInterface { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - this.fragmentEnabled = fragmentEnabled; + if (type == PROFILE) this.fragmentEnabled = fragmentEnabled; } @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - this.fragmentVisible = fragmentVisible; + if (type == PROFILE) this.fragmentVisible = fragmentVisible; } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Objectives/ObjectivesPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Objectives/ObjectivesPlugin.java index 89c319d2c1..1dba46dce5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Objectives/ObjectivesPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Objectives/ObjectivesPlugin.java @@ -51,13 +51,13 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface { @Override public boolean isEnabled(int type) { - return true; + return type == CONSTRAINTS; } @Override public boolean isVisibleInTabs(int type) { LoopPlugin loopPlugin = (LoopPlugin) MainApp.getSpecificPlugin(LoopPlugin.class); - return fragmentVisible && loopPlugin != null && loopPlugin.isVisibleInTabs(type); + return type == CONSTRAINTS && fragmentVisible && loopPlugin != null && loopPlugin.isVisibleInTabs(type); } @Override @@ -71,7 +71,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface { @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - this.fragmentVisible = fragmentVisible; + if (type == CONSTRAINTS) this.fragmentVisible = fragmentVisible; } public class Objective { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java index 4e13e75d17..58a25857e3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java @@ -58,12 +58,12 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == APS && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == APS && fragmentVisible; } @Override @@ -73,12 +73,12 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface { @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - this.fragmentVisible = fragmentVisible; + if (type == APS) this.fragmentVisible = fragmentVisible; } @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - this.fragmentEnabled = fragmentEnabled; + if (type == APS) this.fragmentEnabled = fragmentEnabled; } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java index 164238a57a..2dbc3332d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java @@ -49,7 +49,7 @@ public class OverviewPlugin implements PluginBase { @Override public boolean isEnabled(int type) { - return true; + return type == GENERAL; } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SafetyFragment/SafetyPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SafetyFragment/SafetyPlugin.java index 1b94ff5fad..f501ae5a0e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SafetyFragment/SafetyPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SafetyFragment/SafetyPlugin.java @@ -40,7 +40,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface { @Override public boolean isEnabled(int type) { - return true; + return type == CONSTRAINTS; } @Override @@ -54,7 +54,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface { } @Override - public void setFragmentEnabled(int tyep, boolean fragmentEnabled) { + public void setFragmentEnabled(int type, boolean fragmentEnabled) { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SimpleProfile/SimpleProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SimpleProfile/SimpleProfilePlugin.java index baa3da71f6..dbe6345927 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SimpleProfile/SimpleProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SimpleProfile/SimpleProfilePlugin.java @@ -60,12 +60,12 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == PROFILE && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == PROFILE && fragmentVisible; } @Override @@ -75,12 +75,12 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - this.fragmentEnabled = fragmentEnabled; + if (type == PROFILE) this.fragmentEnabled = fragmentEnabled; } @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - this.fragmentVisible = fragmentVisible; + if (type == PROFILE) this.fragmentVisible = fragmentVisible; } public void storeSettings() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java index 365027c012..1e16b891b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java @@ -100,12 +100,12 @@ public class SmsCommunicatorPlugin implements PluginBase { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == GENERAL && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == GENERAL && fragmentVisible; } @Override @@ -115,12 +115,12 @@ public class SmsCommunicatorPlugin implements PluginBase { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - SmsCommunicatorPlugin.fragmentEnabled = fragmentEnabled; + if (type == GENERAL) this.fragmentEnabled = fragmentEnabled; } @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - SmsCommunicatorPlugin.fragmentVisible = fragmentVisible; + if (type == GENERAL) this.fragmentEnabled = fragmentVisible; } @Subscribe diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SourceNSClient/SourceNSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SourceNSClient/SourceNSClientPlugin.java index fa88a70803..f29acb293d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SourceNSClient/SourceNSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SourceNSClient/SourceNSClientPlugin.java @@ -28,7 +28,7 @@ public class SourceNSClientPlugin implements PluginBase, BgSourceInterface { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == BGSOURCE && fragmentEnabled; } @Override @@ -43,7 +43,7 @@ public class SourceNSClientPlugin implements PluginBase, BgSourceInterface { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - this.fragmentEnabled = fragmentEnabled; + if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled; } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SourceXdrip/SourceXdripPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SourceXdrip/SourceXdripPlugin.java index a2575d9291..f2318580ea 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SourceXdrip/SourceXdripPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SourceXdrip/SourceXdripPlugin.java @@ -30,7 +30,7 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == BGSOURCE && fragmentEnabled; } @Override @@ -45,7 +45,7 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - SourceXdripPlugin.fragmentEnabled = fragmentEnabled; + if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled; } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java index 8cd51bbd1b..a1b5ec8d4e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java @@ -66,12 +66,12 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == TEMPBASAL && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == TEMPBASAL && fragmentVisible; } @Override @@ -81,12 +81,12 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - this.fragmentEnabled = fragmentEnabled; + if (type == TEMPBASAL) this.fragmentEnabled = fragmentEnabled; } @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - this.fragmentVisible = fragmentVisible; + if (type == TEMPBASAL) this.fragmentVisible = fragmentVisible; } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java index 369ce9ddbb..d26b6d0b8c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java @@ -49,12 +49,12 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == TREATMENT && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == TREATMENT && fragmentVisible; } @Override @@ -64,12 +64,12 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - this.fragmentEnabled = fragmentEnabled; + if (type == TREATMENT) this.fragmentEnabled = fragmentEnabled; } @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - this.fragmentVisible = fragmentVisible; + if (type == TREATMENT) this.fragmentVisible = fragmentVisible; } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java index c150748920..a7619d02d7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java @@ -80,12 +80,12 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == PUMP && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == PUMP && fragmentVisible; } @Override @@ -95,12 +95,12 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - this.fragmentEnabled = fragmentEnabled; + if (type == PUMP) this.fragmentEnabled = fragmentEnabled; } @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - this.fragmentVisible = fragmentVisible; + if (type == PUMP) this.fragmentVisible = fragmentVisible; } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java index 4685d3b634..33ad54ee81 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java @@ -28,7 +28,7 @@ public class WearPlugin implements PluginBase { private static WatchUpdaterService watchUS; private final Context ctx; - WearPlugin(Context ctx){ + WearPlugin(Context ctx) { this.ctx = ctx; MainApp.bus().register(this); } @@ -50,12 +50,12 @@ public class WearPlugin implements PluginBase { @Override public boolean isEnabled(int type) { - return fragmentEnabled; + return type == GENERAL && fragmentEnabled; } @Override public boolean isVisibleInTabs(int type) { - return fragmentVisible; + return type == GENERAL && fragmentVisible; } @Override @@ -65,39 +65,41 @@ public class WearPlugin implements PluginBase { @Override public void setFragmentEnabled(int type, boolean fragmentEnabled) { - WearPlugin.fragmentEnabled = fragmentEnabled; - if(watchUS!=null){ - watchUS.setSettings(); + if (type == GENERAL) { + this.fragmentEnabled = fragmentEnabled; + if (watchUS != null) { + watchUS.setSettings(); + } } } @Override public void setFragmentVisible(int type, boolean fragmentVisible) { - WearPlugin.fragmentVisible = fragmentVisible; + if (type == GENERAL) this.fragmentVisible = fragmentVisible; } - private void sendDataToWatch(boolean status, boolean basals, boolean bgValue){ + private void sendDataToWatch(boolean status, boolean basals, boolean bgValue) { if (isEnabled(getType())) { //only start service when this plugin is enabled - if(bgValue){ + if (bgValue) { ctx.startService(new Intent(ctx, WatchUpdaterService.class)); } - if(basals){ + if (basals) { ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BASALS)); } - if(status){ + if (status) { ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_STATUS)); } } } - void resendDataToWatch(){ + void resendDataToWatch() { ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_RESEND)); } - void openSettings(){ + void openSettings() { ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_OPEN_SETTINGS)); } @@ -132,11 +134,11 @@ public class WearPlugin implements PluginBase { return fragmentEnabled; } - public static void registerWatchUpdaterService(WatchUpdaterService wus){ + public static void registerWatchUpdaterService(WatchUpdaterService wus) { watchUS = wus; } - public static void unRegisterWatchUpdaterService(){ + public static void unRegisterWatchUpdaterService() { watchUS = null; } diff --git a/wear/wear.iml b/wear/wear.iml index a3cf0fc780..a09c181fa1 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -43,6 +43,13 @@ + + + + + + + @@ -51,13 +58,6 @@ - - - - - - -