diff --git a/app/build.gradle b/app/build.gradle
index b0f2c864ec..d87426d444 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -57,19 +57,7 @@ android {
}
}
productFlavors {
- flavorDimensions "standard", "limits", "wear"
- adult {
- dimension "limits"
- buildConfigField "int", "MAXBOLUS", "17"
- }
- teenage {
- dimension "limits"
- buildConfigField "int", "MAXBOLUS", "10"
- }
- child {
- dimension "limits"
- buildConfigField "int", "MAXBOLUS", "5"
- }
+ flavorDimensions "standard", "wear"
full {
dimension "standard"
buildConfigField "boolean", "APS", "true"
diff --git a/app/src/main/java/info/nightscout/androidaps/AgreementActivity.java b/app/src/main/java/info/nightscout/androidaps/AgreementActivity.java
index a8486e1d78..3a30659884 100644
--- a/app/src/main/java/info/nightscout/androidaps/AgreementActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/AgreementActivity.java
@@ -9,18 +9,18 @@ import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
+import info.nightscout.utils.SP;
+
public class AgreementActivity extends Activity {
boolean IUnderstand;
CheckBox agreeCheckBox;
Button saveButton;
- SharedPreferences prefs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_agreement);
- prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
- IUnderstand = prefs.getBoolean("I_understand", false);
+ IUnderstand = SP.getBoolean(R.string.key_i_understand, false);
setContentView(R.layout.activity_agreement);
agreeCheckBox = (CheckBox)findViewById(R.id.agreementCheckBox);
agreeCheckBox.setChecked(IUnderstand);
@@ -32,7 +32,7 @@ public class AgreementActivity extends Activity {
saveButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
- prefs.edit().putBoolean("I_understand", agreeCheckBox.isChecked()).apply();
+ SP.putBoolean(R.string.key_i_understand, agreeCheckBox.isChecked());
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
index 0f676470c3..5fcaf2ee13 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
@@ -198,7 +198,8 @@ public class MainActivity extends AppCompatActivity {
}
private void checkEula() {
- boolean IUnderstand = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("I_understand", false);
+ //SP.removeBoolean(R.string.key_i_understand);
+ boolean IUnderstand = SP.getBoolean(R.string.key_i_understand, false);
if (!IUnderstand) {
Intent intent = new Intent(getApplicationContext(), AgreementActivity.class);
startActivity(intent);
diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
index 99b7ee76bc..21fd349822 100644
--- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
@@ -70,7 +70,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
}
}
- private static void initSummary(Preference p) {
+ public static void initSummary(Preference p) {
if (p instanceof PreferenceGroup) {
PreferenceGroup pGrp = (PreferenceGroup) p;
for (int i = 0; i < pGrp.getPreferenceCount(); i++) {
@@ -86,8 +86,9 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_password);
- addPreferencesFromResource(R.xml.pref_quickwizard);
+ addPreferencesFromResource(R.xml.pref_age);
addPreferencesFromResource(R.xml.pref_language);
+ addPreferencesFromResource(R.xml.pref_quickwizard);
if (Config.CAREPORTALENABLED)
addPreferencesFromResource(R.xml.pref_careportal);
addPreferencesFromResource(R.xml.pref_treatments);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgBolusStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgBolusStart.java
index bf6af2841b..3ae5b97b69 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgBolusStart.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgBolusStart.java
@@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
+import info.nightscout.utils.HardLimits;
public class MsgBolusStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgBolusStart.class);
@@ -20,7 +21,7 @@ public class MsgBolusStart extends MessageBase {
// HARDCODED LIMIT
amount = MainApp.getConfigBuilder().applyBolusConstraints(amount);
if (amount < 0) amount = 0d;
- if (amount > BuildConfig.MAXBOLUS) amount = BuildConfig.MAXBOLUS;
+ if (amount > HardLimits.maxBolus()) amount = HardLimits.maxBolus();
AddParamInt((int) (amount * 100));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetExtendedBolusStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetExtendedBolusStart.java
index 894227e07d..9c37fda333 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetExtendedBolusStart.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetExtendedBolusStart.java
@@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
+import info.nightscout.utils.HardLimits;
public class MsgSetExtendedBolusStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetExtendedBolusStart.class);
@@ -22,7 +23,7 @@ public class MsgSetExtendedBolusStart extends MessageBase {
if (halfhours > 16) halfhours = 16;
amount = MainApp.getConfigBuilder().applyBolusConstraints(amount);
if (amount < 0d) amount = 0d;
- if (amount > BuildConfig.MAXBOLUS) amount = BuildConfig.MAXBOLUS;
+ if (amount > HardLimits.maxBolus()) amount = HardLimits.maxBolus();
AddParamInt((int) (amount * 100));
AddParamByte(halfhours);
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 9cbda6bf06..83ace20c71 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
@@ -11,6 +11,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
+import info.nightscout.utils.HardLimits;
import info.nightscout.utils.Round;
import info.nightscout.utils.SP;
@@ -176,7 +177,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
} catch (Exception e) {
insulin = 0d;
}
- if (insulin > BuildConfig.MAXBOLUS) insulin = Double.valueOf(BuildConfig.MAXBOLUS);
+ if (insulin > HardLimits.maxBolus()) insulin = HardLimits.maxBolus();
return insulin;
}
diff --git a/app/src/main/java/info/nightscout/utils/HardLimits.java b/app/src/main/java/info/nightscout/utils/HardLimits.java
new file mode 100644
index 0000000000..ff92cf2e87
--- /dev/null
+++ b/app/src/main/java/info/nightscout/utils/HardLimits.java
@@ -0,0 +1,24 @@
+package info.nightscout.utils;
+
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+
+/**
+ * Created by mike on 22.02.2017.
+ */
+
+public class HardLimits {
+ final static double MAXBOLUS_ADULT = 17d;
+ final static double MAXBOLUS_TEENAGE = 10d;
+ final static double MAXBOLUS_CHILD = 5d;
+
+ public static double maxBolus() {
+ String age = SP.getString(R.string.key_age, "");
+
+ if (age.equals(MainApp.sResources.getString(R.string.key_adult))) return MAXBOLUS_ADULT;
+ if (age.equals(MainApp.sResources.getString(R.string.key_teenage))) return MAXBOLUS_TEENAGE;
+ if (age.equals(MainApp.sResources.getString(R.string.key_child))) return MAXBOLUS_CHILD;
+ return MAXBOLUS_ADULT;
+ }
+
+}
diff --git a/app/src/main/java/info/nightscout/utils/SP.java b/app/src/main/java/info/nightscout/utils/SP.java
index 3626d7c69e..cce1df9474 100644
--- a/app/src/main/java/info/nightscout/utils/SP.java
+++ b/app/src/main/java/info/nightscout/utils/SP.java
@@ -76,6 +76,12 @@ public class SP {
editor.apply();
}
+ static public void removeBoolean(int resourceID) {
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+ editor.remove(MainApp.sResources.getString(resourceID));
+ editor.apply();
+ }
+
static public void putString(String key, String value) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(key, value);
@@ -87,4 +93,10 @@ public class SP {
editor.putString(MainApp.sResources.getString(resourceID), value);
editor.apply();
}
+
+ static public void removeString(int resourceID) {
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+ editor.remove(MainApp.sResources.getString(resourceID));
+ editor.apply();
+ }
}
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index fe14a6a11b..bd89f7efc2 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -28,4 +28,16 @@
- ko
- el
+
+
+ - @string/child
+ - @string/teenage
+ - @string/adult
+
+
+ - @string/key_child
+ - @string/key_teenage
+ - @string/key_adult
+
+
\ 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 5c717d3061..e1cfe1a3d4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -544,4 +544,14 @@
Not available
smscommunicator_allowednumbers
smscommunicator_remotecommandsallowed
+ Patient age
+ Child
+ Teenage
+ Adult
+ age
+ child
+ teenage
+ adult
+ Please select patient age to setup safety limits
+ I_understand
diff --git a/app/src/main/res/xml/pref_age.xml b/app/src/main/res/xml/pref_age.xml
new file mode 100644
index 0000000000..75496fcb41
--- /dev/null
+++ b/app/src/main/res/xml/pref_age.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
\ No newline at end of file