fix of fix :(
This commit is contained in:
parent
86d791d93f
commit
a18e2b4641
|
@ -378,6 +378,11 @@ public class Profile {
|
||||||
else return value * Constants.MMOLL_TO_MGDL;
|
else return value * Constants.MMOLL_TO_MGDL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Double toMmol(Double value, String units) {
|
||||||
|
if (units.equals(Constants.MGDL)) return value * Constants.MGDL_TO_MMOLL;
|
||||||
|
else return value;
|
||||||
|
}
|
||||||
|
|
||||||
public static Double fromMgdlToUnits(Double value, String units) {
|
public static Double fromMgdlToUnits(Double value, String units) {
|
||||||
if (units.equals(Constants.MGDL)) return value;
|
if (units.equals(Constants.MGDL)) return value;
|
||||||
else return value * Constants.MGDL_TO_MMOLL;
|
else return value * Constants.MGDL_TO_MMOLL;
|
||||||
|
@ -393,9 +398,16 @@ public class Profile {
|
||||||
else return DecimalFormatter.to1Decimal(valueInMmol);
|
else return DecimalFormatter.to1Decimal(valueInMmol);
|
||||||
}
|
}
|
||||||
|
|
||||||
// targets are stored in mg/dl
|
// targets are stored in mg/dl but profile vary
|
||||||
public static String toTargetRangeString(double low, double high, String units) {
|
public static String toTargetRangeString(double low, double high, String sourceUnits, String units) {
|
||||||
if (low == high) return toUnitsString(low, Profile.fromMgdlToUnits(low, Constants.MMOL), units);
|
double lowMgdl = toMgdl(low, sourceUnits);
|
||||||
else return toUnitsString(low, Profile.fromMgdlToUnits(low, Constants.MMOL), units) + " - " + toUnitsString(high, Profile.fromMgdlToUnits(high, Constants.MMOL), units);
|
double highMgdl = toMgdl(high, sourceUnits);
|
||||||
|
double lowMmol = toMmol(low, sourceUnits);
|
||||||
|
double highMmol = toMmol(high, sourceUnits);
|
||||||
|
if (low == high)
|
||||||
|
return toUnitsString(lowMgdl, lowMmol, units);
|
||||||
|
else
|
||||||
|
return toUnitsString(lowMgdl, lowMmol, units) + " - " + toUnitsString(highMgdl, highMmol, units);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -952,11 +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);
|
||||||
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, units));
|
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, 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));
|
||||||
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units));
|
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units, units));
|
||||||
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.toTargetRangeString(tempTarget.low, tempTarget.low, profile.getUnits());
|
ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.low, tempTarget.low, Constants.MGDL, 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