calibration dialog cancel button

This commit is contained in:
Milos Kozak 2017-06-27 15:25:11 +02:00
parent 70374ee341
commit 341b0660a8
2 changed files with 9 additions and 13 deletions

View file

@ -32,7 +32,6 @@ import info.nightscout.utils.XdripCalibrations;
public class CalibrationDialog extends DialogFragment implements View.OnClickListener { public class CalibrationDialog extends DialogFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(CalibrationDialog.class); private static Logger log = LoggerFactory.getLogger(CalibrationDialog.class);
Button okButton;
PlusMinusEditText bgText; PlusMinusEditText bgText;
TextView unitsView; TextView unitsView;
TextView bgView; TextView bgView;
@ -57,8 +56,8 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
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);
okButton = (Button) view.findViewById(R.id.overview_calibration_okbutton); view.findViewById(R.id.ok).setOnClickListener(this);
okButton.setOnClickListener(this); view.findViewById(R.id.cancel).setOnClickListener(this);
String units = MainApp.getConfigBuilder().getProfileUnits(); String units = MainApp.getConfigBuilder().getProfileUnits();
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units); Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units);
@ -78,13 +77,16 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
@Override @Override
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.overview_calibration_okbutton: case R.id.ok:
final Double bg = SafeParse.stringToDouble(this.bgView.getText().toString()); final Double bg = SafeParse.stringToDouble(this.bgView.getText().toString());
; ;
XdripCalibrations.confirmAndSendCalibration(bg, context); XdripCalibrations.confirmAndSendCalibration(bg, context);
dismiss(); dismiss();
Answers.getInstance().logCustom(new CustomEvent("Calibration")); Answers.getInstance().logCustom(new CustomEvent("Calibration"));
break; break;
case R.id.cancel:
dismiss();
break;
} }
} }
} }

View file

@ -40,6 +40,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:orientation="horizontal"> android:orientation="horizontal">
@ -81,15 +83,7 @@
</LinearLayout> </LinearLayout>
<Button <include layout="@layout/mdtp_done_button" />
android:id="@+id/overview_calibration_okbutton"
style="?android:attr/buttonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="OK"
android:textSize="20sp"
android:layout_marginTop="30dp" />
</LinearLayout> </LinearLayout>