changing the color of the bolus value, for visual clarify and confirmation. Reducing errors.

This commit is contained in:
SMUSTAF1 2017-09-05 13:29:43 +02:00
parent d35729d874
commit 1fd99a9582
3 changed files with 15 additions and 8 deletions

View file

@ -7,6 +7,7 @@ import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.text.Html;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -80,15 +81,16 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
Double insulin = SafeParse.stringToDouble(editInsulin.getText()); Double insulin = SafeParse.stringToDouble(editInsulin.getText());
final Integer carbs = SafeParse.stringToInt(editCarbs.getText()); final Integer carbs = SafeParse.stringToInt(editCarbs.getText());
String confirmMessage = getString(R.string.entertreatmentquestion) + "\n"; String confirmMessage = getString(R.string.entertreatmentquestion) + "<br/>";
Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(insulin); Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(insulin);
Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbs); Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbs);
confirmMessage += getString(R.string.bolus) + ": " + insulinAfterConstraints + "U"; confirmMessage += getString(R.string.bolus) + ": " + "<font color='"+ MainApp.sResources.getColor(R.color.bolus) + "'>" + insulinAfterConstraints + "U" + "</font>";
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g"; confirmMessage += "<br/>" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
if (insulinAfterConstraints - insulin != 0 || !Objects.equals(carbsAfterConstraints, carbs)) if (insulinAfterConstraints - insulin != 0 || !Objects.equals(carbsAfterConstraints, carbs))
confirmMessage += "\n" + getString(R.string.constraintapllied); confirmMessage += "<br/>" + getString(R.string.constraintapllied);
final double finalInsulinAfterConstraints = insulinAfterConstraints; final double finalInsulinAfterConstraints = insulinAfterConstraints;
final int finalCarbsAfterConstraints = carbsAfterConstraints; final int finalCarbsAfterConstraints = carbsAfterConstraints;
@ -97,7 +99,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(this.getContext().getString(R.string.confirmation)); builder.setTitle(this.getContext().getString(R.string.confirmation));
builder.setMessage(confirmMessage); builder.setMessage(Html.fromHtml(confirmMessage));
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) { if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {

View file

@ -9,6 +9,7 @@ import android.os.HandlerThread;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.text.Editable; import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -274,13 +275,16 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
case R.id.ok: case R.id.ok:
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) { if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00"); DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
String confirmMessage = getString(R.string.entertreatmentquestion); String confirmMessage = getString(R.string.entertreatmentquestion);
Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(calculatedTotalInsulin); Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(calculatedTotalInsulin);
Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(calculatedCarbs); Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(calculatedCarbs);
confirmMessage += "\n" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U"; confirmMessage += "<br/>" + getString(R.string.bolus) + ": " + "<font color='"+ MainApp.sResources.getColor(R.color.bolus) + "'>" + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U" + "</font>";
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g"; confirmMessage += "<br/>" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
if (insulinAfterConstraints - calculatedTotalInsulin != 0 || !carbsAfterConstraints.equals(calculatedCarbs)) { if (insulinAfterConstraints - calculatedTotalInsulin != 0 || !carbsAfterConstraints.equals(calculatedCarbs)) {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
@ -299,7 +303,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
builder.setMessage(confirmMessage); builder.setMessage(Html.fromHtml(confirmMessage));
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) { if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {

View file

@ -3,6 +3,7 @@
<color name="prediction">#ff00ff</color> <color name="prediction">#ff00ff</color>
<color name="basal">#00ffff</color> <color name="basal">#00ffff</color>
<color name="iob">#FFFB8C00</color> <color name="iob">#FFFB8C00</color>
<color name="bolus">#FFFFCC03</color>
<color name="cob">#8BC34A</color> <color name="cob">#8BC34A</color>
<color name="ratio">#FFFFFF</color> <color name="ratio">#FFFFFF</color>
<color name="inrange">#00FF00</color> <color name="inrange">#00FF00</color>