From 4ebc1497838b729a31e1abbe2af91da9e4bb3d8d Mon Sep 17 00:00:00 2001 From: Nico Schmitz Date: Tue, 12 Jun 2018 23:28:11 +0200 Subject: [PATCH 01/13] Add changes of schmitzn/reservoir-view --- .../androidaps/interfaces/PumpInterface.java | 2 + .../plugins/Overview/OverviewFragment.java | 59 +++++++++++++------ .../plugins/PumpCombo/ComboPlugin.java | 5 ++ .../PumpDanaR/AbstractDanaRPlugin.java | 3 + .../plugins/PumpDanaRS/DanaRSPlugin.java | 5 ++ .../plugins/PumpInsight/InsightPlugin.java | 3 + .../androidaps/plugins/PumpMDI/MDIPlugin.java | 3 + .../PumpVirtual/VirtualPumpPlugin.java | 3 + app/src/main/res/layout/overview_fragment.xml | 12 ++++ app/src/main/res/values-de/strings.xml | 2 + app/src/main/res/values/colors.xml | 11 ++-- app/src/main/res/values/strings.xml | 7 +++ app/src/main/res/xml/pref_overview.xml | 32 ++++++++++ 13 files changed, 126 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java index 65911f82c6..9030cf8bfd 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java @@ -33,6 +33,8 @@ public interface PumpInterface { double getBaseBasalRate(); // base basal rate, not temp basal + double getReservoirLevel(); + PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo); void stopBolusDelivering(); PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew); 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 fadb30420c..a5f375a7bb 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 @@ -134,6 +134,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, TextView baseBasalView; TextView extendedBolusView; TextView activeProfileView; + TextView reservoirView; TextView iobView; TextView cobView; TextView apsModeView; @@ -232,6 +233,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal); extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus); activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile); + reservoirView = (TextView) view.findViewById(R.id.overview_reservoir); pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus); pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump); openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps); @@ -1040,25 +1042,25 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun; if (Config.APS && pump.getPumpDescription().isTempBasalCapable) { apsModeView.setVisibility(View.VISIBLE); - apsModeView.setBackgroundColor(MainApp.gc(R.color.loopenabled)); - apsModeView.setTextColor(Color.BLACK); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); + apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); final LoopPlugin loopPlugin = LoopPlugin.getPlugin(); if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuperBolus()) { - apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); apsModeView.setText(String.format(MainApp.gs(R.string.loopsuperbolusfor), loopPlugin.minutesToEndOfSuspend())); - apsModeView.setTextColor(Color.WHITE); + apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); } else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isDisconnected()) { - apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); apsModeView.setText(String.format(MainApp.gs(R.string.loopdisconnectedfor), loopPlugin.minutesToEndOfSuspend())); - apsModeView.setTextColor(Color.WHITE); + apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); } else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuspended()) { - apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); apsModeView.setText(String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())); - apsModeView.setTextColor(Color.WHITE); + apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); } else if (pump.isSuspended()) { - apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); apsModeView.setText(MainApp.gs(R.string.pumpsuspended)); - apsModeView.setTextColor(Color.WHITE); + apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); } else if (loopPlugin.isEnabled(PluginType.LOOP)) { if (closedLoopEnabled.value()) { apsModeView.setText(MainApp.gs(R.string.closedloop)); @@ -1066,9 +1068,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, apsModeView.setText(MainApp.gs(R.string.openloop)); } } else { - apsModeView.setBackgroundColor(MainApp.gc(R.color.loopdisabled)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgCritical)); apsModeView.setText(MainApp.gs(R.string.disabledloop)); - apsModeView.setTextColor(Color.WHITE); + apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextCritical)); } } else { apsModeView.setVisibility(View.GONE); @@ -1077,13 +1079,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, // temp target TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory(); if (tempTarget != null) { - tempTargetView.setTextColor(Color.BLACK); - tempTargetView.setBackgroundColor(MainApp.gc(R.color.tempTargetBackground)); + tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); + tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); tempTargetView.setVisibility(View.VISIBLE); tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end())); } else { - tempTargetView.setTextColor(Color.WHITE); - tempTargetView.setBackgroundColor(MainApp.gc(R.color.tempTargetDisabledBackground)); + tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); + tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units, units)); tempTargetView.setVisibility(View.VISIBLE); } @@ -1190,7 +1192,30 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } activeProfileView.setText(MainApp.getConfigBuilder().getProfileName()); - activeProfileView.setBackgroundColor(Color.GRAY); + activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); + activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); + + if (reservoirView != null) { + boolean showReservoirView = SP.getBoolean(R.string.key_show_reservoirview, false); + int reservoirLevel = pump.isInitialized() ? (int) Math.round(pump.getReservoirLevel()) : -1; + if (showReservoirView && reservoirLevel != -1) { + int levelWarning = SP.getInt(R.string.key_reservoirview_levelwarning, 80); + int levelCritical = SP.getInt(R.string.key_reservoirview_levelcritical, 5); + reservoirView.setText(reservoirLevel + " " + MainApp.sResources.getString(R.string.insulin_unit_shortname)); + if (reservoirLevel <= levelCritical) { + reservoirView.setBackgroundColor(MainApp.gc(R.color.ribbonBgCritical)); + reservoirView.setTextColor(MainApp.gc(R.color.ribbonTextCritical)); + } else if (reservoirLevel <= levelWarning) { + reservoirView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); + reservoirView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); + } else { + reservoirView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); + reservoirView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); + } + } else { + reservoirView.setVisibility(View.GONE); + } + } tempTargetView.setOnLongClickListener(view -> { view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index b1f2b076ae..c78af7a75b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -423,6 +423,11 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint return pump.basalProfile.hourlyRates[currentHour]; } + @Override + public double getReservoirLevel() { + return pump.reservoirLevel; + } + private static BolusProgressReporter bolusProgressReporter = (state, percent, delivered) -> { EventOverviewBolusProgress event = EventOverviewBolusProgress.getInstance(); switch (state) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java index 1f51979126..77263e41b2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java @@ -150,6 +150,9 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte return pump.currentBasal; } + @Override + public double getReservoirLevel() { return pump.reservoirRemainingUnits; } + @Override public void stopBolusDelivering() { if (sExecutionService == null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java index bf44745f4a..574a775426 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java @@ -352,6 +352,11 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte return pump.currentBasal; } + @Override + public double getReservoirLevel() { + return pump.reservoirRemainingUnits; + } + @Override public synchronized PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { detailedBolusInfo.insulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(detailedBolusInfo.insulin)).value(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java index 9fb98d3175..752360cbfc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java @@ -385,6 +385,9 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai return basalRate; } + @Override + public double getReservoirLevel() { return reservoirInUnits; } + public String getBaseBasalRateString() { final DecimalFormat df = new DecimalFormat("#.##"); return df.format(basalRate); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java index 09cff7d97e..76068e71d4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java @@ -129,6 +129,9 @@ public class MDIPlugin extends PluginBase implements PumpInterface { return 0d; } + @Override + public double getReservoirLevel() { return -1; } + @Override public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { PumpEnactResult result = new PumpEnactResult(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java index 653ab66c21..bda4f2402e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java @@ -197,6 +197,9 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { return 0d; } + @Override + public double getReservoirLevel() { return reservoirInUnits; } + @Override public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { PumpEnactResult result = new PumpEnactResult(); diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 8e37ae7675..8f68a3c834 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -47,6 +47,18 @@ android:textAppearance="?android:attr/textAppearanceSmall" /> + TBR Pumpen-Speicher Aktiviere die SuperBolus-Funktion im Wizard. Nicht aktivieren, wenn du nicht weißt, welche Auswirkungen dieser Bolus hat! ES KANN ZU EINER ÜBERDOSIERUNG AN INSULIN KOMMEN! + Zeige Reservoir-Füllstand in Übersicht + Zeigt den Füllstand des Reservoirs in der Übersicht an. Status des Bolus wird ermittelt PAIRING Bolus-Abgabe gestartet diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 7f1fcc268c..9811aff465 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -59,10 +59,6 @@ #de7550 #25912e - #47c8ff - #FFDD7792 - #ff0400 - #FF8C00 #ff0400 #ff5e55 @@ -75,4 +71,11 @@ #72FF0000 #72000000 + #424242 + #f4d700 + #ff0400 + #FFFFFF + #303030 + #FFFFFF + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index eb9e2cc36c..f478801797 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -607,6 +607,13 @@ key_usersuperbolus Enable superbolus in wizard Enable superbolus functionality in wizard. Do not enable until you learn what it really does. IT MAY CAUSE INSULIN OVERDOSE IF USED BLINDLY! + key_show_reservoirview + Show reservoir level in overview + Show the reservoir level on the overview page. + key_reservoirview_levelwarning + Level warning + key_reservoirview_levelcritical + Level critical IOB COB Firmware diff --git a/app/src/main/res/xml/pref_overview.xml b/app/src/main/res/xml/pref_overview.xml index 5d08cd671e..b235a97f1e 100644 --- a/app/src/main/res/xml/pref_overview.xml +++ b/app/src/main/res/xml/pref_overview.xml @@ -143,6 +143,38 @@ android:summary="@string/enablesuperbolus_summary" android:title="@string/enablesuperbolus" /> + + + + + + From 5ba6f02b93b5697f037b84e862e40eb94b116bb1 Mon Sep 17 00:00:00 2001 From: Nico Schmitz Date: Tue, 12 Jun 2018 23:31:46 +0200 Subject: [PATCH 02/13] Remove reservoir TextView --- .../plugins/Overview/OverviewFragment.java | 24 ------------------- app/src/main/res/layout/overview_fragment.xml | 12 ---------- 2 files changed, 36 deletions(-) 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 a5f375a7bb..9dddaa4bb8 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 @@ -134,7 +134,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, TextView baseBasalView; TextView extendedBolusView; TextView activeProfileView; - TextView reservoirView; TextView iobView; TextView cobView; TextView apsModeView; @@ -233,7 +232,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal); extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus); activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile); - reservoirView = (TextView) view.findViewById(R.id.overview_reservoir); pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus); pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump); openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps); @@ -1195,28 +1193,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); - if (reservoirView != null) { - boolean showReservoirView = SP.getBoolean(R.string.key_show_reservoirview, false); - int reservoirLevel = pump.isInitialized() ? (int) Math.round(pump.getReservoirLevel()) : -1; - if (showReservoirView && reservoirLevel != -1) { - int levelWarning = SP.getInt(R.string.key_reservoirview_levelwarning, 80); - int levelCritical = SP.getInt(R.string.key_reservoirview_levelcritical, 5); - reservoirView.setText(reservoirLevel + " " + MainApp.sResources.getString(R.string.insulin_unit_shortname)); - if (reservoirLevel <= levelCritical) { - reservoirView.setBackgroundColor(MainApp.gc(R.color.ribbonBgCritical)); - reservoirView.setTextColor(MainApp.gc(R.color.ribbonTextCritical)); - } else if (reservoirLevel <= levelWarning) { - reservoirView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); - reservoirView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); - } else { - reservoirView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); - reservoirView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); - } - } else { - reservoirView.setVisibility(View.GONE); - } - } - tempTargetView.setOnLongClickListener(view -> { view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog(); diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 8f68a3c834..8e37ae7675 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -47,18 +47,6 @@ android:textAppearance="?android:attr/textAppearanceSmall" /> - Date: Wed, 13 Jun 2018 00:07:13 +0200 Subject: [PATCH 03/13] Integrate info fields from swissalpine/dev-work --- .../plugins/Overview/OverviewFragment.java | 84 +++++++++++++++++++ app/src/main/res/layout/overview_fragment.xml | 48 +++++++++++ 2 files changed, 132 insertions(+) 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 9dddaa4bb8..025bedc789 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 @@ -95,6 +95,7 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalcul import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus; +import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus; import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity; import info.nightscout.androidaps.plugins.Overview.Dialogs.NewCarbsDialog; @@ -154,6 +155,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, TextView sage; TextView pbage; + TextView iageView; + TextView cageView; + TextView reservoirView; + TextView sageView; + TextView pbageView; + RecyclerView notificationsView; LinearLayoutManager llm; @@ -252,6 +259,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, sage = (TextView) view.findViewById(R.id.careportal_sensorage); pbage = (TextView) view.findViewById(R.id.careportal_pbage); + iageView = (TextView) view.findViewById(R.id.overview_insulinage); + cageView = (TextView) view.findViewById(R.id.overview_canulaage); + reservoirView = (TextView) view.findViewById(R.id.overview_reservoirlevel); + sageView = (TextView) view.findViewById(R.id.overview_sensorage); + pbageView = (TextView) view.findViewById(R.id.overview_pbage); + bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph); iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph); @@ -1304,6 +1317,67 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, cobView.setText(cobText); } + CareportalEvent careportalEvent; + NSSettingsStatus nsSettings = new NSSettingsStatus().getInstance(); + + double iageUrgent = nsSettings.getExtendedWarnValue("iage", "urgent", 120); + double iageWarn = nsSettings.getExtendedWarnValue("iage", "warn", 96); + double cageUrgent = nsSettings.getExtendedWarnValue("cage", "urgent", 48); + double cageWarn = nsSettings.getExtendedWarnValue("cage", "warn", 24); + double sageUrgent = nsSettings.getExtendedWarnValue("sage", "urgent", 504); + double sageWarn = nsSettings.getExtendedWarnValue("sage", "warn", 336); + double pbageUrgent = nsSettings.getExtendedWarnValue("pgage", "urgent", 672); + double pbageWarn = nsSettings.getExtendedWarnValue("pgage", "warn", 504); + + if (cageView != null) { + careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE); + if (careportalEvent != null) { + cageView.setTextColor(determineTextColor(careportalEvent, cageWarn, cageUrgent)); + cageView.setText("CAN"); //: " + careportalEvent.age()); + } else { + cageView.setText("n/a"); + } + } + + if (iageView != null) { + careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE); + if (careportalEvent != null) { + iageView.setTextColor(determineTextColor(careportalEvent, iageWarn, iageUrgent)); + iageView.setText("INS"); //: + careportalEvent.age()); + } else { + iageView.setText("n/a"); + } + } + + if (reservoirView != null) { + if (pump.isInitialized() && pump.getReservoirLevel() < 50) { + reservoirView.setTextColor(MainApp.gc(R.color.low)); + } else { + reservoirView.setTextColor(MainApp.gc(R.color.colorLightGray)); + } + reservoirView.setText("RES"); + } + + if (sageView != null) { + careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE); + if (careportalEvent != null) { + sageView.setTextColor(determineTextColor(careportalEvent, sageWarn, sageUrgent)); + sageView.setText("SEN"); // + careportalEvent.age()); + } else { + sageView.setText("n/a"); + } + } + + if (pbageView != null) { + careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.PUMPBATTERYCHANGE); + if (careportalEvent != null) { + pbageView.setTextColor(determineTextColor(careportalEvent, pbageWarn, pbageUrgent)); + pbageView.setText("BAT"); //careportalEvent.age()); + } else { + pbageView.setText("n/a"); + } + } + final boolean predictionsAvailable = finalLastRun != null && finalLastRun.request.hasPredictions; // pump status from ns if (pumpDeviceStatusView != null) { @@ -1466,4 +1540,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } } + public static int determineTextColor(CareportalEvent careportalEvent, double warnThreshold, double urgentThreshold) { + if (careportalEvent.isOlderThan(urgentThreshold)) { + return MainApp.gc(R.color.low); + } else if (careportalEvent.isOlderThan(warnThreshold)) { + return MainApp.gc(R.color.high); + } else { + return MainApp.gc(R.color.colorLightGray); + } + } + } diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 8e37ae7675..79e3c518fe 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -183,6 +183,54 @@ + + + + + + + + + + + + + + Date: Wed, 13 Jun 2018 00:28:17 +0200 Subject: [PATCH 04/13] Implement getBatteryLevel() in PumpInterface and for all pump plugins --- .../androidaps/interfaces/PumpInterface.java | 2 ++ .../androidaps/plugins/PumpCombo/ComboPlugin.java | 12 ++++++++++++ .../plugins/PumpDanaR/AbstractDanaRPlugin.java | 3 +++ .../androidaps/plugins/PumpDanaRS/DanaRSPlugin.java | 3 +++ .../plugins/PumpInsight/InsightPlugin.java | 3 +++ .../androidaps/plugins/PumpMDI/MDIPlugin.java | 3 +++ .../plugins/PumpVirtual/VirtualPumpPlugin.java | 3 +++ 7 files changed, 29 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java index 9030cf8bfd..0200f7635a 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java @@ -35,6 +35,8 @@ public interface PumpInterface { double getReservoirLevel(); + int getBatteryLevel(); // in percent as integer + PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo); void stopBolusDelivering(); PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index c78af7a75b..b11b0c4694 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -428,6 +428,18 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint return pump.reservoirLevel; } + @Override + public int getBatteryLevel() { + switch (pump.state.batteryState) { + case PumpState.EMPTY: + return 0; + case PumpState.LOW: + return 25; + default: + return 100; + } + } + private static BolusProgressReporter bolusProgressReporter = (state, percent, delivered) -> { EventOverviewBolusProgress event = EventOverviewBolusProgress.getInstance(); switch (state) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java index 77263e41b2..5deeac949f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java @@ -153,6 +153,9 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte @Override public double getReservoirLevel() { return pump.reservoirRemainingUnits; } + @Override + public int getBatteryLevel() { return pump.batteryRemaining; } + @Override public void stopBolusDelivering() { if (sExecutionService == null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java index 574a775426..10b7f0f4c2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java @@ -357,6 +357,9 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte return pump.reservoirRemainingUnits; } + @Override + public int getBatteryLevel() { return pump.batteryRemaining; } + @Override public synchronized PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { detailedBolusInfo.insulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(detailedBolusInfo.insulin)).value(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java index 752360cbfc..2b31e4e3d7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java @@ -388,6 +388,9 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai @Override public double getReservoirLevel() { return reservoirInUnits; } + @Override + public int getBatteryLevel() { return batteryPercent; } + public String getBaseBasalRateString() { final DecimalFormat df = new DecimalFormat("#.##"); return df.format(basalRate); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java index 76068e71d4..4247b2b45f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java @@ -132,6 +132,9 @@ public class MDIPlugin extends PluginBase implements PumpInterface { @Override public double getReservoirLevel() { return -1; } + @Override + public int getBatteryLevel() { return -1; } + @Override public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { PumpEnactResult result = new PumpEnactResult(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java index bda4f2402e..949f9c9875 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java @@ -200,6 +200,9 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { @Override public double getReservoirLevel() { return reservoirInUnits; } + @Override + public int getBatteryLevel() { return batteryPercent; } + @Override public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { PumpEnactResult result = new PumpEnactResult(); From 217583d6011271a504c021170b34fcc9f44c5a9e Mon Sep 17 00:00:00 2001 From: Nico Schmitz Date: Wed, 13 Jun 2018 19:58:52 +0200 Subject: [PATCH 05/13] Use getBatteryLevel() for BAT status. Refactor code and layout. --- .../plugins/Overview/OverviewFragment.java | 64 ++++++++----------- app/src/main/res/layout/overview_fragment.xml | 27 ++++++-- 2 files changed, 48 insertions(+), 43 deletions(-) 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 025bedc789..ec2b723bac 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 @@ -1331,51 +1331,30 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, if (cageView != null) { careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE); - if (careportalEvent != null) { - cageView.setTextColor(determineTextColor(careportalEvent, cageWarn, cageUrgent)); - cageView.setText("CAN"); //: " + careportalEvent.age()); - } else { - cageView.setText("n/a"); - } + double canAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; + applyRibbonView(cageView, "CAN", canAge, cageWarn, cageUrgent, Double.MAX_VALUE); } if (iageView != null) { careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE); - if (careportalEvent != null) { - iageView.setTextColor(determineTextColor(careportalEvent, iageWarn, iageUrgent)); - iageView.setText("INS"); //: + careportalEvent.age()); - } else { - iageView.setText("n/a"); - } + double insulinAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; + applyRibbonView(iageView, "INS", insulinAge, iageWarn, iageUrgent, Double.MAX_VALUE); } if (reservoirView != null) { - if (pump.isInitialized() && pump.getReservoirLevel() < 50) { - reservoirView.setTextColor(MainApp.gc(R.color.low)); - } else { - reservoirView.setTextColor(MainApp.gc(R.color.colorLightGray)); - } - reservoirView.setText("RES"); + double reservoirLevel = pump.isInitialized() ? pump.getReservoirLevel() : -1; + applyRibbonView(reservoirView, "RES", reservoirLevel, 80, 10, -1); } if (sageView != null) { careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE); - if (careportalEvent != null) { - sageView.setTextColor(determineTextColor(careportalEvent, sageWarn, sageUrgent)); - sageView.setText("SEN"); // + careportalEvent.age()); - } else { - sageView.setText("n/a"); - } + double sensorAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; + applyRibbonView(sageView, "SEN", sensorAge, sageWarn, sageUrgent, Double.MAX_VALUE); } if (pbageView != null) { - careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.PUMPBATTERYCHANGE); - if (careportalEvent != null) { - pbageView.setTextColor(determineTextColor(careportalEvent, pbageWarn, pbageUrgent)); - pbageView.setText("BAT"); //careportalEvent.age()); - } else { - pbageView.setText("n/a"); - } + double batteryLevel = pump.isInitialized() ? pump.getBatteryLevel() : -1; + applyRibbonView(pbageView, "BAT", batteryLevel, 25, 5, -1); } final boolean predictionsAvailable = finalLastRun != null && finalLastRun.request.hasPredictions; @@ -1540,14 +1519,23 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } } - public static int determineTextColor(CareportalEvent careportalEvent, double warnThreshold, double urgentThreshold) { - if (careportalEvent.isOlderThan(urgentThreshold)) { - return MainApp.gc(R.color.low); - } else if (careportalEvent.isOlderThan(warnThreshold)) { - return MainApp.gc(R.color.high); + public static void applyRibbonView(TextView view, String text, double value, double warnThreshold, double urgentThreshold, double invalid) { + if (value != invalid) { + view.setText(text); + if (value <= urgentThreshold) { + view.setTextColor(MainApp.gc(R.color.ribbonTextCritical)); + view.setBackgroundColor(MainApp.gc(R.color.ribbonBgCritical)); + } else if (value <= warnThreshold) { + view.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); + view.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); + } else { + view.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); + view.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); + } + view.setVisibility(View.VISIBLE); } else { - return MainApp.gc(R.color.colorLightGray); + view.setVisibility(View.GONE); } - } + } } diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 79e3c518fe..2e21c270cd 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -187,13 +187,18 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" + android:layout_marginTop="3dp" + android:layout_marginBottom="2dp" android:orientation="horizontal"> @@ -201,7 +206,10 @@ android:id="@+id/overview_insulinage" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="10dp" + android:paddingLeft="5dp" + android:paddingRight="5dp" + android:layout_marginHorizontal="3dp" + android:gravity="center" android:text="" android:textSize="14sp" /> @@ -209,7 +217,10 @@ android:id="@+id/overview_reservoirlevel" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="10dp" + android:paddingLeft="5dp" + android:paddingRight="5dp" + android:layout_marginHorizontal="3dp" + android:gravity="center" android:text="" android:textSize="14sp" /> @@ -217,7 +228,10 @@ android:id="@+id/overview_sensorage" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="10dp" + android:paddingLeft="5dp" + android:paddingRight="5dp" + android:layout_marginHorizontal="3dp" + android:gravity="center" android:text="" android:textSize="14sp" /> @@ -225,7 +239,10 @@ android:id="@+id/overview_pbage" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="10dp" + android:paddingLeft="5dp" + android:paddingRight="5dp" + android:layout_marginHorizontal="3dp" + android:gravity="center" android:text="" android:textSize="14sp" /> From 18c6bdd4ef29747276b327ab6b4bc6dbcacf7712 Mon Sep 17 00:00:00 2001 From: Nico Schmitz Date: Wed, 13 Jun 2018 21:35:21 +0200 Subject: [PATCH 06/13] Improve layout xml --- app/src/main/res/layout/overview_fragment.xml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 2e21c270cd..5aae13e1f7 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -195,8 +195,7 @@ android:id="@+id/overview_canulaage" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="5dp" - android:paddingRight="5dp" + android:paddingHorizontal="5dp" android:layout_marginHorizontal="3dp" android:gravity="center" android:text="" @@ -206,8 +205,7 @@ android:id="@+id/overview_insulinage" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="5dp" - android:paddingRight="5dp" + android:paddingHorizontal="5dp" android:layout_marginHorizontal="3dp" android:gravity="center" android:text="" @@ -217,8 +215,7 @@ android:id="@+id/overview_reservoirlevel" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="5dp" - android:paddingRight="5dp" + android:paddingHorizontal="5dp" android:layout_marginHorizontal="3dp" android:gravity="center" android:text="" @@ -228,8 +225,7 @@ android:id="@+id/overview_sensorage" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="5dp" - android:paddingRight="5dp" + android:paddingHorizontal="5dp" android:layout_marginHorizontal="3dp" android:gravity="center" android:text="" @@ -239,8 +235,7 @@ android:id="@+id/overview_pbage" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="5dp" - android:paddingRight="5dp" + android:paddingHorizontal="5dp" android:layout_marginHorizontal="3dp" android:gravity="center" android:text="" From 1604b533277a3b3702d3ca06bd094ea992270c5c Mon Sep 17 00:00:00 2001 From: Nico Schmitz Date: Thu, 14 Jun 2018 20:49:58 +0200 Subject: [PATCH 07/13] Fix bugs, refactor code and add preferences --- .../androidaps/db/CareportalEvent.java | 4 +- .../plugins/Overview/OverviewFragment.java | 90 +++++++++++-------- .../plugins/PumpCombo/ComboPlugin.java | 2 +- app/src/main/res/layout/overview_fragment.xml | 3 +- app/src/main/res/values-de/strings.xml | 8 +- app/src/main/res/values/strings.xml | 18 ++-- app/src/main/res/xml/pref_overview.xml | 46 +++++++--- 7 files changed, 110 insertions(+), 61 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java b/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java index 72ff1ddab0..a963158f2f 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java +++ b/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java @@ -86,8 +86,8 @@ public class CareportalEvent implements DataPointWithLabelInterface { return System.currentTimeMillis() - date; } - public long getHoursFromStart() { - return (System.currentTimeMillis() - date) / (60 * 60 * 1000); + public double getHoursFromStart() { + return (System.currentTimeMillis() - date) / (60 * 60 * 1000.0); } public String age() { 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 eedf854860..02053c0b9c 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 @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.Overview; import android.annotation.SuppressLint; import android.app.Activity; import android.app.NotificationManager; +import android.arch.core.util.Function; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; @@ -159,7 +160,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, TextView cageView; TextView reservoirView; TextView sageView; - TextView pbageView; + TextView batteryView; + LinearLayout statuslightsLayout; RecyclerView notificationsView; LinearLayoutManager llm; @@ -263,7 +265,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, cageView = (TextView) view.findViewById(R.id.overview_canulaage); reservoirView = (TextView) view.findViewById(R.id.overview_reservoirlevel); sageView = (TextView) view.findViewById(R.id.overview_sensorage); - pbageView = (TextView) view.findViewById(R.id.overview_pbage); + batteryView = (TextView) view.findViewById(R.id.overview_batterylevel); + statuslightsLayout = (LinearLayout) view.findViewById(R.id.overview_statuslights); bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph); iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph); @@ -1321,44 +1324,54 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, cobView.setText(cobText); } - CareportalEvent careportalEvent; - NSSettingsStatus nsSettings = new NSSettingsStatus().getInstance(); + if (statuslightsLayout != null) { + if (SP.getBoolean(R.string.key_show_statuslights, false)) { + CareportalEvent careportalEvent; + NSSettingsStatus nsSettings = new NSSettingsStatus().getInstance(); + double iageUrgent = nsSettings.getExtendedWarnValue("iage", "urgent", 96); + double iageWarn = nsSettings.getExtendedWarnValue("iage", "warn", 72); + double cageUrgent = nsSettings.getExtendedWarnValue("cage", "urgent", 72); + double cageWarn = nsSettings.getExtendedWarnValue("cage", "warn", 48); + double sageUrgent = nsSettings.getExtendedWarnValue("sage", "urgent", 166); + double sageWarn = nsSettings.getExtendedWarnValue("sage", "warn", 164); + //double pbageUrgent = nsSettings.getExtendedWarnValue("pgage", "urgent", 360); + //double pbageWarn = nsSettings.getExtendedWarnValue("pgage", "warn", 240); + double batUrgent = SP.getDouble(R.string.key_statuslights_bat_critical, 5.0); + double batWarn = SP.getDouble(R.string.key_statuslights_bat_warning, 25.0); + double resUrgent = SP.getDouble(R.string.key_statuslights_res_critical, 10.0); + double resWarn = SP.getDouble(R.string.key_statuslights_res_warning, 80.0); - double iageUrgent = nsSettings.getExtendedWarnValue("iage", "urgent", 120); - double iageWarn = nsSettings.getExtendedWarnValue("iage", "warn", 96); - double cageUrgent = nsSettings.getExtendedWarnValue("cage", "urgent", 48); - double cageWarn = nsSettings.getExtendedWarnValue("cage", "warn", 24); - double sageUrgent = nsSettings.getExtendedWarnValue("sage", "urgent", 504); - double sageWarn = nsSettings.getExtendedWarnValue("sage", "warn", 336); - double pbageUrgent = nsSettings.getExtendedWarnValue("pgage", "urgent", 672); - double pbageWarn = nsSettings.getExtendedWarnValue("pgage", "warn", 504); + if (cageView != null) { + careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE); + double canAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; + applyRibbonView(cageView, "CAN", canAge, cageWarn, cageUrgent, Double.MAX_VALUE, true); + } - if (cageView != null) { - careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE); - double canAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; - applyRibbonView(cageView, "CAN", canAge, cageWarn, cageUrgent, Double.MAX_VALUE); - } + if (iageView != null) { + careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE); + double insulinAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; + applyRibbonView(iageView, "INS", insulinAge, iageWarn, iageUrgent, Double.MAX_VALUE, true); + } - if (iageView != null) { - careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE); - double insulinAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; - applyRibbonView(iageView, "INS", insulinAge, iageWarn, iageUrgent, Double.MAX_VALUE); - } + if (reservoirView != null) { + double reservoirLevel = pump.isInitialized() ? pump.getReservoirLevel() : -1; + applyRibbonView(reservoirView, "RES", reservoirLevel, resWarn, resUrgent, -1, false); + } - if (reservoirView != null) { - double reservoirLevel = pump.isInitialized() ? pump.getReservoirLevel() : -1; - applyRibbonView(reservoirView, "RES", reservoirLevel, 80, 10, -1); - } + if (sageView != null) { + careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE); + double sensorAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; + applyRibbonView(sageView, "SEN", sensorAge, sageWarn, sageUrgent, Double.MAX_VALUE, true); + } - if (sageView != null) { - careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE); - double sensorAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; - applyRibbonView(sageView, "SEN", sensorAge, sageWarn, sageUrgent, Double.MAX_VALUE); - } - - if (pbageView != null) { - double batteryLevel = pump.isInitialized() ? pump.getBatteryLevel() : -1; - applyRibbonView(pbageView, "BAT", batteryLevel, 25, 5, -1); + if (batteryView != null) { + double batteryLevel = pump.isInitialized() ? pump.getBatteryLevel() : -1; + applyRibbonView(batteryView, "BAT", batteryLevel, batWarn, batUrgent, -1, false); + } + statuslightsLayout.setVisibility(View.VISIBLE); + } else { + statuslightsLayout.setVisibility(View.GONE); + } } final boolean predictionsAvailable = finalLastRun != null && finalLastRun.request.hasPredictions; @@ -1523,13 +1536,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } } - public static void applyRibbonView(TextView view, String text, double value, double warnThreshold, double urgentThreshold, double invalid) { + public static void applyRibbonView(TextView view, String text, double value, double warnThreshold, double urgentThreshold, double invalid, boolean checkAscending) { + Function check = checkAscending ? (Double threshold) -> value >= threshold : (Double threshold) -> value <= threshold; if (value != invalid) { view.setText(text); - if (value <= urgentThreshold) { + if (check.apply(urgentThreshold)) { view.setTextColor(MainApp.gc(R.color.ribbonTextCritical)); view.setBackgroundColor(MainApp.gc(R.color.ribbonBgCritical)); - } else if (value <= warnThreshold) { + } else if (check.apply(warnThreshold)) { view.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); view.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index b11b0c4694..d4aa0d7da8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -432,7 +432,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint public int getBatteryLevel() { switch (pump.state.batteryState) { case PumpState.EMPTY: - return 0; + return 5; case PumpState.LOW: return 25; default: diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 5aae13e1f7..3dfe816f46 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -184,6 +184,7 @@ TBR Pumpen-Speicher Aktiviere die SuperBolus-Funktion im Wizard. Nicht aktivieren, wenn du nicht weißt, welche Auswirkungen dieser Bolus hat! ES KANN ZU EINER ÜBERDOSIERUNG AN INSULIN KOMMEN! - Zeige Reservoir-Füllstand in Übersicht - Zeigt den Füllstand des Reservoirs in der Übersicht an. + Zeige Status-Ampeln in der Übersicht + Aktiviert die Statusanzeige für CAGE, IAGE, SAGE, Reservoir- und Batteriestand auf dem Startbildschirm. + Reservoirfüllstand Warnung [IE] + Reservoirfüllstand Alarm [IE] + Batterieladung Warnung [%] + Batterieladung Alarm [%] Status des Bolus wird ermittelt PAIRING Bolus-Abgabe gestartet diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f478801797..4abf52f6d5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -607,13 +607,17 @@ key_usersuperbolus Enable superbolus in wizard Enable superbolus functionality in wizard. Do not enable until you learn what it really does. IT MAY CAUSE INSULIN OVERDOSE IF USED BLINDLY! - key_show_reservoirview - Show reservoir level in overview - Show the reservoir level on the overview page. - key_reservoirview_levelwarning - Level warning - key_reservoirview_levelcritical - Level critical + key_show_statuslights + Show status lights on home screen + Enable status lights for cage, iage, sage, reservoir and battery level on home screen. + key_statuslights_res_warning + Threshold warning reservoir level [U] + key_statuslights_res_critical + Threshold critical reservoir level [U] + key_statuslights_bat_warning + Threshold warning battery level [%] + key_statuslights_bat_critical + Threshold critical battery level [%] IOB COB Firmware diff --git a/app/src/main/res/xml/pref_overview.xml b/app/src/main/res/xml/pref_overview.xml index b235a97f1e..daf1605fb5 100644 --- a/app/src/main/res/xml/pref_overview.xml +++ b/app/src/main/res/xml/pref_overview.xml @@ -145,36 +145,62 @@ + android:key="@string/key_show_statuslights" + android:summary="@string/show_statuslights_summary" + android:title="@string/show_statuslights" /> + + + + From bf3ce735bcfbb78e540fd5015fe50cf5322170b6 Mon Sep 17 00:00:00 2001 From: Nico Schmitz Date: Thu, 14 Jun 2018 23:22:15 +0200 Subject: [PATCH 08/13] Set colors of profile view --- .../androidaps/plugins/Overview/OverviewFragment.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 02053c0b9c..4127ce49a0 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 @@ -1210,8 +1210,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } activeProfileView.setText(MainApp.getConfigBuilder().getProfileName()); - activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); - activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); + if (profile.getPercentage() != 100 || profile.getTimeshift() != 0) { + activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); + activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); + } else { + activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); + activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); + } tempTargetView.setOnLongClickListener(view -> { view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); From 14a17efecc420361e92abf004cda8fe78e732e14 Mon Sep 17 00:00:00 2001 From: Nico Schmitz Date: Fri, 15 Jun 2018 19:36:49 +0200 Subject: [PATCH 09/13] Update colors --- .../androidaps/plugins/Overview/OverviewFragment.java | 8 ++++---- app/src/main/res/values/colors.xml | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) 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 4127ce49a0..6a1812b228 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 @@ -1068,9 +1068,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, apsModeView.setText(String.format(MainApp.gs(R.string.loopsuperbolusfor), loopPlugin.minutesToEndOfSuspend())); apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); } else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isDisconnected()) { - apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgCritical)); apsModeView.setText(String.format(MainApp.gs(R.string.loopdisconnectedfor), loopPlugin.minutesToEndOfSuspend())); - apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); + apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextCritical)); } else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuspended()) { apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); apsModeView.setText(String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())); @@ -1552,8 +1552,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, view.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); view.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); } else { - view.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); - view.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); + view.setTextColor(MainApp.gc(R.color.ribbonTextDisabled)); + view.setBackgroundColor(MainApp.gc(R.color.ribbonBgDisabled)); } view.setVisibility(View.VISIBLE); } else { diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 9811aff465..37c11857e9 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -71,11 +71,13 @@ #72FF0000 #72000000 - #424242 + #5a595b #f4d700 #ff0400 #FFFFFF #303030 #FFFFFF + #424242 + #333333 From db36d6e3f53b2af7fe59139076858e98ef77e71b Mon Sep 17 00:00:00 2001 From: Nico Schmitz Date: Sat, 16 Jun 2018 02:18:03 +0200 Subject: [PATCH 10/13] Change colors and refactor code --- .../plugins/Overview/OverviewFragment.java | 41 +++++++++---------- app/src/main/res/values/colors.xml | 8 ++-- 2 files changed, 22 insertions(+), 27 deletions(-) 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 6a1812b228..e89a040316 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 @@ -1060,23 +1060,23 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun; if (Config.APS && pump.getPumpDescription().isTempBasalCapable) { apsModeView.setVisibility(View.VISIBLE); - apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault)); apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); final LoopPlugin loopPlugin = LoopPlugin.getPlugin(); if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuperBolus()) { - apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning)); apsModeView.setText(String.format(MainApp.gs(R.string.loopsuperbolusfor), loopPlugin.minutesToEndOfSuspend())); apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); } else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isDisconnected()) { - apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgCritical)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonCritical)); apsModeView.setText(String.format(MainApp.gs(R.string.loopdisconnectedfor), loopPlugin.minutesToEndOfSuspend())); apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextCritical)); } else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuspended()) { - apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning)); apsModeView.setText(String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())); apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); } else if (pump.isSuspended()) { - apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning)); apsModeView.setText(MainApp.gs(R.string.pumpsuspended)); apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); } else if (loopPlugin.isEnabled(PluginType.LOOP)) { @@ -1086,7 +1086,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, apsModeView.setText(MainApp.gs(R.string.openloop)); } } else { - apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgCritical)); + apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonCritical)); apsModeView.setText(MainApp.gs(R.string.disabledloop)); apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextCritical)); } @@ -1098,12 +1098,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory(); if (tempTarget != null) { tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); - tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); + tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning)); tempTargetView.setVisibility(View.VISIBLE); tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end())); } else { tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); - tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); + tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault)); tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units, units)); tempTargetView.setVisibility(View.VISIBLE); } @@ -1211,10 +1211,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, activeProfileView.setText(MainApp.getConfigBuilder().getProfileName()); if (profile.getPercentage() != 100 || profile.getTimeshift() != 0) { - activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); + activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning)); activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); } else { - activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault)); + activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault)); activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); } @@ -1349,29 +1349,29 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, if (cageView != null) { careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE); double canAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; - applyRibbonView(cageView, "CAN", canAge, cageWarn, cageUrgent, Double.MAX_VALUE, true); + applyStatuslight(cageView, "CAN", canAge, cageWarn, cageUrgent, Double.MAX_VALUE, true); } if (iageView != null) { careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE); double insulinAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; - applyRibbonView(iageView, "INS", insulinAge, iageWarn, iageUrgent, Double.MAX_VALUE, true); + applyStatuslight(iageView, "INS", insulinAge, iageWarn, iageUrgent, Double.MAX_VALUE, true); } if (reservoirView != null) { double reservoirLevel = pump.isInitialized() ? pump.getReservoirLevel() : -1; - applyRibbonView(reservoirView, "RES", reservoirLevel, resWarn, resUrgent, -1, false); + applyStatuslight(reservoirView, "RES", reservoirLevel, resWarn, resUrgent, -1, false); } if (sageView != null) { careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE); double sensorAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE; - applyRibbonView(sageView, "SEN", sensorAge, sageWarn, sageUrgent, Double.MAX_VALUE, true); + applyStatuslight(sageView, "SEN", sensorAge, sageWarn, sageUrgent, Double.MAX_VALUE, true); } if (batteryView != null) { double batteryLevel = pump.isInitialized() ? pump.getBatteryLevel() : -1; - applyRibbonView(batteryView, "BAT", batteryLevel, batWarn, batUrgent, -1, false); + applyStatuslight(batteryView, "BAT", batteryLevel, batWarn, batUrgent, -1, false); } statuslightsLayout.setVisibility(View.VISIBLE); } else { @@ -1541,19 +1541,16 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } } - public static void applyRibbonView(TextView view, String text, double value, double warnThreshold, double urgentThreshold, double invalid, boolean checkAscending) { + public static void applyStatuslight(TextView view, String text, double value, double warnThreshold, double urgentThreshold, double invalid, boolean checkAscending) { Function check = checkAscending ? (Double threshold) -> value >= threshold : (Double threshold) -> value <= threshold; if (value != invalid) { view.setText(text); if (check.apply(urgentThreshold)) { - view.setTextColor(MainApp.gc(R.color.ribbonTextCritical)); - view.setBackgroundColor(MainApp.gc(R.color.ribbonBgCritical)); + view.setTextColor(MainApp.gc(R.color.ribbonCritical)); } else if (check.apply(warnThreshold)) { - view.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); - view.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning)); + view.setTextColor(MainApp.gc(R.color.ribbonWarning)); } else { - view.setTextColor(MainApp.gc(R.color.ribbonTextDisabled)); - view.setBackgroundColor(MainApp.gc(R.color.ribbonBgDisabled)); + view.setTextColor(MainApp.gc(R.color.ribbonDefault)); } view.setVisibility(View.VISIBLE); } else { diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 37c11857e9..0224c6c9f1 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -71,13 +71,11 @@ #72FF0000 #72000000 - #5a595b - #f4d700 - #ff0400 + #5a595b + #f4d700 + #ff0400 #FFFFFF #303030 #FFFFFF - #424242 - #333333 From 87d7fed75b159411aa9330822b8ed2fdb36eb9c6 Mon Sep 17 00:00:00 2001 From: Nico Schmitz Date: Sat, 16 Jun 2018 14:03:45 +0200 Subject: [PATCH 11/13] Remove margin of status light layout --- app/src/main/res/layout/overview_fragment.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 3dfe816f46..5a0ae676cd 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -188,8 +188,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" - android:layout_marginTop="3dp" - android:layout_marginBottom="2dp" android:orientation="horizontal"> Date: Sun, 17 Jun 2018 21:02:42 +0200 Subject: [PATCH 12/13] Add overview_statuslights to overview_fragment_smallheight.xml --- .../layout/overview_fragment_smallheight.xml | 62 ++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/overview_fragment_smallheight.xml b/app/src/main/res/layout/overview_fragment_smallheight.xml index ca425337f6..c0bd01cf3b 100644 --- a/app/src/main/res/layout/overview_fragment_smallheight.xml +++ b/app/src/main/res/layout/overview_fragment_smallheight.xml @@ -183,6 +183,65 @@ + + + + + + + + + + + + + + + android:orientation="horizontal"> Date: Sun, 17 Jun 2018 22:41:34 +0200 Subject: [PATCH 13/13] Don't show statuslight preferences in NSCLIENT build --- .../nightscout/androidaps/PreferencesActivity.java | 12 ++++++++++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_overview.xml | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java index 014dfcd863..c2d3e8411b 100644 --- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java @@ -9,6 +9,7 @@ import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.preference.PreferenceGroup; import android.preference.PreferenceManager; +import android.preference.PreferenceScreen; import android.text.TextUtils; import info.nightscout.androidaps.events.EventPreferenceChange; @@ -187,6 +188,17 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre addPreferencesFromResourceIfEnabled(StatuslinePlugin.getPlugin(), PluginType.GENERAL); } + if (Config.NSCLIENT || Config.G5UPLOADER) { + PreferenceScreen scrnAdvancedSettings = (PreferenceScreen)findPreference(getString(R.string.key_advancedsettings)); + if (scrnAdvancedSettings != null) { + scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_res_warning))); + scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_res_critical))); + scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_bat_warning))); + scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_bat_critical))); + scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_show_statuslights))); + } + } + initSummary(getPreferenceScreen()); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 499679a44d..430ba8ebba 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -475,6 +475,7 @@ Always use short average delta instead of simple delta Useful when data from unfiltered sources like xDrip gets noisy. Advanced Settings + key_advancedsettings Model: %02X Protocol: %02X Code: %02X Profile Default value: 3 This is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware that’s what is discussed about “3x max daily; 4x current” for safety caps. diff --git a/app/src/main/res/xml/pref_overview.xml b/app/src/main/res/xml/pref_overview.xml index daf1605fb5..af25a0cf9e 100644 --- a/app/src/main/res/xml/pref_overview.xml +++ b/app/src/main/res/xml/pref_overview.xml @@ -135,7 +135,7 @@ - +