Shared preferences cleanup
This commit is contained in:
parent
3216ff636a
commit
8a374f1b35
|
@ -32,12 +32,12 @@ public class Constants {
|
||||||
public static final int CPP_MAX_PERCENTAGE = 200;
|
public static final int CPP_MAX_PERCENTAGE = 200;
|
||||||
|
|
||||||
// Defaults for settings
|
// Defaults for settings
|
||||||
public static final String MAX_BG_DEFAULT_MGDL = "180";
|
public static final Double MAX_BG_DEFAULT_MGDL = 180d;
|
||||||
public static final String MAX_BG_DEFAULT_MMOL = "10";
|
public static final Double MAX_BG_DEFAULT_MMOL = 10d;
|
||||||
public static final String MIN_BG_DEFAULT_MGDL = "100";
|
public static final Double MIN_BG_DEFAULT_MGDL = 100d;
|
||||||
public static final String MIN_BG_DEFAULT_MMOL = "5";
|
public static final Double MIN_BG_DEFAULT_MMOL = 5d;
|
||||||
public static final String TARGET_BG_DEFAULT_MGDL = "150";
|
public static final Double TARGET_BG_DEFAULT_MGDL = 150d;
|
||||||
public static final String TARGET_BG_DEFAULT_MMOL = "7";
|
public static final Double TARGET_BG_DEFAULT_MMOL = 7d;
|
||||||
|
|
||||||
// Very Hard Limits Ranges
|
// Very Hard Limits Ranges
|
||||||
// First value is the Lowest and second value is the Highest a Limit can define
|
// First value is the Lowest and second value is the Highest a Limit can define
|
||||||
|
|
|
@ -36,10 +36,11 @@ import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.tabs.SlidingTabLayout;
|
import info.nightscout.androidaps.tabs.SlidingTabLayout;
|
||||||
import info.nightscout.androidaps.tabs.TabPageAdapter;
|
import info.nightscout.androidaps.tabs.TabPageAdapter;
|
||||||
import info.nightscout.utils.LogDialog;
|
|
||||||
import info.nightscout.utils.ImportExportPrefs;
|
import info.nightscout.utils.ImportExportPrefs;
|
||||||
import info.nightscout.utils.LocaleHelper;
|
import info.nightscout.utils.LocaleHelper;
|
||||||
|
import info.nightscout.utils.LogDialog;
|
||||||
import info.nightscout.utils.PasswordProtection;
|
import info.nightscout.utils.PasswordProtection;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
private static Logger log = LoggerFactory.getLogger(MainActivity.class);
|
private static Logger log = LoggerFactory.getLogger(MainActivity.class);
|
||||||
|
@ -86,7 +87,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventRefreshGui ev) {
|
public void onStatusEvent(final EventRefreshGui ev) {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
|
||||||
String lang = SP.getString("language", "en");
|
String lang = SP.getString("language", "en");
|
||||||
LocaleHelper.setLocale(getApplicationContext(), lang);
|
LocaleHelper.setLocale(getApplicationContext(), lang);
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
MainApp.bus().post(new EventPreferenceChange());
|
MainApp.bus().post(new EventPreferenceChange(key));
|
||||||
if (key.equals("language")) {
|
if (key.equals("language")) {
|
||||||
String lang = sharedPreferences.getString("language", "en");
|
String lang = sharedPreferences.getString("language", "en");
|
||||||
LocaleHelper.setLocale(getApplicationContext(), lang);
|
LocaleHelper.setLocale(getApplicationContext(), lang);
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package info.nightscout.androidaps.events;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 17.02.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class EventConfigBuilderChange {
|
||||||
|
}
|
|
@ -1,7 +1,21 @@
|
||||||
package info.nightscout.androidaps.events;
|
package info.nightscout.androidaps.events;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 19.06.2016.
|
* Created by mike on 19.06.2016.
|
||||||
*/
|
*/
|
||||||
public class EventPreferenceChange {
|
public class EventPreferenceChange {
|
||||||
|
public String changedKey;
|
||||||
|
public EventPreferenceChange(String key) {
|
||||||
|
changedKey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isChanged(int id) {
|
||||||
|
return changedKey.equals(MainApp.sResources.getString(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isChanged(String id) {
|
||||||
|
return changedKey.equals(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.PlusMinusEditText;
|
import info.nightscout.utils.PlusMinusEditText;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
public class FillDialog extends DialogFragment implements OnClickListener {
|
public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
|
@ -72,10 +73,9 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
Button button3 = (Button) view.findViewById(R.id.fill_preset_button3);
|
Button button3 = (Button) view.findViewById(R.id.fill_preset_button3);
|
||||||
View divider = view.findViewById(R.id.fill_preset_divider);
|
View divider = view.findViewById(R.id.fill_preset_divider);
|
||||||
|
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
amount1 = SP.getDouble("fill_button1", 0.3);
|
||||||
amount1 = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button1", "0.3"))));
|
amount2 = SP.getDouble("fill_button2", 0d);
|
||||||
amount2 = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button2", "0"))));
|
amount3 = SP.getDouble("fill_button3", 0d);
|
||||||
amount3 = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button3", "0"))));
|
|
||||||
|
|
||||||
if(amount1 >0) {
|
if(amount1 >0) {
|
||||||
button1.setVisibility(View.VISIBLE);
|
button1.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -3,11 +3,9 @@ package info.nightscout.androidaps.plugins.Careportal.Dialogs;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -42,7 +40,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
@ -53,10 +50,11 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;
|
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.PlusMinusEditText;
|
import info.nightscout.utils.PlusMinusEditText;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
import info.nightscout.utils.Translator;
|
import info.nightscout.utils.Translator;
|
||||||
|
@ -391,7 +389,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
|
|
||||||
|
|
||||||
JSONObject gatherData() {
|
JSONObject gatherData() {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
String enteredBy = SP.getString("careportal_enteredby", "");
|
String enteredBy = SP.getString("careportal_enteredby", "");
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
@Override
|
@Override
|
||||||
public String getNameShort() {
|
public String getNameShort() {
|
||||||
String name = MainApp.sResources.getString(R.string.circadian_percentage_profile_shortname);
|
String name = MainApp.sResources.getString(R.string.circadian_percentage_profile_shortname);
|
||||||
if (!name.trim().isEmpty()){
|
if (!name.trim().isEmpty()) {
|
||||||
//only if translation exists
|
//only if translation exists
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -125,75 +126,19 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
void loadSettings() {
|
void loadSettings() {
|
||||||
if (Config.logPrefsChange)
|
if (Config.logPrefsChange)
|
||||||
log.debug("Loading stored settings");
|
log.debug("Loading stored settings");
|
||||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
|
|
||||||
if (settings.contains(SETTINGS_PREFIX + "mgdl"))
|
mgdl = SP.getBoolean(SETTINGS_PREFIX + "mgdl", true);
|
||||||
try {
|
mmol = SP.getBoolean(SETTINGS_PREFIX + "mmol", false);
|
||||||
mgdl = settings.getBoolean(SETTINGS_PREFIX + "mgdl", true);
|
dia = SP.getDouble(SETTINGS_PREFIX + "dia", 3d);
|
||||||
} catch (Exception e) {
|
targetLow = SP.getDouble(SETTINGS_PREFIX + "targetlow", 80d);
|
||||||
log.debug(e.getMessage());
|
targetHigh = SP.getDouble(SETTINGS_PREFIX + "targethigh", 120d);
|
||||||
}
|
percentage = SP.getInt(SETTINGS_PREFIX + "percentage", 100);
|
||||||
else mgdl = true;
|
timeshift = SP.getInt(SETTINGS_PREFIX + "timeshift", 0);
|
||||||
if (settings.contains(SETTINGS_PREFIX + "mmol"))
|
|
||||||
try {
|
|
||||||
mmol = settings.getBoolean(SETTINGS_PREFIX + "mmol", false);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else mmol = false;
|
|
||||||
if (settings.contains(SETTINGS_PREFIX + "dia"))
|
|
||||||
try {
|
|
||||||
dia = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "dia", "3"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else dia = 3d;
|
|
||||||
if (settings.contains(SETTINGS_PREFIX + "targetlow"))
|
|
||||||
try {
|
|
||||||
targetLow = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "targetlow", "80"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else targetLow = 80d;
|
|
||||||
if (settings.contains(SETTINGS_PREFIX + "targethigh"))
|
|
||||||
try {
|
|
||||||
targetHigh = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "targethigh", "120"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else targetHigh = 120d;
|
|
||||||
if (settings.contains(SETTINGS_PREFIX + "percentage"))
|
|
||||||
try {
|
|
||||||
percentage = SafeParse.stringToInt(settings.getString(SETTINGS_PREFIX + "percentage", "100"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else percentage = 100;
|
|
||||||
|
|
||||||
if (settings.contains(SETTINGS_PREFIX + "timeshift"))
|
|
||||||
try {
|
|
||||||
timeshift = SafeParse.stringToInt(settings.getString(SETTINGS_PREFIX + "timeshift", "0"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else timeshift = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < 24; i++) {
|
for (int i = 0; i < 24; i++) {
|
||||||
try {
|
basebasal[i] = SP.getDouble(SETTINGS_PREFIX + "basebasal" + i, basebasal[i]);
|
||||||
basebasal[i] = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "basebasal" + i, DecimalFormatter.to2Decimal(basebasal[i])));
|
baseic[i] = SP.getDouble(SETTINGS_PREFIX + "baseic" + i, baseic[i]);
|
||||||
} catch (Exception e) {
|
baseisf[i] = SP.getDouble(SETTINGS_PREFIX + "baseisf" + i, baseisf[i]);
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
baseic[i] = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "baseic" + i, DecimalFormatter.to2Decimal(baseic[i])));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
baseisf[i] = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "baseisf" + i, DecimalFormatter.to2Decimal(baseisf[i])));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -259,7 +204,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performLimitCheck() {
|
private void performLimitCheck() {
|
||||||
if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE){
|
if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) {
|
||||||
String msg = String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Percentage");
|
String msg = String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Percentage");
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
MainApp.getConfigBuilder().uploadError(msg);
|
MainApp.getConfigBuilder().uploadError(msg);
|
||||||
|
@ -289,13 +234,15 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
return profileString(baseisf, 0, 100, false);
|
return profileString(baseisf, 0, 100, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
String baseBasalString() {return profileString(basebasal, 0, 100, true);}
|
String baseBasalString() {
|
||||||
|
return profileString(basebasal, 0, 100, true);
|
||||||
|
}
|
||||||
|
|
||||||
public double baseBasalSum(){
|
public double baseBasalSum() {
|
||||||
return sum(basebasal);
|
return sum(basebasal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double percentageBasalSum(){
|
public double percentageBasalSum() {
|
||||||
double result = 0;
|
double result = 0;
|
||||||
for (int i = 0; i < basebasal.length; i++) {
|
for (int i = 0; i < basebasal.length; i++) {
|
||||||
result += SafeParse.stringToDouble(DecimalFormatter.to2Decimal(basebasal[i] * percentage / 100d));
|
result += SafeParse.stringToDouble(DecimalFormatter.to2Decimal(basebasal[i] * percentage / 100d));
|
||||||
|
@ -304,7 +251,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static double sum(double values[]){
|
public static double sum(double values[]) {
|
||||||
double result = 0;
|
double result = 0;
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
result += values[i];
|
result += values[i];
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||||
|
@ -197,6 +198,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
|
||||||
onEnabledCategoryChanged(plugin, type);
|
onEnabledCategoryChanged(plugin, type);
|
||||||
configBuilderPlugin.storeSettings();
|
configBuilderPlugin.storeSettings();
|
||||||
MainApp.bus().post(new EventRefreshGui(true));
|
MainApp.bus().post(new EventRefreshGui(true));
|
||||||
|
MainApp.bus().post(new EventConfigBuilderChange());
|
||||||
getPlugin().logPluginStatus();
|
getPlugin().logPluginStatus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
||||||
|
@ -195,11 +194,6 @@ public class DanaRFragment extends Fragment implements FragmentBase {
|
||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventPreferenceChange s) {
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
// GUI functions
|
// GUI functions
|
||||||
private void updateGUI() {
|
private void updateGUI() {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.DanaR;
|
package info.nightscout.androidaps.plugins.DanaR;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -11,9 +8,9 @@ import java.text.DecimalFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 04.07.2016.
|
* Created by mike on 04.07.2016.
|
||||||
|
@ -122,8 +119,7 @@ public class DanaRPump {
|
||||||
// Evening / 17:00–21:59
|
// Evening / 17:00–21:59
|
||||||
// Night / 22:00–5:59
|
// Night / 22:00–5:59
|
||||||
|
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
double dia = SP.getDouble(R.string.key_danarprofile_dia, 3d);
|
||||||
double dia = SafeParse.stringToDouble(SP.getString("danarprofile_dia", "3"));
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json.put("defaultProfile", PROFILE_PREFIX + (activeProfile + 1));
|
json.put("defaultProfile", PROFILE_PREFIX + (activeProfile + 1));
|
||||||
|
|
|
@ -82,13 +82,13 @@ import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
public class ExecutionService extends Service {
|
public class ExecutionService extends Service {
|
||||||
private static Logger log = LoggerFactory.getLogger(ExecutionService.class);
|
private static Logger log = LoggerFactory.getLogger(ExecutionService.class);
|
||||||
|
|
||||||
private SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
private String devName;
|
private String devName;
|
||||||
|
|
||||||
private SerialIOThread mSerialIOThread;
|
private SerialIOThread mSerialIOThread;
|
||||||
|
@ -187,7 +187,7 @@ public class ExecutionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(String from) {
|
public void connect(String from) {
|
||||||
if (danaRPump.password != -1 && danaRPump.password != SafeParse.stringToInt(SP.getString("danar_password", "-1"))) {
|
if (danaRPump.password != -1 && danaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.wrongpumppassword), R.raw.error);
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.wrongpumppassword), R.raw.error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ public class ExecutionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getBTSocketForSelectedPump() {
|
private void getBTSocketForSelectedPump() {
|
||||||
devName = SP.getString("danar_bt_name", "");
|
devName = SP.getString(MainApp.sResources.getString(R.string.key_danar_bt_name), "");
|
||||||
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
|
||||||
if (bluetoothAdapter != null) {
|
if (bluetoothAdapter != null) {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
||||||
|
@ -192,11 +191,6 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
|
||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventPreferenceChange s) {
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
// GUI functions
|
// GUI functions
|
||||||
private void updateGUI() {
|
private void updateGUI() {
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.DanaRKorean;
|
package info.nightscout.androidaps.plugins.DanaRKorean;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -11,9 +8,9 @@ import java.text.DecimalFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 04.07.2016.
|
* Created by mike on 04.07.2016.
|
||||||
|
@ -115,8 +112,7 @@ public class DanaRKoreanPump {
|
||||||
// Evening / 17:00–21:59
|
// Evening / 17:00–21:59
|
||||||
// Night / 22:00–5:59
|
// Night / 22:00–5:59
|
||||||
|
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
double dia = SP.getDouble(R.string.key_danarprofile_dia, 3d);
|
||||||
double dia = SafeParse.stringToDouble(SP.getString("danarprofile_dia", "3"));
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json.put("defaultProfile", PROFILE_PREFIX + (activeProfile + 1));
|
json.put("defaultProfile", PROFILE_PREFIX + (activeProfile + 1));
|
||||||
|
|
|
@ -8,11 +8,9 @@ import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
@ -75,16 +73,15 @@ import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSettingShippingInf
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgStatusBasic;
|
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgStatusBasic;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgStatusBolusExtended;
|
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgStatusBolusExtended;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgStatusTempBasal;
|
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgStatusTempBasal;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
public class ExecutionService extends Service {
|
public class ExecutionService extends Service {
|
||||||
private static Logger log = LoggerFactory.getLogger(ExecutionService.class);
|
private static Logger log = LoggerFactory.getLogger(ExecutionService.class);
|
||||||
|
|
||||||
private SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
private String devName;
|
private String devName;
|
||||||
|
|
||||||
private SerialIOThread mSerialIOThread;
|
private SerialIOThread mSerialIOThread;
|
||||||
|
@ -183,7 +180,7 @@ public class ExecutionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(String from) {
|
public void connect(String from) {
|
||||||
if (danaRKoreanPump.password != -1 && danaRKoreanPump.password != SafeParse.stringToInt(SP.getString("danar_password", "-1"))) {
|
if (danaRKoreanPump.password != -1 && danaRKoreanPump.password != SP.getInt(R.string.key_danar_password, -1)) {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.wrongpumppassword), R.raw.error);
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.wrongpumppassword), R.raw.error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +239,7 @@ public class ExecutionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getBTSocketForSelectedPump() {
|
private void getBTSocketForSelectedPump() {
|
||||||
devName = SP.getString("danar_bt_name", "");
|
devName = SP.getString(MainApp.sResources.getString(R.string.key_danar_bt_name), "");
|
||||||
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
|
||||||
if (bluetoothAdapter != null) {
|
if (bluetoothAdapter != null) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +63,7 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
@Override
|
@Override
|
||||||
public String getNameShort() {
|
public String getNameShort() {
|
||||||
String name = MainApp.sResources.getString(R.string.localprofile_shortname);
|
String name = MainApp.sResources.getString(R.string.localprofile_shortname);
|
||||||
if (!name.trim().isEmpty()){
|
if (!name.trim().isEmpty()) {
|
||||||
//only if translation exists
|
//only if translation exists
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -116,117 +117,48 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
private void loadSettings() {
|
private void loadSettings() {
|
||||||
if (Config.logPrefsChange)
|
if (Config.logPrefsChange)
|
||||||
log.debug("Loading stored settings");
|
log.debug("Loading stored settings");
|
||||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
|
|
||||||
if (settings.contains("LocalProfile" + "mgdl"))
|
mgdl = SP.getBoolean("LocalProfile" + "mgdl", false);
|
||||||
|
mmol = SP.getBoolean("LocalProfile" + "mmol", true);
|
||||||
|
dia = SP.getDouble("LocalProfile" + "dia", 3d);
|
||||||
try {
|
try {
|
||||||
mgdl = settings.getBoolean("LocalProfile" + "mgdl", false);
|
ic = new JSONArray(SP.getString("LocalProfile" + "ic", DEFAULTARRAY));
|
||||||
} catch (Exception e) {
|
} catch (JSONException e1) {
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else mgdl = false;
|
|
||||||
if (settings.contains("LocalProfile" + "mmol"))
|
|
||||||
try {
|
|
||||||
mmol = settings.getBoolean("LocalProfile" + "mmol", true);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else mmol = true;
|
|
||||||
if (settings.contains("LocalProfile" + "dia"))
|
|
||||||
try {
|
|
||||||
dia = SafeParse.stringToDouble(settings.getString("LocalProfile" + "dia", "3"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else dia = 3d;
|
|
||||||
if (settings.contains("LocalProfile" + "ic"))
|
|
||||||
try {
|
|
||||||
ic = new JSONArray(settings.getString("LocalProfile" + "ic", DEFAULTARRAY));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
try {
|
try {
|
||||||
ic = new JSONArray(DEFAULTARRAY);
|
ic = new JSONArray(DEFAULTARRAY);
|
||||||
|
} catch (JSONException e2) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
isf = new JSONArray(SP.getString("LocalProfile" + "isf", DEFAULTARRAY));
|
||||||
} catch (JSONException e1) {
|
} catch (JSONException e1) {
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
ic = new JSONArray(DEFAULTARRAY);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (settings.contains("LocalProfile" + "isf"))
|
|
||||||
try {
|
|
||||||
isf = new JSONArray(settings.getString("LocalProfile" + "isf", DEFAULTARRAY));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
try {
|
try {
|
||||||
isf = new JSONArray(DEFAULTARRAY);
|
isf = new JSONArray(DEFAULTARRAY);
|
||||||
|
} catch (JSONException e2) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
basal = new JSONArray(SP.getString("LocalProfile" + "basal", DEFAULTARRAY));
|
||||||
} catch (JSONException e1) {
|
} catch (JSONException e1) {
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
isf = new JSONArray(DEFAULTARRAY);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (settings.contains("LocalProfile" + "basal"))
|
|
||||||
try {
|
|
||||||
basal = new JSONArray(settings.getString("LocalProfile" + "basal", DEFAULTARRAY));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
try {
|
try {
|
||||||
basal = new JSONArray(DEFAULTARRAY);
|
basal = new JSONArray(DEFAULTARRAY);
|
||||||
|
} catch (JSONException e2) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
targetLow = new JSONArray(SP.getString("LocalProfile" + "targetlow", DEFAULTARRAY));
|
||||||
} catch (JSONException e1) {
|
} catch (JSONException e1) {
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
basal = new JSONArray(DEFAULTARRAY);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (settings.contains("LocalProfile" + "targetlow"))
|
|
||||||
try {
|
|
||||||
targetLow = new JSONArray(settings.getString("LocalProfile" + "targetlow", DEFAULTARRAY));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
try {
|
try {
|
||||||
targetLow = new JSONArray(DEFAULTARRAY);
|
targetLow = new JSONArray(DEFAULTARRAY);
|
||||||
|
} catch (JSONException e2) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
targetHigh = new JSONArray(SP.getString("LocalProfile" + "targethigh", DEFAULTARRAY));
|
||||||
} catch (JSONException e1) {
|
} catch (JSONException e1) {
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
targetLow = new JSONArray(DEFAULTARRAY);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (settings.contains("LocalProfile" + "targethigh"))
|
|
||||||
try {
|
|
||||||
targetHigh = new JSONArray(settings.getString("LocalProfile" + "targethigh", DEFAULTARRAY));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
try {
|
try {
|
||||||
targetHigh = new JSONArray(DEFAULTARRAY);
|
targetHigh = new JSONArray(DEFAULTARRAY);
|
||||||
} catch (JSONException e1) {
|
} catch (JSONException e2) {
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
targetHigh = new JSONArray(DEFAULTARRAY);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createConvertedProfile();
|
createConvertedProfile();
|
||||||
|
|
|
@ -2,10 +2,8 @@ package info.nightscout.androidaps.plugins.NSClientInternal;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -25,8 +23,8 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
|
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart;
|
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
|
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class NSClientInternalFragment extends Fragment implements FragmentBase, View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
public class NSClientInternalFragment extends Fragment implements FragmentBase, View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(NSClientInternalFragment.class);
|
private static Logger log = LoggerFactory.getLogger(NSClientInternalFragment.class);
|
||||||
|
@ -106,19 +104,15 @@ public class NSClientInternalFragment extends Fragment implements FragmentBase,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
SharedPreferences.Editor editor = SP.edit();
|
|
||||||
switch (buttonView.getId()) {
|
switch (buttonView.getId()) {
|
||||||
case R.id.nsclientinternal_paused:
|
case R.id.nsclientinternal_paused:
|
||||||
editor.putBoolean("nsclientinternal_paused", isChecked);
|
SP.putBoolean("nsclientinternal_paused", isChecked);
|
||||||
editor.apply();
|
|
||||||
getPlugin().paused = isChecked;
|
getPlugin().paused = isChecked;
|
||||||
// TODO
|
// TODO
|
||||||
updateGUI();
|
updateGUI();
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_autoscroll:
|
case R.id.nsclientinternal_autoscroll:
|
||||||
editor.putBoolean("nsclientinternal_autoscroll", isChecked);
|
SP.putBoolean("nsclientinternal_autoscroll", isChecked);
|
||||||
editor.apply();
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientR
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
|
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
|
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
|
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class NSClientInternalPlugin implements PluginBase {
|
public class NSClientInternalPlugin implements PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(NSClientInternalPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(NSClientInternalPlugin.class);
|
||||||
|
@ -59,7 +60,6 @@ public class NSClientInternalPlugin implements PluginBase {
|
||||||
|
|
||||||
public NSClientInternalPlugin() {
|
public NSClientInternalPlugin() {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
paused = SP.getBoolean("nsclientinternal_paused", false);
|
paused = SP.getBoolean("nsclientinternal_paused", false);
|
||||||
autoscroll = SP.getBoolean("nsclientinternal_autoscroll", true);
|
autoscroll = SP.getBoolean("nsclientinternal_autoscroll", true);
|
||||||
url = SP.getString("nsclientinternal_url", "");
|
url = SP.getString("nsclientinternal_url", "");
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.NSClientInternal;
|
package info.nightscout.androidaps.plugins.NSClientInternal;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
@ -13,13 +12,11 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.acks.NSAddAck;
|
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.acks.NSUpdateAck;
|
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastQueueStatus;
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastQueueStatus;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.DbRequest;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.DbRequest;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
|
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 21.02.2016.
|
* Created by mike on 21.02.2016.
|
||||||
|
@ -120,9 +117,8 @@ public class UploadQueue {
|
||||||
|
|
||||||
private void loadMap() {
|
private void loadMap() {
|
||||||
queue = new HashMap<String, DbRequest>();
|
queue = new HashMap<String, DbRequest>();
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
try {
|
try {
|
||||||
String jsonString = sp.getString(KEY, (new JSONObject()).toString());
|
String jsonString = SP.getString(KEY, (new JSONObject()).toString());
|
||||||
JSONObject jsonObject = new JSONObject(jsonString);
|
JSONObject jsonObject = new JSONObject(jsonString);
|
||||||
Iterator<String> keysItr = jsonObject.keys();
|
Iterator<String> keysItr = jsonObject.keys();
|
||||||
while (keysItr.hasNext()) {
|
while (keysItr.hasNext()) {
|
||||||
|
|
|
@ -31,6 +31,8 @@ import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
|
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||||
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
||||||
|
@ -54,6 +56,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.data.NSStatus;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
|
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
|
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
import io.socket.client.IO;
|
import io.socket.client.IO;
|
||||||
import io.socket.client.Socket;
|
import io.socket.client.Socket;
|
||||||
|
@ -144,6 +147,25 @@ public class NSClientService extends Service {
|
||||||
log.debug("EventAppExit finished");
|
log.debug("EventAppExit finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(EventPreferenceChange ev) {
|
||||||
|
if (ev.isChanged(R.string.key_nsclientinternal_url) ||
|
||||||
|
ev.isChanged(R.string.key_nsclientinternal_api_secret) ||
|
||||||
|
ev.isChanged(R.string.key_nsclientinternal_hours)
|
||||||
|
) {
|
||||||
|
destroy();
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(EventConfigBuilderChange ev) {
|
||||||
|
if (nsEnabled != MainApp.getSpecificPlugin(NSClientInternalPlugin.class).isEnabled(PluginBase.GENERAL)) {
|
||||||
|
destroy();
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setNsProfile(NSProfile profile) {
|
public static void setNsProfile(NSProfile profile) {
|
||||||
nsProfile = profile;
|
nsProfile = profile;
|
||||||
}
|
}
|
||||||
|
@ -251,11 +273,10 @@ public class NSClientService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readPreferences() {
|
public void readPreferences() {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
nsEnabled = MainApp.getSpecificPlugin(NSClientInternalPlugin.class).isEnabled(PluginBase.GENERAL);
|
nsEnabled = MainApp.getSpecificPlugin(NSClientInternalPlugin.class).isEnabled(PluginBase.GENERAL);
|
||||||
nsURL = SP.getString(MainApp.sResources.getString(R.string.key_nsclientinternal_url), "");
|
nsURL = SP.getString(R.string.key_nsclientinternal_url, "");
|
||||||
nsAPISecret = SP.getString(MainApp.sResources.getString(R.string.key_nsclientinternal_api_secret), "");
|
nsAPISecret = SP.getString(R.string.key_nsclientinternal_api_secret, "");
|
||||||
nsHours = SafeParse.stringToInt(SP.getString(MainApp.sResources.getString(R.string.key_nsclientinternal_hours), "3"));
|
nsHours = SP.getInt(R.string.key_nsclientinternal_hours, 3);
|
||||||
nsDevice = SP.getString("careportal_enteredby", "");
|
nsDevice = SP.getString("careportal_enteredby", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,9 @@ import info.nightscout.androidaps.Services.Intents;
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.plugins.NSProfile.events.EventNSProfileUpdateGUI;
|
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
import info.nightscout.androidaps.plugins.NSProfile.events.EventNSProfileUpdateGUI;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
|
@ -110,9 +111,8 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
private void loadNSProfile() {
|
private void loadNSProfile() {
|
||||||
if (Config.logPrefsChange)
|
if (Config.logPrefsChange)
|
||||||
log.debug("Loading stored profile");
|
log.debug("Loading stored profile");
|
||||||
SharedPreferences store = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
String activeProfile = SP.getString("activeProfile", null);
|
||||||
String activeProfile = store.getString("activeProfile", null);
|
String profileString = SP.getString("profile", null);
|
||||||
String profileString = store.getString("profile", null);
|
|
||||||
if (profileString != null) {
|
if (profileString != null) {
|
||||||
if (Config.logPrefsChange) {
|
if (Config.logPrefsChange) {
|
||||||
log.debug("Loaded profile: " + profileString);
|
log.debug("Loaded profile: " + profileString);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,20 +212,19 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadProgress() {
|
void loadProgress() {
|
||||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
for (int num = 0; num < objectives.size(); num++) {
|
for (int num = 0; num < objectives.size(); num++) {
|
||||||
Objective o = objectives.get(num);
|
Objective o = objectives.get(num);
|
||||||
try {
|
try {
|
||||||
o.started = new Date(SafeParse.stringToLong(settings.getString("Objectives" + num + "started", "0")));
|
o.started = new Date(SP.getLong("Objectives" + num + "started", 0L));
|
||||||
o.accomplished = new Date(SafeParse.stringToLong(settings.getString("Objectives" + num + "accomplished", "0")));
|
o.accomplished = new Date(SP.getLong("Objectives" + num + "accomplished", 0L));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bgIsAvailableInNS = settings.getBoolean("Objectives" + "bgIsAvailableInNS", false);
|
bgIsAvailableInNS = SP.getBoolean("Objectives" + "bgIsAvailableInNS", false);
|
||||||
pumpStatusIsAvailableInNS = settings.getBoolean("Objectives" + "pumpStatusIsAvailableInNS", false);
|
pumpStatusIsAvailableInNS = SP.getBoolean("Objectives" + "pumpStatusIsAvailableInNS", false);
|
||||||
try {
|
try {
|
||||||
manualEnacts = SafeParse.stringToInt(settings.getString("Objectives" + "manualEnacts", "0"));
|
manualEnacts = SP.getInt("Objectives" + "manualEnacts", 0);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.OpenAPSAMA;
|
package info.nightscout.androidaps.plugins.OpenAPSAMA;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -16,6 +13,7 @@ import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +21,6 @@ public class Autosens {
|
||||||
private static Logger log = LoggerFactory.getLogger(Autosens.class);
|
private static Logger log = LoggerFactory.getLogger(Autosens.class);
|
||||||
|
|
||||||
public static AutosensResult detectSensitivityandCarbAbsorption(List<BgReading> glucose_data, Long mealTime) {
|
public static AutosensResult detectSensitivityandCarbAbsorption(List<BgReading> glucose_data, Long mealTime) {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
|
|
||||||
//console.error(mealTime);
|
//console.error(mealTime);
|
||||||
|
@ -131,7 +128,7 @@ public class Autosens {
|
||||||
if (mealTime != null && bgTime > mealTime) {
|
if (mealTime != null && bgTime > mealTime) {
|
||||||
// figure out how many carbs that represents
|
// figure out how many carbs that represents
|
||||||
// but always assume at least 3mg/dL/5m (default) absorption
|
// but always assume at least 3mg/dL/5m (default) absorption
|
||||||
double ci = Math.max(deviation, SafeParse.stringToDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0")));
|
double ci = Math.max(deviation, SP.getDouble("openapsama_min_5m_carbimpact", 3.0));
|
||||||
double absorbed = ci * profile.getIc(secondsFromMidnight) / sens;
|
double absorbed = ci * profile.getIc(secondsFromMidnight) / sens;
|
||||||
// and add that to the running total carbsAbsorbed
|
// and add that to the running total carbsAbsorbed
|
||||||
carbsAbsorbed += absorbed;
|
carbsAbsorbed += absorbed;
|
||||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
public class DetermineBasalAdapterAMAJS {
|
public class DetermineBasalAdapterAMAJS {
|
||||||
|
@ -206,7 +207,6 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
double min_5m_carbimpact) {
|
double min_5m_carbimpact) {
|
||||||
|
|
||||||
String units = profile.getUnits();
|
String units = profile.getUnits();
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
|
|
||||||
mProfile = new V8Object(mV8rt);
|
mProfile = new V8Object(mV8rt);
|
||||||
mProfile.add("max_iob", maxIob);
|
mProfile.add("max_iob", maxIob);
|
||||||
|
@ -219,13 +219,13 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
mProfile.add("target_bg", targetBg);
|
mProfile.add("target_bg", targetBg);
|
||||||
mProfile.add("carb_ratio", profile.getIc(profile.secondsFromMidnight()));
|
mProfile.add("carb_ratio", profile.getIc(profile.secondsFromMidnight()));
|
||||||
mProfile.add("sens", NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()).doubleValue(), units));
|
mProfile.add("sens", NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()).doubleValue(), units));
|
||||||
mProfile.add("max_daily_safety_multiplier", SafeParse.stringToInt(preferences.getString("openapsama_max_daily_safety_multiplier", "3")));
|
mProfile.add("max_daily_safety_multiplier", SP.getInt("openapsama_max_daily_safety_multiplier", 3));
|
||||||
mProfile.add("current_basal_safety_multiplier", SafeParse.stringToInt(preferences.getString("openapsama_max_basal_safety_multiplier", "4")));
|
mProfile.add("current_basal_safety_multiplier", SP.getInt("openapsama_max_basal_safety_multiplier", 4));
|
||||||
mProfile.add("skip_neutral_temps", true);
|
mProfile.add("skip_neutral_temps", true);
|
||||||
mProfile.add("current_basal", pump.getBaseBasalRate());
|
mProfile.add("current_basal", pump.getBaseBasalRate());
|
||||||
mProfile.add("temptargetSet", tempTargetSet);
|
mProfile.add("temptargetSet", tempTargetSet);
|
||||||
mProfile.add("autosens_adjust_targets", preferences.getBoolean("openapsama_autosens_adjusttargets", true));
|
mProfile.add("autosens_adjust_targets", SP.getBoolean("openapsama_autosens_adjusttargets", true));
|
||||||
mProfile.add("min_5m_carbimpact", SafeParse.stringToDouble(preferences.getString("openapsama_min_5m_carbimpact", "3.0")));
|
mProfile.add("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", 3d));
|
||||||
mV8rt.add(PARAM_profile, mProfile);
|
mV8rt.add(PARAM_profile, mProfile);
|
||||||
|
|
||||||
mCurrentTemp = new V8Object(mV8rt);
|
mCurrentTemp = new V8Object(mV8rt);
|
||||||
|
|
|
@ -32,6 +32,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.Profiler;
|
import info.nightscout.utils.Profiler;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
|
@ -155,12 +156,11 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
String units = profile.getUnits();
|
String units = profile.getUnits();
|
||||||
|
|
||||||
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
||||||
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
||||||
String targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
|
Double targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
|
||||||
if (!units.equals(Constants.MGDL)) {
|
if (!units.equals(Constants.MGDL)) {
|
||||||
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
||||||
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
||||||
|
@ -169,11 +169,11 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
|
||||||
double maxIob = SafeParse.stringToDouble(SP.getString("openapsma_max_iob", "1.5"));
|
double maxIob = SP.getDouble("openapsma_max_iob", 1.5d);
|
||||||
double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1"));
|
double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
|
||||||
double minBg = NSProfile.toMgdl(SafeParse.stringToDouble(SP.getString("openapsma_min_bg", minBgDefault)), units);
|
double minBg = NSProfile.toMgdl(SP.getDouble("openapsma_min_bg", minBgDefault), units);
|
||||||
double maxBg = NSProfile.toMgdl(SafeParse.stringToDouble(SP.getString("openapsma_max_bg", maxBgDefault)), units);
|
double maxBg = NSProfile.toMgdl(SP.getDouble("openapsma_max_bg", maxBgDefault), units);
|
||||||
double targetBg = NSProfile.toMgdl(SafeParse.stringToDouble(SP.getString("openapsma_target_bg", targetBgDefault)), units);
|
double targetBg = NSProfile.toMgdl(SP.getDouble("openapsma_target_bg", targetBgDefault), units);
|
||||||
|
|
||||||
minBg = Round.roundTo(minBg, 0.1d);
|
minBg = Round.roundTo(minBg, 0.1d);
|
||||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.OpenAPSMA;
|
package info.nightscout.androidaps.plugins.OpenAPSMA;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -25,13 +22,14 @@ import info.nightscout.androidaps.interfaces.TempBasalsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||||
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
|
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.Profiler;
|
import info.nightscout.utils.Profiler;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin.checkOnlyHardLimits;
|
import static info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin.checkOnlyHardLimits;
|
||||||
|
@ -156,12 +154,11 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
String units = profile.getUnits();
|
String units = profile.getUnits();
|
||||||
|
|
||||||
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
||||||
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
||||||
String targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
|
Double targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
|
||||||
if (!units.equals(Constants.MGDL)) {
|
if (!units.equals(Constants.MGDL)) {
|
||||||
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
||||||
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
||||||
|
@ -170,11 +167,11 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
|
||||||
double maxIob = SafeParse.stringToDouble(SP.getString("openapsma_max_iob", "1.5"));
|
double maxIob = SP.getDouble("openapsma_max_iob", 1.5d);
|
||||||
double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1"));
|
double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1"));
|
||||||
double minBg = NSProfile.toMgdl(SafeParse.stringToDouble(SP.getString("openapsma_min_bg", minBgDefault)), units);
|
double minBg = NSProfile.toMgdl(SP.getDouble("openapsma_min_bg", minBgDefault), units);
|
||||||
double maxBg = NSProfile.toMgdl(SafeParse.stringToDouble(SP.getString("openapsma_max_bg", maxBgDefault)), units);
|
double maxBg = NSProfile.toMgdl(SP.getDouble("openapsma_max_bg", maxBgDefault), units);
|
||||||
double targetBg = NSProfile.toMgdl(SafeParse.stringToDouble(SP.getString("openapsma_target_bg", targetBgDefault)), units);
|
double targetBg = NSProfile.toMgdl(SP.getDouble("openapsma_target_bg", targetBgDefault), units);
|
||||||
|
|
||||||
minBg = Round.roundTo(minBg, 0.1d);
|
minBg = Round.roundTo(minBg, 0.1d);
|
||||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||||
|
|
|
@ -92,6 +92,7 @@ import info.nightscout.utils.BolusWizard;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,7 +100,6 @@ public class OverviewFragment extends Fragment {
|
||||||
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
|
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
|
||||||
|
|
||||||
private static OverviewPlugin overviewPlugin = new OverviewPlugin();
|
private static OverviewPlugin overviewPlugin = new OverviewPlugin();
|
||||||
private SharedPreferences prefs;
|
|
||||||
|
|
||||||
public static OverviewPlugin getPlugin() {
|
public static OverviewPlugin getPlugin() {
|
||||||
return overviewPlugin;
|
return overviewPlugin;
|
||||||
|
@ -151,7 +151,6 @@ public class OverviewFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
||||||
|
|
||||||
View view = inflater.inflate(R.layout.overview_fragment, container, false);
|
View view = inflater.inflate(R.layout.overview_fragment, container, false);
|
||||||
bgView = (TextView) view.findViewById(R.id.overview_bg);
|
bgView = (TextView) view.findViewById(R.id.overview_bg);
|
||||||
|
@ -185,12 +184,13 @@ public class OverviewFragment extends Fragment {
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
llm = new LinearLayoutManager(view.getContext());
|
||||||
notificationsView.setLayoutManager(llm);
|
notificationsView.setLayoutManager(llm);
|
||||||
|
|
||||||
showPredictionView.setChecked(prefs.getBoolean("showprediction", false));
|
showPredictionView.setChecked(SP.getBoolean("showprediction", false));
|
||||||
|
|
||||||
showPredictionView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
showPredictionView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
editor.putBoolean("showprediction", showPredictionView.isChecked());
|
editor.putBoolean("showprediction", showPredictionView.isChecked());
|
||||||
editor.apply();
|
editor.apply();
|
||||||
updateGUI();
|
updateGUI();
|
||||||
|
@ -623,15 +623,15 @@ public class OverviewFragment extends Fragment {
|
||||||
tempTargetView.setText(NSProfile.toUnitsString(tempTarget.low, NSProfile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + NSProfile.toUnitsString(tempTarget.high, NSProfile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits()));
|
tempTargetView.setText(NSProfile.toUnitsString(tempTarget.low, NSProfile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + NSProfile.toUnitsString(tempTarget.high, NSProfile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits()));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
||||||
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
||||||
if (!profile.getUnits().equals(Constants.MGDL)) {
|
if (!profile.getUnits().equals(Constants.MGDL)) {
|
||||||
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
||||||
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
||||||
}
|
}
|
||||||
tempTargetView.setTextColor(Color.WHITE);
|
tempTargetView.setTextColor(Color.WHITE);
|
||||||
tempTargetView.setBackgroundResource(R.drawable.temptargetborderdisabled);
|
tempTargetView.setBackgroundResource(R.drawable.temptargetborderdisabled);
|
||||||
tempTargetView.setText(prefs.getString("openapsma_min_bg", minBgDefault) + " - " + prefs.getString("openapsma_max_bg", maxBgDefault));
|
tempTargetView.setText(SP.getDouble("openapsma_min_bg", minBgDefault) + " - " + SP.getDouble("openapsma_max_bg", maxBgDefault));
|
||||||
tempTargetView.setVisibility(View.VISIBLE);
|
tempTargetView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -799,8 +799,8 @@ public class OverviewFragment extends Fragment {
|
||||||
endTime = toTime;
|
endTime = toTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
Double lowLine = SafeParse.stringToDouble(prefs.getString("low_mark", "0"));
|
Double lowLine = SP.getDouble("low_mark", 0d);
|
||||||
Double highLine = SafeParse.stringToDouble(prefs.getString("high_mark", "0"));
|
Double highLine = SP.getDouble("high_mark", 0d);
|
||||||
|
|
||||||
if (lowLine < 1) {
|
if (lowLine < 1) {
|
||||||
lowLine = NSProfile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units);
|
lowLine = NSProfile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units);
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.Overview;
|
package info.nightscout.androidaps.plugins.Overview;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -13,6 +10,7 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
|
@ -27,8 +25,7 @@ public class OverviewPlugin implements PluginBase {
|
||||||
public NotificationStore notificationStore = new NotificationStore();
|
public NotificationStore notificationStore = new NotificationStore();
|
||||||
|
|
||||||
public OverviewPlugin() {
|
public OverviewPlugin() {
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
String storedData = SP.getString("QuickWizard", "[]");
|
||||||
String storedData = preferences.getString("QuickWizard", "[]");
|
|
||||||
try {
|
try {
|
||||||
quickWizard.setData(new JSONArray(storedData));
|
quickWizard.setData(new JSONArray(storedData));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.SafetyFragment;
|
package info.nightscout.androidaps.plugins.SafetyFragment;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -15,7 +12,7 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
|
@ -78,7 +75,6 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public boolean isClosedModeEnabled() {
|
public boolean isClosedModeEnabled() {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
String mode = SP.getString("aps_mode", "open");
|
String mode = SP.getString("aps_mode", "open");
|
||||||
return mode.equals("closed") && BuildConfig.CLOSEDLOOP;
|
return mode.equals("closed") && BuildConfig.CLOSEDLOOP;
|
||||||
}
|
}
|
||||||
|
@ -96,15 +92,14 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||||
@Override
|
@Override
|
||||||
public Double applyBasalConstraints(Double absoluteRate) {
|
public Double applyBasalConstraints(Double absoluteRate) {
|
||||||
Double origAbsoluteRate = absoluteRate;
|
Double origAbsoluteRate = absoluteRate;
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
Double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
|
||||||
Double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1"));
|
|
||||||
|
|
||||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null) return absoluteRate;
|
if (profile == null) return absoluteRate;
|
||||||
if (absoluteRate < 0) absoluteRate = 0d;
|
if (absoluteRate < 0) absoluteRate = 0d;
|
||||||
|
|
||||||
Integer maxBasalMult = SafeParse.stringToInt(SP.getString("openapsama_max_basal_safety_multiplier", "4"));
|
Integer maxBasalMult = SP.getInt("openapsama_max_basal_safety_multiplier", 4);
|
||||||
Integer maxBasalFromDaily = SafeParse.stringToInt(SP.getString("openapsama_max_daily_safety_multiplier", "3"));
|
Integer maxBasalFromDaily = SP.getInt("openapsama_max_daily_safety_multiplier", 3);
|
||||||
// Check percentRate but absolute rate too, because we know real current basal in pump
|
// Check percentRate but absolute rate too, because we know real current basal in pump
|
||||||
Double origRate = absoluteRate;
|
Double origRate = absoluteRate;
|
||||||
if (absoluteRate > maxBasal) {
|
if (absoluteRate > maxBasal) {
|
||||||
|
@ -128,8 +123,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||||
@Override
|
@Override
|
||||||
public Integer applyBasalConstraints(Integer percentRate) {
|
public Integer applyBasalConstraints(Integer percentRate) {
|
||||||
Integer origPercentRate = percentRate;
|
Integer origPercentRate = percentRate;
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
Double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
|
||||||
Double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1"));
|
|
||||||
|
|
||||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null) return percentRate;
|
if (profile == null) return percentRate;
|
||||||
|
@ -142,8 +136,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||||
|
|
||||||
if (absoluteRate < 0) absoluteRate = 0d;
|
if (absoluteRate < 0) absoluteRate = 0d;
|
||||||
|
|
||||||
Integer maxBasalMult = SafeParse.stringToInt(SP.getString("openapsama_max_basal_safety_multiplier", "4"));
|
Integer maxBasalMult = SP.getInt("openapsama_max_basal_safety_multiplier", 4);
|
||||||
Integer maxBasalFromDaily = SafeParse.stringToInt(SP.getString("openapsama_max_daily_safety_multiplier", "3"));
|
Integer maxBasalFromDaily = SP.getInt("openapsama_max_daily_safety_multiplier", 3);
|
||||||
// Check percentRate but absolute rate too, because we know real current basal in pump
|
// Check percentRate but absolute rate too, because we know real current basal in pump
|
||||||
Double origRate = absoluteRate;
|
Double origRate = absoluteRate;
|
||||||
if (absoluteRate > maxBasal) {
|
if (absoluteRate > maxBasal) {
|
||||||
|
@ -174,9 +168,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double applyBolusConstraints(Double insulin) {
|
public Double applyBolusConstraints(Double insulin) {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
try {
|
try {
|
||||||
Double maxBolus = SafeParse.stringToDouble(SP.getString("treatmentssafety_maxbolus", "3"));
|
Double maxBolus = SP.getDouble("treatmentssafety_maxbolus", 3d);
|
||||||
|
|
||||||
if (insulin < 0) insulin = 0d;
|
if (insulin < 0) insulin = 0d;
|
||||||
if (insulin > maxBolus) insulin = maxBolus;
|
if (insulin > maxBolus) insulin = maxBolus;
|
||||||
|
@ -189,9 +182,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer applyCarbsConstraints(Integer carbs) {
|
public Integer applyCarbsConstraints(Integer carbs) {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
try {
|
try {
|
||||||
Integer maxCarbs = SafeParse.stringToInt(SP.getString("treatmentssafety_maxcarbs", "48"));
|
Integer maxCarbs = SP.getInt("treatmentssafety_maxcarbs", 48);
|
||||||
|
|
||||||
if (carbs < 0) carbs = 0;
|
if (carbs < 0) carbs = 0;
|
||||||
if (carbs > maxCarbs) carbs = maxCarbs;
|
if (carbs > maxCarbs) carbs = maxCarbs;
|
||||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +61,7 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
@Override
|
@Override
|
||||||
public String getNameShort() {
|
public String getNameShort() {
|
||||||
String name = MainApp.sResources.getString(R.string.simpleprofile_shortname);
|
String name = MainApp.sResources.getString(R.string.simpleprofile_shortname);
|
||||||
if (!name.trim().isEmpty()){
|
if (!name.trim().isEmpty()) {
|
||||||
//only if translation exists
|
//only if translation exists
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -114,64 +115,15 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
private void loadSettings() {
|
private void loadSettings() {
|
||||||
if (Config.logPrefsChange)
|
if (Config.logPrefsChange)
|
||||||
log.debug("Loading stored settings");
|
log.debug("Loading stored settings");
|
||||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
|
|
||||||
if (settings.contains("SimpleProfile" + "mgdl"))
|
mgdl = SP.getBoolean("SimpleProfile" + "mgdl", true);
|
||||||
try {
|
mmol = SP.getBoolean("SimpleProfile" + "mmol", false);
|
||||||
mgdl = settings.getBoolean("SimpleProfile" + "mgdl", true);
|
dia = SP.getDouble("SimpleProfile" + "dia", 3d);
|
||||||
} catch (Exception e) {
|
ic = SP.getDouble("SimpleProfile" + "ic", 20d);
|
||||||
log.debug(e.getMessage());
|
isf = SP.getDouble("SimpleProfile" + "isf", 200d);
|
||||||
}
|
basal = SP.getDouble("SimpleProfile" + "basal", 1d);
|
||||||
else mgdl = true;
|
targetLow = SP.getDouble("SimpleProfile" + "targetlow", 80d);
|
||||||
if (settings.contains("SimpleProfile" + "mmol"))
|
targetHigh = SP.getDouble("SimpleProfile" + "targethigh", 120d);
|
||||||
try {
|
|
||||||
mmol = settings.getBoolean("SimpleProfile" + "mmol", false);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else mmol = false;
|
|
||||||
if (settings.contains("SimpleProfile" + "dia"))
|
|
||||||
try {
|
|
||||||
dia = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "dia", "3"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else dia = 3d;
|
|
||||||
if (settings.contains("SimpleProfile" + "ic"))
|
|
||||||
try {
|
|
||||||
ic = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "ic", "20"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else ic = 20d;
|
|
||||||
if (settings.contains("SimpleProfile" + "isf"))
|
|
||||||
try {
|
|
||||||
isf = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "isf", "200"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else isf = 200d;
|
|
||||||
if (settings.contains("SimpleProfile" + "basal"))
|
|
||||||
try {
|
|
||||||
basal = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "basal", "1"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else basal = 1d;
|
|
||||||
if (settings.contains("SimpleProfile" + "targetlow"))
|
|
||||||
try {
|
|
||||||
targetLow = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "targetlow", "80"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else targetLow = 80d;
|
|
||||||
if (settings.contains("SimpleProfile" + "targethigh"))
|
|
||||||
try {
|
|
||||||
targetHigh = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "targethigh", "120"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug(e.getMessage());
|
|
||||||
}
|
|
||||||
else targetHigh = 120d;
|
|
||||||
createConvertedProfile();
|
createConvertedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.Services.Intents;
|
import info.nightscout.androidaps.Services.Intents;
|
||||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||||
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
@ -30,13 +31,13 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
|
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
|
||||||
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
|
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
import info.nightscout.utils.XdripCalibrations;
|
import info.nightscout.utils.XdripCalibrations;
|
||||||
|
|
||||||
|
@ -159,8 +160,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void processSettings(final EventPreferenceChange ev) {
|
public void processSettings(final EventPreferenceChange ev) {
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
String settings = SP.getString("smscommunicator_allowednumbers", "");
|
||||||
String settings = sharedPreferences.getString("smscommunicator_allowednumbers", "");
|
|
||||||
|
|
||||||
String pattern = ";";
|
String pattern = ";";
|
||||||
|
|
||||||
|
@ -191,8 +191,6 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processSms(Sms receivedSms) {
|
private void processSms(Sms receivedSms) {
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
|
|
||||||
if (!isEnabled(PluginBase.GENERAL)) {
|
if (!isEnabled(PluginBase.GENERAL)) {
|
||||||
log.debug("Ignoring SMS. Plugin disabled.");
|
log.debug("Ignoring SMS. Plugin disabled.");
|
||||||
return;
|
return;
|
||||||
|
@ -319,7 +317,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
break;
|
break;
|
||||||
case "BASAL":
|
case "BASAL":
|
||||||
if (splited.length > 1) {
|
if (splited.length > 1) {
|
||||||
boolean remoteCommandsAllowed = sharedPreferences.getBoolean("smscommunicator_remotecommandsallowed", false);
|
boolean remoteCommandsAllowed = SP.getBoolean("smscommunicator_remotecommandsallowed", false);
|
||||||
if (splited[1].toUpperCase().equals("CANCEL") || splited[1].toUpperCase().equals("STOP")) {
|
if (splited[1].toUpperCase().equals("CANCEL") || splited[1].toUpperCase().equals("STOP")) {
|
||||||
if (remoteCommandsAllowed) {
|
if (remoteCommandsAllowed) {
|
||||||
passCode = generatePasscode();
|
passCode = generatePasscode();
|
||||||
|
@ -355,7 +353,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
} else if (splited.length > 1) {
|
} else if (splited.length > 1) {
|
||||||
amount = SafeParse.stringToDouble(splited[1]);
|
amount = SafeParse.stringToDouble(splited[1]);
|
||||||
amount = MainApp.getConfigBuilder().applyBolusConstraints(amount);
|
amount = MainApp.getConfigBuilder().applyBolusConstraints(amount);
|
||||||
boolean remoteCommandsAllowed = sharedPreferences.getBoolean("smscommunicator_remotecommandsallowed", false);
|
boolean remoteCommandsAllowed = SP.getBoolean("smscommunicator_remotecommandsallowed", false);
|
||||||
if (amount > 0d && remoteCommandsAllowed) {
|
if (amount > 0d && remoteCommandsAllowed) {
|
||||||
passCode = generatePasscode();
|
passCode = generatePasscode();
|
||||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusreplywithcode), amount, passCode);
|
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusreplywithcode), amount, passCode);
|
||||||
|
@ -372,7 +370,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
case "CAL":
|
case "CAL":
|
||||||
if (splited.length > 1) {
|
if (splited.length > 1) {
|
||||||
amount = SafeParse.stringToDouble(splited[1]);
|
amount = SafeParse.stringToDouble(splited[1]);
|
||||||
boolean remoteCommandsAllowed = sharedPreferences.getBoolean("smscommunicator_remotecommandsallowed", false);
|
boolean remoteCommandsAllowed = SP.getBoolean("smscommunicator_remotecommandsallowed", false);
|
||||||
if (amount > 0d && remoteCommandsAllowed) {
|
if (amount > 0d && remoteCommandsAllowed) {
|
||||||
passCode = generatePasscode();
|
passCode = generatePasscode();
|
||||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_calibrationreplywithcode), amount, passCode);
|
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_calibrationreplywithcode), amount, passCode);
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
Iob tIOB = t.iobCalc(now, dia);
|
Iob tIOB = t.iobCalc(now, dia);
|
||||||
total.iob += tIOB.iobContrib;
|
total.iob += tIOB.iobContrib;
|
||||||
total.activity += tIOB.activityContrib;
|
total.activity += tIOB.activityContrib;
|
||||||
Iob bIOB = t.iobCalc(now, dia / SafeParse.stringToInt(SP.getString("openapsama_bolussnooze_dia_divisor", "2")));
|
Iob bIOB = t.iobCalc(now, dia / SP.getInt("openapsama_bolussnooze_dia_divisor", 2));
|
||||||
total.bolussnooze += bIOB.iobContrib;
|
total.bolussnooze += bIOB.iobContrib;
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.Wear;
|
package info.nightscout.androidaps.plugins.Wear;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import com.j256.ormlite.dao.Dao;
|
import com.j256.ormlite.dao.Dao;
|
||||||
|
@ -25,12 +23,13 @@ import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
|
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
|
||||||
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;
|
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
|
@ -46,9 +45,6 @@ public class ActionStringHandler {
|
||||||
private static String lastConfirmActionString = null;
|
private static String lastConfirmActionString = null;
|
||||||
private static BolusWizard lastBolusWizard = null;
|
private static BolusWizard lastBolusWizard = null;
|
||||||
|
|
||||||
private static SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
|
|
||||||
|
|
||||||
private static HandlerThread handlerThread = new HandlerThread(FillDialog.class.getSimpleName());
|
private static HandlerThread handlerThread = new HandlerThread(FillDialog.class.getSimpleName());
|
||||||
static {
|
static {
|
||||||
handlerThread.start();
|
handlerThread.start();
|
||||||
|
@ -73,11 +69,11 @@ public class ActionStringHandler {
|
||||||
///////////////////////////////////// PRIME/FILL
|
///////////////////////////////////// PRIME/FILL
|
||||||
double amount = 0d;
|
double amount = 0d;
|
||||||
if ("1".equals(act[1])) {
|
if ("1".equals(act[1])) {
|
||||||
amount = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button1", "0.3"))));
|
amount = SP.getDouble("fill_button1", 0.3);
|
||||||
} else if ("2".equals(act[1])) {
|
} else if ("2".equals(act[1])) {
|
||||||
amount = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button2", "0"))));
|
amount = SP.getDouble("fill_button2", 0d);
|
||||||
} else if ("3".equals(act[1])) {
|
} else if ("3".equals(act[1])) {
|
||||||
amount = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button3", "0"))));
|
amount = SP.getDouble("fill_button3", 0d);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -295,17 +291,17 @@ public class ActionStringHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Default Range/Target
|
//Default Range/Target
|
||||||
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
||||||
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
||||||
String targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
|
Double targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
|
||||||
if (!profile.getUnits().equals(Constants.MGDL)) {
|
if (!profile.getUnits().equals(Constants.MGDL)) {
|
||||||
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
||||||
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
||||||
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
|
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
|
||||||
}
|
}
|
||||||
ret += "DEFAULT RANGE: ";
|
ret += "DEFAULT RANGE: ";
|
||||||
ret += sp.getString("openapsma_min_bg", minBgDefault) + " - " + sp.getString("openapsma_max_bg", maxBgDefault);
|
ret += SP.getDouble("openapsma_min_bg", minBgDefault) + " - " + SP.getDouble("openapsma_max_bg", maxBgDefault);
|
||||||
ret += " target: " + sp.getString("openapsma_target_bg", targetBgDefault);
|
ret += " target: " + SP.getDouble("openapsma_target_bg", targetBgDefault);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,7 @@ public class LocaleHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getPersistedData(Context context, String defaultLanguage) {
|
private static String getPersistedData(Context context, String defaultLanguage) {
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
return SP.getString(SELECTED_LANGUAGE, defaultLanguage);
|
||||||
return preferences.getString(SELECTED_LANGUAGE, defaultLanguage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void persist(Context context, String language) {
|
private static void persist(Context context, String language) {
|
||||||
|
|
|
@ -3,8 +3,6 @@ package info.nightscout.utils;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
@ -19,7 +17,6 @@ import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
public class PasswordProtection {
|
public class PasswordProtection {
|
||||||
static public boolean isLocked(String preference) {
|
static public boolean isLocked(String preference) {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
final String password = SP.getString(preference, "");
|
final String password = SP.getString(preference, "");
|
||||||
if (password.equals("")) {
|
if (password.equals("")) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -28,7 +25,6 @@ public class PasswordProtection {
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void QueryPassword(final Context context, int stringID, String preference, final Runnable ok, final Runnable fail) {
|
static public void QueryPassword(final Context context, int stringID, String preference, final Runnable ok, final Runnable fail) {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
final String password = SP.getString(preference, "");
|
final String password = SP.getString(preference, "");
|
||||||
if (password.equals("")) {
|
if (password.equals("")) {
|
||||||
if (ok != null) ok.run();
|
if (ok != null) ok.run();
|
||||||
|
|
72
app/src/main/java/info/nightscout/utils/SP.java
Normal file
72
app/src/main/java/info/nightscout/utils/SP.java
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
package info.nightscout.utils;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 17.02.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SP {
|
||||||
|
static SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
|
|
||||||
|
static public boolean contains(String key) {
|
||||||
|
return sharedPreferences.contains(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public String getString(int resourceID, String defaultValue) {
|
||||||
|
return sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public String getString(String key, String defaultValue) {
|
||||||
|
return sharedPreferences.getString(key, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public boolean getBoolean(int resourceID, boolean defaultValue) {
|
||||||
|
try {
|
||||||
|
return sharedPreferences.getBoolean(MainApp.sResources.getString(resourceID), defaultValue);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static public boolean getBoolean(String key, boolean defaultValue) {
|
||||||
|
try {
|
||||||
|
return sharedPreferences.getBoolean(key, defaultValue);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static public Double getDouble(int resourceID, Double defaultValue) {
|
||||||
|
return SafeParse.stringToDouble(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public Double getDouble(String key, Double defaultValue) {
|
||||||
|
return SafeParse.stringToDouble(sharedPreferences.getString(key, defaultValue.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public int getInt(int resourceID, Integer defaultValue) {
|
||||||
|
return SafeParse.stringToInt(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public int getInt(String key, Integer defaultValue) {
|
||||||
|
return SafeParse.stringToInt(sharedPreferences.getString(key, defaultValue.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public long getLong(int resourceID, Long defaultValue) {
|
||||||
|
return SafeParse.stringToLong(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public long getLong(String key, Long defaultValue) {
|
||||||
|
return SafeParse.stringToLong(sharedPreferences.getString(key, defaultValue.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public void putBoolean(String key, boolean value) {
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
editor.putBoolean(key, value);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
}
|
|
@ -267,7 +267,7 @@
|
||||||
<string name="danar_history_syspend">Прекъсване</string>
|
<string name="danar_history_syspend">Прекъсване</string>
|
||||||
<string name="danar_historyreload">Презареждане</string>
|
<string name="danar_historyreload">Презареждане</string>
|
||||||
<string name="danar_iob_label">IOB на помпата</string>
|
<string name="danar_iob_label">IOB на помпата</string>
|
||||||
<string name="danar_password">Парола за помпа</string>
|
<string name="danar_password_title">Парола за помпа</string>
|
||||||
<string name="danar_refill">пълнене</string>
|
<string name="danar_refill">пълнене</string>
|
||||||
<string name="danar_totaluploaded" formatted="false">Общо %d записа са изпратени</string>
|
<string name="danar_totaluploaded" formatted="false">Общо %d записа са изпратени</string>
|
||||||
<string name="enacted">Приложено</string>
|
<string name="enacted">Приложено</string>
|
||||||
|
|
|
@ -265,7 +265,7 @@
|
||||||
<string name="uploading">Nahrávám</string>
|
<string name="uploading">Nahrávám</string>
|
||||||
<string name="pumpbusy">Pumpa je zaneprázdněna</string>
|
<string name="pumpbusy">Pumpa je zaneprázdněna</string>
|
||||||
<string name="wrongpumppassword">Špatné heslo k pumpě</string>
|
<string name="wrongpumppassword">Špatné heslo k pumpě</string>
|
||||||
<string name="danar_password">Heslo k pumpě</string>
|
<string name="danar_password_title">Heslo k pumpě</string>
|
||||||
<string name="occlusion">Okluze</string>
|
<string name="occlusion">Okluze</string>
|
||||||
<string name="overview_bolusprogress_delivered">Podáno</string>
|
<string name="overview_bolusprogress_delivered">Podáno</string>
|
||||||
<string name="overview_bolusprogress_stop">Stop</string>
|
<string name="overview_bolusprogress_stop">Stop</string>
|
||||||
|
|
|
@ -259,7 +259,7 @@
|
||||||
<string name="danar_history_glucose">Glukose</string>
|
<string name="danar_history_glucose">Glukose</string>
|
||||||
<string name="danar_history_refill">Füllmenge</string>
|
<string name="danar_history_refill">Füllmenge</string>
|
||||||
<string name="danar_history_syspend">Unterbrechungen</string>
|
<string name="danar_history_syspend">Unterbrechungen</string>
|
||||||
<string name="danar_password">Pumpen-Passwort</string>
|
<string name="danar_password_title">Pumpen-Passwort</string>
|
||||||
<string name="mealbolus">Essensbolus</string>
|
<string name="mealbolus">Essensbolus</string>
|
||||||
<string name="noprofileselected">Kein Profil gewählt</string>
|
<string name="noprofileselected">Kein Profil gewählt</string>
|
||||||
<string name="overview_bolusprogress_stop">Stop</string>
|
<string name="overview_bolusprogress_stop">Stop</string>
|
||||||
|
|
|
@ -275,7 +275,7 @@
|
||||||
<string name="danar_history_refill">Rellenar</string>
|
<string name="danar_history_refill">Rellenar</string>
|
||||||
<string name="danar_history_syspend">Suspender</string>
|
<string name="danar_history_syspend">Suspender</string>
|
||||||
<string formatted="false" name="danar_history_connectingfor">Conexión de %d s</string>
|
<string formatted="false" name="danar_history_connectingfor">Conexión de %d s</string>
|
||||||
<string name="danar_password">Contraseña de la bomba</string>
|
<string name="danar_password_title">Contraseña de la bomba</string>
|
||||||
<string name="wrongpumppassword">Contraseña de la bomba incorrecta!</string>
|
<string name="wrongpumppassword">Contraseña de la bomba incorrecta!</string>
|
||||||
<string name="pumpbusy">Bomba ocupada</string>
|
<string name="pumpbusy">Bomba ocupada</string>
|
||||||
<string name="overview_bolusprogress_delivered">Entregado</string>
|
<string name="overview_bolusprogress_delivered">Entregado</string>
|
||||||
|
|
|
@ -278,7 +278,7 @@
|
||||||
<string name="danar_history_refill">교체</string>
|
<string name="danar_history_refill">교체</string>
|
||||||
<string name="danar_history_syspend">중지</string>
|
<string name="danar_history_syspend">중지</string>
|
||||||
<string name="danar_history_connectingfor" formatted="false">%d 초 동안 연결중</string>
|
<string name="danar_history_connectingfor" formatted="false">%d 초 동안 연결중</string>
|
||||||
<string name="danar_password">펌프 비밀번호</string>
|
<string name="danar_password_title">펌프 비밀번호</string>
|
||||||
<string name="wrongpumppassword">펌프 비밀번호가 잘못되었습니다!</string>
|
<string name="wrongpumppassword">펌프 비밀번호가 잘못되었습니다!</string>
|
||||||
<string name="pumpbusy">펌프가 바쁩니다</string>
|
<string name="pumpbusy">펌프가 바쁩니다</string>
|
||||||
<string name="overview_bolusprogress_delivered">주입됨</string>
|
<string name="overview_bolusprogress_delivered">주입됨</string>
|
||||||
|
|
|
@ -294,7 +294,7 @@
|
||||||
<string name="danar_history_refill">Refill</string>
|
<string name="danar_history_refill">Refill</string>
|
||||||
<string name="danar_history_syspend">Suspend</string>
|
<string name="danar_history_syspend">Suspend</string>
|
||||||
<string name="danar_history_connectingfor" formatted="false">Connecting for %d s</string>
|
<string name="danar_history_connectingfor" formatted="false">Connecting for %d s</string>
|
||||||
<string name="danar_password">Pump password</string>
|
<string name="danar_password_title">Pump password</string>
|
||||||
<string name="wrongpumppassword">Wrong pump password!</string>
|
<string name="wrongpumppassword">Wrong pump password!</string>
|
||||||
<string name="pumpbusy">Pump is busy</string>
|
<string name="pumpbusy">Pump is busy</string>
|
||||||
<string name="overview_bolusprogress_delivered">Delivered</string>
|
<string name="overview_bolusprogress_delivered">Delivered</string>
|
||||||
|
@ -532,4 +532,8 @@
|
||||||
<string name="key_nsclientinternal_url" translatable="false">nsclientinternal_url</string>
|
<string name="key_nsclientinternal_url" translatable="false">nsclientinternal_url</string>
|
||||||
<string name="key_nsclientinternal_api_secret" translatable="false">nsclientinternal_api_secret</string>
|
<string name="key_nsclientinternal_api_secret" translatable="false">nsclientinternal_api_secret</string>
|
||||||
<string name="key_nsclientinternal_hours" translatable="false">nsclientinternal_hours</string>
|
<string name="key_nsclientinternal_hours" translatable="false">nsclientinternal_hours</string>
|
||||||
|
<string name="key_danar_bt_name" translatable="false">danar_bt_name</string>
|
||||||
|
<string name="key_danar_password" translatable="false">danar_password</string>
|
||||||
|
<string name="key_danar_useextended" translatable="false">danar_useextended</string>
|
||||||
|
<string name="key_danarprofile_dia" translatable="false">danarprofile_dia</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -6,16 +6,16 @@
|
||||||
|
|
||||||
<info.nightscout.androidaps.plugins.DanaR.BluetoothDevicePreference
|
<info.nightscout.androidaps.plugins.DanaR.BluetoothDevicePreference
|
||||||
android:dialogTitle="@string/danar_bt_name_title"
|
android:dialogTitle="@string/danar_bt_name_title"
|
||||||
android:key="danar_bt_name"
|
android:key="@string/key_danar_bt_name"
|
||||||
android:title="@string/danar_bt_name_title" />
|
android:title="@string/danar_bt_name_title" />
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:title="@string/danar_password"
|
android:title="@string/danar_password_title"
|
||||||
android:key="danar_password"
|
android:key="@string/key_danar_password"
|
||||||
android:inputType="numberPassword">
|
android:inputType="numberPassword">
|
||||||
</EditTextPreference>
|
</EditTextPreference>
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="danar_useextended"
|
android:key="@string/key_danar_useextended"
|
||||||
android:title="@string/danar_useextended_title" />
|
android:title="@string/danar_useextended_title" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
android:title="@string/danarprofile">
|
android:title="@string/danarprofile">
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:defaultValue=""
|
android:defaultValue=""
|
||||||
android:key="danarprofile_dia"
|
android:key="@string/key_danarprofile_dia"
|
||||||
android:numeric="decimal"
|
android:numeric="decimal"
|
||||||
android:dialogMessage="@string/danarprofile_dia_summary"
|
android:dialogMessage="@string/danarprofile_dia_summary"
|
||||||
android:title="@string/danarprofile_dia" />
|
android:title="@string/danarprofile_dia" />
|
||||||
|
|
Loading…
Reference in a new issue