diff --git a/app/src/main/java/info/nightscout/androidaps/data/Profile.java b/app/src/main/java/info/nightscout/androidaps/data/Profile.java index dc49d95455..48081c956c 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/app/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -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); + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 0e6b089744..c9719427c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -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, tempTarget.low, units)); - else - tempTargetView.setText(Profile.toUnitsString(tempTarget.low, tempTarget.low, units) + " - " + Profile.toUnitsString(tempTarget.high, tempTarget.high, 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(Profile.toUnitsString(low, low, units)); - else - tempTargetView.setText(Profile.toUnitsString(low, low, units) + " - " + Profile.toUnitsString(high, high, units)); + tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units)); tempTargetView.setVisibility(View.VISIBLE); } if (Config.NSCLIENT && tempTarget == null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index aead0fe0eb..cbff033fb6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -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, tempTarget.low, profile.getUnits()) + " - " + Profile.toUnitsString(tempTarget.high, tempTarget.high, profile.getUnits()); + ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.low, tempTarget.low, profile.getUnits()); ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd()); ret += "\n\n"; }