From 0ac7357ee91b83cf45bc34ec02e9343eaf00db3b Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 3 Aug 2017 03:12:47 +0200 Subject: [PATCH] color for active temp --- .../androidaps/db/TemporaryBasal.java | 33 ++++++++++++++++--- .../plugins/Overview/OverviewFragment.java | 7 ++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java b/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java index 83ef07fbc8..751e679699 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java +++ b/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java @@ -289,17 +289,17 @@ public class TemporaryBasal implements Interval { Profile profile = MainApp.getConfigBuilder().getProfile(); Double currentBasalRate = profile.getBasal(); double rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate); - return DecimalFormatter.to2Decimal(rate) + "U/h ("+DecimalFormatter.to2Decimal(netExtendedRate)+"E) @" + + return getCalcuatedPercentageIfNeeded() + DecimalFormatter.to2Decimal(rate) + "U/h ("+DecimalFormatter.to2Decimal(netExtendedRate)+"E) @" + DateUtil.timeString(date) + - " " + getRealDuration() + "/" + durationInMinutes + "min"; + " " + getRealDuration() + "/" + durationInMinutes + "'"; } else if (isAbsolute) { return DecimalFormatter.to2Decimal(absoluteRate) + "U/h @" + DateUtil.timeString(date) + - " " + getRealDuration() + "/" + durationInMinutes + "min"; + " " + getRealDuration() + "/" + durationInMinutes + "'"; } else { // percent return percentRate + "% @" + DateUtil.timeString(date) + - " " + getRealDuration() + "/" + durationInMinutes + "min"; + " " + getRealDuration() + "/" + durationInMinutes + "'"; } } @@ -330,6 +330,31 @@ public class TemporaryBasal implements Interval { } } + private String getCalcuatedPercentageIfNeeded(){ + if (isAbsolute || isFakeExtended) { + + double rate = 0d; + if (isFakeExtended) { + Profile profile = MainApp.getConfigBuilder().getProfile(); + Double currentBasalRate = profile.getBasal(); + rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate); + } else if (isAbsolute){ + rate = absoluteRate; + } + + if(SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)){ + Profile profile = MainApp.getConfigBuilder().getProfile(); + if(profile != null) { + double basal = profile.getBasal(); + if(basal != 0){ + return Math.round(rate*100d/basal) + "% "; + } + } + } + } + return ""; + } + public String toStringVeryShort() { if (isAbsolute || isFakeExtended) { 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 74ad8cd893..193b7c564c 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 @@ -1044,6 +1044,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, basalText += "(" + DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + "U/h)"; } } + if (activeTemp != null) { + baseBasalView.setTextColor(MainApp.sResources.getColor(R.color.basal)); + } else { + baseBasalView.setTextColor(Color.WHITE); + + } + baseBasalView.setText(basalText); final ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());