CPP support to profile switch
This commit is contained in:
parent
349b27e31a
commit
082414f0d3
|
@ -32,6 +32,8 @@ public class Constants {
|
||||||
// Circadian Percentage Profile
|
// Circadian Percentage Profile
|
||||||
public static final int CPP_MIN_PERCENTAGE = 50;
|
public static final int CPP_MIN_PERCENTAGE = 50;
|
||||||
public static final int CPP_MAX_PERCENTAGE = 200;
|
public static final int CPP_MAX_PERCENTAGE = 200;
|
||||||
|
public static final int CPP_MIN_TIMESHIFT = -6;
|
||||||
|
public static final int CPP_MAX_TIMESHIFT = 6;
|
||||||
|
|
||||||
// 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
|
||||||
|
|
|
@ -65,6 +65,14 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCustomizedName() {
|
||||||
|
String name = profileName;
|
||||||
|
if (isCPP) {
|
||||||
|
name += "(" + percentage + "%," + timeshift + "h)";
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEqual(ProfileSwitch other) {
|
public boolean isEqual(ProfileSwitch other) {
|
||||||
if (date != other.date) {
|
if (date != other.date) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -47,26 +47,27 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
}
|
}
|
||||||
|
|
||||||
// bg,insulin,carbs,prebolus,duration,percent,absolute,profile,split,temptarget
|
// bg,insulin,carbs,prebolus,duration,percent,absolute,profile,split,temptarget
|
||||||
public static final OptionsToShow bgcheck = new OptionsToShow(R.id.careportal_bgcheck, R.string.careportal_bgcheck, true, true, true, false, false, false, false, false, false, false);
|
public static final OptionsToShow bgcheck = new OptionsToShow(R.id.careportal_bgcheck, R.string.careportal_bgcheck, true, true, true, true, false, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow snackbolus = new OptionsToShow(R.id.careportal_snackbolus, R.string.careportal_snackbolus, true, true, true, true, false, false, false, false, false, false);
|
public static final OptionsToShow snackbolus = new OptionsToShow(R.id.careportal_snackbolus, R.string.careportal_snackbolus, true, true, true, true, true, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow mealbolus = new OptionsToShow(R.id.careportal_mealbolus, R.string.careportal_mealbolus, true, true, true, true, false, false, false, false, false, false);
|
public static final OptionsToShow mealbolus = new OptionsToShow(R.id.careportal_mealbolus, R.string.careportal_mealbolus, true, true, true, true, true, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow correctionbolus = new OptionsToShow(R.id.careportal_correctionbolus, R.string.careportal_correctionbolus, true, true, true, true, false, false, false, false, false, false);
|
public static final OptionsToShow correctionbolus = new OptionsToShow(R.id.careportal_correctionbolus, R.string.careportal_correctionbolus, true, true, true, true, true, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow carbcorrection = new OptionsToShow(R.id.careportal_carbscorrection, R.string.careportal_carbscorrection, true, false, true, false, false, false, false, false, false, false);
|
public static final OptionsToShow carbcorrection = new OptionsToShow(R.id.careportal_carbscorrection, R.string.careportal_carbscorrection, true, true, false, true, false, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow combobolus = new OptionsToShow(R.id.careportal_combobolus, R.string.careportal_combobolus, true, true, true, true, true, false, false, false, true, false);
|
public static final OptionsToShow combobolus = new OptionsToShow(R.id.careportal_combobolus, R.string.careportal_combobolus, true, true, true, true, true, true, false, false, false, true, false);
|
||||||
public static final OptionsToShow announcement = new OptionsToShow(R.id.careportal_announcement, R.string.careportal_announcement, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow announcement = new OptionsToShow(R.id.careportal_announcement, R.string.careportal_announcement, true, true, false, false, false, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow note = new OptionsToShow(R.id.careportal_note, R.string.careportal_note, true, false, false, false, true, false, false, false, false, false);
|
public static final OptionsToShow note = new OptionsToShow(R.id.careportal_note, R.string.careportal_note, true, true, false, false, false, true, false, false, false, false, false);
|
||||||
public static final OptionsToShow question = new OptionsToShow(R.id.careportal_question, R.string.careportal_question, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow question = new OptionsToShow(R.id.careportal_question, R.string.careportal_question, true, true, false, false, false, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow exercise = new OptionsToShow(R.id.careportal_exercise, R.string.careportal_exercise, false, false, false, false, true, false, false, false, false, false);
|
public static final OptionsToShow exercise = new OptionsToShow(R.id.careportal_exercise, R.string.careportal_exercise, true, false, false, false, false, true, false, false, false, false, false);
|
||||||
public static final OptionsToShow sitechange = new OptionsToShow(R.id.careportal_pumpsitechange, R.string.careportal_pumpsitechange, true, true, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow sitechange = new OptionsToShow(R.id.careportal_pumpsitechange, R.string.careportal_pumpsitechange, true, true, true, false, false, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow sensorstart = new OptionsToShow(R.id.careportal_cgmsensorstart, R.string.careportal_cgmsensorstart, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow sensorstart = new OptionsToShow(R.id.careportal_cgmsensorstart, R.string.careportal_cgmsensorstart, true, true, false, false, false, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow sensorchange = new OptionsToShow(R.id.careportal_cgmsensorinsert, R.string.careportal_cgmsensorinsert, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow sensorchange = new OptionsToShow(R.id.careportal_cgmsensorinsert, R.string.careportal_cgmsensorinsert, true, true, false, false, false, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow insulinchange = new OptionsToShow(R.id.careportal_insulincartridgechange, R.string.careportal_insulincartridgechange, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow insulinchange = new OptionsToShow(R.id.careportal_insulincartridgechange, R.string.careportal_insulincartridgechange, true, true, false, false, false, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow pumpbatterychange = new OptionsToShow(R.id.careportal_pumpbatterychange, R.string.careportal_pumpbatterychange, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow pumpbatterychange = new OptionsToShow(R.id.careportal_pumpbatterychange, R.string.careportal_pumpbatterychange, true, true, false, false, false, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow tempbasalstart = new OptionsToShow(R.id.careportal_tempbasalstart, R.string.careportal_tempbasalstart, true, false, false, false, true, true, true, false, false, false);
|
public static final OptionsToShow tempbasalstart = new OptionsToShow(R.id.careportal_tempbasalstart, R.string.careportal_tempbasalstart, true, true, false, false, false, true, true, true, false, false, false);
|
||||||
public static final OptionsToShow tempbasalend = new OptionsToShow(R.id.careportal_tempbasalend, R.string.careportal_tempbasalend, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow tempbasalend = new OptionsToShow(R.id.careportal_tempbasalend, R.string.careportal_tempbasalend, true, true, false, false, false, false, false, false, false, false, false);
|
||||||
public static final OptionsToShow profileswitch = new OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch, true, false, false, false, true, false, false, true, false, false);
|
public static final OptionsToShow profileswitch = new OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch, true, false, false, false, false, true, false, false, true, false, false);
|
||||||
public static final OptionsToShow openapsoffline = new OptionsToShow(R.id.careportal_openapsoffline, R.string.careportal_openapsoffline, false, false, false, false, true, false, false, false, false, false);
|
public static final OptionsToShow profileswitchdirect = new OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch, false, false, false, false, false, true, false, false, true, false, false);
|
||||||
public static final OptionsToShow temptarget = new OptionsToShow(R.id.careportal_temporarytarget, R.string.careportal_temporarytarget, false, false, false, false, true, false, false, false, false, true);
|
public static final OptionsToShow openapsoffline = new OptionsToShow(R.id.careportal_openapsoffline, R.string.careportal_openapsoffline, true, false, false, false, false, true, false, false, false, false, false);
|
||||||
|
public static final OptionsToShow temptarget = new OptionsToShow(R.id.careportal_temporarytarget, R.string.careportal_temporarytarget, true, false, false, false, false, true, false, false, false, false, true);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
|
|
@ -52,7 +52,6 @@ import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
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.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
|
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.NumberPicker;
|
import info.nightscout.utils.NumberPicker;
|
||||||
|
@ -73,17 +72,9 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
String units;
|
String units;
|
||||||
|
|
||||||
TextView eventTypeText;
|
TextView eventTypeText;
|
||||||
LinearLayout layoutBg;
|
|
||||||
LinearLayout layoutBgSource;
|
|
||||||
LinearLayout layoutInsulin;
|
|
||||||
LinearLayout layoutCarbs;
|
|
||||||
LinearLayout layoutSplit;
|
|
||||||
LinearLayout layoutDuration;
|
|
||||||
LinearLayout layoutPercent;
|
LinearLayout layoutPercent;
|
||||||
LinearLayout layoutAbsolute;
|
LinearLayout layoutAbsolute;
|
||||||
LinearLayout layoutCarbTime;
|
|
||||||
LinearLayout layoutProfile;
|
|
||||||
LinearLayout layoutTempTarget;
|
|
||||||
TextView dateButton;
|
TextView dateButton;
|
||||||
TextView timeButton;
|
TextView timeButton;
|
||||||
|
|
||||||
|
@ -104,6 +95,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
NumberPicker editAbsolute;
|
NumberPicker editAbsolute;
|
||||||
NumberPicker editCarbTime;
|
NumberPicker editCarbTime;
|
||||||
NumberPicker editTemptarget;
|
NumberPicker editTemptarget;
|
||||||
|
NumberPicker editPercentage;
|
||||||
|
NumberPicker editTimeshift;
|
||||||
|
|
||||||
Date eventTime;
|
Date eventTime;
|
||||||
|
|
||||||
|
@ -144,17 +137,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
setStyle(DialogFragment.STYLE_NORMAL, getTheme());
|
setStyle(DialogFragment.STYLE_NORMAL, getTheme());
|
||||||
View view = inflater.inflate(R.layout.careportal_newnstreatment_dialog, container, false);
|
View view = inflater.inflate(R.layout.careportal_newnstreatment_dialog, container, false);
|
||||||
|
|
||||||
layoutBg = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_bg_layout);
|
|
||||||
layoutBgSource = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_bgsource_layout);
|
|
||||||
layoutInsulin = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_insulin_layout);
|
|
||||||
layoutCarbs = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_carbs_layout);
|
|
||||||
layoutSplit = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_split_layout);
|
|
||||||
layoutDuration = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_duration_layout);
|
|
||||||
layoutPercent = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_percent_layout);
|
layoutPercent = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_percent_layout);
|
||||||
layoutAbsolute = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_absolute_layout);
|
layoutAbsolute = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_absolute_layout);
|
||||||
layoutCarbTime = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout);
|
|
||||||
layoutProfile = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_profile_layout);
|
|
||||||
layoutTempTarget = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout);
|
|
||||||
|
|
||||||
eventTypeText = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventtype);
|
eventTypeText = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventtype);
|
||||||
eventTypeText.setText(event);
|
eventTypeText.setText(event);
|
||||||
|
@ -297,18 +281,26 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
editCarbTime = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
|
editCarbTime = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
|
||||||
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
||||||
|
|
||||||
|
editPercentage = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentage);
|
||||||
|
editPercentage.setParams(100d, (double) Constants.CPP_MIN_PERCENTAGE, (double) Constants.CPP_MAX_PERCENTAGE, 5d, new DecimalFormat("0"), false);
|
||||||
|
|
||||||
showOrHide(layoutBg, options.bg);
|
editTimeshift = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_timeshift);
|
||||||
showOrHide(layoutBgSource, options.bg);
|
editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false);
|
||||||
showOrHide(layoutInsulin, options.insulin);
|
|
||||||
showOrHide(layoutCarbs, options.carbs);
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_eventtime_layout), options.date);
|
||||||
showOrHide(layoutSplit, options.split);
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_bg_layout), options.bg);
|
||||||
showOrHide(layoutDuration, options.duration);
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_bgsource_layout), options.bg);
|
||||||
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_insulin_layout), options.insulin);
|
||||||
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_carbs_layout), options.carbs);
|
||||||
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_split_layout), options.split);
|
||||||
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_duration_layout), options.duration);
|
||||||
showOrHide(layoutPercent, options.percent);
|
showOrHide(layoutPercent, options.percent);
|
||||||
showOrHide(layoutAbsolute, options.absolute);
|
showOrHide(layoutAbsolute, options.absolute);
|
||||||
showOrHide(layoutCarbTime, options.prebolus);
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout), options.prebolus);
|
||||||
showOrHide(layoutProfile, options.profile);
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_profile_layout), options.profile);
|
||||||
showOrHide(layoutTempTarget, options.tempTarget);
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_percentage_layout), options.profile);
|
||||||
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_timeshift_layout), options.profile);
|
||||||
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -451,7 +443,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
allowZeroDuration = true;
|
allowZeroDuration = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (SafeParse.stringToDouble(editBg.getText()) != 0d) {
|
if (options.bg && SafeParse.stringToDouble(editBg.getText()) != 0d) {
|
||||||
data.put("glucose", SafeParse.stringToDouble(editBg.getText()));
|
data.put("glucose", SafeParse.stringToDouble(editBg.getText()));
|
||||||
if (meterRadioButton.isChecked()) data.put("glucoseType", "Finger");
|
if (meterRadioButton.isChecked()) data.put("glucoseType", "Finger");
|
||||||
if (sensorRadioButton.isChecked()) data.put("glucoseType", "Sensor");
|
if (sensorRadioButton.isChecked()) data.put("glucoseType", "Sensor");
|
||||||
|
@ -469,6 +461,10 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
data.put("absolute", SafeParse.stringToDouble(editAbsolute.getText()));
|
data.put("absolute", SafeParse.stringToDouble(editAbsolute.getText()));
|
||||||
if (options.profile && profileSpinner.getSelectedItem() != null)
|
if (options.profile && profileSpinner.getSelectedItem() != null)
|
||||||
data.put("profile", profileSpinner.getSelectedItem().toString());
|
data.put("profile", profileSpinner.getSelectedItem().toString());
|
||||||
|
if (options.profile)
|
||||||
|
data.put("percentage", SafeParse.stringToInt(editPercentage.getText()));
|
||||||
|
if (options.profile)
|
||||||
|
data.put("timeshift", SafeParse.stringToInt(editTimeshift.getText()));
|
||||||
if (SafeParse.stringToDouble(editCarbTime.getText()) != 0d)
|
if (SafeParse.stringToDouble(editCarbTime.getText()) != 0d)
|
||||||
data.put("preBolus", SafeParse.stringToDouble(editCarbTime.getText()));
|
data.put("preBolus", SafeParse.stringToDouble(editCarbTime.getText()));
|
||||||
if (!notesEdit.getText().toString().equals(""))
|
if (!notesEdit.getText().toString().equals(""))
|
||||||
|
@ -556,6 +552,18 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
ret += data.get("profile");
|
ret += data.get("profile");
|
||||||
ret += "\n";
|
ret += "\n";
|
||||||
}
|
}
|
||||||
|
if (data.has("percentage")) {
|
||||||
|
ret += getString(R.string.careportal_newnstreatment_percentage_label);
|
||||||
|
ret += ": ";
|
||||||
|
ret += data.get("percentage");
|
||||||
|
ret += " %\n";
|
||||||
|
}
|
||||||
|
if (data.has("timeshift")) {
|
||||||
|
ret += getString(R.string.careportal_newnstreatment_timeshift_label);
|
||||||
|
ret += ": ";
|
||||||
|
ret += data.get("timeshift");
|
||||||
|
ret += " h\n";
|
||||||
|
}
|
||||||
if (data.has("targetBottom") && data.has("targetTop")) {
|
if (data.has("targetBottom") && data.has("targetTop")) {
|
||||||
ret += getString(R.string.target_range);
|
ret += getString(R.string.target_range);
|
||||||
ret += " ";
|
ret += " ";
|
||||||
|
@ -594,7 +602,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
if (options.executeProfileSwitch) {
|
if (options.executeProfileSwitch) {
|
||||||
if (data.has("profile")) {
|
if (data.has("profile")) {
|
||||||
try {
|
try {
|
||||||
doProfileSwitch(profileStore, data.getString("profile"), data.getInt("duration"));
|
doProfileSwitch(profileStore, data.getString("profile"), data.getInt("duration"), data.getInt("percentage"), data.getInt("timeshift"));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
@ -641,7 +649,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void doProfileSwitch(final ProfileStore profileStore, final String profileName, final int duration) {
|
public static void doProfileSwitch(final ProfileStore profileStore, final String profileName, final int duration, final int percentage, final int timeshift) {
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -652,12 +660,9 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString();
|
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString();
|
||||||
profileSwitch.profilePlugin = ConfigBuilderPlugin.getActiveProfileInterface().getClass().getName();
|
profileSwitch.profilePlugin = ConfigBuilderPlugin.getActiveProfileInterface().getClass().getName();
|
||||||
profileSwitch.durationInMinutes = duration;
|
profileSwitch.durationInMinutes = duration;
|
||||||
if (ConfigBuilderPlugin.getActiveProfileInterface() instanceof CircadianPercentageProfilePlugin) {
|
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
||||||
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) ConfigBuilderPlugin.getActiveProfileInterface();
|
profileSwitch.timeshift = timeshift;
|
||||||
profileSwitch.isCPP = true;
|
profileSwitch.percentage = percentage;
|
||||||
profileSwitch.timeshift = cpp.timeshift;
|
|
||||||
profileSwitch.percentage = cpp.percentage;
|
|
||||||
}
|
|
||||||
MainApp.getConfigBuilder().addToHistoryProfileSwitch(profileSwitch);
|
MainApp.getConfigBuilder().addToHistoryProfileSwitch(profileSwitch);
|
||||||
|
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
|
|
|
@ -7,6 +7,7 @@ package info.nightscout.androidaps.plugins.Careportal;
|
||||||
public class OptionsToShow {
|
public class OptionsToShow {
|
||||||
public int eventType;
|
public int eventType;
|
||||||
public int eventName;
|
public int eventName;
|
||||||
|
public boolean date;
|
||||||
public boolean bg;
|
public boolean bg;
|
||||||
public boolean insulin;
|
public boolean insulin;
|
||||||
public boolean carbs;
|
public boolean carbs;
|
||||||
|
@ -24,6 +25,7 @@ public class OptionsToShow {
|
||||||
|
|
||||||
public OptionsToShow(int eventType,
|
public OptionsToShow(int eventType,
|
||||||
int eventName,
|
int eventName,
|
||||||
|
boolean date,
|
||||||
boolean bg,
|
boolean bg,
|
||||||
boolean insulin,
|
boolean insulin,
|
||||||
boolean carbs,
|
boolean carbs,
|
||||||
|
@ -36,6 +38,7 @@ public class OptionsToShow {
|
||||||
boolean tempTarget) {
|
boolean tempTarget) {
|
||||||
this.eventType = eventType;
|
this.eventType = eventType;
|
||||||
this.eventName = eventName;
|
this.eventName = eventName;
|
||||||
|
this.date = date;
|
||||||
this.bg = bg;
|
this.bg = bg;
|
||||||
this.insulin = insulin;
|
this.insulin = insulin;
|
||||||
this.carbs = carbs;
|
this.carbs = carbs;
|
||||||
|
|
|
@ -937,7 +937,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time);
|
ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time);
|
||||||
if (profileSwitch != null) {
|
if (profileSwitch != null) {
|
||||||
if (profileSwitch.profileJson != null) {
|
if (profileSwitch.profileJson != null) {
|
||||||
return profileSwitch.profileName;
|
return profileSwitch.getCustomizedName();
|
||||||
} else {
|
} else {
|
||||||
Profile profile = activeProfile.getProfile().getSpecificProfile(profileSwitch.profileName);
|
Profile profile = activeProfile.getProfile().getSpecificProfile(profileSwitch.profileName);
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
|
|
|
@ -1093,7 +1093,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public boolean onLongClick(View view) {
|
public boolean onLongClick(View view) {
|
||||||
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
final OptionsToShow profileswitch = CareportalFragment.profileswitchdirect;
|
||||||
profileswitch.executeProfileSwitch = true;
|
profileswitch.executeProfileSwitch = true;
|
||||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
|
|
|
@ -178,7 +178,7 @@ public class CircadianPercentageProfileFragment extends SubscriberFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
final OptionsToShow profileswitch = CareportalFragment.profileswitchdirect;
|
||||||
profileswitch.executeProfileSwitch = true;
|
profileswitch.executeProfileSwitch = true;
|
||||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
|
|
|
@ -199,7 +199,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
|
|
||||||
//send profile to pumpe
|
//send profile to pumpe
|
||||||
new NewNSTreatmentDialog(); //init
|
new NewNSTreatmentDialog(); //init
|
||||||
NewNSTreatmentDialog.doProfileSwitch(this.getProfile(), this.getProfileName(), 0);
|
NewNSTreatmentDialog.doProfileSwitch(this.getProfile(), this.getProfileName(), 0, percentage, timeshift);
|
||||||
|
|
||||||
//return formatted string
|
//return formatted string
|
||||||
/*msg += "%: " + this.percentage + " h: +" + this.timeshift;
|
/*msg += "%: " + this.percentage + " h: +" + this.timeshift;
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class LocalProfileFragment extends SubscriberFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
final OptionsToShow profileswitch = CareportalFragment.profileswitchdirect;
|
||||||
profileswitch.executeProfileSwitch = true;
|
profileswitch.executeProfileSwitch = true;
|
||||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class SimpleProfileFragment extends SubscriberFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
final OptionsToShow profileswitch = CareportalFragment.profileswitchdirect;
|
||||||
profileswitch.executeProfileSwitch = true;
|
profileswitch.executeProfileSwitch = true;
|
||||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class ProfileViewerDialog extends DialogFragment {
|
||||||
noProfile.setVisibility(View.GONE);
|
noProfile.setVisibility(View.GONE);
|
||||||
units.setText(profile.getUnits());
|
units.setText(profile.getUnits());
|
||||||
dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h");
|
dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h");
|
||||||
activeProfile.setText(profileSwitch.profileName);
|
activeProfile.setText(profileSwitch.getCustomizedName());
|
||||||
dateTextView.setText(DateUtil.dateAndTimeString(profileSwitch.date));
|
dateTextView.setText(DateUtil.dateAndTimeString(profileSwitch.date));
|
||||||
ic.setText(profile.getIcList());
|
ic.setText(profile.getIcList());
|
||||||
isf.setText(profile.getIsfList());
|
isf.setText(profile.getIsfList());
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
|
||||||
} else {
|
} else {
|
||||||
holder.duration.setText("");
|
holder.duration.setText("");
|
||||||
}
|
}
|
||||||
holder.name.setText(profileSwitch.profileName);
|
holder.name.setText(profileSwitch.getCustomizedName());
|
||||||
if (profileSwitch.isInProgress())
|
if (profileSwitch.isInProgress())
|
||||||
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
||||||
else
|
else
|
||||||
|
|
|
@ -354,6 +354,72 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/careportal_newnstreatment_percentage_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:width="120dp"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="@string/careportal_newnstreatment_percentage_label"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<info.nightscout.utils.NumberPicker
|
||||||
|
android:id="@+id/careportal_newnstreatment_percentage"
|
||||||
|
android:layout_width="130dp"
|
||||||
|
android:layout_height="40dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="left"
|
||||||
|
android:minWidth="45dp"
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:text="%"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/careportal_newnstreatment_timeshift_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:width="120dp"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="@string/careportal_newnstreatment_timeshift_label"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<info.nightscout.utils.NumberPicker
|
||||||
|
android:id="@+id/careportal_newnstreatment_timeshift"
|
||||||
|
android:layout_width="130dp"
|
||||||
|
android:layout_height="40dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="left"
|
||||||
|
android:minWidth="45dp"
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:text="h"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/careportal_newnstreatment_temptarget_layout"
|
android:id="@+id/careportal_newnstreatment_temptarget_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:baselineAligned="true"
|
android:baselineAligned="true"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
@ -23,56 +23,59 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:gravity="center_vertical|right"
|
android:gravity="center_vertical|end"
|
||||||
android:paddingLeft="10dp"
|
android:paddingEnd="5dp"
|
||||||
android:paddingRight="5dp"
|
android:paddingStart="10dp"
|
||||||
android:text="{fa-clock-o}" />
|
android:text="{fa-clock-o}" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/profileswitch_date"
|
android:id="@+id/profileswitch_date"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="10dp"
|
android:paddingStart="10dp"
|
||||||
android:text="1.1.2000 18:00"
|
android:text="1.1.2000 18:00"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/profileswitch_name"
|
android:id="@+id/profileswitch_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="10dp"
|
android:layout_weight="1"
|
||||||
|
android:paddingStart="10dp"
|
||||||
android:text="Name"
|
android:text="Name"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:baselineAligned="true"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/profileswitch_duration"
|
android:id="@+id/profileswitch_duration"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="5dp"
|
android:layout_weight="1"
|
||||||
|
android:paddingStart="10dp"
|
||||||
android:text="60 min"
|
android:text="60 min"
|
||||||
android:textAlignment="viewEnd"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/pump_sign"
|
android:id="@+id/pump_sign"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="10dp"
|
android:paddingEnd="10dp"
|
||||||
android:text="PH"
|
android:text="PH"
|
||||||
|
android:textAlignment="viewEnd"
|
||||||
android:textColor="@color/colorSetTempButton" />
|
android:textColor="@color/colorSetTempButton" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/ns_sign"
|
android:id="@+id/ns_sign"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="10dp"
|
android:paddingEnd="10dp"
|
||||||
android:text="NS"
|
android:text="NS"
|
||||||
android:textColor="@color/colorSetTempButton" />
|
android:textColor="@color/colorSetTempButton" />
|
||||||
|
|
||||||
|
@ -80,18 +83,16 @@
|
||||||
android:id="@+id/profileswitch_remove"
|
android:id="@+id/profileswitch_remove"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="10dp"
|
android:paddingEnd="5dp"
|
||||||
android:paddingRight="5dp"
|
android:paddingStart="10dp"
|
||||||
android:text="@string/overview_quickwizard_item_remove_button"
|
android:text="@string/overview_quickwizard_item_remove_button"
|
||||||
android:textAlignment="viewEnd"
|
android:textAlignment="viewEnd"
|
||||||
android:textColor="@android:color/holo_orange_light" />
|
android:textColor="@android:color/holo_orange_light" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="2dip"
|
android:layout_height="2dip"
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
|
|
|
@ -707,5 +707,7 @@
|
||||||
<string name="key_wizard_include_trend_bg">wizard_include_trend_bg</string>
|
<string name="key_wizard_include_trend_bg">wizard_include_trend_bg</string>
|
||||||
<string name="key_wizard_include_bolus_iob">wizard_include_bolus_iob</string>
|
<string name="key_wizard_include_bolus_iob">wizard_include_bolus_iob</string>
|
||||||
<string name="key_wizard_include_basal_iob">wizard_include_basal_iob</string>
|
<string name="key_wizard_include_basal_iob">wizard_include_basal_iob</string>
|
||||||
|
<string name="careportal_newnstreatment_percentage_label">Percentage</string>
|
||||||
|
<string name="careportal_newnstreatment_timeshift_label">Time shift</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue