From 4aefea0b2886ae2ba16c2d173455206a5424ec00 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Thu, 17 May 2018 14:21:35 +0100 Subject: [PATCH] Add constants file and modified status. --- .../driver/MedtronicPumpStatus.java | 17 ++++++------- .../PumpMedtronic/util/MedtronicConst.java | 24 +++++++++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/util/MedtronicConst.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/driver/MedtronicPumpStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/driver/MedtronicPumpStatus.java index 75ee4fdc61..2b4de3e6bc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/driver/MedtronicPumpStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/driver/MedtronicPumpStatus.java @@ -11,6 +11,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus; import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType; +import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicConst; import info.nightscout.utils.SP; /** @@ -92,7 +93,7 @@ public class MedtronicPumpStatus extends PumpStatus { this.maxBasal = null; - String serialNr = SP.getString("pref_medtronic_serial", null); + String serialNr = SP.getString(MedtronicConst.Prefs.PumpSerial, null); if (serialNr == null) { this.errorDescription = MainApp.gs(R.string.medtronic_error_serial_not_set); @@ -107,7 +108,7 @@ public class MedtronicPumpStatus extends PumpStatus { } - String pumpType = SP.getString("pref_medtronic_pump_type", null); + String pumpType = SP.getString(MedtronicConst.Prefs.PumpType, null); if (pumpType == null) { this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_type_not_set); @@ -129,7 +130,7 @@ public class MedtronicPumpStatus extends PumpStatus { } - String pumpFrequency = SP.getString("pref_medtronic_frequency", null); + String pumpFrequency = SP.getString(MedtronicConst.Prefs.PumpFrequency, null); if (pumpFrequency == null) { this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_frequency_not_set); @@ -145,7 +146,7 @@ public class MedtronicPumpStatus extends PumpStatus { } - String rileyLinkAddress = SP.getString("pref_medtronic_rileylink_mac", null); + String rileyLinkAddress = SP.getString(MedtronicConst.Prefs.RileyLinkAddress, null); if (rileyLinkAddress == null) { this.errorDescription = MainApp.gs(R.string.medtronic_error_rileylink_address_invalid); @@ -159,20 +160,20 @@ public class MedtronicPumpStatus extends PumpStatus { } - String value = SP.getString("pref_medtronic_max_bolus", "25"); + String value = SP.getString(MedtronicConst.Prefs.MaxBolus, "25"); maxBolus = Integer.parseInt(value); if (maxBolus > 25) { - SP.putString("pref_medtronic_max_bolus", "25"); + SP.putString(MedtronicConst.Prefs.MaxBolus, "25"); } - value = SP.getString("pref_medtronic_max_basal", "35"); + value = SP.getString(MedtronicConst.Prefs.MaxBasal, "35"); maxBasal = Integer.parseInt(value); if (maxBasal > 35) { - SP.putString("pref_medtronic_max_basal", "35"); + SP.putString(MedtronicConst.Prefs.MaxBasal, "35"); } } catch (Exception ex) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/util/MedtronicConst.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/util/MedtronicConst.java new file mode 100644 index 0000000000..64a2fb2b35 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/util/MedtronicConst.java @@ -0,0 +1,24 @@ +package info.nightscout.androidaps.plugins.PumpMedtronic.util; + +/** + * Created by andy on 5/12/18. + */ + +public class MedtronicConst { + + static String Prefix = "AAPS.Medtronic."; + + public class Prefs { + + public static final String PrefPrefix = "pref_medtronic_"; + public static final String PumpSerial = PrefPrefix + "serial"; + public static final String PumpType = PrefPrefix + "pump_type"; + public static final String PumpFrequency = PrefPrefix + "frequency"; + public static final String RileyLinkAddress = PrefPrefix + "rileylink_mac"; + public static final String MaxBolus = PrefPrefix + "max_bolus"; + public static final String MaxBasal = PrefPrefix + "max_basal"; + + + } + +}