i18n for Omnipod short status and hide battery level in overview and sms response when Use RL battery level setting is disabled

This commit is contained in:
Bart Sopers 2020-12-19 15:57:20 +01:00
parent f87b35b017
commit 849e333cf4
3 changed files with 48 additions and 22 deletions

View file

@ -9,6 +9,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.db.CareportalEvent
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.WarnColors
@ -49,8 +50,14 @@ class StatusLightHandler @Inject constructor(
else
careportal_sensorbatterylevel?.text = ""
}
if (!config.NSCLIENT && pump.model() != PumpType.AccuChekCombo)
handleLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%")
if (!config.NSCLIENT) {
if (pump.model() == PumpType.Insulet_Omnipod) {
handleOmnipodBatteryLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%", (pump as OmnipodPumpPlugin).isUseRileyLinkBatteryLevel)
} else if (pump.model() != PumpType.AccuChekCombo) {
handleLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%")
}
}
}
private fun handleAge(view: TextView?, eventName: String, @StringRes warnSettings: Int, defaultWarnThreshold: Double, @StringRes urgentSettings: Int, defaultUrgentThreshold: Double) {
@ -75,16 +82,21 @@ class StatusLightHandler @Inject constructor(
// Omnipod only reports reservoir level when it's 50 units or less, so we display "50+U" for any value > 50
private fun handleOmnipodReservoirLevel(view: TextView?, criticalSetting: Int, criticalDefaultValue: Double, warnSetting: Int, warnDefaultValue: Double, level: Double, units: String) {
val resUrgent = sp.getDouble(criticalSetting, criticalDefaultValue)
val resWarn = sp.getDouble(warnSetting, warnDefaultValue)
if (level > OmnipodConstants.MAX_RESERVOIR_READING) {
@Suppress("SetTextI18n")
view?.text = " 50+$units"
view?.setTextColor(Color.WHITE)
} else {
@Suppress("SetTextI18n")
view?.text = " " + DecimalFormatter.to0Decimal(level) + units
warnColors.setColorInverse(view, level, resWarn, resUrgent)
handleLevel(view, criticalSetting, criticalDefaultValue, warnSetting, warnDefaultValue, level, units)
}
}
private fun handleOmnipodBatteryLevel(view: TextView?, criticalSetting: Int, criticalDefaultValue: Double, warnSetting: Int, warnDefaultValue: Double, level: Double, units: String, useRileyLinkBatteryLevel: Boolean) {
if (useRileyLinkBatteryLevel) {
handleLevel(view, criticalSetting, criticalDefaultValue, warnSetting, warnDefaultValue, level, units)
} else {
view?.text = resourceHelper.gs(R.string.notavailable)
view?.setTextColor(Color.WHITE)
}
}
}

View file

@ -119,7 +119,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
private static final long STATUS_CHECK_INTERVAL_MILLIS = 60 * 1000L; // 1 minute
public static final int STARTUP_STATUS_REQUEST_TRIES = 2;
public static final double RESERVOIR_OVER_50_UNITS_DEFAULT = 75.0;
private static final int DEFAULT_BATTERY_LEVEL = 75;
private final PodStateManager podStateManager;
private final RileyLinkServiceData rileyLinkServiceData;
@ -617,7 +616,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
return rileyLinkServiceData.batteryLevel == null ? 0 : rileyLinkServiceData.batteryLevel;
}
return DEFAULT_BATTERY_LEVEL;
return 0;
}
@NonNull @Override
@ -741,7 +740,9 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
status.put("timestamp", DateUtil.toISOString(new Date()));
pump.put("battery", battery);
if (isUseRileyLinkBatteryLevel()) {
pump.put("battery", battery);
}
pump.put("status", status);
pump.put("extended", extended);
@ -779,34 +780,34 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
return pumpDescription;
}
// FIXME i18n, null checks: iob, TDD
@NonNull @Override
public String shortStatus(boolean veryShort) {
if (!podStateManager.isPodActivationCompleted()) {
return "No active pod";
return resourceHelper.gs(R.string.omnipod_short_status_no_active_pod);
}
String ret = "";
if (lastConnectionTimeMillis != 0) {
long agoMsec = System.currentTimeMillis() - lastConnectionTimeMillis;
int agoMin = (int) (agoMsec / 60d / 1000d);
ret += "LastConn: " + agoMin + " min ago\n";
ret += resourceHelper.gs(R.string.omnipod_short_status_last_connection, agoMin) + "\n";
}
if (podStateManager.getLastBolusStartTime() != null) {
ret += "LastBolus: " + DecimalFormatter.to2Decimal(podStateManager.getLastBolusAmount()) + "U @" + //
android.text.format.DateFormat.format("HH:mm", podStateManager.getLastBolusStartTime().toDate()) + "\n";
ret += resourceHelper.gs(R.string.omnipod_short_status_last_bolus, DecimalFormatter.to2Decimal(podStateManager.getLastBolusAmount()),
android.text.format.DateFormat.format("HH:mm", podStateManager.getLastBolusStartTime().toDate())) + "\n";
}
TemporaryBasal activeTemp = activePlugin.getActiveTreatments().getRealTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) {
ret += "Temp: " + activeTemp.toStringFull() + "\n";
ret += resourceHelper.gs(R.string.omnipod_short_status_temp_basal, activeTemp.toStringFull()) + "\n";
}
ExtendedBolus activeExtendedBolus = activePlugin.getActiveTreatments().getExtendedBolusFromHistory(
System.currentTimeMillis());
if (activeExtendedBolus != null) {
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
ret += resourceHelper.gs(R.string.omnipod_short_status_extended_bolus, activeExtendedBolus.toString()) + "\n";
}
ret += resourceHelper.gs(R.string.omnipod_short_status_reservoir, (getReservoirLevel() > OmnipodConstants.MAX_RESERVOIR_READING ? "50+" : DecimalFormatter.to0Decimal(getReservoirLevel()))) + "\n";
if (isUseRileyLinkBatteryLevel()) {
ret += resourceHelper.gs(R.string.omnipod_short_status_rl_battery, getBatteryLevel()) + "\n";
}
ret += "Reserv: " + (getReservoirLevel() > OmnipodConstants.MAX_RESERVOIR_READING ? "50+U" : DecimalFormatter.to0Decimal(getReservoirLevel()) + "U") + "\n";
ret += "Batt: " + getBatteryLevel();
return ret.trim();
}
@ -1042,6 +1043,10 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver);
}
public boolean isUseRileyLinkBatteryLevel() {
return aapsOmnipodManager.isUseRileyLinkBatteryLevel();
}
private void initializeAfterRileyLinkConnection() {
if (podStateManager.getActivationProgress().isAtLeast(ActivationProgress.PAIRING_COMPLETED)) {
boolean success = false;

View file

@ -44,8 +44,8 @@
<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 RileyLink (experimental)</string>
<string name="omnipod_config_use_riley_link_battery_level_summary">Only tested with EmaLink. The reported battery level may be inaccurate with other devices.\nWhen disabled, the battery level show a fixed value of 75.</string>
<string name="omnipod_config_use_riley_link_battery_level">Use battery level reported by RileyLink</string>
<string name="omnipod_config_use_riley_link_battery_level_summary">Works with EmaLink and OrangeLink.\nDOES NOT work with the original RileyLink: it will not report the actual battery level. Might also not work with other RileyLink alternatives.</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>
@ -91,6 +91,15 @@
<string name="omnipod_history_bolus_value_with_carbs">%1$.2f U, CH=%2$.1f g</string>
<string name="omnipod_history_tbr_value">Rate: %1$.2f U, duration: %2$d minutes</string>
<!-- Omnipod - Short status -->
<string name="omnipod_short_status_no_active_pod">No active Pod</string>
<string name="omnipod_short_status_last_connection">LastConn: %1$d min ago</string>
<string name="omnipod_short_status_last_bolus">LastBolus: %1$s @ %2$s</string>
<string name="omnipod_short_status_temp_basal">Temp: %1$s</string>
<string name="omnipod_short_status_extended_bolus">Extended: %1$s</string>
<string name="omnipod_short_status_reservoir">Reserv: %1$sU</string>
<string name="omnipod_short_status_rl_battery">RLBatt: %1$d</string>
<!-- Omnipod - Error -->
<string name="omnipod_warning">Warning</string>
<string name="omnipod_error_rileylink_address_invalid">RileyLink address invalid.</string>