Merge pull request #363 from jotomo/target-format
Overview: format target using unit specific format.
This commit is contained in:
commit
d907aa9eb1
3 changed files with 8 additions and 11 deletions
|
@ -391,4 +391,9 @@ public class Profile {
|
||||||
if (units.equals(Constants.MGDL)) return DecimalFormatter.to0Decimal(valueInMgdl);
|
if (units.equals(Constants.MGDL)) return DecimalFormatter.to0Decimal(valueInMgdl);
|
||||||
else return DecimalFormatter.to1Decimal(valueInMmol);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -952,19 +952,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
tempTargetView.setTextColor(Color.BLACK);
|
tempTargetView.setTextColor(Color.BLACK);
|
||||||
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
|
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
|
||||||
tempTargetView.setVisibility(View.VISIBLE);
|
tempTargetView.setVisibility(View.VISIBLE);
|
||||||
if (tempTarget.low == tempTarget.high)
|
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, units));
|
||||||
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));
|
|
||||||
} else {
|
} else {
|
||||||
tempTargetView.setTextColor(Color.WHITE);
|
tempTargetView.setTextColor(Color.WHITE);
|
||||||
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));
|
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));
|
||||||
double low = MainApp.getConfigBuilder().getProfile().getTargetLow();
|
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units));
|
||||||
double high = MainApp.getConfigBuilder().getProfile().getTargetHigh();
|
|
||||||
if (low == high)
|
|
||||||
tempTargetView.setText("" + low);
|
|
||||||
else
|
|
||||||
tempTargetView.setText(low + " - " + high);
|
|
||||||
tempTargetView.setVisibility(View.VISIBLE);
|
tempTargetView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
if (Config.NSCLIENT && tempTarget == null) {
|
if (Config.NSCLIENT && tempTarget == null) {
|
||||||
|
|
|
@ -472,7 +472,7 @@ public class ActionStringHandler {
|
||||||
//Check for Temp-Target:
|
//Check for Temp-Target:
|
||||||
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
|
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
|
||||||
if (tempTarget != null) {
|
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 += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd());
|
||||||
ret += "\n\n";
|
ret += "\n\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue