From 04af3eb80666f45a477608b3616bda0852152906 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 14 Aug 2018 16:06:02 +0200 Subject: [PATCH] source selection in nsclient after dropping g5 uploader --- .../info/nightscout/androidaps/MainApp.java | 15 +++++---------- .../plugins/Source/SourceDexcomG5Plugin.java | 1 - .../plugins/Source/SourceNSClientPlugin.java | 2 -- .../plugins/Source/SourcePoctechPlugin.java | 1 - .../androidaps/setupwizard/SWDefinition.java | 19 +++++++++++++++++++ 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index ac5f401a55..d7a542e396 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -172,17 +172,12 @@ public class MainApp extends Application { pluginsList.add(TreatmentsPlugin.getPlugin()); if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin()); if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin()); - if (!Config.NSCLIENT) - pluginsList.add(SourceXdripPlugin.getPlugin()); + pluginsList.add(SourceXdripPlugin.getPlugin()); pluginsList.add(SourceNSClientPlugin.getPlugin()); - if (!Config.NSCLIENT) - pluginsList.add(SourceMM640gPlugin.getPlugin()); - if (!Config.NSCLIENT) - pluginsList.add(SourceGlimpPlugin.getPlugin()); - if (!Config.NSCLIENT) - pluginsList.add(SourceDexcomG5Plugin.getPlugin()); - if (!Config.NSCLIENT) - pluginsList.add(SourcePoctechPlugin.getPlugin()); + pluginsList.add(SourceMM640gPlugin.getPlugin()); + pluginsList.add(SourceGlimpPlugin.getPlugin()); + pluginsList.add(SourceDexcomG5Plugin.getPlugin()); + pluginsList.add(SourcePoctechPlugin.getPlugin()); if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin()); pluginsList.add(FoodPlugin.getPlugin()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java index 46d138c73d..994721ba5c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java @@ -42,7 +42,6 @@ public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterfac .fragmentClass(BGSourceFragment.class.getName()) .pluginName(R.string.DexcomG5) .shortName(R.string.dexcomG5_shortname) - .showInList(!Config.NSCLIENT) .preferencesId(R.xml.pref_dexcomg5) .description(R.string.description_source_dexcom_g5) ); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java index 50ad9e0984..9f222d935e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java @@ -44,8 +44,6 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment.class.getName()) .pluginName(R.string.nsclientbg) - .showInList(!Config.NSCLIENT) - .alwaysEnabled(Config.NSCLIENT) .description(R.string.description_source_ns_client) ); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java index 4cdd8dd810..df390522d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java @@ -42,7 +42,6 @@ public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment.class.getName()) .pluginName(R.string.poctech) - .showInList(!Config.NSCLIENT) .preferencesId(R.xml.pref_poctech) .description(R.string.description_source_poctech) ); diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java index 4e56e0fca1..ca1ef02fda 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java @@ -545,6 +545,25 @@ public class SWDefinition { .validator(() -> NSClientPlugin.getPlugin().nsClientService != null && NSClientPlugin.getPlugin().nsClientService.isConnected && NSClientPlugin.getPlugin().nsClientService.hasWriteAuth) .visibility(() -> !(NSClientPlugin.getPlugin().nsClientService != null && NSClientPlugin.getPlugin().nsClientService.isConnected && NSClientPlugin.getPlugin().nsClientService.hasWriteAuth)) ) + .add(new SWScreen(R.string.configbuilder_bgsource) + .skippable(false) + .add(new SWPlugin() + .option(PluginType.BGSOURCE, R.string.configbuilder_bgsource_description) + .label(R.string.configbuilder_bgsource)) + .add(new SWBreak()) + .add(new SWButton() + .text(R.string.bgsourcesetup) + .action(() -> { + final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveBgSource(); + PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> { + Intent i = new Intent(activity, PreferencesActivity.class); + i.putExtra("id", plugin.getPreferencesId()); + activity.startActivity(i); + }, null); + }) + .visibility(() -> MainApp.getConfigBuilder().getActiveBgSource()!= null && ((PluginBase) MainApp.getConfigBuilder().getActiveBgSource()).getPreferencesId() > 0)) + .validator(() -> MainApp.getConfigBuilder().getActiveBgSource() != null) + ) .add(new SWScreen(R.string.patientage) .skippable(false) .add(new SWInfotext()