more readable var names and

This commit is contained in:
Roumen Georgiev 2018-03-02 15:28:32 +02:00
parent e923bf2156
commit 6c75b1b317

View file

@ -248,41 +248,41 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
confirmMessage += "<br/>" + "Loop: " + "<font color='" + MainApp.sResources.getColor(R.color.low) + "'>" + "Suspend for 30 min</font>"; confirmMessage += "<br/>" + "Loop: " + "<font color='" + MainApp.sResources.getColor(R.color.low) + "'>" + "Suspend for 30 min</font>";
} }
double prefTTDuration = SP.getDouble(R.string.key_activity_duration, 90d); double activityTTDurationSettings = SP.getDouble(R.string.key_activity_duration, 90d);
double eatingSoonTTDuration = SP.getDouble(R.string.key_eatingsoon_duration, 45d); double eatingSoonTTDuration = SP.getDouble(R.string.key_eatingsoon_duration, 45d);
double eatingSoonTT = SP.getDouble(R.string.key_eatingsoon_target, 90d); double eatingSoonTT = SP.getDouble(R.string.key_eatingsoon_target, 90d);
double ttDuration = prefTTDuration > 0 ? prefTTDuration : 90d; double activityTTDuration = activityTTDurationSettings > 0 ? activityTTDurationSettings : 90d;
final double esDuration = eatingSoonTTDuration > 0 ? eatingSoonTTDuration : 45d; final double esTTDuration = eatingSoonTTDuration > 0 ? eatingSoonTTDuration : 45d;
double prefTT = SP.getDouble(R.string.key_activity_target, 140d); double prefTT = SP.getDouble(R.string.key_activity_target, 140d);
double tt = 140d; double activityTT = 140d;
double esTT = 90d; double esTT = 90d;
Profile currentProfile = MainApp.getConfigBuilder().getProfile(); Profile currentProfile = MainApp.getConfigBuilder().getProfile();
if(currentProfile == null) if(currentProfile == null)
return; return;
if(currentProfile.getUnits().equals(Constants.MMOL)) { if(currentProfile.getUnits().equals(Constants.MMOL)) {
esTT = eatingSoonTT > 0 ? Profile.toMgdl(eatingSoonTT,Constants.MGDL) : 90d; esTT = eatingSoonTT > 0 ? Profile.toMgdl(eatingSoonTT,Constants.MGDL) : 90d;
tt = prefTT > 0 ? Profile.toMgdl(prefTT,Constants.MGDL) : 140d; activityTT = prefTT > 0 ? Profile.toMgdl(prefTT,Constants.MGDL) : 140d;
} else { } else {
esTT = eatingSoonTT > 0 ? eatingSoonTT : 90d; esTT = eatingSoonTT > 0 ? eatingSoonTT : 90d;
tt = prefTT > 0 ? prefTT : 140d; activityTT = prefTT > 0 ? prefTT : 140d;
} }
if (startActivityTTCheckbox.isChecked()) { if (startActivityTTCheckbox.isChecked()) {
if(currentProfile.getUnits().equals(Constants.MMOL)) { if(currentProfile.getUnits().equals(Constants.MMOL)) {
confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + Profile.toMmol(tt,Constants.MGDL) + " mmol/l for " + ((int) ttDuration) + " min </font>"; confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + Profile.toMmol(activityTT,Constants.MGDL) + " mmol/l for " + ((int) activityTTDuration) + " min </font>";
} else } else
confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + ((int) tt) + " mg/dl for " + ((int) ttDuration) + " min </font>"; confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + ((int) activityTT) + " mg/dl for " + ((int) activityTTDuration) + " min </font>";
} }
if (startEsTTCheckbox.isChecked() && !startActivityTTCheckbox.isChecked()) { if (startEsTTCheckbox.isChecked() && !startActivityTTCheckbox.isChecked()) {
if(currentProfile.getUnits().equals(Constants.MMOL)) { if(currentProfile.getUnits().equals(Constants.MMOL)) {
confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.low) + "'>" + Profile.toMmol(esTT,Constants.MGDL) + " mmol/l for " + ((int) esDuration) + " min </font>"; confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.low) + "'>" + Profile.toMmol(esTT,Constants.MGDL) + " mmol/l for " + ((int) esTTDuration) + " min </font>";
} else } else
confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.low) + "'>" + ((int) esTT) + " mg/dl for " + ((int) esDuration) + " min </font>"; confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.low) + "'>" + ((int) esTT) + " mg/dl for " + ((int) esTTDuration) + " min </font>";
} }
final double finalTT = tt; final double finalTT = activityTT;
final double finalEsTT = esTT; final double finalEsTT = esTT;
if (StringUtils.isNoneEmpty(food)) { if (StringUtils.isNoneEmpty(food)) {
confirmMessage += "<br/>" + "Food: " + food; confirmMessage += "<br/>" + "Food: " + food;
@ -327,7 +327,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
if (startActivityTTCheckbox.isChecked() || (startActivityTTCheckbox.isChecked() && startEsTTCheckbox.isChecked())) { if (startActivityTTCheckbox.isChecked() || (startActivityTTCheckbox.isChecked() && startEsTTCheckbox.isChecked())) {
TempTarget tempTarget = new TempTarget(); TempTarget tempTarget = new TempTarget();
tempTarget.date = System.currentTimeMillis(); tempTarget.date = System.currentTimeMillis();
tempTarget.durationInMinutes = (int) ttDuration; tempTarget.durationInMinutes = (int) activityTTDuration;
tempTarget.reason = "Activity"; tempTarget.reason = "Activity";
tempTarget.source = Source.USER; tempTarget.source = Source.USER;
tempTarget.low = (double) finalTT; tempTarget.low = (double) finalTT;
@ -336,7 +336,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
} else if (startEsTTCheckbox.isChecked()) { } else if (startEsTTCheckbox.isChecked()) {
TempTarget tempTarget = new TempTarget(); TempTarget tempTarget = new TempTarget();
tempTarget.date = System.currentTimeMillis(); tempTarget.date = System.currentTimeMillis();
tempTarget.durationInMinutes = (int) esDuration; tempTarget.durationInMinutes = (int) esTTDuration;
tempTarget.reason = "Eating soon"; tempTarget.reason = "Eating soon";
tempTarget.source = Source.USER; tempTarget.source = Source.USER;
tempTarget.low = (double) finalEsTT; tempTarget.low = (double) finalEsTT;