From 082414f0d3c7ce84d568e0bb4898a9754910b6a8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 24 Sep 2017 10:39:54 +0200 Subject: [PATCH] CPP support to profile switch --- .../info/nightscout/androidaps/Constants.java | 2 + .../androidaps/db/ProfileSwitch.java | 8 ++ .../Careportal/CareportalFragment.java | 41 +++---- .../Dialogs/NewNSTreatmentDialog.java | 111 +++++++++--------- .../plugins/Careportal/OptionsToShow.java | 3 + .../ConfigBuilder/ConfigBuilderPlugin.java | 2 +- .../plugins/Overview/OverviewFragment.java | 2 +- .../CircadianPercentageProfileFragment.java | 2 +- .../CircadianPercentageProfilePlugin.java | 2 +- .../ProfileLocal/LocalProfileFragment.java | 2 +- .../ProfileSimple/SimpleProfileFragment.java | 2 +- .../fragments/ProfileViewerDialog.java | 2 +- .../TreatmentsProfileSwitchFragment.java | 2 +- .../careportal_newnstreatment_dialog.xml | 66 +++++++++++ .../layout/treatments_profileswitch_item.xml | 47 ++++---- app/src/main/res/values/strings.xml | 2 + 16 files changed, 192 insertions(+), 104 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/Constants.java b/app/src/main/java/info/nightscout/androidaps/Constants.java index e361e4cc8c..c31b120a3c 100644 --- a/app/src/main/java/info/nightscout/androidaps/Constants.java +++ b/app/src/main/java/info/nightscout/androidaps/Constants.java @@ -32,6 +32,8 @@ public class Constants { // Circadian Percentage Profile public static final int CPP_MIN_PERCENTAGE = 50; 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 // First value is the Lowest and second value is the Highest a Limit can define diff --git a/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java b/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java index 72dd268776..1d73016384 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java +++ b/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java @@ -65,6 +65,14 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface { return profile; } + public String getCustomizedName() { + String name = profileName; + if (isCPP) { + name += "(" + percentage + "%," + timeshift + "h)"; + } + return name; + } + public boolean isEqual(ProfileSwitch other) { if (date != other.date) { return false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java index 2353fa6645..4db2491b4e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java @@ -47,26 +47,27 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli } // 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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, 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, true, 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, true, false, false, false, true, 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, 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, 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, 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, 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, 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, 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, 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, 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, false, true, false, false, true, 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 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 public View onCreateView(LayoutInflater inflater, ViewGroup container, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java index cc337d6c00..4afa4c15c6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java @@ -52,7 +52,6 @@ import info.nightscout.androidaps.events.EventNewBasalProfile; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; -import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin; import info.nightscout.utils.DateUtil; import info.nightscout.utils.NSUpload; import info.nightscout.utils.NumberPicker; @@ -73,17 +72,9 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick String units; TextView eventTypeText; - LinearLayout layoutBg; - LinearLayout layoutBgSource; - LinearLayout layoutInsulin; - LinearLayout layoutCarbs; - LinearLayout layoutSplit; - LinearLayout layoutDuration; LinearLayout layoutPercent; LinearLayout layoutAbsolute; - LinearLayout layoutCarbTime; - LinearLayout layoutProfile; - LinearLayout layoutTempTarget; + TextView dateButton; TextView timeButton; @@ -104,6 +95,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick NumberPicker editAbsolute; NumberPicker editCarbTime; NumberPicker editTemptarget; + NumberPicker editPercentage; + NumberPicker editTimeshift; Date eventTime; @@ -144,17 +137,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick setStyle(DialogFragment.STYLE_NORMAL, getTheme()); 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); 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.setText(event); @@ -297,18 +281,26 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick editCarbTime = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput); 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); - showOrHide(layoutBgSource, options.bg); - showOrHide(layoutInsulin, options.insulin); - showOrHide(layoutCarbs, options.carbs); - showOrHide(layoutSplit, options.split); - showOrHide(layoutDuration, options.duration); + editTimeshift = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_timeshift); + editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false); + + showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_eventtime_layout), options.date); + showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_bg_layout), options.bg); + 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(layoutAbsolute, options.absolute); - showOrHide(layoutCarbTime, options.prebolus); - showOrHide(layoutProfile, options.profile); - showOrHide(layoutTempTarget, options.tempTarget); + showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout), options.prebolus); + showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_profile_layout), options.profile); + 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; } @@ -451,7 +443,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick allowZeroDuration = true; break; } - if (SafeParse.stringToDouble(editBg.getText()) != 0d) { + if (options.bg && SafeParse.stringToDouble(editBg.getText()) != 0d) { data.put("glucose", SafeParse.stringToDouble(editBg.getText())); if (meterRadioButton.isChecked()) data.put("glucoseType", "Finger"); 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())); if (options.profile && profileSpinner.getSelectedItem() != null) 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) data.put("preBolus", SafeParse.stringToDouble(editCarbTime.getText())); if (!notesEdit.getText().toString().equals("")) @@ -556,6 +552,18 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick ret += data.get("profile"); 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")) { ret += getString(R.string.target_range); ret += " "; @@ -594,7 +602,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick if (options.executeProfileSwitch) { if (data.has("profile")) { 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) { log.error("Unhandled exception", e); } @@ -641,33 +649,30 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick 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() { @Override public void run() { - ProfileSwitch profileSwitch = new ProfileSwitch(); - profileSwitch.date = System.currentTimeMillis(); - profileSwitch.source = Source.USER; - profileSwitch.profileName = profileName; - profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString(); - profileSwitch.profilePlugin = ConfigBuilderPlugin.getActiveProfileInterface().getClass().getName(); - profileSwitch.durationInMinutes = duration; - if (ConfigBuilderPlugin.getActiveProfileInterface() instanceof CircadianPercentageProfilePlugin) { - CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) ConfigBuilderPlugin.getActiveProfileInterface(); - profileSwitch.isCPP = true; - profileSwitch.timeshift = cpp.timeshift; - profileSwitch.percentage = cpp.percentage; - } - MainApp.getConfigBuilder().addToHistoryProfileSwitch(profileSwitch); + ProfileSwitch profileSwitch = new ProfileSwitch(); + profileSwitch.date = System.currentTimeMillis(); + profileSwitch.source = Source.USER; + profileSwitch.profileName = profileName; + profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString(); + profileSwitch.profilePlugin = ConfigBuilderPlugin.getActiveProfileInterface().getClass().getName(); + profileSwitch.durationInMinutes = duration; + profileSwitch.isCPP = percentage != 100 || timeshift != 0; + profileSwitch.timeshift = timeshift; + profileSwitch.percentage = percentage; + MainApp.getConfigBuilder().addToHistoryProfileSwitch(profileSwitch); - PumpInterface pump = MainApp.getConfigBuilder(); - if (pump != null) { - pump.setNewBasalProfile(profileStore.getSpecificProfile(profileName)); - MainApp.bus().post(new EventNewBasalProfile()); - } else { - log.error("No active pump selected"); - } - Answers.getInstance().logCustom(new CustomEvent("ProfileSwitch")); + PumpInterface pump = MainApp.getConfigBuilder(); + if (pump != null) { + pump.setNewBasalProfile(profileStore.getSpecificProfile(profileName)); + MainApp.bus().post(new EventNewBasalProfile()); + } else { + log.error("No active pump selected"); + } + Answers.getInstance().logCustom(new CustomEvent("ProfileSwitch")); } }); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/OptionsToShow.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/OptionsToShow.java index 23ce1dbcde..2685112a44 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/OptionsToShow.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/OptionsToShow.java @@ -7,6 +7,7 @@ package info.nightscout.androidaps.plugins.Careportal; public class OptionsToShow { public int eventType; public int eventName; + public boolean date; public boolean bg; public boolean insulin; public boolean carbs; @@ -24,6 +25,7 @@ public class OptionsToShow { public OptionsToShow(int eventType, int eventName, + boolean date, boolean bg, boolean insulin, boolean carbs, @@ -36,6 +38,7 @@ public class OptionsToShow { boolean tempTarget) { this.eventType = eventType; this.eventName = eventName; + this.date = date; this.bg = bg; this.insulin = insulin; this.carbs = carbs; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index ffc5c3426f..7a15bbabc2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -937,7 +937,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time); if (profileSwitch != null) { if (profileSwitch.profileJson != null) { - return profileSwitch.profileName; + return profileSwitch.getCustomizedName(); } else { Profile profile = activeProfile.getProfile().getSpecificProfile(profileSwitch.profileName); if (profile != null) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 5d1c3e5ca7..2c810bada3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -1093,7 +1093,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, public boolean onLongClick(View view) { view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); - final OptionsToShow profileswitch = CareportalFragment.profileswitch; + final OptionsToShow profileswitch = CareportalFragment.profileswitchdirect; profileswitch.executeProfileSwitch = true; newDialog.setOptions(profileswitch, R.string.careportal_profileswitch); newDialog.show(getFragmentManager(), "NewNSTreatmentDialog"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfileFragment.java index c7d7333aba..e82a5f519d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfileFragment.java @@ -178,7 +178,7 @@ public class CircadianPercentageProfileFragment extends SubscriberFragment { @Override public void onClick(View view) { NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); - final OptionsToShow profileswitch = CareportalFragment.profileswitch; + final OptionsToShow profileswitch = CareportalFragment.profileswitchdirect; profileswitch.executeProfileSwitch = true; newDialog.setOptions(profileswitch, R.string.careportal_profileswitch); newDialog.show(getFragmentManager(), "NewNSTreatmentDialog"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java index 6158a00978..deba685f5a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java @@ -199,7 +199,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte //send profile to pumpe new NewNSTreatmentDialog(); //init - NewNSTreatmentDialog.doProfileSwitch(this.getProfile(), this.getProfileName(), 0); + NewNSTreatmentDialog.doProfileSwitch(this.getProfile(), this.getProfileName(), 0, percentage, timeshift); //return formatted string /*msg += "%: " + this.percentage + " h: +" + this.timeshift; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java index e491a41b1b..685a81db46 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java @@ -103,7 +103,7 @@ public class LocalProfileFragment extends SubscriberFragment { @Override public void onClick(View view) { NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); - final OptionsToShow profileswitch = CareportalFragment.profileswitch; + final OptionsToShow profileswitch = CareportalFragment.profileswitchdirect; profileswitch.executeProfileSwitch = true; newDialog.setOptions(profileswitch, R.string.careportal_profileswitch); newDialog.show(getFragmentManager(), "NewNSTreatmentDialog"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java index 5cf36409b6..3041bb3ab6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java @@ -101,7 +101,7 @@ public class SimpleProfileFragment extends SubscriberFragment { @Override public void onClick(View view) { NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); - final OptionsToShow profileswitch = CareportalFragment.profileswitch; + final OptionsToShow profileswitch = CareportalFragment.profileswitchdirect; profileswitch.executeProfileSwitch = true; newDialog.setOptions(profileswitch, R.string.careportal_profileswitch); newDialog.show(getFragmentManager(), "NewNSTreatmentDialog"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/ProfileViewerDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/ProfileViewerDialog.java index 2d5fed0541..42e36bba27 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/ProfileViewerDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/ProfileViewerDialog.java @@ -95,7 +95,7 @@ public class ProfileViewerDialog extends DialogFragment { noProfile.setVisibility(View.GONE); units.setText(profile.getUnits()); dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h"); - activeProfile.setText(profileSwitch.profileName); + activeProfile.setText(profileSwitch.getCustomizedName()); dateTextView.setText(DateUtil.dateAndTimeString(profileSwitch.date)); ic.setText(profile.getIcList()); isf.setText(profile.getIsfList()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java index 7fcca51e67..e5655cdb18 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java @@ -74,7 +74,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen } else { holder.duration.setText(""); } - holder.name.setText(profileSwitch.profileName); + holder.name.setText(profileSwitch.getCustomizedName()); if (profileSwitch.isInProgress()) holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive)); else diff --git a/app/src/main/res/layout/careportal_newnstreatment_dialog.xml b/app/src/main/res/layout/careportal_newnstreatment_dialog.xml index 5128262950..09d8a458a4 100644 --- a/app/src/main/res/layout/careportal_newnstreatment_dialog.xml +++ b/app/src/main/res/layout/careportal_newnstreatment_dialog.xml @@ -354,6 +354,72 @@ + + + + + + + + + + + + + + + + + + + + @@ -23,56 +23,59 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:gravity="center_vertical|right" - android:paddingLeft="10dp" - android:paddingRight="5dp" + android:gravity="center_vertical|end" + android:paddingEnd="5dp" + android:paddingStart="10dp" android:text="{fa-clock-o}" /> + + + + - - @@ -80,18 +83,16 @@ android:id="@+id/profileswitch_remove" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="10dp" - android:paddingRight="5dp" + android:paddingEnd="5dp" + android:paddingStart="10dp" android:text="@string/overview_quickwizard_item_remove_button" android:textAlignment="viewEnd" android:textColor="@android:color/holo_orange_light" /> - wizard_include_trend_bg wizard_include_bolus_iob wizard_include_basal_iob + Percentage + Time shift