From b898fc044ee17fd929137958f059d964f41eeac9 Mon Sep 17 00:00:00 2001 From: LadyViktoria Date: Wed, 25 Jan 2017 15:18:01 +0100 Subject: [PATCH 01/36] Add prefernces.json to advanced settings --- .../info/nightscout/androidaps/Constants.java | 11 ---- .../plugins/OpenAPSAMA/Autosens.java | 11 ++-- .../DetermineBasalAdapterAMAJS.java | 11 ++-- .../plugins/OpenAPSAMA/OpenAPSAMAPlugin.java | 2 +- .../plugins/SafetyFragment/SafetyPlugin.java | 8 +-- .../plugins/Treatments/TreatmentsPlugin.java | 6 +- app/src/main/res/values/strings.xml | 16 +++++ app/src/main/res/xml/pref_advanced.xml | 63 +++++++++++++++++++ app/src/main/res/xml/pref_openapsama.xml | 7 --- 9 files changed, 101 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/Constants.java b/app/src/main/java/info/nightscout/androidaps/Constants.java index 77c8e2b9a0..96f18396ce 100644 --- a/app/src/main/java/info/nightscout/androidaps/Constants.java +++ b/app/src/main/java/info/nightscout/androidaps/Constants.java @@ -25,19 +25,8 @@ public class Constants { public static final long keepAliveMsecs = 5 * 60 * 1000L; // SMS COMMUNICATOR - public static final long remoteBolusMinDistance = 15 * 60 * 1000L; - - // AMA - public static final int MAX_DAILY_SAFETY_MULTIPLIER = 3; - public static final int CURRENT_BASAL_SAFETY_MULTIPLIER = 4; - - public static final int BOLUSSNOOZE_DIA_ADVISOR = 2; - public static final double AUTOSENS_MAX = 1.2d; - public static final double AUTOSENS_MIN = 0.7d; - public static final double MIN_5M_CARBIMPACT = 3d; - // Circadian Percentage Profile public static final int CPP_MIN_PERCENTAGE = 50; public static final int CPP_MAX_PERCENTAGE = 200; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/Autosens.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/Autosens.java index 7f4d1c4aa9..d695576daf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/Autosens.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/Autosens.java @@ -1,5 +1,8 @@ package info.nightscout.androidaps.plugins.OpenAPSAMA; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,7 +23,7 @@ public class Autosens { private static Logger log = LoggerFactory.getLogger(Autosens.class); public static AutosensResult detectSensitivityandCarbAbsorption(List glucose_data, long mealTime) { - + SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); //console.error(mealTime); @@ -128,7 +131,7 @@ public class Autosens { if (bgTime > mealTime) { // figure out how many carbs that represents // but always assume at least 3mg/dL/5m (default) absorption - double ci = Math.max(deviation, Constants.MIN_5M_CARBIMPACT); + double ci = Math.max(deviation, Double.parseDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))); double absorbed = ci * profile.getIc(secondsFromMidnight) / sens; // and add that to the running total carbsAbsorbed carbsAbsorbed += absorbed; @@ -173,8 +176,8 @@ public class Autosens { // don't adjust more than 1.5x double rawRatio = ratio; - ratio = Math.max(ratio, Constants.AUTOSENS_MIN); - ratio = Math.min(ratio, Constants.AUTOSENS_MAX); + ratio = Math.max(ratio, Double.parseDouble(SP.getString("openapsama_autosens_min", "0.7"))); + ratio = Math.min(ratio, Double.parseDouble(SP.getString("openapsama_autosens_max", "1.2"))); String ratioLimit = ""; if (ratio != rawRatio) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java index 925a97e98b..800c433943 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java @@ -218,7 +218,6 @@ public class DetermineBasalAdapterAMAJS { String units = profile.getUnits(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); - boolean autosensAdustTargets = preferences.getBoolean("openapsama_autosens_adjusttargets", false); mProfile = new V8Object(mV8rt); mProfile.add("max_iob", maxIob); @@ -232,13 +231,13 @@ public class DetermineBasalAdapterAMAJS { mProfile.add("target_bg", targetBg); mProfile.add("carb_ratio", profile.getIc(profile.secondsFromMidnight())); mProfile.add("sens", NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()).doubleValue(), units)); - mProfile.add("max_daily_safety_multiplier", Constants.MAX_DAILY_SAFETY_MULTIPLIER); - mProfile.add("current_basal_safety_multiplier", Constants.CURRENT_BASAL_SAFETY_MULTIPLIER); - mProfile.add("skip_neutral_temps", true); + mProfile.add("max_daily_safety_multiplier", Integer.parseInt(preferences.getString("openapsama_max_daily_safety_multiplier", "3"))); + mProfile.add("current_basal_safety_multiplier", Integer.parseInt(preferences.getString("openapsama_max_basal_safety_multiplier", "4"))); + mProfile.add("skip_neutral_temps", preferences.getBoolean("openapsama_skip_neutral_temps", false)); mProfile.add("current_basal", pump.getBaseBasalRate()); mProfile.add("temptargetSet", tempTargetSet); - mProfile.add("autosens_adjust_targets", autosensAdustTargets); - mProfile.add("min_5m_carbimpact", min_5m_carbimpact); + mProfile.add("autosens_adjust_targets", preferences.getBoolean("openapsama_autosens_adjusttargets", true)); + mProfile.add("min_5m_carbimpact", Double.parseDouble(preferences.getString("openapsama_min_5m_carbimpact", "3.0"))); mV8rt.add(PARAM_profile, mProfile); mCurrentTemp = new V8Object(mV8rt); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index 0ba7fb18ee..0d31191ff1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -224,7 +224,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface { determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData, lastAutosensResult.ratio, //autosensDataRatio isTempTarget, - Constants.MIN_5M_CARBIMPACT //min_5m_carbimpact + Double.parseDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))//min_5m_carbimpact ); 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 ceb0d96efa..b0aafb2a11 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 @@ -103,8 +103,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface { if (profile == null) return absoluteRate; if (absoluteRate < 0) absoluteRate = 0d; - Integer maxBasalMult = Constants.CURRENT_BASAL_SAFETY_MULTIPLIER; - Integer maxBasalFromDaily = Constants.MAX_DAILY_SAFETY_MULTIPLIER; + Integer maxBasalMult = Integer.parseInt(SP.getString("openapsama_max_basal_safety_multiplier", "4")); + Integer maxBasalFromDaily = Integer.parseInt(SP.getString("openapsama_max_daily_safety_multiplier", "3")); // Check percentRate but absolute rate too, because we know real current basal in pump Double origRate = absoluteRate; if (absoluteRate > maxBasal) { @@ -142,8 +142,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface { if (absoluteRate < 0) absoluteRate = 0d; - Integer maxBasalMult = Constants.CURRENT_BASAL_SAFETY_MULTIPLIER; - Integer maxBasalFromDaily = Constants.MAX_DAILY_SAFETY_MULTIPLIER; + Integer maxBasalMult = Integer.parseInt(SP.getString("openapsama_max_basal_safety_multiplier", "4")); + Integer maxBasalFromDaily = Integer.parseInt(SP.getString("openapsama_max_daily_safety_multiplier", "3")); // Check percentRate but absolute rate too, because we know real current basal in pump Double origRate = absoluteRate; if (absoluteRate > maxBasal) { 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 eca00d6159..9a1d98d5f8 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 @@ -1,5 +1,8 @@ package info.nightscout.androidaps.plugins.Treatments; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; + import com.j256.ormlite.dao.Dao; import com.j256.ormlite.stmt.PreparedQuery; import com.j256.ormlite.stmt.QueryBuilder; @@ -121,6 +124,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { @Override public IobTotal getCalculationToTime(long time) { + SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); IobTotal total = new IobTotal(time); if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet @@ -138,7 +142,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { Iob tIOB = t.iobCalc(now, dia); total.iob += tIOB.iobContrib; total.activity += tIOB.activityContrib; - Iob bIOB = t.iobCalc(now, dia / Constants.BOLUSSNOOZE_DIA_ADVISOR); + Iob bIOB = t.iobCalc(now, dia / Integer.parseInt(SP.getString("openapsama_bolussnooze_dia_divisor", "2"))); total.bolussnooze += bIOB.iobContrib; } return total; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4831be7e3b..f53e42b44f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -429,6 +429,7 @@ Initializing ... Temporary Target Allow autosens to adjust targets + This is used to allow autosens to adjust BG targets, in addition to ISF and basals. ACT CONF LOOP @@ -452,4 +453,19 @@ Always use short average delta instead of simple delta Useful when data from unfiltered sources like xDrip gets noisy. Advanced Settings + max_daily_safety_multiplier + This is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware that’s what is discussed about “3x max daily; 4x current” for safety caps. + current_basal_safety_multiplier + This is the other half of the key OpenAPS safety caps, and the other half of “3x max daily; 4x current” of the safety caps. This means your basal, regardless of max basal set on your pump, cannot be any higher than this number times the current level of your basal. This is to prevent people from getting into dangerous territory by setting excessively high max basals before understanding how the algorithm works. Again, the default is 4x; most people will never need to adjust this and are instead more likely to need to adjust other settings if they feel like they are “running into” this safety cap. + autosens_max + This is a multiplier cap for autosens (and soon autotune) to set a 20% max limit on how high the autosens ratio can be, which in turn determines how high autosens can adjust basals, how low it can adjust ISF, and how low it can set the BG target. + autosens_min + The other side of the autosens safety limits, putting a cap on how low autosens can adjust basals, and how high it can adjust ISF and BG targets. + skip_neutral_temps + Defaults to false, so that OpenAPS will set temps whenever it can, so it will be easier to see if the system is working, even when you are offline. This means OpenAPS will set a “neutral” temp (same as your default basal) if no adjustments are needed. If you are a light sleeper and the “on the hour” buzzing or beeping wakes you up (even in vibrate mode), you may want to turn this to “true” to skip this setting. However, we recommend it for most people who will be using this system on the go and out of constant connectivity. + bolussnooze_dia_divisor + Bolus snooze is enacted after you do a meal bolus, so the loop won’t counteract with low temps when you’ve just eaten. The example here and default is 2; so a 3 hour DIA means that bolus snooze will be gradually phased out over 1.5 hours (3DIA/2). + min_5m_carbimpact + This is a setting for default carb absorption impact per 5 minutes. The default is an expected 3mg/dl/5min. This affects how fast COB are decayed, and how much carb absorption is assumed in calculating future predicted BG, when BG is falling more than expected, or not rising as much as expected. + diff --git a/app/src/main/res/xml/pref_advanced.xml b/app/src/main/res/xml/pref_advanced.xml index 61552cb3be..76ef53758e 100644 --- a/app/src/main/res/xml/pref_advanced.xml +++ b/app/src/main/res/xml/pref_advanced.xml @@ -25,6 +25,69 @@ android:title="@string/always_use_shortavg" android:summary="@string/always_use_shortavg_summary"/> + + + + + + + + + + diff --git a/app/src/main/res/xml/pref_openapsama.xml b/app/src/main/res/xml/pref_openapsama.xml index 268152944d..0dce8b7d8a 100644 --- a/app/src/main/res/xml/pref_openapsama.xml +++ b/app/src/main/res/xml/pref_openapsama.xml @@ -9,13 +9,6 @@ android:key="openapsama_useautosens" android:title="@string/openapsama_useautosens" /> - - - \ No newline at end of file From 2a0968eba9dd3ef2441b9a4bac24fc2b9b1f3cd6 Mon Sep 17 00:00:00 2001 From: LadyViktoria Date: Wed, 25 Jan 2017 15:32:38 +0100 Subject: [PATCH 02/36] Add prefences.Json show summary --- .../java/info/nightscout/androidaps/PreferencesActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java index 858d7fde6e..c0425b388d 100644 --- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java @@ -57,7 +57,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre { pref.setSummary("******"); } else if (editTextPref.getText() != null && !editTextPref.getText().equals("")){ - pref.setSummary(editTextPref.getText()); + pref.setSummary("Value is set to: " +editTextPref.getText() + "\n" + editTextPref.getSummary()); } } if (pref instanceof MultiSelectListPreference) { From c01488e7a9075cc2b5a6bf2c528b5c85aad11f1b Mon Sep 17 00:00:00 2001 From: viktoria Date: Wed, 25 Jan 2017 20:19:00 +0100 Subject: [PATCH 03/36] Add prefernces.json switch to SafeParse --- .../nightscout/androidaps/PreferencesActivity.java | 9 +++++---- .../androidaps/plugins/OpenAPSAMA/Autosens.java | 7 ++++--- .../plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java | 7 ++++--- .../plugins/OpenAPSAMA/OpenAPSAMAPlugin.java | 2 +- .../plugins/SafetyFragment/SafetyPlugin.java | 10 +++++----- .../plugins/Treatments/TreatmentsPlugin.java | 3 ++- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java index c0425b388d..9506792926 100644 --- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java @@ -10,6 +10,7 @@ import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.preference.PreferenceGroup; import android.preference.PreferenceManager; +import android.preference.SwitchPreference; import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRefreshGui; @@ -53,11 +54,11 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre } if (pref instanceof EditTextPreference) { EditTextPreference editTextPref = (EditTextPreference) pref; - if (pref.getTitle().toString().toLowerCase().contains("password")) - { + if (pref.getTitle().toString().toLowerCase().contains("password")) { pref.setSummary("******"); - } else if (editTextPref.getText() != null && !editTextPref.getText().equals("")){ - pref.setSummary("Value is set to: " +editTextPref.getText() + "\n" + editTextPref.getSummary()); + } else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) { + ((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage()); + pref.setSummary(editTextPref.getText()); } } if (pref instanceof MultiSelectListPreference) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/Autosens.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/Autosens.java index d695576daf..eef79757cc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/Autosens.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/Autosens.java @@ -17,6 +17,7 @@ import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.db.BgReading; import info.nightscout.client.data.NSProfile; import info.nightscout.utils.Round; +import info.nightscout.utils.SafeParse; public class Autosens { @@ -131,7 +132,7 @@ public class Autosens { if (bgTime > mealTime) { // figure out how many carbs that represents // but always assume at least 3mg/dL/5m (default) absorption - double ci = Math.max(deviation, Double.parseDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))); + double ci = Math.max(deviation, SafeParse.stringToDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))); double absorbed = ci * profile.getIc(secondsFromMidnight) / sens; // and add that to the running total carbsAbsorbed carbsAbsorbed += absorbed; @@ -176,8 +177,8 @@ public class Autosens { // don't adjust more than 1.5x double rawRatio = ratio; - ratio = Math.max(ratio, Double.parseDouble(SP.getString("openapsama_autosens_min", "0.7"))); - ratio = Math.min(ratio, Double.parseDouble(SP.getString("openapsama_autosens_max", "1.2"))); + ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7"))); + ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_max", "1.2"))); String ratioLimit = ""; if (ratio != rawRatio) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java index 800c433943..f3f58fe785 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java @@ -26,6 +26,7 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.client.data.NSProfile; +import info.nightscout.utils.SafeParse; public class DetermineBasalAdapterAMAJS { private static Logger log = LoggerFactory.getLogger(DetermineBasalAdapterAMAJS.class); @@ -231,13 +232,13 @@ public class DetermineBasalAdapterAMAJS { mProfile.add("target_bg", targetBg); mProfile.add("carb_ratio", profile.getIc(profile.secondsFromMidnight())); mProfile.add("sens", NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()).doubleValue(), units)); - mProfile.add("max_daily_safety_multiplier", Integer.parseInt(preferences.getString("openapsama_max_daily_safety_multiplier", "3"))); - mProfile.add("current_basal_safety_multiplier", Integer.parseInt(preferences.getString("openapsama_max_basal_safety_multiplier", "4"))); + mProfile.add("max_daily_safety_multiplier", SafeParse.stringToInt(preferences.getString("openapsama_max_daily_safety_multiplier", "3"))); + mProfile.add("current_basal_safety_multiplier", SafeParse.stringToInt(preferences.getString("openapsama_max_basal_safety_multiplier", "4"))); mProfile.add("skip_neutral_temps", preferences.getBoolean("openapsama_skip_neutral_temps", false)); mProfile.add("current_basal", pump.getBaseBasalRate()); mProfile.add("temptargetSet", tempTargetSet); mProfile.add("autosens_adjust_targets", preferences.getBoolean("openapsama_autosens_adjusttargets", true)); - mProfile.add("min_5m_carbimpact", Double.parseDouble(preferences.getString("openapsama_min_5m_carbimpact", "3.0"))); + mProfile.add("min_5m_carbimpact", SafeParse.stringToDouble(preferences.getString("openapsama_min_5m_carbimpact", "3.0"))); mV8rt.add(PARAM_profile, mProfile); mCurrentTemp = new V8Object(mV8rt); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index 0d31191ff1..7392e1f263 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -224,7 +224,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface { determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData, lastAutosensResult.ratio, //autosensDataRatio isTempTarget, - Double.parseDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))//min_5m_carbimpact + SafeParse.stringToDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))//min_5m_carbimpact ); 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 b0aafb2a11..b01abf3436 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 @@ -103,8 +103,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface { if (profile == null) return absoluteRate; if (absoluteRate < 0) absoluteRate = 0d; - Integer maxBasalMult = Integer.parseInt(SP.getString("openapsama_max_basal_safety_multiplier", "4")); - Integer maxBasalFromDaily = Integer.parseInt(SP.getString("openapsama_max_daily_safety_multiplier", "3")); + Integer maxBasalMult = SafeParse.stringToInt(SP.getString("openapsama_max_basal_safety_multiplier", "4")); + Integer maxBasalFromDaily = SafeParse.stringToInt(SP.getString("openapsama_max_daily_safety_multiplier", "3")); // Check percentRate but absolute rate too, because we know real current basal in pump Double origRate = absoluteRate; if (absoluteRate > maxBasal) { @@ -142,8 +142,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface { if (absoluteRate < 0) absoluteRate = 0d; - Integer maxBasalMult = Integer.parseInt(SP.getString("openapsama_max_basal_safety_multiplier", "4")); - Integer maxBasalFromDaily = Integer.parseInt(SP.getString("openapsama_max_daily_safety_multiplier", "3")); + Integer maxBasalMult = SafeParse.stringToInt(SP.getString("openapsama_max_basal_safety_multiplier", "4")); + Integer maxBasalFromDaily = SafeParse.stringToInt(SP.getString("openapsama_max_daily_safety_multiplier", "3")); // Check percentRate but absolute rate too, because we know real current basal in pump Double origRate = absoluteRate; if (absoluteRate > maxBasal) { @@ -191,7 +191,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface { public Integer applyCarbsConstraints(Integer carbs) { SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); try { - Integer maxCarbs = Integer.parseInt(SP.getString("treatmentssafety_maxcarbs", "48")); + Integer maxCarbs = SafeParse.stringToInt(SP.getString("treatmentssafety_maxcarbs", "48")); if (carbs < 0) carbs = 0; if (carbs > maxCarbs) carbs = maxCarbs; 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 9a1d98d5f8..966a5e7578 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 @@ -29,6 +29,7 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.client.data.NSProfile; +import info.nightscout.utils.SafeParse; /** * Created by mike on 05.08.2016. @@ -142,7 +143,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { Iob tIOB = t.iobCalc(now, dia); total.iob += tIOB.iobContrib; total.activity += tIOB.activityContrib; - Iob bIOB = t.iobCalc(now, dia / Integer.parseInt(SP.getString("openapsama_bolussnooze_dia_divisor", "2"))); + Iob bIOB = t.iobCalc(now, dia / SafeParse.stringToInt(SP.getString("openapsama_bolussnooze_dia_divisor", "2"))); total.bolussnooze += bIOB.iobContrib; } return total; From 0838ede6a3857dc70ae0339fcdaa13eb5c6fef87 Mon Sep 17 00:00:00 2001 From: viktoria Date: Wed, 25 Jan 2017 20:19:53 +0100 Subject: [PATCH 04/36] Add prefernces.json change secondary text color to white --- app/src/main/res/values/styles.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4d2ddf901c..378f7c0f1e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -8,7 +8,9 @@ @color/colorAccent - +