PROFILE logging
This commit is contained in:
parent
54c83dc374
commit
188a9b6313
11 changed files with 292 additions and 205 deletions
|
@ -23,8 +23,6 @@ public class Config {
|
||||||
public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
|
public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
|
||||||
|
|
||||||
|
|
||||||
public static boolean logFunctionCalls = true;
|
|
||||||
public static boolean logPrefsChange = true;
|
|
||||||
public static boolean logConfigBuilder = true;
|
public static boolean logConfigBuilder = true;
|
||||||
public static boolean logCongigBuilderActions = true;
|
public static boolean logCongigBuilderActions = true;
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ import info.nightscout.androidaps.events.EventFeatureRunning;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.Food.FoodPlugin;
|
import info.nightscout.androidaps.plugins.Food.FoodPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
@ -62,7 +63,7 @@ import info.nightscout.utils.PasswordProtection;
|
||||||
import info.nightscout.utils.SP;
|
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(L.CORE);
|
||||||
|
|
||||||
protected PowerManager.WakeLock mWakeLock;
|
protected PowerManager.WakeLock mWakeLock;
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
if (Config.logFunctionCalls)
|
if (L.isEnabled(L.CORE))
|
||||||
log.debug("onCreate");
|
log.debug("onCreate");
|
||||||
|
|
||||||
Iconify.with(new FontAwesomeModule());
|
Iconify.with(new FontAwesomeModule());
|
||||||
|
@ -134,6 +135,9 @@ public class MainActivity extends AppCompatActivity {
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
if (L.isEnabled(L.CORE))
|
||||||
|
log.debug("onResume");
|
||||||
|
|
||||||
if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) {
|
if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) {
|
||||||
Intent intent = new Intent(this, SetupWizardActivity.class);
|
Intent intent = new Intent(this, SetupWizardActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
@ -153,6 +157,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
if (L.isEnabled(L.CORE))
|
||||||
|
log.debug("onDestroy");
|
||||||
if (mWakeLock != null)
|
if (mWakeLock != null)
|
||||||
if (mWakeLock.isHeld())
|
if (mWakeLock.isHeld())
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
|
|
|
@ -24,13 +24,12 @@ import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import ch.qos.logback.classic.LoggerContext;
|
import ch.qos.logback.classic.LoggerContext;
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.services.Intents;
|
|
||||||
import info.nightscout.androidaps.data.ConstraintChecker;
|
import info.nightscout.androidaps.data.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
|
import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
@ -43,6 +42,7 @@ import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlu
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
|
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
||||||
|
@ -77,13 +77,13 @@ import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
||||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||||
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
||||||
|
import info.nightscout.androidaps.services.Intents;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
|
||||||
import io.fabric.sdk.android.Fabric;
|
import io.fabric.sdk.android.Fabric;
|
||||||
|
|
||||||
|
|
||||||
public class MainApp extends Application {
|
public class MainApp extends Application {
|
||||||
private static Logger log = LoggerFactory.getLogger(MainApp.class);
|
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
||||||
private static KeepAliveReceiver keepAliveReceiver;
|
private static KeepAliveReceiver keepAliveReceiver;
|
||||||
|
|
||||||
private static Bus sBus;
|
private static Bus sBus;
|
||||||
|
@ -107,6 +107,8 @@ public class MainApp extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
if (L.isEnabled(L.CORE))
|
||||||
|
log.debug("onCreate");
|
||||||
sInstance = this;
|
sInstance = this;
|
||||||
sResources = getResources();
|
sResources = getResources();
|
||||||
sConstraintsChecker = new ConstraintChecker(this);
|
sConstraintsChecker = new ConstraintChecker(this);
|
||||||
|
@ -119,7 +121,7 @@ public class MainApp extends Application {
|
||||||
Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION);
|
Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
android.util.Log.e("ANDROIDAPS", "Error with Fabric init! " + e);
|
log.error("Error with Fabric init! " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
JodaTimeAndroid.init(this);
|
JodaTimeAndroid.init(this);
|
||||||
|
@ -395,6 +397,8 @@ public class MainApp extends Application {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTerminate() {
|
public void onTerminate() {
|
||||||
|
if (L.isEnabled(L.CORE))
|
||||||
|
log.debug("onTerminate");
|
||||||
super.onTerminate();
|
super.onTerminate();
|
||||||
if (sDatabaseHelper != null) {
|
if (sDatabaseHelper != null) {
|
||||||
sDatabaseHelper.close();
|
sDatabaseHelper.close();
|
||||||
|
|
103
app/src/main/java/info/nightscout/androidaps/logging/L.java
Normal file
103
app/src/main/java/info/nightscout/androidaps/logging/L.java
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
package info.nightscout.androidaps.logging;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
public class L {
|
||||||
|
|
||||||
|
public static class LogElement {
|
||||||
|
String name;
|
||||||
|
boolean defaultValue;
|
||||||
|
boolean enabled;
|
||||||
|
boolean requiresRestart = false;
|
||||||
|
|
||||||
|
LogElement(String name, boolean defaultValue) {
|
||||||
|
this.name = name;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
enabled = SP.getBoolean(getSPName(), defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
LogElement(String name, boolean defaultValue, boolean requiresRestart) {
|
||||||
|
this.name = name;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
this.requiresRestart = requiresRestart;
|
||||||
|
enabled = SP.getBoolean(getSPName(), defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
LogElement(boolean defaultValue) {
|
||||||
|
this.name = "NONEXISTING";
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
enabled = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSPName() {
|
||||||
|
return "log_" + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<LogElement> logElements;
|
||||||
|
|
||||||
|
static {
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LogElement findByName(String name) {
|
||||||
|
for (LogElement element: logElements
|
||||||
|
) {
|
||||||
|
if (element.name.equals(name))
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
return new LogElement(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEnabled(String name) {
|
||||||
|
return findByName(name).enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String CORE = "CORE";
|
||||||
|
public static final String AUTOSENS = "AUTOSENS";
|
||||||
|
public static final String EVENTS = "EVENTS";
|
||||||
|
public static final String BGSOURCE = "BGSOURCE";
|
||||||
|
public static final String OVERVIEW = "OVERVIEW";
|
||||||
|
public static final String NOTIFICATION = "NOTIFICATION";
|
||||||
|
public static final String ALARM = "ALARM";
|
||||||
|
public static final String DATASERVICE = "DATASERVICE";
|
||||||
|
public static final String DATABASE = "DATABASE";
|
||||||
|
public static final String DATAFOOD = "DATAFOOD";
|
||||||
|
public static final String DATATREATMENTS = "DATATREATMENTS";
|
||||||
|
public static final String NSCLIENT = "NSCLIENT";
|
||||||
|
public static final String OBJECTIVES = "OBJECTIVES";
|
||||||
|
public static final String PUMP = "PUMP";
|
||||||
|
public static final String PUMPQUEUE = "PUMPQUEUE";
|
||||||
|
public static final String PUMPCOMM = "PUMPCOMM";
|
||||||
|
public static final String PUMPBTCOMM = "PUMPBTCOMM";
|
||||||
|
public static final String APS = "APS";
|
||||||
|
public static final String PROFILE = "PROFILE";
|
||||||
|
|
||||||
|
private static void initialize() {
|
||||||
|
logElements = new ArrayList<>();
|
||||||
|
logElements.add(new LogElement(CORE, true));
|
||||||
|
logElements.add(new LogElement(AUTOSENS, false));
|
||||||
|
logElements.add(new LogElement(EVENTS, false, true));
|
||||||
|
logElements.add(new LogElement(BGSOURCE, true));
|
||||||
|
logElements.add(new LogElement(OVERVIEW, true));
|
||||||
|
logElements.add(new LogElement(NOTIFICATION, true));
|
||||||
|
logElements.add(new LogElement(ALARM, false));
|
||||||
|
logElements.add(new LogElement(DATASERVICE, true));
|
||||||
|
logElements.add(new LogElement(DATABASE, true));
|
||||||
|
logElements.add(new LogElement(DATAFOOD, true));
|
||||||
|
logElements.add(new LogElement(DATATREATMENTS, true));
|
||||||
|
logElements.add(new LogElement(NSCLIENT, true));
|
||||||
|
logElements.add(new LogElement(OBJECTIVES, false));
|
||||||
|
logElements.add(new LogElement(PUMP, true));
|
||||||
|
logElements.add(new LogElement(PUMPQUEUE, true));
|
||||||
|
logElements.add(new LogElement(PUMPCOMM, true));
|
||||||
|
logElements.add(new LogElement(PUMPBTCOMM, false));
|
||||||
|
logElements.add(new LogElement(APS, true));
|
||||||
|
logElements.add(new LogElement(PROFILE, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -120,7 +120,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
|
|
||||||
public void storeSettings(String from) {
|
public void storeSettings(String from) {
|
||||||
if (pluginList != null) {
|
if (pluginList != null) {
|
||||||
if (Config.logPrefsChange)
|
if (Config.logConfigBuilder)
|
||||||
log.debug("Storing settings from: " + from);
|
log.debug("Storing settings from: " + from);
|
||||||
|
|
||||||
for (PluginBase p : pluginList) {
|
for (PluginBase p : pluginList) {
|
||||||
|
@ -152,7 +152,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadSettings() {
|
private void loadSettings() {
|
||||||
if (Config.logPrefsChange)
|
if (Config.logConfigBuilder)
|
||||||
log.debug("Loading stored settings");
|
log.debug("Loading stored settings");
|
||||||
for (PluginBase p : pluginList) {
|
for (PluginBase p : pluginList) {
|
||||||
PluginType type = p.getType();
|
PluginType type = p.getType();
|
||||||
|
@ -189,7 +189,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
private void upgradeSettings() {
|
private void upgradeSettings() {
|
||||||
if (!SP.contains("ConfigBuilder_1_NSProfilePlugin_Enabled"))
|
if (!SP.contains("ConfigBuilder_1_NSProfilePlugin_Enabled"))
|
||||||
return;
|
return;
|
||||||
if (Config.logPrefsChange)
|
if (Config.logConfigBuilder)
|
||||||
log.debug("Upgrading stored settings");
|
log.debug("Upgrading stored settings");
|
||||||
for (PluginBase p : pluginList) {
|
for (PluginBase p : pluginList) {
|
||||||
log.debug("Processing " + p.getName());
|
log.debug("Processing " + p.getName());
|
||||||
|
|
|
@ -25,20 +25,18 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
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.FabricPrivacy;
|
|
||||||
import info.nightscout.utils.NumberPicker;
|
import info.nightscout.utils.NumberPicker;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
import info.nightscout.utils.TimeListEdit;
|
import info.nightscout.utils.TimeListEdit;
|
||||||
|
|
||||||
public class LocalProfileFragment extends SubscriberFragment {
|
public class LocalProfileFragment extends SubscriberFragment {
|
||||||
private static Logger log = LoggerFactory.getLogger(LocalProfileFragment.class);
|
|
||||||
|
|
||||||
NumberPicker diaView;
|
NumberPicker diaView;
|
||||||
RadioButton mgdlView;
|
RadioButton mgdlView;
|
||||||
RadioButton mmolView;
|
RadioButton mmolView;
|
||||||
|
@ -81,80 +79,72 @@ public class LocalProfileFragment extends SubscriberFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
try {
|
PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||||
|
View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
|
||||||
|
diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
|
||||||
|
diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
|
||||||
|
mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl);
|
||||||
|
mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
|
||||||
|
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
|
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
|
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
|
||||||
|
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.gs(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
|
profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch);
|
||||||
|
resetButton = (Button) layout.findViewById(R.id.localprofile_reset);
|
||||||
|
saveButton = (Button) layout.findViewById(R.id.localprofile_save);
|
||||||
|
|
||||||
PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
|
||||||
View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
|
invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile);
|
||||||
diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
|
|
||||||
diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
|
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
|
||||||
mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl);
|
layout.findViewById(R.id.localprofile_basal).setVisibility(View.GONE);
|
||||||
mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
|
}
|
||||||
|
|
||||||
|
mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
|
||||||
|
mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
|
||||||
|
|
||||||
|
mgdlView.setOnClickListener(v -> {
|
||||||
|
LocalProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
|
||||||
|
LocalProfilePlugin.getPlugin().mmol = !LocalProfilePlugin.getPlugin().mgdl;
|
||||||
|
mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
|
||||||
|
doEdit();
|
||||||
|
});
|
||||||
|
mmolView.setOnClickListener(v -> {
|
||||||
|
LocalProfilePlugin.getPlugin().mmol = mmolView.isChecked();
|
||||||
|
LocalProfilePlugin.getPlugin().mgdl = !LocalProfilePlugin.getPlugin().mmol;
|
||||||
|
mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
|
||||||
|
doEdit();
|
||||||
|
});
|
||||||
|
|
||||||
|
profileswitchButton.setOnClickListener(view -> {
|
||||||
|
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||||
|
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT;
|
||||||
|
profileswitch.executeProfileSwitch = true;
|
||||||
|
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||||
|
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
|
});
|
||||||
|
|
||||||
|
resetButton.setOnClickListener(view -> {
|
||||||
|
LocalProfilePlugin.getPlugin().loadSettings();
|
||||||
|
mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
|
||||||
|
mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
|
||||||
|
diaView.setParams(LocalProfilePlugin.getPlugin().dia, 5d, 12d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
|
||||||
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
|
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
|
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
|
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
|
||||||
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.gs(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
|
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.gs(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch);
|
updateGUI();
|
||||||
resetButton = (Button) layout.findViewById(R.id.localprofile_reset);
|
});
|
||||||
saveButton = (Button) layout.findViewById(R.id.localprofile_save);
|
|
||||||
|
|
||||||
|
saveButton.setOnClickListener(view -> {
|
||||||
invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile);
|
if (!LocalProfilePlugin.getPlugin().isValidEditState()) {
|
||||||
|
return; //Should not happen as saveButton should not be visible if not valid
|
||||||
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
|
|
||||||
layout.findViewById(R.id.localprofile_basal).setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
LocalProfilePlugin.getPlugin().storeSettings();
|
||||||
|
updateGUI();
|
||||||
|
});
|
||||||
|
|
||||||
mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
|
return layout;
|
||||||
mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
|
|
||||||
|
|
||||||
mgdlView.setOnClickListener(v -> {
|
|
||||||
LocalProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
|
|
||||||
LocalProfilePlugin.getPlugin().mmol = !LocalProfilePlugin.getPlugin().mgdl;
|
|
||||||
mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
|
|
||||||
doEdit();
|
|
||||||
});
|
|
||||||
mmolView.setOnClickListener(v -> {
|
|
||||||
LocalProfilePlugin.getPlugin().mmol = mmolView.isChecked();
|
|
||||||
LocalProfilePlugin.getPlugin().mgdl = !LocalProfilePlugin.getPlugin().mmol;
|
|
||||||
mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
|
|
||||||
doEdit();
|
|
||||||
});
|
|
||||||
|
|
||||||
profileswitchButton.setOnClickListener(view -> {
|
|
||||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
|
||||||
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT;
|
|
||||||
profileswitch.executeProfileSwitch = true;
|
|
||||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
|
||||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
|
||||||
});
|
|
||||||
|
|
||||||
resetButton.setOnClickListener(view -> {
|
|
||||||
LocalProfilePlugin.getPlugin().loadSettings();
|
|
||||||
mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
|
|
||||||
mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
|
|
||||||
diaView.setParams(LocalProfilePlugin.getPlugin().dia, 5d, 12d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
|
|
||||||
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
|
|
||||||
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
|
|
||||||
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
|
|
||||||
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.gs(R.string.nsprofileview_target_label) + ":", LocalProfilePlugin.getPlugin().targetLow, LocalProfilePlugin.getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
|
|
||||||
updateGUI();
|
|
||||||
});
|
|
||||||
|
|
||||||
saveButton.setOnClickListener(view -> {
|
|
||||||
if(!LocalProfilePlugin.getPlugin().isValidEditState()){
|
|
||||||
return; //Should not happen as saveButton should not be visible if not valid
|
|
||||||
}
|
|
||||||
LocalProfilePlugin.getPlugin().storeSettings();
|
|
||||||
updateGUI();
|
|
||||||
});
|
|
||||||
|
|
||||||
return layout;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Unhandled exception: ", e);
|
|
||||||
FabricPrivacy.logException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doEdit() {
|
public void doEdit() {
|
||||||
|
@ -203,7 +193,7 @@ public class LocalProfileFragment extends SubscriberFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Show reset button iff data was edited
|
//Show reset button iff data was edited
|
||||||
if(isEdited) {
|
if (isEdited) {
|
||||||
resetButton.setVisibility(View.VISIBLE);
|
resetButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
resetButton.setVisibility(View.GONE);
|
resetButton.setVisibility(View.GONE);
|
||||||
|
|
|
@ -8,7 +8,6 @@ import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
|
||||||
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;
|
||||||
|
@ -18,6 +17,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import info.nightscout.utils.SP;
|
||||||
*/
|
*/
|
||||||
public class LocalProfilePlugin extends PluginBase implements ProfileInterface {
|
public class LocalProfilePlugin extends PluginBase implements ProfileInterface {
|
||||||
public static final String LOCAL_PROFILE = "LocalProfile";
|
public static final String LOCAL_PROFILE = "LocalProfile";
|
||||||
private static Logger log = LoggerFactory.getLogger(LocalProfilePlugin.class);
|
private static Logger log = LoggerFactory.getLogger(L.PROFILE);
|
||||||
|
|
||||||
private static LocalProfilePlugin localProfilePlugin;
|
private static LocalProfilePlugin localProfilePlugin;
|
||||||
|
|
||||||
|
@ -81,13 +81,13 @@ public class LocalProfilePlugin extends PluginBase implements ProfileInterface {
|
||||||
|
|
||||||
createAndStoreConvertedProfile();
|
createAndStoreConvertedProfile();
|
||||||
edited = false;
|
edited = false;
|
||||||
if (Config.logPrefsChange)
|
if (L.isEnabled(L.PROFILE))
|
||||||
log.debug("Storing settings: " + getRawProfile().getData().toString());
|
log.debug("Storing settings: " + getRawProfile().getData().toString());
|
||||||
MainApp.bus().post(new EventProfileStoreChanged());
|
MainApp.bus().post(new EventProfileStoreChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void loadSettings() {
|
public synchronized void loadSettings() {
|
||||||
if (Config.logPrefsChange)
|
if (L.isEnabled(L.PROFILE))
|
||||||
log.debug("Loading stored settings");
|
log.debug("Loading stored settings");
|
||||||
|
|
||||||
mgdl = SP.getBoolean(LOCAL_PROFILE + "mgdl", false);
|
mgdl = SP.getBoolean(LOCAL_PROFILE + "mgdl", false);
|
||||||
|
|
|
@ -27,7 +27,6 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
|
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileGraph;
|
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileGraph;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
|
||||||
import info.nightscout.utils.OKDialog;
|
import info.nightscout.utils.OKDialog;
|
||||||
|
|
||||||
import static butterknife.OnItemSelected.Callback.NOTHING_SELECTED;
|
import static butterknife.OnItemSelected.Callback.NOTHING_SELECTED;
|
||||||
|
@ -62,24 +61,22 @@ public class NSProfileFragment extends SubscriberFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
try {
|
View view = inflater.inflate(R.layout.nsprofile_fragment, container, false);
|
||||||
View view = inflater.inflate(R.layout.nsprofile_fragment, container, false);
|
|
||||||
|
|
||||||
unbinder = ButterKnife.bind(this, view);
|
unbinder = ButterKnife.bind(this, view);
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
} catch (Exception e) {
|
|
||||||
FabricPrivacy.logException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNSProfileUpdateGUI ev) {
|
public void onStatusEvent(final EventNSProfileUpdateGUI ev) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(() -> { synchronized (NSProfileFragment.this) { updateGUI(); } });
|
activity.runOnUiThread(() -> {
|
||||||
|
synchronized (NSProfileFragment.this) {
|
||||||
|
updateGUI();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ import info.nightscout.utils.SP;
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class NSProfilePlugin extends PluginBase implements ProfileInterface {
|
public class NSProfilePlugin extends PluginBase implements ProfileInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(NSProfilePlugin.class);
|
private static Logger log = LoggerFactory.getLogger(L.PROFILE);
|
||||||
|
|
||||||
private static NSProfilePlugin nsProfilePlugin;
|
private static NSProfilePlugin nsProfilePlugin;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
|
||||||
MainApp.bus().post(new EventProfileStoreChanged());
|
MainApp.bus().post(new EventProfileStoreChanged());
|
||||||
MainApp.bus().post(new EventNSProfileUpdateGUI());
|
MainApp.bus().post(new EventNSProfileUpdateGUI());
|
||||||
}
|
}
|
||||||
if (L.isEnabled(L.NSCLIENT))
|
if (L.isEnabled(L.PROFILE))
|
||||||
log.debug("Received profileStore: " + activeProfile + " " + profile);
|
log.debug("Received profileStore: " + activeProfile + " " + profile);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
|
@ -87,31 +87,29 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
|
||||||
|
|
||||||
private void storeNSProfile() {
|
private void storeNSProfile() {
|
||||||
SP.putString("profile", profile.getData().toString());
|
SP.putString("profile", profile.getData().toString());
|
||||||
if (Config.logPrefsChange)
|
if (L.isEnabled(L.PROFILE))
|
||||||
log.debug("Storing profile");
|
log.debug("Storing profile");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadNSProfile() {
|
private void loadNSProfile() {
|
||||||
if (Config.logPrefsChange)
|
if (L.isEnabled(L.PROFILE))
|
||||||
log.debug("Loading stored profile");
|
log.debug("Loading stored profile");
|
||||||
String profileString = SP.getString("profile", null);
|
String profileString = SP.getString("profile", null);
|
||||||
if (profileString != null) {
|
if (profileString != null) {
|
||||||
if (Config.logPrefsChange) {
|
if (L.isEnabled(L.PROFILE))
|
||||||
log.debug("Loaded profile: " + profileString);
|
log.debug("Loaded profile: " + profileString);
|
||||||
try {
|
try {
|
||||||
profile = new ProfileStore(new JSONObject(profileString));
|
profile = new ProfileStore(new JSONObject(profileString));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
profile = null;
|
profile = null;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Config.logPrefsChange) {
|
if (L.isEnabled(L.PROFILE))
|
||||||
log.debug("Stored profile not found");
|
log.debug("Stored profile not found");
|
||||||
// force restart of nsclient to fetch profile
|
// force restart of nsclient to fetch profile
|
||||||
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
|
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
|
||||||
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
|
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,9 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
public class SimpleProfileFragment extends SubscriberFragment {
|
public class SimpleProfileFragment extends SubscriberFragment {
|
||||||
private static Logger log = LoggerFactory.getLogger(SimpleProfileFragment.class);
|
|
||||||
|
|
||||||
EditText diaView;
|
EditText diaView;
|
||||||
RadioButton mgdlView;
|
RadioButton mgdlView;
|
||||||
RadioButton mmolView;
|
RadioButton mmolView;
|
||||||
|
@ -46,92 +43,86 @@ public class SimpleProfileFragment extends SubscriberFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
try {
|
View layout = inflater.inflate(R.layout.simpleprofile_fragment, container, false);
|
||||||
View layout = inflater.inflate(R.layout.simpleprofile_fragment, container, false);
|
diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
|
||||||
diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
|
mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
|
||||||
mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
|
mmolView = (RadioButton) layout.findViewById(R.id.simpleprofile_mmol);
|
||||||
mmolView = (RadioButton) layout.findViewById(R.id.simpleprofile_mmol);
|
icView = (EditText) layout.findViewById(R.id.simpleprofile_ic);
|
||||||
icView = (EditText) layout.findViewById(R.id.simpleprofile_ic);
|
isfView = (EditText) layout.findViewById(R.id.simpleprofile_isf);
|
||||||
isfView = (EditText) layout.findViewById(R.id.simpleprofile_isf);
|
basalView = (EditText) layout.findViewById(R.id.simpleprofile_basalrate);
|
||||||
basalView = (EditText) layout.findViewById(R.id.simpleprofile_basalrate);
|
targetlowView = (EditText) layout.findViewById(R.id.simpleprofile_targetlow);
|
||||||
targetlowView = (EditText) layout.findViewById(R.id.simpleprofile_targetlow);
|
targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
|
||||||
targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
|
profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
|
||||||
profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
|
invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile);
|
||||||
invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile);
|
|
||||||
|
|
||||||
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
|
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
|
||||||
layout.findViewById(R.id.simpleprofile_basalrate).setVisibility(View.GONE);
|
layout.findViewById(R.id.simpleprofile_basalrate).setVisibility(View.GONE);
|
||||||
layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
|
layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
|
||||||
}
|
|
||||||
|
|
||||||
mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
|
|
||||||
mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
|
|
||||||
diaView.setText(SimpleProfilePlugin.getPlugin().dia.toString());
|
|
||||||
icView.setText(SimpleProfilePlugin.getPlugin().ic.toString());
|
|
||||||
isfView.setText(SimpleProfilePlugin.getPlugin().isf.toString());
|
|
||||||
basalView.setText(SimpleProfilePlugin.getPlugin().basal.toString());
|
|
||||||
targetlowView.setText(SimpleProfilePlugin.getPlugin().targetLow.toString());
|
|
||||||
targethighView.setText(SimpleProfilePlugin.getPlugin().targetHigh.toString());
|
|
||||||
|
|
||||||
mgdlView.setOnClickListener(v -> {
|
|
||||||
SimpleProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
|
|
||||||
SimpleProfilePlugin.getPlugin().mmol = !SimpleProfilePlugin.getPlugin().mgdl;
|
|
||||||
mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
|
|
||||||
SimpleProfilePlugin.getPlugin().storeSettings();
|
|
||||||
});
|
|
||||||
mmolView.setOnClickListener(v -> {
|
|
||||||
SimpleProfilePlugin.getPlugin().mmol = mmolView.isChecked();
|
|
||||||
SimpleProfilePlugin.getPlugin().mgdl = !SimpleProfilePlugin.getPlugin().mmol;
|
|
||||||
mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
|
|
||||||
SimpleProfilePlugin.getPlugin().storeSettings();
|
|
||||||
});
|
|
||||||
|
|
||||||
profileswitchButton.setOnClickListener(view -> {
|
|
||||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
|
||||||
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCH;
|
|
||||||
profileswitch.executeProfileSwitch = true;
|
|
||||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
|
||||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
|
||||||
});
|
|
||||||
|
|
||||||
TextWatcher textWatch = new TextWatcher() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start,
|
|
||||||
int count, int after) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start,
|
|
||||||
int before, int count) {
|
|
||||||
SimpleProfilePlugin.getPlugin().dia = SafeParse.stringToDouble(diaView.getText().toString());
|
|
||||||
SimpleProfilePlugin.getPlugin().ic = SafeParse.stringToDouble(icView.getText().toString());
|
|
||||||
SimpleProfilePlugin.getPlugin().isf = SafeParse.stringToDouble(isfView.getText().toString());
|
|
||||||
SimpleProfilePlugin.getPlugin().basal = SafeParse.stringToDouble(basalView.getText().toString());
|
|
||||||
SimpleProfilePlugin.getPlugin().targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
|
|
||||||
SimpleProfilePlugin.getPlugin().targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
|
|
||||||
SimpleProfilePlugin.getPlugin().storeSettings();
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
diaView.addTextChangedListener(textWatch);
|
|
||||||
icView.addTextChangedListener(textWatch);
|
|
||||||
isfView.addTextChangedListener(textWatch);
|
|
||||||
basalView.addTextChangedListener(textWatch);
|
|
||||||
targetlowView.addTextChangedListener(textWatch);
|
|
||||||
targethighView.addTextChangedListener(textWatch);
|
|
||||||
|
|
||||||
return layout;
|
|
||||||
} catch (Exception e) {
|
|
||||||
FabricPrivacy.logException(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
|
||||||
|
mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
|
||||||
|
diaView.setText(SimpleProfilePlugin.getPlugin().dia.toString());
|
||||||
|
icView.setText(SimpleProfilePlugin.getPlugin().ic.toString());
|
||||||
|
isfView.setText(SimpleProfilePlugin.getPlugin().isf.toString());
|
||||||
|
basalView.setText(SimpleProfilePlugin.getPlugin().basal.toString());
|
||||||
|
targetlowView.setText(SimpleProfilePlugin.getPlugin().targetLow.toString());
|
||||||
|
targethighView.setText(SimpleProfilePlugin.getPlugin().targetHigh.toString());
|
||||||
|
|
||||||
|
mgdlView.setOnClickListener(v -> {
|
||||||
|
SimpleProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
|
||||||
|
SimpleProfilePlugin.getPlugin().mmol = !SimpleProfilePlugin.getPlugin().mgdl;
|
||||||
|
mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
|
||||||
|
SimpleProfilePlugin.getPlugin().storeSettings();
|
||||||
|
});
|
||||||
|
mmolView.setOnClickListener(v -> {
|
||||||
|
SimpleProfilePlugin.getPlugin().mmol = mmolView.isChecked();
|
||||||
|
SimpleProfilePlugin.getPlugin().mgdl = !SimpleProfilePlugin.getPlugin().mmol;
|
||||||
|
mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
|
||||||
|
SimpleProfilePlugin.getPlugin().storeSettings();
|
||||||
|
});
|
||||||
|
|
||||||
|
profileswitchButton.setOnClickListener(view -> {
|
||||||
|
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||||
|
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCH;
|
||||||
|
profileswitch.executeProfileSwitch = true;
|
||||||
|
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||||
|
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
|
});
|
||||||
|
|
||||||
|
TextWatcher textWatch = new TextWatcher() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start,
|
||||||
|
int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start,
|
||||||
|
int before, int count) {
|
||||||
|
SimpleProfilePlugin.getPlugin().dia = SafeParse.stringToDouble(diaView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().ic = SafeParse.stringToDouble(icView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().isf = SafeParse.stringToDouble(isfView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().basal = SafeParse.stringToDouble(basalView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().storeSettings();
|
||||||
|
updateGUI();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
diaView.addTextChangedListener(textWatch);
|
||||||
|
icView.addTextChangedListener(textWatch);
|
||||||
|
isfView.addTextChangedListener(textWatch);
|
||||||
|
basalView.addTextChangedListener(textWatch);
|
||||||
|
targetlowView.addTextChangedListener(textWatch);
|
||||||
|
targethighView.addTextChangedListener(textWatch);
|
||||||
|
|
||||||
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
|
||||||
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;
|
||||||
|
@ -19,13 +18,14 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class SimpleProfilePlugin extends PluginBase implements ProfileInterface {
|
public class SimpleProfilePlugin extends PluginBase implements ProfileInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(SimpleProfilePlugin.class);
|
private static Logger log = LoggerFactory.getLogger(L.PROFILE);
|
||||||
|
|
||||||
private static SimpleProfilePlugin simpleProfilePlugin;
|
private static SimpleProfilePlugin simpleProfilePlugin;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class SimpleProfilePlugin extends PluginBase implements ProfileInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeSettings() {
|
public void storeSettings() {
|
||||||
if (Config.logPrefsChange)
|
if (L.isEnabled(L.PROFILE))
|
||||||
log.debug("Storing settings");
|
log.debug("Storing settings");
|
||||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
SharedPreferences.Editor editor = settings.edit();
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
@ -73,13 +73,13 @@ public class SimpleProfilePlugin extends PluginBase implements ProfileInterface
|
||||||
|
|
||||||
editor.apply();
|
editor.apply();
|
||||||
createConvertedProfile();
|
createConvertedProfile();
|
||||||
if (Config.logPrefsChange)
|
if (L.isEnabled(L.PROFILE))
|
||||||
log.debug("Storing settings: " + getRawProfile().getData().toString());
|
log.debug("Storing settings: " + getRawProfile().getData().toString());
|
||||||
MainApp.bus().post(new EventProfileStoreChanged());
|
MainApp.bus().post(new EventProfileStoreChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadSettings() {
|
private void loadSettings() {
|
||||||
if (Config.logPrefsChange)
|
if (L.isEnabled(L.PROFILE))
|
||||||
log.debug("Loading stored settings");
|
log.debug("Loading stored settings");
|
||||||
|
|
||||||
mgdl = SP.getBoolean("SimpleProfile" + "mgdl", true);
|
mgdl = SP.getBoolean("SimpleProfile" + "mgdl", true);
|
||||||
|
|
Loading…
Reference in a new issue