Add setting for showing RL battery level for Medtronic and add setting for enabling battery change logging for Omnipod

This commit is contained in:
Bart Sopers 2021-01-07 23:38:00 +01:00
parent 4cfbcd6040
commit 5c0545cd99
11 changed files with 61 additions and 22 deletions

View file

@ -25,6 +25,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.skins.SkinProvider
import info.nightscout.androidaps.utils.FabricPrivacy
@ -254,7 +255,7 @@ class ActionsFragment : DaggerFragment() {
val activeBgSource = activePlugin.activeBgSource
actions_historybrowser.visibility = (profile != null).toVisibility()
actions_fill?.visibility = (pump.pumpDescription.isRefillingCapable && pump.isInitialized && !pump.isSuspended).toVisibility()
actions_pumpbatterychange?.visibility = pump.pumpDescription.isBatteryReplaceable.toVisibility()
actions_pumpbatterychange?.visibility = (pump.pumpDescription.isBatteryReplaceable || (pump is OmnipodPumpPlugin && pump.isUseRileyLinkBatteryLevel && pump.isBatteryChangeLoggingEnabled)).toVisibility()
actions_temptarget?.visibility = (profile != null && config.APS).toVisibility()
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()

View file

@ -15,7 +15,6 @@
<string name="key_medtronic_encoding" translatable="false">pref_medtronic_encoding</string>
<string name="key_medtronic_battery_type" translatable="false">pref_medtronic_battery_type</string>
<string name="key_medtronic_bolus_debug" translatable="false">pref_medtronic_bolus_debug</string>
<string name="key_rileylink_mac_address" translatable="false">pref_rileylink_mac_address</string>
<string name="key_medtronic_pump_frequency_us_ca" translatable="false">medtronic_pump_frequency_us_ca</string>
<string name="key_medtronic_pump_frequency_worldwide" translatable="false">medtronic_pump_frequency_worldwide</string>
<string name="key_medtronic_pump_encoding_4b6b_local" translatable="false">medtronic_pump_encoding_4b6b_local</string>

View file

@ -98,6 +98,12 @@
<intent android:action="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEConfigActivity" />
</Preference>
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_riley_link_show_battery_level"
android:summary="@string/riley_link_show_battery_level_summary"
android:title="@string/riley_link_show_battery_level" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_set_neutral_temps"

View file

@ -318,7 +318,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.SUSPEND_DELIVERY_BUTTON_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.RILEY_LINK_STATS_BUTTON_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.USE_RILEY_LINK_BATTERY_LEVEL) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.SHOW_RILEY_LINK_BATTERY_LEVEL) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.BATTERY_CHANGE_LOGGING_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED) ||
@ -624,7 +625,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
@Override
public int getBatteryLevel() {
if (aapsOmnipodManager.isUseRileyLinkBatteryLevel()) {
if (aapsOmnipodManager.isShowRileyLinkBatteryLevel()) {
return Optional.ofNullable(rileyLinkServiceData.batteryLevel).orElse(0);
}
@ -1058,7 +1059,11 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
}
public boolean isUseRileyLinkBatteryLevel() {
return aapsOmnipodManager.isUseRileyLinkBatteryLevel();
return aapsOmnipodManager.isShowRileyLinkBatteryLevel();
}
public boolean isBatteryChangeLoggingEnabled() {
return aapsOmnipodManager.isBatteryChangeLoggingEnabled();
}
private void initializeAfterRileyLinkConnection() {

View file

@ -22,7 +22,8 @@ public class OmnipodStorageKeys {
public static final int NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED = R.string.key_omnipod_notification_uncertain_bolus_sound_enabled;
public static final int AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED = R.string.key_omnipod_automatically_acknowledge_alerts_enabled;
public static final int RILEY_LINK_STATS_BUTTON_ENABLED = R.string.key_omnipod_riley_link_stats_button_enabled;
public static final int USE_RILEY_LINK_BATTERY_LEVEL = R.string.key_omnipod_use_riley_link_battery_level;
public static final int SHOW_RILEY_LINK_BATTERY_LEVEL = R.string.key_riley_link_show_battery_level;
public static final int BATTERY_CHANGE_LOGGING_ENABLED = R.string.key_omnipod_battery_change_logging_enabled;
}
public static class Statistics {

View file

@ -121,7 +121,8 @@ public class AapsOmnipodManager {
private boolean notificationUncertainBolusSoundEnabled;
private boolean automaticallyAcknowledgeAlertsEnabled;
private boolean rileylinkStatsButtonEnabled;
private boolean useRileyLinkBatteryLevel;
private boolean showRileyLinkBatteryLevel;
private boolean batteryChangeLoggingEnabled;
@Inject
public AapsOmnipodManager(OmnipodRileyLinkCommunicationManager communicationService,
@ -166,7 +167,8 @@ public class AapsOmnipodManager {
suspendDeliveryButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.SUSPEND_DELIVERY_BUTTON_ENABLED, false);
pulseLogButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED, false);
rileylinkStatsButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.RILEY_LINK_STATS_BUTTON_ENABLED, false);
useRileyLinkBatteryLevel = sp.getBoolean(OmnipodStorageKeys.Preferences.USE_RILEY_LINK_BATTERY_LEVEL, false);
showRileyLinkBatteryLevel = sp.getBoolean(OmnipodStorageKeys.Preferences.SHOW_RILEY_LINK_BATTERY_LEVEL, false);
batteryChangeLoggingEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.BATTERY_CHANGE_LOGGING_ENABLED, false);
timeChangeEventEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED, true);
notificationUncertainTbrSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED, false);
notificationUncertainSmbSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED, true);
@ -669,8 +671,12 @@ public class AapsOmnipodManager {
return rileylinkStatsButtonEnabled;
}
public boolean isUseRileyLinkBatteryLevel() {
return useRileyLinkBatteryLevel;
public boolean isShowRileyLinkBatteryLevel() {
return showRileyLinkBatteryLevel;
}
public boolean isBatteryChangeLoggingEnabled() {
return batteryChangeLoggingEnabled;
}
public boolean isTimeChangeEventEnabled() {

View file

@ -11,7 +11,7 @@
<string name="key_omnipod_suspend_delivery_button_enabled" translatable="false">AAPS.Omnipod.suspend_delivery_button_enabled</string>
<string name="key_omnipod_pulse_log_button_enabled" translatable="false">AAPS.Omnipod.pulse_log_button_enabled</string>
<string name="key_omnipod_riley_link_stats_button_enabled" translatable="false">AAPS.Omnipod.rileylink_stats_button_enabled</string>
<string name="key_omnipod_use_riley_link_battery_level" translatable="false">AAPS.Omnipod.use_riley_link_battery_level</string>
<string name="key_omnipod_battery_change_logging_enabled" translatable="false">AAPS.Omnipod.enable_battery_change_logging</string>
<string name="key_omnipod_time_change_event_enabled" translatable="false">AAPS.Omnipod.time_change_enabled</string>
<string name="key_omnipod_expiration_reminder_enabled" translatable="false">AAPS.Omnipod.expiration_reminder_enabled</string>
<string name="key_omnipod_expiration_reminder_hours_before_shutdown" translatable="false">AAPS.Omnipod.expiration_reminder_hours_before_shutdown</string>
@ -45,8 +45,7 @@
<string name="omnipod_config_suspend_delivery_button_enabled">Show Suspend Delivery button in Omnipod tab</string>
<string name="omnipod_config_pulse_log_button_enabled">Show Pulse Log button in Pod Management menu</string>
<string name="omnipod_config_rileylink_stats_button_enabled">Show RileyLink Stats button in Pod Management menu</string>
<string name="omnipod_config_use_riley_link_battery_level">Use battery level reported by OrangeLink/EmaLink</string>
<string name="omnipod_config_use_riley_link_battery_level_summary">DOES NOT work with the original RileyLink. May not work with other RileyLink alternatives.</string>
<string name="omnipod_config_battery_change_logging_enabled">Enable battery change logging in Actions</string>
<string name="omnipod_config_time_change_enabled">DST/Time zone detection enabled</string>
<string name="omnipod_config_expiration_reminder_enabled">Expiration reminder enabled</string>
<string name="omnipod_config_expiration_reminder_hours_before_shutdown">Hours before shutdown</string>

View file

@ -11,6 +11,18 @@
<intent android:action="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEConfigActivity" />
</Preference>
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_riley_link_show_battery_level"
android:summary="@string/riley_link_show_battery_level_summary"
android:title="@string/riley_link_show_battery_level" />
<SwitchPreference
android:defaultValue="false"
android:dependency="@string/key_riley_link_show_battery_level"
android:key="@string/key_omnipod_battery_change_logging_enabled"
android:title="@string/omnipod_config_battery_change_logging_enabled" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/omnipod_preference_category_confirmation_beeps">
@ -114,12 +126,6 @@
android:key="@string/key_omnipod_riley_link_stats_button_enabled"
android:title="@string/omnipod_config_rileylink_stats_button_enabled" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_omnipod_use_riley_link_battery_level"
android:summary="@string/omnipod_config_use_riley_link_battery_level_summary"
android:title="@string/omnipod_config_use_riley_link_battery_level" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_omnipod_time_change_event_enabled"

View file

@ -25,6 +25,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.Riley
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
/**
* Created by andy on 5/19/18.
@ -39,10 +40,12 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
@Inject AAPSLogger aapsLogger;
@Inject RileyLinkServiceData rileyLinkServiceData;
@Inject DateUtil dateUtil;
@Inject SP sp;
private TextView connectionStatus;
private TextView configuredRileyLinkAddress;
private TextView configuredRileyLinkName;
private View batteryLevelRow;
private TextView batteryLevel;
private TextView connectionError;
private View connectedDeviceDetails;
@ -67,6 +70,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status);
this.configuredRileyLinkAddress = getActivity().findViewById(R.id.rls_t1_configured_riley_link_address);
this.configuredRileyLinkName = getActivity().findViewById(R.id.rls_t1_configured_riley_link_name);
this.batteryLevelRow = getActivity().findViewById(R.id.rls_t1_battery_level_row);
this.batteryLevel = getActivity().findViewById(R.id.rls_t1_battery_level);
this.connectionError = getActivity().findViewById(R.id.rls_t1_connection_error);
this.connectedDeviceDetails = getActivity().findViewById(R.id.rls_t1_connected_device_details);
@ -92,8 +96,13 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
this.configuredRileyLinkAddress.setText(Optional.ofNullable(rileyLinkServiceData.rileyLinkAddress).orElse(PLACEHOLDER));
this.configuredRileyLinkName.setText(Optional.ofNullable(rileyLinkServiceData.rileyLinkName).orElse(PLACEHOLDER));
Integer batteryLevel = rileyLinkServiceData.batteryLevel;
this.batteryLevel.setText(batteryLevel == null ? PLACEHOLDER : resourceHelper.gs(R.string.rileylink_battery_level_value, batteryLevel));
if (sp.getBoolean(resourceHelper.gs(R.string.key_riley_link_show_battery_level), false)) {
batteryLevelRow.setVisibility(View.VISIBLE);
Integer batteryLevel = rileyLinkServiceData.batteryLevel;
this.batteryLevel.setText(batteryLevel == null ? PLACEHOLDER : resourceHelper.gs(R.string.rileylink_battery_level_value, batteryLevel));
} else {
batteryLevelRow.setVisibility(View.GONE);
}
RileyLinkError rileyLinkError = rileyLinkServiceData.rileyLinkError;
this.connectionError.setText(rileyLinkError == null ? PLACEHOLDER : resourceHelper.gs(rileyLinkError.getResourceId(targetDevice)));

View file

@ -83,12 +83,14 @@
</LinearLayout>
<LinearLayout
android:id="@+id/rls_t1_battery_level_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:gravity="center_vertical"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="58dp"

View file

@ -6,6 +6,7 @@
<string name="key_medtronic_pump_encoding_4b6b_rileylink" translatable="false">medtronic_pump_encoding_4b6b_rileylink</string>
<string name="key_rileylink_mac_address" translatable="false">pref_rileylink_mac_address</string>
<string name="key_rileylink_name" translatable="false">pref_rileylink_name</string>
<string name="key_riley_link_show_battery_level" translatable="false">pref_riley_link_show_reported_battery_level</string>
<string name="key_medtronic_encoding" translatable="false">pref_medtronic_encoding</string>
<!-- RL BLE Config -->
@ -75,6 +76,10 @@
<string name="riley_link_common_yes">Yes</string>
<string name="riley_link_common_no">No</string>
<!-- RileyLink - Preferences -->
<string name="riley_link_show_battery_level">Show battery level reported by OrangeLink/EmaLink</string>
<string name="riley_link_show_battery_level_summary">DOES NOT work with the original RileyLink. May not work with other RileyLink alternatives.</string>
<plurals name="duration_days">
<item quantity="one">%1$d day</item>
<item quantity="other">%1$d days</item>