From e357c7fd1bdf16557a189177c0d2fbbb9f88d8f3 Mon Sep 17 00:00:00 2001 From: Roumen Georgiev Date: Tue, 8 May 2018 15:14:36 +0300 Subject: [PATCH] adding pump selection --- .../startupwizard/SWDefinition.java | 36 +++++++++++++++++++ .../startupwizard/SWRadioButton.java | 9 ++++- app/src/main/res/values/arrays.xml | 11 ++++++ app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/startupwizard/SWDefinition.java b/app/src/main/java/info/nightscout/androidaps/startupwizard/SWDefinition.java index 6e4cd42f2f..a7c140e3fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/startupwizard/SWDefinition.java +++ b/app/src/main/java/info/nightscout/androidaps/startupwizard/SWDefinition.java @@ -14,9 +14,12 @@ import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin; +import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; +import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.androidaps.startupwizard.events.EventSWUpdate; import info.nightscout.utils.LocaleHelper; import info.nightscout.utils.SP; +//Needed for pump validation public class SWDefinition { private static Logger log = LoggerFactory.getLogger(SWDefinition.class); @@ -77,6 +80,39 @@ public class SWDefinition { .visibility(() -> !NSClientPlugin.getPlugin().isEnabled(PluginType.GENERAL))) .validator(() -> NSClientPlugin.getPlugin().nsClientService != null && NSClientPlugin.getPlugin().nsClientService.isConnected && NSClientPlugin.getPlugin().nsClientService.hasWriteAuth) ) + .add(new SWScreen(R.string.configbuilder_pump) + .skippable(true) + + .add(new SWPlugin() + .option(PluginType.PUMP) + .label(R.string.configbuilder_pump) + .comment(R.string.configbuilder_pump)) + .validator(() -> MainApp.getSpecificPluginsList(PluginType.PUMP) != null) + ) + .add(new SWScreen(R.string.setupwizard_pump_test) + .skippable(true) + // Adding DanaR specific fields + .add(DanaRPlugin.getPlugin().isEnabled(PluginType.PUMP)?new SWString() + .preferenceId(R.string.key_danar_bt_name) + .label(R.string.danar_bt_name_title) + .comment(R.string.danar_bt_name_title) : new SWItem(SWItem.Type.STRING) + ) + .add(DanaRPlugin.getPlugin().isEnabled(PluginType.PUMP)?new SWString() + .preferenceId(R.string.key_danar_password) + .label(R.string.danar_password_title) + .comment(R.string.danar_password_title): new SWItem(SWItem.Type.STRING) + ) + // Virtual pump + .add(VirtualPumpPlugin.getPlugin().isEnabled(PluginType.PUMP)? + new SWRadioButton() + .option(R.array.trueFalseArray, R.array.trueFalseValues) + .preferenceId(R.string.key_virtualpump_uploadstatus) + .label(R.string.virtualpump_uploadstatus_title) + .comment(R.string.virtualpump_uploadstatus_title): new SWItem(SWItem.Type.STRING) + ) + .validator(() -> MainApp.getSpecificPluginsList(PluginType.PUMP) != null) + ) + .add(new SWScreen(R.string.patientage) .skippable(false) .add(new SWRadioButton() diff --git a/app/src/main/java/info/nightscout/androidaps/startupwizard/SWRadioButton.java b/app/src/main/java/info/nightscout/androidaps/startupwizard/SWRadioButton.java index 7cdbee3d71..9b91e289a1 100644 --- a/app/src/main/java/info/nightscout/androidaps/startupwizard/SWRadioButton.java +++ b/app/src/main/java/info/nightscout/androidaps/startupwizard/SWRadioButton.java @@ -10,6 +10,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; import info.nightscout.utils.SP; public class SWRadioButton extends SWItem { @@ -41,7 +42,13 @@ public class SWRadioButton extends SWItem { public void generateDialog(View view, LinearLayout layout) { Context context = view.getContext(); // Get if there is already value in SP - String previousValue = SP.getString(preferenceId, "none"); + String previousValue = "none"; + if(preferenceId == R.string.key_virtualpump_uploadstatus) { + Boolean booleanValue = SP.getBoolean(preferenceId, false); + previousValue = booleanValue.toString(); + } else { + previousValue = SP.getString(preferenceId, "none"); + } radioGroup = new RadioGroup(context); radioGroup.clearCheck(); radioGroup.setOrientation(LinearLayout.VERTICAL); diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 12492d4a50..cacea337fc 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -105,4 +105,15 @@ @string/no @string/yes + + + @string/yes + @string/no + + + + true + false + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index af30252d7c..b63c14cee2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -523,6 +523,7 @@ resistantadult Please select patient age to setup safety limits I_understand + virtualpump_uploadstatus Glimp Device does not appear to support battery optimization whitelisting! Please Allow Permission @@ -1018,6 +1019,7 @@ Skip FINISH Select your language + Test pump connection language openapsama_min_5m_carbimpact Asked: %.2fU Delivered: %.2fU Error code: %d