From 6f2e39dca7eee3d8bac47f23d7f42e68a3d62fd4 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Sun, 19 Jan 2020 21:40:37 +0100 Subject: [PATCH] Remove pump unreachable preferences for pumps that have a fixed unreachable warning --- .../activities/PreferencesActivity.java | 17 +++++++++++++++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_others.xml | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java index 0e93a47151..54e9bfe39a 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/activities/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 info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; @@ -17,11 +18,13 @@ import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRebuildTabs; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin; import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin; import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin; import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin; import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin; @@ -199,6 +202,20 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre for (PluginBase plugin : MainApp.getPluginsList()) { plugin.preprocessPreferences(this); } + + PumpInterface activePump = ConfigBuilderPlugin.getPlugin().getActivePump(); + PreferenceScreen localAlertsPreferenceScreen = (PreferenceScreen) findPreference(MainApp.gs(R.string.key_preferences_screen_local_alerts)); + if (activePump != null && localAlertsPreferenceScreen != null && activePump.getPumpDescription().hasFixedUnreachableAlert) { + Preference pumpUnreachableEnabledPreference = findPreference(MainApp.gs(R.string.key_enable_pump_unreachable_alert)); + if (pumpUnreachableEnabledPreference != null) { + localAlertsPreferenceScreen.removePreference(pumpUnreachableEnabledPreference); + } + + Preference pumpUnreachableThresholdPreference = findPreference(MainApp.gs(R.string.key_pump_unreachable_threshold)); + if (pumpUnreachableThresholdPreference != null) { + localAlertsPreferenceScreen.removePreference(pumpUnreachableThresholdPreference); + } + } } @Override diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f083f9a09d..267e9195a5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -812,6 +812,7 @@ Use system notifications for alerts and notifications enable_pump_unreachable_alert enable_missed_bg_readings + preferences_screen_local_alerts Local alerts Alert if no BG data is received Alert if pump is unreachable diff --git a/app/src/main/res/xml/pref_others.xml b/app/src/main/res/xml/pref_others.xml index cbe2b9c705..10302348b3 100644 --- a/app/src/main/res/xml/pref_others.xml +++ b/app/src/main/res/xml/pref_others.xml @@ -72,7 +72,7 @@ android:key="@string/key_short_tabtitles" android:title="@string/short_tabtitles" /> - +