Remove pump unreachable preferences for pumps that have a fixed unreachable warning

This commit is contained in:
Bart Sopers 2020-01-19 21:40:37 +01:00
parent 9dcb8d5137
commit 6f2e39dca7
3 changed files with 19 additions and 1 deletions

View file

@ -9,6 +9,7 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup; import android.preference.PreferenceGroup;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; 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.events.EventRebuildTabs;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType; 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.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin; import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin; import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
import info.nightscout.androidaps.plugins.bus.RxBus; 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.constraints.safety.SafetyPlugin;
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin; import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin;
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin; import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin;
@ -199,6 +202,20 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
for (PluginBase plugin : MainApp.getPluginsList()) { for (PluginBase plugin : MainApp.getPluginsList()) {
plugin.preprocessPreferences(this); 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 @Override

View file

@ -812,6 +812,7 @@
<string name="raise_notifications_as_android_notifications">Use system notifications for alerts and notifications</string> <string name="raise_notifications_as_android_notifications">Use system notifications for alerts and notifications</string>
<string name="key_enable_pump_unreachable_alert" translatable="false">enable_pump_unreachable_alert</string> <string name="key_enable_pump_unreachable_alert" translatable="false">enable_pump_unreachable_alert</string>
<string name="key_enable_missed_bg_readings_alert" translatable="false">enable_missed_bg_readings</string> <string name="key_enable_missed_bg_readings_alert" translatable="false">enable_missed_bg_readings</string>
<string name="key_preferences_screen_local_alerts">preferences_screen_local_alerts</string>
<string name="localalertsettings_title">Local alerts</string> <string name="localalertsettings_title">Local alerts</string>
<string name="enable_missed_bg_readings_alert">Alert if no BG data is received</string> <string name="enable_missed_bg_readings_alert">Alert if no BG data is received</string>
<string name="enable_pump_unreachable_alert">Alert if pump is unreachable</string> <string name="enable_pump_unreachable_alert">Alert if pump is unreachable</string>

View file

@ -72,7 +72,7 @@
android:key="@string/key_short_tabtitles" android:key="@string/key_short_tabtitles"
android:title="@string/short_tabtitles" /> android:title="@string/short_tabtitles" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceScreen android:title="@string/localalertsettings_title"> <PreferenceScreen android:key="@string/key_preferences_screen_local_alerts" android:title="@string/localalertsettings_title">
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_enable_missed_bg_readings_alert" android:key="@string/key_enable_missed_bg_readings_alert"