Merge pull request #363 from jotomo/target-format

Overview: format target using unit specific format.
This commit is contained in:
Milos Kozak 2017-08-16 08:10:39 +02:00 committed by GitHub
commit d907aa9eb1
3 changed files with 8 additions and 11 deletions

View file

@ -391,4 +391,9 @@ public class Profile {
if (units.equals(Constants.MGDL)) return DecimalFormatter.to0Decimal(valueInMgdl);
else return DecimalFormatter.to1Decimal(valueInMmol);
}
public static String toTargetRangeString(double low, double high, String units) {
if (low == high) return toUnitsString(low, low, units);
else return toUnitsString(low, low, units) + " - " + toUnitsString(high, high, units);
}
}

View file

@ -952,19 +952,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
tempTargetView.setTextColor(Color.BLACK);
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
tempTargetView.setVisibility(View.VISIBLE);
if (tempTarget.low == tempTarget.high)
tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units));
else
tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, units), units));
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, units));
} else {
tempTargetView.setTextColor(Color.WHITE);
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));
double low = MainApp.getConfigBuilder().getProfile().getTargetLow();
double high = MainApp.getConfigBuilder().getProfile().getTargetHigh();
if (low == high)
tempTargetView.setText("" + low);
else
tempTargetView.setText(low + " - " + high);
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units));
tempTargetView.setVisibility(View.VISIBLE);
}
if (Config.NSCLIENT && tempTarget == null) {

View file

@ -472,7 +472,7 @@ public class ActionStringHandler {
//Check for Temp-Target:
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
if (tempTarget != null) {
ret += "Temp Target: " + Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits());
ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.low, tempTarget.low, profile.getUnits());
ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd());
ret += "\n\n";
}