Merge pull request #1227 from PoweRGbg/rotation
fix for carbs and wizard dialogs on screen rotation
This commit is contained in:
commit
503d61e1be
3 changed files with 95 additions and 3 deletions
|
@ -206,8 +206,11 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
double defaultDuration;
|
||||
double defaultTarget = 0;
|
||||
if (profile != null) {
|
||||
if (profile != null && editTemptarget.getValue() == bg) {
|
||||
defaultTarget = bg;
|
||||
} else {
|
||||
//prevent changes on screen rotate
|
||||
defaultTarget = editTemptarget.getValue();
|
||||
}
|
||||
boolean erase = false;
|
||||
|
||||
|
@ -222,6 +225,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
} else if (MainApp.gs(R.string.hypo).equals(reasonList.get(position))) {
|
||||
defaultDuration = helper.determineHypoTTDuration();
|
||||
defaultTarget = helper.determineHypoTT(units);
|
||||
} else if (editDuration.getValue() != 0) {
|
||||
defaultDuration = editDuration.getValue();
|
||||
} else {
|
||||
defaultDuration = 0;
|
||||
erase = true;
|
||||
|
@ -258,7 +263,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
if (sensorRadioButton.isChecked()) meterRadioButton.setChecked(true);
|
||||
}
|
||||
};
|
||||
|
||||
editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
|
||||
editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
|
||||
if (profile == null) {
|
||||
|
@ -271,9 +275,14 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
editBg.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false, bgTextWatcher);
|
||||
editTemptarget.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
||||
}
|
||||
|
||||
sensorRadioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
Double bg1 = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile.getUnits());
|
||||
editBg.setValue(bg1);
|
||||
if (savedInstanceState != null && savedInstanceState.getDouble("editBg") != bg1) {
|
||||
editBg.setValue(savedInstanceState.getDouble("editBg"));
|
||||
} else {
|
||||
editBg.setValue(bg1);
|
||||
}
|
||||
});
|
||||
|
||||
Integer maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||
|
@ -378,6 +387,25 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
|
||||
setCancelable(true);
|
||||
getDialog().setCanceledOnTouchOutside(false);
|
||||
//recovering state if there is something
|
||||
// only numberPickers and editTexts
|
||||
if (savedInstanceState != null) {
|
||||
editBg.setValue(savedInstanceState.getDouble("editBg"));
|
||||
editTemptarget.setValue(savedInstanceState.getDouble("editTemptarget"));
|
||||
notesEdit.setText(savedInstanceState.getString("notesEdit"));
|
||||
editCarbs.setValue(savedInstanceState.getDouble("editCarbs"));
|
||||
editCarbs.setValue(savedInstanceState.getDouble("editCarbs"));
|
||||
editInsulin.setValue(savedInstanceState.getDouble("editInsulin"));
|
||||
editDuration.setValue(savedInstanceState.getDouble("editDuration"));
|
||||
editPercent.setValue(savedInstanceState.getDouble("editPercent"));
|
||||
editAbsolute.setValue(savedInstanceState.getDouble("editAbsolute"));
|
||||
editCarbTime.setValue(savedInstanceState.getDouble("editCarbTime"));
|
||||
editPercentage.setValue(savedInstanceState.getDouble("editPercentage"));
|
||||
editTimeshift.setValue(savedInstanceState.getDouble("editTimeshift"));
|
||||
// time and date
|
||||
dateButton.setText(savedInstanceState.getString("dateButton"));
|
||||
timeButton.setText(savedInstanceState.getString("timeButton"));
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -772,4 +800,22 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||
savedInstanceState.putString("notesEdit", notesEdit.getText().toString());
|
||||
savedInstanceState.putString("dateButton", dateButton.getText().toString());
|
||||
savedInstanceState.putString("timeButton", timeButton.getText().toString());
|
||||
savedInstanceState.putDouble("editBg", editBg.getValue());
|
||||
savedInstanceState.putDouble("editCarbs", editCarbs.getValue());
|
||||
savedInstanceState.putDouble("editInsulin", editInsulin.getValue());
|
||||
savedInstanceState.putDouble("editDuration", editDuration.getValue());
|
||||
savedInstanceState.putDouble("editPercent", editPercent.getValue());
|
||||
savedInstanceState.putDouble("editAbsolute", editAbsolute.getValue());
|
||||
savedInstanceState.putDouble("editCarbTime", editCarbTime.getValue());
|
||||
savedInstanceState.putDouble("editTemptarget", editTemptarget.getValue());
|
||||
savedInstanceState.putDouble("editPercentage", editPercentage.getValue());
|
||||
savedInstanceState.putDouble("editTimeshift", editTimeshift.getValue());
|
||||
super.onSaveInstanceState(savedInstanceState);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -164,6 +164,13 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
|||
|
||||
setCancelable(true);
|
||||
getDialog().setCanceledOnTouchOutside(false);
|
||||
|
||||
//recovering state if there is something
|
||||
if (savedInstanceState != null) {
|
||||
editCarbs.setValue(savedInstanceState.getDouble("editCarbs"));
|
||||
editTime.setValue(savedInstanceState.getDouble("editTime"));
|
||||
editDuration.setValue(savedInstanceState.getDouble("editDuration"));
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -171,6 +178,19 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
|||
return value > 0 ? "+" + value : String.valueOf(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle carbsDialogState) {
|
||||
carbsDialogState.putBoolean("startActivityTTCheckbox",startActivityTTCheckbox.isChecked());
|
||||
carbsDialogState.putBoolean("startEatingSoonTTCheckbox", startEatingSoonTTCheckbox.isChecked());
|
||||
carbsDialogState.putBoolean("startHypoTTCheckbox", startHypoTTCheckbox.isChecked());
|
||||
carbsDialogState.putDouble("editTime", editTime.getValue());
|
||||
carbsDialogState.putDouble("editDuration", editDuration.getValue());
|
||||
carbsDialogState.putDouble("editCarbs", editCarbs.getValue());
|
||||
super.onSaveInstanceState(carbsDialogState);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
|
@ -228,6 +248,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
// Logic to disable a selected radio when pressed: when a checked radio
|
||||
|
|
|
@ -147,6 +147,23 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||
savedInstanceState.putBoolean("bgCheckbox", bgCheckbox.isChecked());
|
||||
savedInstanceState.putBoolean("ttCheckbox", ttCheckbox.isChecked());
|
||||
savedInstanceState.putBoolean("bolusIobCheckbox", bolusIobCheckbox.isChecked());
|
||||
savedInstanceState.putBoolean("basalIobCheckbox", basalIobCheckbox.isChecked());
|
||||
savedInstanceState.putBoolean("bgtrendCheckbox", bgtrendCheckbox.isChecked());
|
||||
savedInstanceState.putBoolean("cobCheckbox", cobCheckbox.isChecked());
|
||||
savedInstanceState.putDouble("editBg", editBg.getValue());
|
||||
savedInstanceState.putDouble("editCarbs", editCarbs.getValue());
|
||||
savedInstanceState.putDouble("editCorr", editCorr.getValue());
|
||||
savedInstanceState.putDouble("editCarbTime", editCarbTime.getValue());
|
||||
super.onSaveInstanceState(savedInstanceState);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNewBG e) {
|
||||
Activity activity = getActivity();
|
||||
|
@ -259,6 +276,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
|
||||
setCancelable(true);
|
||||
getDialog().setCanceledOnTouchOutside(false);
|
||||
//recovering state if there is something
|
||||
if (savedInstanceState != null) {
|
||||
editCarbs.setValue(savedInstanceState.getDouble("editCarbs"));
|
||||
editBg.setValue(savedInstanceState.getDouble("editBg"));
|
||||
editCarbTime.setValue(savedInstanceState.getDouble("editCarbTime"));
|
||||
editCorr.setValue(savedInstanceState.getDouble("editCorr"));
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue