Cleanups.
This commit is contained in:
parent
f420491611
commit
10604299e7
3 changed files with 56 additions and 70 deletions
|
@ -50,16 +50,15 @@ import static info.nightscout.utils.DateUtil.now;
|
||||||
public class FillDialog extends DialogFragment implements OnClickListener {
|
public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(FillDialog.class);
|
private static Logger log = LoggerFactory.getLogger(FillDialog.class);
|
||||||
|
|
||||||
|
private CheckBox pumpSiteChangeCheckbox;
|
||||||
|
private CheckBox insulinCartridgeChangeCheckbox;
|
||||||
|
|
||||||
|
private NumberPicker editInsulin;
|
||||||
|
|
||||||
double amount1 = 0d;
|
double amount1 = 0d;
|
||||||
double amount2 = 0d;
|
double amount2 = 0d;
|
||||||
double amount3 = 0d;
|
double amount3 = 0d;
|
||||||
|
|
||||||
CheckBox pumpSiteChangeCheckbox;
|
|
||||||
CheckBox insulinCartridgeChangeCheckbox;
|
|
||||||
|
|
||||||
NumberPicker editInsulin;
|
|
||||||
|
|
||||||
private LinearLayout notesLayout;
|
|
||||||
private EditText notesEdit;
|
private EditText notesEdit;
|
||||||
|
|
||||||
final private TextWatcher textWatcher = new TextWatcher() {
|
final private TextWatcher textWatcher = new TextWatcher() {
|
||||||
|
@ -133,7 +132,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
preset3Button.setVisibility(View.GONE);
|
preset3Button.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
notesLayout = view.findViewById(R.id.fill_notes_layout);
|
LinearLayout notesLayout = view.findViewById(R.id.fill_notes_layout);
|
||||||
notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE);
|
notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE);
|
||||||
notesEdit = view.findViewById(R.id.fill_notes);
|
notesEdit = view.findViewById(R.id.fill_notes);
|
||||||
|
|
||||||
|
|
|
@ -53,28 +53,22 @@ import static info.nightscout.utils.DateUtil.now;
|
||||||
public class NewCarbsDialog extends DialogFragment implements OnClickListener, CompoundButton.OnCheckedChangeListener {
|
public class NewCarbsDialog extends DialogFragment implements OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(NewCarbsDialog.class);
|
private static Logger log = LoggerFactory.getLogger(NewCarbsDialog.class);
|
||||||
|
|
||||||
private Button fav1Button;
|
|
||||||
private Button fav2Button;
|
|
||||||
private Button fav3Button;
|
|
||||||
|
|
||||||
private LinearLayout notesLayout;
|
|
||||||
private EditText notesEdit;
|
|
||||||
|
|
||||||
private static final int FAV1_DEFAULT = 5;
|
private static final int FAV1_DEFAULT = 5;
|
||||||
private static final int FAV2_DEFAULT = 10;
|
private static final int FAV2_DEFAULT = 10;
|
||||||
private static final int FAV3_DEFAULT = 20;
|
private static final int FAV3_DEFAULT = 20;
|
||||||
|
|
||||||
private RadioButton startActivityTTCheckbox;
|
private RadioButton startActivityTTCheckbox;
|
||||||
private RadioButton startEatingSoonTTCheckbox;
|
private RadioButton startEatingSoonTTCheckbox;
|
||||||
private RadioButton startHypoTTCheckbox;
|
private RadioButton startHypoTTCheckbox;
|
||||||
private boolean togglingTT;
|
private boolean togglingTT;
|
||||||
|
|
||||||
private NumberPicker editTime;
|
private NumberPicker editTime;
|
||||||
private LinearLayout durationLayout;
|
|
||||||
private NumberPicker editDuration;
|
private NumberPicker editDuration;
|
||||||
private NumberPicker editCarbs;
|
private NumberPicker editCarbs;
|
||||||
|
|
||||||
private Integer maxCarbs;
|
private Integer maxCarbs;
|
||||||
|
|
||||||
|
private EditText notesEdit;
|
||||||
|
|
||||||
//one shot guards
|
//one shot guards
|
||||||
private boolean accepted;
|
private boolean accepted;
|
||||||
private boolean okClicked;
|
private boolean okClicked;
|
||||||
|
@ -128,11 +122,6 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||||
|
|
||||||
maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
|
||||||
|
|
||||||
editCarbs = view.findViewById(R.id.newcarb_carbsamount);
|
|
||||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
|
||||||
|
|
||||||
startActivityTTCheckbox = view.findViewById(R.id.newcarbs_activity_tt);
|
startActivityTTCheckbox = view.findViewById(R.id.newcarbs_activity_tt);
|
||||||
startActivityTTCheckbox.setOnCheckedChangeListener(this);
|
startActivityTTCheckbox.setOnCheckedChangeListener(this);
|
||||||
startEatingSoonTTCheckbox = view.findViewById(R.id.newcarbs_eating_soon_tt);
|
startEatingSoonTTCheckbox = view.findViewById(R.id.newcarbs_eating_soon_tt);
|
||||||
|
@ -143,25 +132,30 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
editTime = view.findViewById(R.id.newcarbs_time);
|
editTime = view.findViewById(R.id.newcarbs_time);
|
||||||
editTime.setParams(0d, -12 * 60d, 12 * 60d, 5d, new DecimalFormat("0"), false, textWatcher);
|
editTime.setParams(0d, -12 * 60d, 12 * 60d, 5d, new DecimalFormat("0"), false, textWatcher);
|
||||||
|
|
||||||
durationLayout = view.findViewById(R.id.newcarbs_duration_layout);
|
LinearLayout durationLayout = view.findViewById(R.id.newcarbs_duration_layout);
|
||||||
durationLayout.setVisibility(MainApp.engineeringMode ? View.VISIBLE : View.GONE);
|
durationLayout.setVisibility(MainApp.engineeringMode ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
editDuration = view.findViewById(R.id.new_carbs_duration);
|
editDuration = view.findViewById(R.id.new_carbs_duration);
|
||||||
editDuration.setParams(0d, 0d, 10d, 1d, new DecimalFormat("0"), false, textWatcher);
|
editDuration.setParams(0d, 0d, 10d, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||||
|
|
||||||
fav1Button = view.findViewById(R.id.newcarbs_plus1);
|
maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||||
|
|
||||||
|
editCarbs = view.findViewById(R.id.newcarb_carbsamount);
|
||||||
|
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||||
|
|
||||||
|
Button fav1Button = view.findViewById(R.id.newcarbs_plus1);
|
||||||
fav1Button.setOnClickListener(this);
|
fav1Button.setOnClickListener(this);
|
||||||
fav1Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_1, FAV1_DEFAULT)));
|
fav1Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_1, FAV1_DEFAULT)));
|
||||||
|
|
||||||
fav2Button = view.findViewById(R.id.newcarbs_plus2);
|
Button fav2Button = view.findViewById(R.id.newcarbs_plus2);
|
||||||
fav2Button.setOnClickListener(this);
|
fav2Button.setOnClickListener(this);
|
||||||
fav2Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_2, FAV2_DEFAULT)));
|
fav2Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_2, FAV2_DEFAULT)));
|
||||||
|
|
||||||
fav3Button = view.findViewById(R.id.newcarbs_plus3);
|
Button fav3Button = view.findViewById(R.id.newcarbs_plus3);
|
||||||
fav3Button.setOnClickListener(this);
|
fav3Button.setOnClickListener(this);
|
||||||
fav3Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_3, FAV3_DEFAULT)));
|
fav3Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_3, FAV3_DEFAULT)));
|
||||||
|
|
||||||
notesLayout = view.findViewById(R.id.newcarbs_notes_layout);
|
LinearLayout notesLayout = view.findViewById(R.id.newcarbs_notes_layout);
|
||||||
notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE);
|
notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE);
|
||||||
notesEdit = view.findViewById(R.id.newcarbs_notes);
|
notesEdit = view.findViewById(R.id.newcarbs_notes);
|
||||||
|
|
||||||
|
@ -336,7 +330,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
int timeOffset = editTime.getValue().intValue();
|
int timeOffset = editTime.getValue().intValue();
|
||||||
final long time = now() + timeOffset * 1000 * 60;
|
final long time = now() + timeOffset * 1000 * 60;
|
||||||
if (timeOffset != 0) {
|
if (timeOffset != 0) {
|
||||||
actions.add("Time: " + DateUtil.dateAndTimeString(time));
|
actions.add(MainApp.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time));
|
||||||
}
|
}
|
||||||
int duration = editDuration.getValue().intValue();
|
int duration = editDuration.getValue().intValue();
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
|
|
|
@ -55,16 +55,6 @@ import static info.nightscout.utils.DateUtil.now;
|
||||||
public class NewInsulinDialog extends DialogFragment implements OnClickListener {
|
public class NewInsulinDialog extends DialogFragment implements OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(NewInsulinDialog.class);
|
private static Logger log = LoggerFactory.getLogger(NewInsulinDialog.class);
|
||||||
|
|
||||||
private LinearLayout editLayout;
|
|
||||||
private NumberPicker editTime;
|
|
||||||
private NumberPicker editInsulin;
|
|
||||||
private LinearLayout notesLayout;
|
|
||||||
private EditText notesEdit;
|
|
||||||
|
|
||||||
private Button plus1Button;
|
|
||||||
private Button plus2Button;
|
|
||||||
private Button plus3Button;
|
|
||||||
|
|
||||||
public static final double PLUS1_DEFAULT = 0.5d;
|
public static final double PLUS1_DEFAULT = 0.5d;
|
||||||
public static final double PLUS2_DEFAULT = 1d;
|
public static final double PLUS2_DEFAULT = 1d;
|
||||||
public static final double PLUS3_DEFAULT = 2d;
|
public static final double PLUS3_DEFAULT = 2d;
|
||||||
|
@ -72,8 +62,13 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
||||||
private CheckBox startESMCheckbox;
|
private CheckBox startESMCheckbox;
|
||||||
private CheckBox recordOnlyCheckbox;
|
private CheckBox recordOnlyCheckbox;
|
||||||
|
|
||||||
|
private LinearLayout editLayout;
|
||||||
|
private NumberPicker editTime;
|
||||||
|
private NumberPicker editInsulin;
|
||||||
private Double maxInsulin;
|
private Double maxInsulin;
|
||||||
|
|
||||||
|
private EditText notesEdit;
|
||||||
|
|
||||||
//one shot guards
|
//one shot guards
|
||||||
private boolean accepted;
|
private boolean accepted;
|
||||||
private boolean okClicked;
|
private boolean okClicked;
|
||||||
|
@ -137,17 +132,17 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
||||||
editInsulin = view.findViewById(R.id.newinsulin_amount);
|
editInsulin = view.findViewById(R.id.newinsulin_amount);
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
||||||
|
|
||||||
plus1Button = view.findViewById(R.id.newinsulin_plus05);
|
Button plus1Button = view.findViewById(R.id.newinsulin_plus05);
|
||||||
plus1Button.setOnClickListener(this);
|
plus1Button.setOnClickListener(this);
|
||||||
plus1Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_1), PLUS1_DEFAULT)));
|
plus1Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_1), PLUS1_DEFAULT)));
|
||||||
plus2Button = view.findViewById(R.id.newinsulin_plus10);
|
Button plus2Button = view.findViewById(R.id.newinsulin_plus10);
|
||||||
plus2Button.setOnClickListener(this);
|
plus2Button.setOnClickListener(this);
|
||||||
plus2Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_2), PLUS2_DEFAULT)));
|
plus2Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_2), PLUS2_DEFAULT)));
|
||||||
plus3Button = view.findViewById(R.id.newinsulin_plus20);
|
Button plus3Button = view.findViewById(R.id.newinsulin_plus20);
|
||||||
plus3Button.setOnClickListener(this);
|
plus3Button.setOnClickListener(this);
|
||||||
plus3Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_3), PLUS3_DEFAULT)));
|
plus3Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_3), PLUS3_DEFAULT)));
|
||||||
|
|
||||||
notesLayout = view.findViewById(R.id.newcarbs_notes_layout);
|
LinearLayout notesLayout = view.findViewById(R.id.newcarbs_notes_layout);
|
||||||
notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE);
|
notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE);
|
||||||
notesEdit = view.findViewById(R.id.newcarbs_notes);
|
notesEdit = view.findViewById(R.id.newcarbs_notes);
|
||||||
|
|
||||||
|
@ -234,7 +229,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
||||||
int timeOffset = editTime.getValue().intValue();
|
int timeOffset = editTime.getValue().intValue();
|
||||||
final long time = now() + timeOffset * 1000 * 60;
|
final long time = now() + timeOffset * 1000 * 60;
|
||||||
if (timeOffset != 0) {
|
if (timeOffset != 0) {
|
||||||
actions.add(MainApp.gs(R.string.time) + DateUtil.dateAndTimeString(time));
|
actions.add(MainApp.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time));
|
||||||
}
|
}
|
||||||
final String notes = notesEdit.getText().toString();
|
final String notes = notesEdit.getText().toString();
|
||||||
if (!notes.isEmpty()) {
|
if (!notes.isEmpty()) {
|
||||||
|
@ -268,35 +263,33 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalInsulinAfterConstraints == 0) {
|
if (finalInsulinAfterConstraints > 0) {
|
||||||
return;
|
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||||
}
|
detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS;
|
||||||
|
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
detailedBolusInfo.context = context;
|
||||||
detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS;
|
detailedBolusInfo.source = Source.USER;
|
||||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
detailedBolusInfo.notes = notes;
|
||||||
detailedBolusInfo.context = context;
|
if (recordOnlyCheckbox.isChecked()) {
|
||||||
detailedBolusInfo.source = Source.USER;
|
detailedBolusInfo.date = time;
|
||||||
detailedBolusInfo.notes = notes;
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
if (recordOnlyCheckbox.isChecked()) {
|
} else {
|
||||||
detailedBolusInfo.date = time;
|
detailedBolusInfo.date = now();
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||||
} else {
|
@Override
|
||||||
detailedBolusInfo.date = now();
|
public void run() {
|
||||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
if (!result.success) {
|
||||||
@Override
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
public void run() {
|
i.putExtra("soundid", R.raw.boluserror);
|
||||||
if (!result.success) {
|
i.putExtra("status", result.comment);
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
i.putExtra("status", result.comment);
|
MainApp.instance().startActivity(i);
|
||||||
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
|
}
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
MainApp.instance().startActivity(i);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("Bolus"));
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Bolus"));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue