diff --git a/.gitignore b/.gitignore index 692e056954..b80e6aff48 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ wear/wear.iml .DS_Store /build /captures +*.apk +build/ +**/*.iml diff --git a/app/build.gradle b/app/build.gradle index 997c5e1d87..b2f9660bd8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,12 +105,22 @@ android { } } +allprojects { + repositories { + jcenter() + flatDir { + dirs 'libs' + } + } +} + dependencies { wearWearApp project(path: ':wear', configuration: 'fullRelease') compile fileTree(include: ['*.jar'], dir: 'libs') compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') { transitive = true; } + compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:support-v4:23.4.0' compile 'com.android.support:cardview-v7:23.4.0' @@ -134,4 +144,6 @@ dependencies { androidTestCompile 'org.mockito:mockito-core:2.+' androidTestCompile "com.google.dexmaker:dexmaker:1.2" androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2" + compile(name:'android-edittext-validator-v1.3.4-mod', ext:'aar') + } diff --git a/app/libs/android-edittext-validator-v1.3.4-mod.aar b/app/libs/android-edittext-validator-v1.3.4-mod.aar new file mode 100644 index 0000000000..e08904b772 Binary files /dev/null and b/app/libs/android-edittext-validator-v1.3.4-mod.aar differ 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/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java index 67723e9a74..ccd6fc3857 100644 --- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java @@ -11,6 +11,7 @@ import android.preference.PreferenceFragment; import android.preference.PreferenceGroup; import android.preference.PreferenceManager; + import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.interfaces.PluginBase; @@ -53,10 +54,10 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre } if (pref instanceof EditTextPreference) { EditTextPreference editTextPref = (EditTextPreference) pref; - if (pref.getTitle().toString().toLowerCase().contains("password")) - { + if (pref.getKey().contains("danar_password")) { pref.setSummary("******"); - } else if (editTextPref.getText() != null && !editTextPref.getText().equals("")){ + } else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) { + ((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage()); pref.setSummary(editTextPref.getText()); } } 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 cf89f07fe1..eb449b96c8 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; @@ -14,13 +17,14 @@ 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 { 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 +132,7 @@ public class Autosens { if (mealTime != null && 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, 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,10 +180,10 @@ public class Autosens { log.debug(sensResult); ratio = 1 + (basalOff / profile.getMaxDailyBasal()); - // don't adjust more than 1.5x - double rawRatio = ratio; - ratio = Math.max(ratio, Constants.AUTOSENS_MIN); - ratio = Math.min(ratio, Constants.AUTOSENS_MAX); + // don't adjust more than 1.5x + double rawRatio = ratio; + 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"))); if (ratio != rawRatio) { ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio; 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 ed14acb591..d443113fc4 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 @@ -27,6 +27,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); @@ -209,7 +210,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); @@ -222,13 +222,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("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", true); 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", 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 e90a14ff96..49d5b760b9 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 @@ -235,7 +235,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 + 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 ceb0d96efa..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 = Constants.CURRENT_BASAL_SAFETY_MULTIPLIER; - Integer maxBasalFromDaily = Constants.MAX_DAILY_SAFETY_MULTIPLIER; + 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 = Constants.CURRENT_BASAL_SAFETY_MULTIPLIER; - Integer maxBasalFromDaily = Constants.MAX_DAILY_SAFETY_MULTIPLIER; + 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 eca00d6159..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 @@ -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; @@ -26,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. @@ -121,6 +125,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 +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 / Constants.BOLUSSNOOZE_DIA_ADVISOR); + Iob bIOB = t.iobCalc(now, dia / SafeParse.stringToInt(SP.getString("openapsama_bolussnooze_dia_divisor", "2"))); total.bolussnooze += bIOB.iobContrib; } return total; diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 6db2e7134f..c0f505f944 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -328,4 +328,8 @@ "CONF" "CPP" "CP" + Bitte verwenden Sie nur Ziffern. + Pflichtfeld + Telefonnummer ist nicht gültig. + Bitte verwenden Sie nur Ziffern von %1$s - %2$s diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 9dcc45a2a3..da573aa83c 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -402,5 +402,8 @@ Unidades: Reajuste objetivos por autosens - + Sólo se permiten caracteres numéricos + Sólo se permiten dígitos en el rango %1$s - %2$s + Este campo no puede estar vacío + Número de teléfono inválido diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b9a049a119..8769253001 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -211,8 +211,10 @@ Greek The minimum BG value to be in range. The maximum BG value to be in range. - Max U/hr a Temp Basal can be set to - Maximum basal IOB OpenAPS can deliver [U] + Max U/hr a Temp Basal can be set to + This value is called max basal in OpenAPS context + Maximum basal IOB OpenAPS can deliver [U] + This value is called Max IOB in OpenAPS context\nThis will default to zero. After several days or weeks, depending on your comfort level, you may choose to adjust this number. Bulgarian DISMISS Language @@ -264,7 +266,8 @@ Temporary Target Cancel DanaR profile settings DIA [h] - Failed to update basal profile + Duration of Insulin Activity + Failed to update basal profile History Reload Uploading @@ -426,7 +429,6 @@ Total Base Basal TBB * 2 Initializing ... - Allow autosens to adjust targets ACT CONF LOOP @@ -453,5 +455,25 @@ Firmware: Model: %02X Protocol: %02X Code: %02X Profile + max_daily_safety_multiplier + Default value: 3\nThis 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 + Default value: 4\nThis 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 + Default value: 1.2\nThis 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 + Default value: 0.7\nThe 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. + autosens_adjust_targets + Default value: true\nThis is used to allow autosens to adjust BG targets, in addition to ISF and basals. + bolussnooze_dia_divisor + Default value: 2\nBolus 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 + Default value: 3.0\nThis 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. + Attention!\nNormally you do not have to change these values below. Please CLICK HERE and READ the text and make sure you UNDERSTAND it before change any of these values. + http://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-3/beyond-low-glucose-suspend.html + Only numeric digits are allowed. + Only numeric digits within the range %1$s - %2$s are allowed. + The field must not be empty + Phone number not valid Invalid SMS phone number 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 - +