Add optional Suspend delivery button; fix bug where AAPS tries to set bolus before Pod activation is completed; cleanup preferences & several enums; use String resources for RL History items

This commit is contained in:
Bart Sopers 2020-08-26 13:45:32 +02:00
parent 28df570a6a
commit 14652ab917
27 changed files with 349 additions and 272 deletions

View file

@ -182,7 +182,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
pumpDescription = new PumpDescription(pumpType); pumpDescription = new PumpDescription(pumpType);
customActions.add(new CustomAction( customActions.add(new CustomAction(
R.string.omnipod_custom_action_reset_rileylink, OmnipodCustomActionType.ResetRileyLinkConfiguration, true)); R.string.omnipod_custom_action_reset_rileylink, OmnipodCustomActionType.RESET_RILEY_LINK_CONFIGURATION, true));
this.serviceConnection = new ServiceConnection() { this.serviceConnection = new ServiceConnection() {
@Override @Override
@ -252,12 +252,13 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
.toObservable(EventPreferenceChange.class) .toObservable(EventPreferenceChange.class)
.observeOn(Schedulers.io()) .observeOn(Schedulers.io())
.subscribe(event -> { .subscribe(event -> {
if ((event.isChanged(getResourceHelper(), R.string.key_omnipod_beep_basal_enabled)) || if ((event.isChanged(getResourceHelper(), R.string.key_omnipod_basal_beeps_enabled)) ||
(event.isChanged(getResourceHelper(), R.string.key_omnipod_beep_bolus_enabled)) || (event.isChanged(getResourceHelper(), R.string.key_omnipod_bolus_beeps_enabled)) ||
(event.isChanged(getResourceHelper(), R.string.key_omnipod_beep_tbr_enabled)) || (event.isChanged(getResourceHelper(), R.string.key_omnipod_tbr_beeps_enabled)) ||
(event.isChanged(getResourceHelper(), R.string.key_omnipod_pod_debugging_options_enabled)) || (event.isChanged(getResourceHelper(), R.string.key_omnipod_smb_beeps_enabled)) ||
(event.isChanged(getResourceHelper(), R.string.key_omnipod_beep_smb_enabled)) || (event.isChanged(getResourceHelper(), R.string.key_omnipod_suspend_delivery_button_enabled)) ||
(event.isChanged(getResourceHelper(), R.string.key_omnipod_timechange_enabled))) (event.isChanged(getResourceHelper(), R.string.key_omnipod_pulse_log_button_enabled)) ||
(event.isChanged(getResourceHelper(), R.string.key_omnipod_time_change_event_enabled)))
aapsOmnipodManager.reloadSettings(); aapsOmnipodManager.reloadSettings();
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
); );
@ -269,8 +270,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
// If so, add it to history // If so, add it to history
// Needs to be done after EventAppInitialized because otherwise, TreatmentsPlugin.onStart() hasn't been called yet // Needs to be done after EventAppInitialized because otherwise, TreatmentsPlugin.onStart() hasn't been called yet
// so it didn't initialize a TreatmentService yet, resulting in a NullPointerException // so it didn't initialize a TreatmentService yet, resulting in a NullPointerException
if (sp.contains(OmnipodStorageKeys.Prefs.ActiveBolus)) { if (sp.contains(OmnipodStorageKeys.Preferences.ACTIVE_BOLUS)) {
String activeBolusString = sp.getString(OmnipodStorageKeys.Prefs.ActiveBolus, ""); String activeBolusString = sp.getString(OmnipodStorageKeys.Preferences.ACTIVE_BOLUS, "");
aapsLogger.warn(LTag.PUMP, "Found active bolus in SP: {}. Adding Treatment.", activeBolusString); aapsLogger.warn(LTag.PUMP, "Found active bolus in SP: {}. Adding Treatment.", activeBolusString);
try { try {
ActiveBolus activeBolus = aapsOmnipodUtil.getGsonInstance().fromJson(activeBolusString, ActiveBolus.class); ActiveBolus activeBolus = aapsOmnipodUtil.getGsonInstance().fromJson(activeBolusString, ActiveBolus.class);
@ -278,7 +279,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error(LTag.PUMP, "Failed to add active bolus to history", ex); aapsLogger.error(LTag.PUMP, "Failed to add active bolus to history", ex);
} }
sp.remove(OmnipodStorageKeys.Prefs.ActiveBolus); sp.remove(OmnipodStorageKeys.Preferences.ACTIVE_BOLUS);
} }
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
); );
@ -411,9 +412,9 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
while (iterator.hasNext()) { while (iterator.hasNext()) {
OmnipodStatusRequestType statusRequest = iterator.next(); OmnipodStatusRequestType statusRequest = iterator.next();
switch (statusRequest) { switch (statusRequest) {
case GetPodPulseLog: case GET_PULSE_LOG:
try { try {
PodInfoRecentPulseLog result = executeCommand(OmnipodCommandType.GetPodPulseLog, aapsOmnipodManager::readPulseLog); PodInfoRecentPulseLog result = executeCommand(OmnipodCommandType.GET_POD_PULSE_LOG, aapsOmnipodManager::readPulseLog);
Intent i = new Intent(context, ErrorHelperActivity.class); Intent i = new Intent(context, ErrorHelperActivity.class);
i.putExtra("soundid", 0); i.putExtra("soundid", 0);
i.putExtra("status", "Pulse Log (copied to clipboard):\n" + result.toString()); i.putExtra("status", "Pulse Log (copied to clipboard):\n" + result.toString());
@ -431,11 +432,14 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
context.startActivity(i); context.startActivity(i);
} }
break; break;
case AcknowledgeAlerts: case ACKNOWLEDGE_ALERTS:
executeCommand(OmnipodCommandType.AcknowledgeAlerts, aapsOmnipodManager::acknowledgeAlerts); executeCommand(OmnipodCommandType.ACKNOWLEDGE_ALERTS, aapsOmnipodManager::acknowledgeAlerts);
break; break;
case GetPodState: case GET_POD_STATE:
executeCommand(OmnipodCommandType.GetPodStatus, aapsOmnipodManager::getPodStatus); executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);
break;
case SUSPEND_DELIVERY:
executeCommand(OmnipodCommandType.SUSPEND_DELIVERY, aapsOmnipodManager::suspendDelivery);
break; break;
default: default:
aapsLogger.error(LTag.PUMP, "Unknown status request: " + statusRequest.name()); aapsLogger.error(LTag.PUMP, "Unknown status request: " + statusRequest.name());
@ -443,7 +447,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
iterator.remove(); iterator.remove();
} }
} else if (this.hasTimeDateOrTimeZoneChanged) { } else if (this.hasTimeDateOrTimeZoneChanged) {
PumpEnactResult result = executeCommand(OmnipodCommandType.SetTime, aapsOmnipodManager::setTime); PumpEnactResult result = executeCommand(OmnipodCommandType.SET_TIME, aapsOmnipodManager::setTime);
if (result.success) { if (result.success) {
this.hasTimeDateOrTimeZoneChanged = false; this.hasTimeDateOrTimeZoneChanged = false;
@ -469,7 +473,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
@NotNull @NotNull
@Override @Override
public PumpEnactResult setNewBasalProfile(Profile profile) { public PumpEnactResult setNewBasalProfile(Profile profile) {
PumpEnactResult result = executeCommand(OmnipodCommandType.SetBasalProfile, () -> aapsOmnipodManager.setBasalProfile(profile)); PumpEnactResult result = executeCommand(OmnipodCommandType.SET_BASAL_PROFILE, () -> aapsOmnipodManager.setBasalProfile(profile));
aapsLogger.info(LTag.PUMP, "Basal Profile was set: " + result.success); aapsLogger.info(LTag.PUMP, "Basal Profile was set: " + result.success);
@ -492,7 +496,9 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
@Override @Override
public boolean isThisProfileSet(Profile profile) { public boolean isThisProfileSet(Profile profile) {
if (!podStateManager.isPodActivationCompleted()) { if (!podStateManager.isPodActivationCompleted()) {
return false; // When no Pod is active, return true here in order to prevent AAPS from setting a profile
// When we activate a new Pod, we just use ProfileFunction to set the currently active profile
return true;
} }
return podStateManager.getBasalSchedule().equals(AapsOmnipodManager.mapProfileToBasalSchedule(profile)); return podStateManager.getBasalSchedule().equals(AapsOmnipodManager.mapProfileToBasalSchedule(profile));
} }
@ -560,7 +566,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
@Override @Override
public void stopBolusDelivering() { public void stopBolusDelivering() {
executeCommand(OmnipodCommandType.CancelBolus, aapsOmnipodManager::cancelBolus); executeCommand(OmnipodCommandType.CANCEL_BOLUS, aapsOmnipodManager::cancelBolus);
} }
// if enforceNew===true current temp basal is canceled and new TBR set (duration is prolonged), // if enforceNew===true current temp basal is canceled and new TBR set (duration is prolonged),
@ -586,12 +592,12 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
} }
} }
PumpEnactResult result = executeCommand(OmnipodCommandType.SetTemporaryBasal, () -> aapsOmnipodManager.setTemporaryBasal(new TempBasalPair(absoluteRate, false, durationInMinutes))); PumpEnactResult result = executeCommand(OmnipodCommandType.SET_TEMPORARY_BASAL, () -> aapsOmnipodManager.setTemporaryBasal(new TempBasalPair(absoluteRate, false, durationInMinutes)));
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - setTBR. Response: " + result.success); aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - setTBR. Response: " + result.success);
if (result.success) { if (result.success) {
incrementStatistics(OmnipodStorageKeys.Statistics.TBRsSet); incrementStatistics(OmnipodStorageKeys.Statistics.TBRS_SET);
} }
return result; return result;
@ -607,7 +613,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
return new PumpEnactResult(getInjector()).success(true).enacted(false); return new PumpEnactResult(getInjector()).success(true).enacted(false);
} }
PumpEnactResult result = executeCommand(OmnipodCommandType.CancelTemporaryBasal, aapsOmnipodManager::cancelTemporaryBasal); PumpEnactResult result = executeCommand(OmnipodCommandType.CANCEL_TEMPORARY_BASAL, aapsOmnipodManager::cancelTemporaryBasal);
if (result.success) { if (result.success) {
// TODO is this necessary? // TODO is this necessary?
@ -733,7 +739,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
OmnipodCustomActionType mcat = (OmnipodCustomActionType) customActionType; OmnipodCustomActionType mcat = (OmnipodCustomActionType) customActionType;
switch (mcat) { switch (mcat) {
case ResetRileyLinkConfiguration: case RESET_RILEY_LINK_CONFIGURATION:
serviceTaskExecutor.startTask(new ResetRileyLinkConfigurationTask(getInjector())); serviceTaskExecutor.startTask(new ResetRileyLinkConfigurationTask(getInjector()));
break; break;
@ -836,7 +842,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
private void initializeAfterRileyLinkConnection() { private void initializeAfterRileyLinkConnection() {
if (podStateManager.isPodInitialized() && podStateManager.getPodProgressStatus().isAtLeast(PodProgressStatus.PAIRING_COMPLETED)) { if (podStateManager.isPodInitialized() && podStateManager.getPodProgressStatus().isAtLeast(PodProgressStatus.PAIRING_COMPLETED)) {
PumpEnactResult result = executeCommand(OmnipodCommandType.GetPodStatus, aapsOmnipodManager::getPodStatus); PumpEnactResult result = executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);
if (result.success) { if (result.success) {
aapsLogger.debug(LTag.PUMP, "Successfully retrieved Pod status on startup"); aapsLogger.debug(LTag.PUMP, "Successfully retrieved Pod status on startup");
} else { } else {
@ -859,11 +865,11 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
} }
@NonNull private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) { @NonNull private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
PumpEnactResult result = executeCommand(OmnipodCommandType.SetBolus, () -> aapsOmnipodManager.bolus(detailedBolusInfo)); PumpEnactResult result = executeCommand(OmnipodCommandType.SET_BOLUS, () -> aapsOmnipodManager.bolus(detailedBolusInfo));
if (result.success) { if (result.success) {
incrementStatistics(detailedBolusInfo.isSMB ? OmnipodStorageKeys.Statistics.SMBBoluses incrementStatistics(detailedBolusInfo.isSMB ? OmnipodStorageKeys.Statistics.SMB_BOLUSES_DELIVERED
: OmnipodStorageKeys.Statistics.StandardBoluses); : OmnipodStorageKeys.Statistics.STANDARD_BOLUSES_DELIVERED);
result.carbsDelivered(detailedBolusInfo.carbs); result.carbsDelivered(detailedBolusInfo.carbs);
} }
@ -874,7 +880,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
private <T> T executeCommand(OmnipodCommandType commandType, Supplier<T> supplier) { private <T> T executeCommand(OmnipodCommandType commandType, Supplier<T> supplier) {
aapsLogger.debug(LTag.PUMP, "Executing command: {}", commandType); aapsLogger.debug(LTag.PUMP, "Executing command: {}", commandType);
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItemOmnipod(commandType)); rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItemOmnipod(getInjector(), commandType));
T pumpEnactResult = supplier.get(); T pumpEnactResult = supplier.get();

View file

@ -2,6 +2,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.data;
import org.joda.time.LocalDateTime; import org.joda.time.LocalDateTime;
import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.pump.omnipod.definition.OmnipodCommandType; import info.nightscout.androidaps.plugins.pump.omnipod.definition.OmnipodCommandType;
@ -9,17 +12,19 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
public class RLHistoryItemOmnipod extends RLHistoryItem { public class RLHistoryItemOmnipod extends RLHistoryItem {
@Inject ResourceHelper resourceHelper;
private final OmnipodCommandType omnipodCommandType; private final OmnipodCommandType omnipodCommandType;
public RLHistoryItemOmnipod(OmnipodCommandType omnipodCommandType) { public RLHistoryItemOmnipod(HasAndroidInjector injector, OmnipodCommandType omnipodCommandType) {
super(new LocalDateTime(), RLHistoryItemSource.OmnipodCommand, RileyLinkTargetDevice.Omnipod); super(new LocalDateTime(), RLHistoryItemSource.OmnipodCommand, RileyLinkTargetDevice.Omnipod);
injector.androidInjector().inject(this);
this.omnipodCommandType = omnipodCommandType; this.omnipodCommandType = omnipodCommandType;
} }
@Override @Override
public String getDescription(ResourceHelper resourceHelper) { public String getDescription(ResourceHelper resourceHelper) {
if (RLHistoryItemSource.OmnipodCommand.equals(source)) { if (RLHistoryItemSource.OmnipodCommand.equals(source)) {
return omnipodCommandType.name(); return resourceHelper.gs(omnipodCommandType.getResourceId());
} }
return super.getDescription(resourceHelper); return super.getDescription(resourceHelper);
} }

View file

@ -1,20 +1,33 @@
package info.nightscout.androidaps.plugins.pump.omnipod.definition; package info.nightscout.androidaps.plugins.pump.omnipod.definition;
import info.nightscout.androidaps.plugins.pump.omnipod.R;
/** /**
* Created by andy on 4.8.2019 * Created by andy on 4.8.2019
*/ */
public enum OmnipodCommandType { public enum OmnipodCommandType {
PairAndPrimePod, // First step of Pod activation PAIR_AND_PRIME_POD(R.string.omnipod_cmd_pair_and_prime), // First step of Pod activation
FillCanulaAndSetBasalProfile, // Second step of Pod activation FILL_CANNULA_AND_SET_BASAL_PROFILE(R.string.omnipod_cmd_fill_cannula_set_basal_profile), // Second step of Pod activation
DeactivatePod, // DEACTIVATE_POD(R.string.omnipod_cmd_deactivate_pod), //
SetBasalProfile, // SET_BASAL_PROFILE(R.string.omnipod_cmd_set_basal_schedule), //
SetBolus, // SET_BOLUS(R.string.omnipod_cmd_set_bolus), //
CancelBolus, // CANCEL_BOLUS(R.string.omnipod_cmd_cancel_bolus), //
SetTemporaryBasal, // SET_TEMPORARY_BASAL(R.string.omnipod_cmd_set_tbr), //
CancelTemporaryBasal, // CANCEL_TEMPORARY_BASAL(R.string.omnipod_cmd_cancel_tbr_by_driver), //
ResetPodStatus, // DISCARD_POD(R.string.omnipod_cmd_discard_pod), //
GetPodStatus, // GET_POD_STATUS(R.string.omnipod_cmd_get_pod_status), //
SetTime, // SET_TIME(R.string.omnipod_cmd_set_time), //
AcknowledgeAlerts, // ACKNOWLEDGE_ALERTS(R.string.omnipod_cmd_acknowledge_alerts), //
GetPodPulseLog; GET_POD_PULSE_LOG(R.string.omnipod_cmd_get_pulse_log), //
SUSPEND_DELIVERY(R.string.omnipod_cmd_suspend_delivery);
private int resourceId;
OmnipodCommandType(int resourceId) {
this.resourceId = resourceId;
}
public int getResourceId() {
return resourceId;
}
} }

View file

@ -7,7 +7,7 @@ import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
*/ */
public enum OmnipodCustomActionType implements CustomActionType { public enum OmnipodCustomActionType implements CustomActionType {
ResetRileyLinkConfiguration; RESET_RILEY_LINK_CONFIGURATION;
@Override @Override
public String getKey() { public String getKey() {

View file

@ -1,7 +1,8 @@
package info.nightscout.androidaps.plugins.pump.omnipod.definition; package info.nightscout.androidaps.plugins.pump.omnipod.definition;
public enum OmnipodStatusRequestType { public enum OmnipodStatusRequestType {
AcknowledgeAlerts, ACKNOWLEDGE_ALERTS,
GetPodState, GET_POD_STATE,
GetPodPulseLog GET_PULSE_LOG,
SUSPEND_DELIVERY
} }

View file

@ -3,23 +3,23 @@ package info.nightscout.androidaps.plugins.pump.omnipod.definition;
import info.nightscout.androidaps.plugins.pump.omnipod.R; import info.nightscout.androidaps.plugins.pump.omnipod.R;
public class OmnipodStorageKeys { public class OmnipodStorageKeys {
private static final String Prefix = "AAPS.Omnipod."; private static final String PREFIX = "AAPS.Omnipod.";
public static class Prefs { public static class Preferences {
public static final String PodState = Prefix + "pod_state"; public static final String POD_STATE = PREFIX + "pod_state";
public static final String ActiveBolus = Prefix + "current_bolus"; public static final String ACTIVE_BOLUS = PREFIX + "current_bolus";
public static final int BeepBasalEnabled = R.string.key_omnipod_beep_basal_enabled; public static final int BASAL_BEEPS_ENABLED = R.string.key_omnipod_basal_beeps_enabled;
public static final int BeepBolusEnabled = R.string.key_omnipod_beep_bolus_enabled; public static final int BOLUS_BEEPS_ENABLED = R.string.key_omnipod_bolus_beeps_enabled;
public static final int BeepSMBEnabled = R.string.key_omnipod_beep_smb_enabled; public static final int SMB_BEEPS_ENABLED = R.string.key_omnipod_smb_beeps_enabled;
public static final int BeepTBREnabled = R.string.key_omnipod_beep_tbr_enabled; public static final int TBR_BEEPS_ENABLED = R.string.key_omnipod_tbr_beeps_enabled;
public static final int PodDebuggingOptionsEnabled = R.string.key_omnipod_pod_debugging_options_enabled; public static final int SUSPEND_DELIVERY_BUTTON_ENABLED = R.string.key_omnipod_pulse_log_button_enabled;
public static final int TimeChangeEventEnabled = R.string.key_omnipod_timechange_enabled; public static final int PULSE_LOG_BUTTON_ENABLED = R.string.key_omnipod_pulse_log_button_enabled;
public static final int TIME_CHANGE_EVENT_ENABLED = R.string.key_omnipod_time_change_event_enabled;
} }
public static class Statistics { public static class Statistics {
static final String StatsPrefix = "omnipod_"; public static final String TBRS_SET = PREFIX + "tbrs_set";
public static final String TBRsSet = StatsPrefix + "tbrs_set"; public static final String STANDARD_BOLUSES_DELIVERED = PREFIX + "std_boluses_delivered";
public static final String StandardBoluses = StatsPrefix + "std_boluses_delivered"; public static final String SMB_BOLUSES_DELIVERED = PREFIX + "smb_boluses_delivered";
public static final String SMBBoluses = StatsPrefix + "smb_boluses_delivered";
} }
} }

View file

@ -13,31 +13,31 @@ import info.nightscout.androidaps.plugins.pump.omnipod.R;
*/ */
public enum PodHistoryEntryType { public enum PodHistoryEntryType {
PairAndPrime(1, R.string.omnipod_init_pod_wizard_step2_title, PumpHistoryEntryGroup.Prime), PAIR_AND_PRIME(1, R.string.omnipod_init_pod_wizard_step2_title, PumpHistoryEntryGroup.Prime),
FillCannulaSetBasalProfile(2, R.string.omnipod_init_pod_wizard_step4_title, PumpHistoryEntryGroup.Prime), FILL_CANNULA_SET_BASAL_PROFILE(2, R.string.omnipod_init_pod_wizard_step4_title, PumpHistoryEntryGroup.Prime),
DeactivatePod(3, R.string.omnipod_cmd_deactivate_pod, PumpHistoryEntryGroup.Prime), DEACTIVATE_POD(3, R.string.omnipod_cmd_deactivate_pod, PumpHistoryEntryGroup.Prime),
ResetPodState(4, R.string.omnipod_cmd_reset_pod, PumpHistoryEntryGroup.Prime), RESET_POD_STATE(4, R.string.omnipod_cmd_discard_pod, PumpHistoryEntryGroup.Prime),
SetTemporaryBasal(10, R.string.omnipod_cmd_set_tbr, PumpHistoryEntryGroup.Basal), SET_TEMPORARY_BASAL(10, R.string.omnipod_cmd_set_tbr, PumpHistoryEntryGroup.Basal),
CancelTemporaryBasal(11, R.string.omnipod_cmd_cancel_tbr, PumpHistoryEntryGroup.Basal), CANCEL_TEMPORARY_BASAL_BY_DRIVER(11, R.string.omnipod_cmd_cancel_tbr_by_driver, PumpHistoryEntryGroup.Basal),
CancelTemporaryBasalForce(12, R.string.omnipod_cmd_cancel_tbr_forced, PumpHistoryEntryGroup.Basal), CANCEL_TEMPORARY_BASAL(12, R.string.omnipod_cmd_cancel_tbr, PumpHistoryEntryGroup.Basal),
SetBasalSchedule(20, R.string.omnipod_cmd_set_basal_schedule, PumpHistoryEntryGroup.Basal), SET_BASAL_SCHEDULE(20, R.string.omnipod_cmd_set_basal_schedule, PumpHistoryEntryGroup.Basal),
GetPodStatus(30, R.string.omnipod_cmd_get_pod_status, PumpHistoryEntryGroup.Configuration), GET_POD_STATUS(30, R.string.omnipod_cmd_get_pod_status, PumpHistoryEntryGroup.Configuration),
GetPodInfo(31, R.string.omnipod_cmd_get_pod_info, PumpHistoryEntryGroup.Configuration), GET_POD_INFO(31, R.string.omnipod_cmd_get_pod_info, PumpHistoryEntryGroup.Configuration),
SetTime(32, R.string.omnipod_cmd_set_time, PumpHistoryEntryGroup.Configuration), SET_TIME(32, R.string.omnipod_cmd_set_time, PumpHistoryEntryGroup.Configuration),
SetBolus(40, R.string.omnipod_cmd_set_bolus, PumpHistoryEntryGroup.Bolus), SET_BOLUS(40, R.string.omnipod_cmd_set_bolus, PumpHistoryEntryGroup.Bolus),
CancelBolus(41, R.string.omnipod_cmd_cancel_bolus, PumpHistoryEntryGroup.Bolus), CANCEL_BOLUS(41, R.string.omnipod_cmd_cancel_bolus, PumpHistoryEntryGroup.Bolus),
ConfigureAlerts(50, R.string.omnipod_cmd_configure_alerts, PumpHistoryEntryGroup.Alarm), CONFIGURE_ALERTS(50, R.string.omnipod_cmd_configure_alerts, PumpHistoryEntryGroup.Alarm),
AcknowledgeAlerts(51, R.string.omnipod_cmd_acknowledge_alerts, PumpHistoryEntryGroup.Alarm), ACKNOWLEDGE_ALERTS(51, R.string.omnipod_cmd_acknowledge_alerts, PumpHistoryEntryGroup.Alarm),
SuspendDelivery(60, R.string.omnipod_cmd_suspend_delivery, PumpHistoryEntryGroup.Basal), SUSPEND_DELIVERY(60, R.string.omnipod_cmd_suspend_delivery, PumpHistoryEntryGroup.Basal),
ResumeDelivery(61, R.string.omnipod_cmd_resume_delivery, PumpHistoryEntryGroup.Basal), RESUME_DELIVERY(61, R.string.omnipod_cmd_resume_delivery, PumpHistoryEntryGroup.Basal),
UnknownEntryType(99, R.string.omnipod_cmd_unknown_entry); UNKNOWN_ENTRY_TYPE(99, R.string.omnipod_cmd_unknown_entry);
private int code; private int code;
private static final Map<Integer, PodHistoryEntryType> instanceMap; private static final Map<Integer, PodHistoryEntryType> instanceMap;
@ -82,7 +82,7 @@ public enum PodHistoryEntryType {
if (instanceMap.containsKey(code)) { if (instanceMap.containsKey(code)) {
return instanceMap.get(code); return instanceMap.get(code);
} else { } else {
return UnknownEntryType; return UNKNOWN_ENTRY_TYPE;
} }
} }

View file

@ -7,17 +7,17 @@ import info.nightscout.androidaps.plugins.pump.omnipod.R;
public enum PodInitActionType { public enum PodInitActionType {
PairAndPrimeWizardStep(), // PAIR_AND_PRIME_WIZARD_STEP(), //
PairPod(R.string.omnipod_init_pod_pair_pod, PairAndPrimeWizardStep), // PAIR_POD(R.string.omnipod_init_pod_pair_pod, PAIR_AND_PRIME_WIZARD_STEP), //
PrimePod(R.string.omnipod_init_pod_prime_pod, PairAndPrimeWizardStep), // PRIME_POD(R.string.omnipod_init_pod_prime_pod, PAIR_AND_PRIME_WIZARD_STEP), //
FillCannulaSetBasalProfileWizardStep(), // FILL_CANNULA_SET_BASAL_PROFILE_WIZARD_STEP(), //
FillCannula(R.string.omnipod_init_pod_fill_cannula, FillCannulaSetBasalProfileWizardStep), // FILL_CANNULA(R.string.omnipod_init_pod_fill_cannula, FILL_CANNULA_SET_BASAL_PROFILE_WIZARD_STEP), //
SetBasalProfile(R.string.omnipod_init_pod_set_basal_profile, FillCannulaSetBasalProfileWizardStep), // SET_BASAL_PROFILE(R.string.omnipod_init_pod_set_basal_profile, FILL_CANNULA_SET_BASAL_PROFILE_WIZARD_STEP), //
DeactivatePodWizardStep(), // DEACTIVATE_POD_WIZARD_STEP(), //
CancelDelivery(R.string.omnipod_deactivate_pod_cancel_delivery, DeactivatePodWizardStep), // CANCEL_DELIVERY(R.string.omnipod_deactivate_pod_cancel_delivery, DEACTIVATE_POD_WIZARD_STEP), //
DeactivatePod(R.string.omnipod_deactivate_pod_deactivate_pod, DeactivatePodWizardStep); DEACTIVATE_POD(R.string.omnipod_deactivate_pod_deactivate_pod, DEACTIVATE_POD_WIZARD_STEP);
private int resourceId; private int resourceId;
private PodInitActionType parent; private PodInitActionType parent;

View file

@ -468,7 +468,7 @@ public class OmnipodManager {
logCommandExecutionFinished("deactivatePod"); logCommandExecutionFinished("deactivatePod");
} }
podStateManager.removeState(); podStateManager.discardState();
} }
public OmnipodRileyLinkCommunicationManager getCommunicationService() { public OmnipodRileyLinkCommunicationManager getCommunicationService() {

View file

@ -43,7 +43,7 @@ public abstract class PodStateManager {
this.gsonInstance = createGson(); this.gsonInstance = createGson();
} }
public final void removeState() { public final void discardState() {
this.podState = null; this.podState = null;
storePodState(); storePodState();
} }

View file

@ -96,7 +96,8 @@ public class AapsOmnipodManager {
private boolean bolusBeepsEnabled; private boolean bolusBeepsEnabled;
private boolean smbBeepsEnabled; private boolean smbBeepsEnabled;
private boolean tbrBeepsEnabled; private boolean tbrBeepsEnabled;
private boolean podDebuggingOptionsEnabled; private boolean suspendDeliveryButtonEnabled;
private boolean pulseLogButtonEnabled;
private boolean timeChangeEventEnabled; private boolean timeChangeEventEnabled;
@Inject @Inject
@ -135,16 +136,17 @@ public class AapsOmnipodManager {
} }
public void reloadSettings() { public void reloadSettings() {
basalBeepsEnabled = sp.getBoolean(OmnipodStorageKeys.Prefs.BeepBasalEnabled, true); basalBeepsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.BASAL_BEEPS_ENABLED, true);
bolusBeepsEnabled = sp.getBoolean(OmnipodStorageKeys.Prefs.BeepBolusEnabled, true); bolusBeepsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.BOLUS_BEEPS_ENABLED, true);
smbBeepsEnabled = sp.getBoolean(OmnipodStorageKeys.Prefs.BeepSMBEnabled, true); smbBeepsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.SMB_BEEPS_ENABLED, true);
tbrBeepsEnabled = sp.getBoolean(OmnipodStorageKeys.Prefs.BeepTBREnabled, true); tbrBeepsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TBR_BEEPS_ENABLED, true);
podDebuggingOptionsEnabled = sp.getBoolean(OmnipodStorageKeys.Prefs.PodDebuggingOptionsEnabled, false); suspendDeliveryButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.SUSPEND_DELIVERY_BUTTON_ENABLED, false);
timeChangeEventEnabled = sp.getBoolean(OmnipodStorageKeys.Prefs.TimeChangeEventEnabled, true); pulseLogButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED, false);
timeChangeEventEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED, true);
} }
public PumpEnactResult pairAndPrime(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver) { public PumpEnactResult pairAndPrime(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver) {
if (podInitActionType != PodInitActionType.PairAndPrimeWizardStep) { if (podInitActionType != PodInitActionType.PAIR_AND_PRIME_WIZARD_STEP) {
return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_illegal_init_action_type, podInitActionType.name())); return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_illegal_init_action_type, podInitActionType.name()));
} }
@ -158,13 +160,13 @@ public class AapsOmnipodManager {
} catch (Exception ex) { } catch (Exception ex) {
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
podInitReceiver.returnInitTaskStatus(podInitActionType, false, comment); podInitReceiver.returnInitTaskStatus(podInitActionType, false, comment);
addFailureToHistory(time, PodHistoryEntryType.PairAndPrime, comment); addFailureToHistory(time, PodHistoryEntryType.PAIR_AND_PRIME, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
} }
public PumpEnactResult setInitialBasalScheduleAndInsertCannula(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver, Profile profile) { public PumpEnactResult setInitialBasalScheduleAndInsertCannula(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver, Profile profile) {
if (podInitActionType != PodInitActionType.FillCannulaSetBasalProfileWizardStep) { if (podInitActionType != PodInitActionType.FILL_CANNULA_SET_BASAL_PROFILE_WIZARD_STEP) {
return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_illegal_init_action_type, podInitActionType.name())); return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_illegal_init_action_type, podInitActionType.name()));
} }
@ -186,7 +188,7 @@ public class AapsOmnipodManager {
} catch (Exception ex) { } catch (Exception ex) {
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
podInitReceiver.returnInitTaskStatus(podInitActionType, false, comment); podInitReceiver.returnInitTaskStatus(podInitActionType, false, comment);
addFailureToHistory(time, PodHistoryEntryType.FillCannulaSetBasalProfile, comment); addFailureToHistory(time, PodHistoryEntryType.FILL_CANNULA_SET_BASAL_PROFILE, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
} }
@ -195,11 +197,11 @@ public class AapsOmnipodManager {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
try { try {
StatusResponse statusResponse = delegate.getPodStatus(); StatusResponse statusResponse = delegate.getPodStatus();
addSuccessToHistory(time, PodHistoryEntryType.GetPodStatus, statusResponse); addSuccessToHistory(time, PodHistoryEntryType.GET_POD_STATUS, statusResponse);
return new PumpEnactResult(injector).success(true).enacted(false); return new PumpEnactResult(injector).success(true).enacted(false);
} catch (Exception ex) { } catch (Exception ex) {
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
addFailureToHistory(time, PodHistoryEntryType.GetPodStatus, comment); addFailureToHistory(time, PodHistoryEntryType.GET_POD_STATUS, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
} }
@ -210,16 +212,16 @@ public class AapsOmnipodManager {
delegate.deactivatePod(); delegate.deactivatePod();
} catch (Exception ex) { } catch (Exception ex) {
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
podInitReceiver.returnInitTaskStatus(PodInitActionType.DeactivatePodWizardStep, false, comment); podInitReceiver.returnInitTaskStatus(PodInitActionType.DEACTIVATE_POD_WIZARD_STEP, false, comment);
addFailureToHistory(time, PodHistoryEntryType.DeactivatePod, comment); addFailureToHistory(time, PodHistoryEntryType.DEACTIVATE_POD, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
reportImplicitlyCanceledTbr(); reportImplicitlyCanceledTbr();
addSuccessToHistory(time, PodHistoryEntryType.DeactivatePod, null); addSuccessToHistory(time, PodHistoryEntryType.DEACTIVATE_POD, null);
podInitReceiver.returnInitTaskStatus(PodInitActionType.DeactivatePodWizardStep, true, null); podInitReceiver.returnInitTaskStatus(PodInitActionType.DEACTIVATE_POD_WIZARD_STEP, true, null);
return new PumpEnactResult(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} }
@ -236,28 +238,28 @@ public class AapsOmnipodManager {
delegate.setBasalSchedule(basalSchedule, isBasalBeepsEnabled()); delegate.setBasalSchedule(basalSchedule, isBasalBeepsEnabled());
// Because setting a basal profile actually suspends and then resumes delivery, TBR is implicitly cancelled // Because setting a basal profile actually suspends and then resumes delivery, TBR is implicitly cancelled
reportImplicitlyCanceledTbr(); reportImplicitlyCanceledTbr();
addSuccessToHistory(time, PodHistoryEntryType.SetBasalSchedule, profile.getBasalValues()); addSuccessToHistory(time, PodHistoryEntryType.SET_BASAL_SCHEDULE, profile.getBasalValues());
} catch (Exception ex) { } catch (Exception ex) {
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) { if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
reportImplicitlyCanceledTbr(); reportImplicitlyCanceledTbr();
addToHistory(time, PodHistoryEntryType.SetBasalSchedule, "Uncertain failure", false); addToHistory(time, PodHistoryEntryType.SET_BASAL_SCHEDULE, "Uncertain failure", false);
return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_basal_failed_uncertain)); return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_basal_failed_uncertain));
} }
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
reportImplicitlyCanceledTbr(); reportImplicitlyCanceledTbr();
addFailureToHistory(time, PodHistoryEntryType.SetBasalSchedule, comment); addFailureToHistory(time, PodHistoryEntryType.SET_BASAL_SCHEDULE, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
return new PumpEnactResult(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} }
public PumpEnactResult resetPodStatus() { public PumpEnactResult discardPodState() {
podStateManager.removeState(); podStateManager.discardState();
reportImplicitlyCanceledTbr(); reportImplicitlyCanceledTbr();
addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.ResetPodState, null); addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.RESET_POD_STATE, null);
return new PumpEnactResult(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} }
@ -280,7 +282,7 @@ public class AapsOmnipodManager {
bolusStarted = new Date(); bolusStarted = new Date();
} catch (Exception ex) { } catch (Exception ex) {
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.SetBolus, comment); addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.SET_BOLUS, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
@ -312,7 +314,7 @@ public class AapsOmnipodManager {
// I discussed this with the AAPS team but nobody seems to care so we're stuck with this ugly workaround for now // I discussed this with the AAPS team but nobody seems to care so we're stuck with this ugly workaround for now
try { try {
ActiveBolus activeBolus = ActiveBolus.fromDetailedBolusInfo(detailedBolusInfo); ActiveBolus activeBolus = ActiveBolus.fromDetailedBolusInfo(detailedBolusInfo);
sp.putString(OmnipodStorageKeys.Prefs.ActiveBolus, aapsOmnipodUtil.getGsonInstance().toJson(activeBolus)); sp.putString(OmnipodStorageKeys.Preferences.ACTIVE_BOLUS, aapsOmnipodUtil.getGsonInstance().toJson(activeBolus));
aapsLogger.debug(LTag.PUMP, "Stored active bolus to SP for recovery"); aapsLogger.debug(LTag.PUMP, "Stored active bolus to SP for recovery");
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.error(LTag.PUMP, "Failed to store active bolus to SP", ex); aapsLogger.error(LTag.PUMP, "Failed to store active bolus to SP", ex);
@ -331,7 +333,7 @@ public class AapsOmnipodManager {
addBolusToHistory(detailedBolusInfo); addBolusToHistory(detailedBolusInfo);
sp.remove(OmnipodStorageKeys.Prefs.ActiveBolus); sp.remove(OmnipodStorageKeys.Preferences.ACTIVE_BOLUS);
return new PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(detailedBolusInfo.insulin); return new PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(detailedBolusInfo.insulin);
} }
@ -347,7 +349,7 @@ public class AapsOmnipodManager {
} else { } else {
aapsLogger.debug(LTag.PUMP, "Not cancelling bolus: bolus command failed"); aapsLogger.debug(LTag.PUMP, "Not cancelling bolus: bolus command failed");
String comment = getStringResource(R.string.omnipod_bolus_did_not_succeed); String comment = getStringResource(R.string.omnipod_bolus_did_not_succeed);
addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, comment); addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, comment);
return new PumpEnactResult(injector).success(true).enacted(false).comment(comment); return new PumpEnactResult(injector).success(true).enacted(false).comment(comment);
} }
} }
@ -358,12 +360,12 @@ public class AapsOmnipodManager {
try { try {
delegate.cancelBolus(isBolusBeepsEnabled()); delegate.cancelBolus(isBolusBeepsEnabled());
aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus", i); aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus", i);
addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, null); addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, null);
return new PumpEnactResult(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} catch (PodFaultException ex) { } catch (PodFaultException ex) {
aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus (implicitly because of a Pod Fault)"); aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus (implicitly because of a Pod Fault)");
showPodFaultErrorDialog(ex.getFaultEvent().getFaultEventCode(), null); showPodFaultErrorDialog(ex.getFaultEvent().getFaultEventCode(), null);
addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, null); addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, null);
return new PumpEnactResult(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} catch (Exception ex) { } catch (Exception ex) {
aapsLogger.debug(LTag.PUMP, "Failed to cancel bolus", ex); aapsLogger.debug(LTag.PUMP, "Failed to cancel bolus", ex);
@ -371,7 +373,7 @@ public class AapsOmnipodManager {
} }
} }
addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, comment); addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
@ -383,17 +385,17 @@ public class AapsOmnipodManager {
time = System.currentTimeMillis(); time = System.currentTimeMillis();
} catch (Exception ex) { } catch (Exception ex) {
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) { if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
addToHistory(time, PodHistoryEntryType.SetTemporaryBasal, "Uncertain failure", false); addToHistory(time, PodHistoryEntryType.SET_TEMPORARY_BASAL, "Uncertain failure", false);
return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_temp_basal_failed_uncertain)); return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_temp_basal_failed_uncertain));
} }
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
addFailureToHistory(time, PodHistoryEntryType.SetTemporaryBasal, comment); addFailureToHistory(time, PodHistoryEntryType.SET_TEMPORARY_BASAL, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
reportImplicitlyCanceledTbr(); reportImplicitlyCanceledTbr();
long pumpId = addSuccessToHistory(time, PodHistoryEntryType.SetTemporaryBasal, tempBasalPair); long pumpId = addSuccessToHistory(time, PodHistoryEntryType.SET_TEMPORARY_BASAL, tempBasalPair);
TemporaryBasal tempStart = new TemporaryBasal(injector) // TemporaryBasal tempStart = new TemporaryBasal(injector) //
.date(time) // .date(time) //
@ -411,10 +413,10 @@ public class AapsOmnipodManager {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
try { try {
delegate.cancelTemporaryBasal(isTbrBeepsEnabled()); delegate.cancelTemporaryBasal(isTbrBeepsEnabled());
addSuccessToHistory(time, PodHistoryEntryType.CancelTemporaryBasalForce, null); addSuccessToHistory(time, PodHistoryEntryType.CANCEL_TEMPORARY_BASAL, null);
} catch (Exception ex) { } catch (Exception ex) {
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
addFailureToHistory(time, PodHistoryEntryType.CancelTemporaryBasalForce, comment); addFailureToHistory(time, PodHistoryEntryType.CANCEL_TEMPORARY_BASAL, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
@ -425,10 +427,10 @@ public class AapsOmnipodManager {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
try { try {
delegate.acknowledgeAlerts(); delegate.acknowledgeAlerts();
addSuccessToHistory(time, PodHistoryEntryType.AcknowledgeAlerts, null); addSuccessToHistory(time, PodHistoryEntryType.ACKNOWLEDGE_ALERTS, null);
} catch (Exception ex) { } catch (Exception ex) {
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
addFailureToHistory(time, PodHistoryEntryType.AcknowledgeAlerts, comment); addFailureToHistory(time, PodHistoryEntryType.ACKNOWLEDGE_ALERTS, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
return new PumpEnactResult(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
@ -442,11 +444,11 @@ public class AapsOmnipodManager {
// because the pod state we keep, doesn't get updated from a PodInfoResponse. // because the pod state we keep, doesn't get updated from a PodInfoResponse.
// We use StatusResponses for that, which can be obtained from the getPodStatus method // We use StatusResponses for that, which can be obtained from the getPodStatus method
PodInfoResponse podInfo = delegate.getPodInfo(podInfoType); PodInfoResponse podInfo = delegate.getPodInfo(podInfoType);
addSuccessToHistory(time, PodHistoryEntryType.GetPodInfo, podInfo); addSuccessToHistory(time, PodHistoryEntryType.GET_POD_INFO, podInfo);
return new PumpEnactResult(injector).success(true).enacted(true); return new PumpEnactResult(injector).success(true).enacted(true);
} catch (Exception ex) { } catch (Exception ex) {
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
addFailureToHistory(time, PodHistoryEntryType.GetPodInfo, comment); addFailureToHistory(time, PodHistoryEntryType.GET_POD_INFO, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
} }
@ -480,16 +482,16 @@ public class AapsOmnipodManager {
delegate.setTime(isBasalBeepsEnabled()); delegate.setTime(isBasalBeepsEnabled());
// Because set time actually suspends and then resumes delivery, TBR is implicitly cancelled // Because set time actually suspends and then resumes delivery, TBR is implicitly cancelled
reportImplicitlyCanceledTbr(); reportImplicitlyCanceledTbr();
addSuccessToHistory(time, PodHistoryEntryType.SetTime, null); addSuccessToHistory(time, PodHistoryEntryType.SET_TIME, null);
} catch (Exception ex) { } catch (Exception ex) {
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) { if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
reportImplicitlyCanceledTbr(); reportImplicitlyCanceledTbr();
addFailureToHistory(time, PodHistoryEntryType.SetTime, "Uncertain failure"); addFailureToHistory(time, PodHistoryEntryType.SET_TIME, "Uncertain failure");
return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_time_failed_uncertain)); return new PumpEnactResult(injector).success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_time_failed_uncertain));
} }
String comment = handleAndTranslateException(ex); String comment = handleAndTranslateException(ex);
reportImplicitlyCanceledTbr(); reportImplicitlyCanceledTbr();
addFailureToHistory(time, PodHistoryEntryType.SetTime, comment); addFailureToHistory(time, PodHistoryEntryType.SET_TIME, comment);
return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment);
} }
@ -525,8 +527,12 @@ public class AapsOmnipodManager {
return tbrBeepsEnabled; return tbrBeepsEnabled;
} }
public boolean isPodDebuggingOptionsEnabled() { public boolean isSuspendDeliveryButtonEnabled() {
return podDebuggingOptionsEnabled; return suspendDeliveryButtonEnabled;
}
public boolean isPulseLogButtonEnabled() {
return pulseLogButtonEnabled;
} }
public boolean isTimeChangeEventEnabled() { public boolean isTimeChangeEventEnabled() {
@ -534,7 +540,7 @@ public class AapsOmnipodManager {
} }
public void addBolusToHistory(DetailedBolusInfo detailedBolusInfo) { public void addBolusToHistory(DetailedBolusInfo detailedBolusInfo) {
long pumpId = addSuccessToHistory(detailedBolusInfo.date, PodHistoryEntryType.SetBolus, detailedBolusInfo.insulin + ";" + detailedBolusInfo.carbs); long pumpId = addSuccessToHistory(detailedBolusInfo.date, PodHistoryEntryType.SET_BOLUS, detailedBolusInfo.insulin + ";" + detailedBolusInfo.carbs);
detailedBolusInfo.pumpId = pumpId; detailedBolusInfo.pumpId = pumpId;
activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false); activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false);
} }
@ -547,7 +553,7 @@ public class AapsOmnipodManager {
long time = System.currentTimeMillis() - 1000; long time = System.currentTimeMillis() - 1000;
addSuccessToHistory(time, PodHistoryEntryType.CancelTemporaryBasal, null); addSuccessToHistory(time, PodHistoryEntryType.CANCEL_TEMPORARY_BASAL_BY_DRIVER, null);
TemporaryBasal temporaryBasal = new TemporaryBasal(injector) // TemporaryBasal temporaryBasal = new TemporaryBasal(injector) //
.date(time) // .date(time) //
@ -600,10 +606,10 @@ public class AapsOmnipodManager {
break; break;
} }
if (podInitActionType == PodInitActionType.PairAndPrimeWizardStep) { if (podInitActionType == PodInitActionType.PAIR_AND_PRIME_WIZARD_STEP) {
addToHistory(time, PodHistoryEntryType.PairAndPrime, comment, res.getResultType().isSuccess()); addToHistory(time, PodHistoryEntryType.PAIR_AND_PRIME, comment, res.getResultType().isSuccess());
} else { } else {
addToHistory(time, PodHistoryEntryType.FillCannulaSetBasalProfile, res.getResultType().isSuccess() ? profile.getBasalValues() : comment, res.getResultType().isSuccess()); addToHistory(time, PodHistoryEntryType.FILL_CANNULA_SET_BASAL_PROFILE, res.getResultType().isSuccess() ? profile.getBasalValues() : comment, res.getResultType().isSuccess());
} }
podInitReceiver.returnInitTaskStatus(podInitActionType, res.getResultType().isSuccess(), comment); podInitReceiver.returnInitTaskStatus(podInitActionType, res.getResultType().isSuccess(), comment);

View file

@ -28,11 +28,11 @@ public class AapsPodStateManager extends PodStateManager {
@Override @Override
protected String readPodState() { protected String readPodState() {
return sp.getString(OmnipodStorageKeys.Prefs.PodState, ""); return sp.getString(OmnipodStorageKeys.Preferences.POD_STATE, "");
} }
@Override @Override
protected void storePodState(String podState) { protected void storePodState(String podState) {
sp.putString(OmnipodStorageKeys.Prefs.PodState, podState); sp.putString(OmnipodStorageKeys.Preferences.POD_STATE, podState);
} }
} }

View file

@ -87,12 +87,12 @@ class OmnipodFragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
omnipod_resume_delivery.setOnClickListener { omnipod_button_resume_delivery.setOnClickListener {
disablePodActionButtons() disablePodActionButtons()
commandQueue.startPump(null) commandQueue.startPump(null)
} }
omnipod_pod_mgmt.setOnClickListener { omnipod_button_pod_mgmt.setOnClickListener {
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) { if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
activity?.let { activity -> activity?.let { activity ->
protectionCheck.queryProtection( protectionCheck.queryProtection(
@ -105,13 +105,13 @@ class OmnipodFragment : DaggerFragment() {
} }
} }
omnipod_refresh.setOnClickListener { omnipod_button_refresh_status.setOnClickListener {
disablePodActionButtons() disablePodActionButtons()
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequestType.GetPodState); omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequestType.GET_POD_STATE);
commandQueue.readStatus("Clicked Refresh", null) commandQueue.readStatus("Clicked Refresh", null)
} }
omnipod_rileylink_stats.setOnClickListener { omnipod_button_rileylink_stats.setOnClickListener {
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) { if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
startActivity(Intent(context, RileyLinkStatusActivity::class.java)) startActivity(Intent(context, RileyLinkStatusActivity::class.java))
} else { } else {
@ -119,24 +119,22 @@ class OmnipodFragment : DaggerFragment() {
} }
} }
omnipod_pod_active_alerts_ack.setOnClickListener { omnipod_button_acknowledge_active_alerts.setOnClickListener {
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
displayNotConfiguredDialog()
} else {
disablePodActionButtons() disablePodActionButtons()
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequestType.AcknowledgeAlerts); omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequestType.ACKNOWLEDGE_ALERTS);
commandQueue.readStatus("Clicked Alert Ack", null) commandQueue.readStatus("Clicked Acknowledge Alert", null)
}
} }
omnipod_pod_debug.setOnClickListener { omnipod_button_suspend_delivery.setOnClickListener {
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
displayNotConfiguredDialog()
} else {
disablePodActionButtons() disablePodActionButtons()
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequestType.GetPodPulseLog); omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequestType.SUSPEND_DELIVERY);
commandQueue.readStatus("Clicked Pulse Log", null) commandQueue.readStatus("Clicked Suspend Delivery", null)
} }
omnipod_button_pulse_log.setOnClickListener {
disablePodActionButtons()
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequestType.GET_PULSE_LOG);
commandQueue.readStatus("Clicked Pulse Log", null)
} }
} }
@ -359,47 +357,57 @@ class OmnipodFragment : DaggerFragment() {
private fun updatePodActionButtons() { private fun updatePodActionButtons() {
updateRefreshStatusButton() updateRefreshStatusButton()
updateAcknowledgeAlertsButton()
updatePulseLogButton()
updateResumeDeliveryButton() updateResumeDeliveryButton()
updateAcknowledgeAlertsButton()
updateSuspendDeliveryButton()
updatePulseLogButton()
} }
private fun disablePodActionButtons() { private fun disablePodActionButtons() {
omnipod_pod_active_alerts_ack.isEnabled = false omnipod_button_acknowledge_active_alerts.isEnabled = false
omnipod_refresh.isEnabled = false omnipod_button_resume_delivery.isEnabled = false
omnipod_pod_debug.isEnabled = false omnipod_button_refresh_status.isEnabled = false
omnipod_resume_delivery.isEnabled = false omnipod_button_pulse_log.isEnabled = false
} }
private fun updateRefreshStatusButton() { private fun updateRefreshStatusButton() {
omnipod_refresh.isEnabled = podStateManager.isPodInitialized && podStateManager.podProgressStatus.isAtLeast(PodProgressStatus.PAIRING_COMPLETED) omnipod_button_refresh_status.isEnabled = podStateManager.isPodInitialized && podStateManager.podProgressStatus.isAtLeast(PodProgressStatus.PAIRING_COMPLETED)
&& rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty() && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
} }
private fun updateAcknowledgeAlertsButton() {
if (podStateManager.isPodInitialized && podStateManager.hasActiveAlerts() && !podStateManager.isPodDead) {
omnipod_pod_active_alerts_ack.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
} else {
omnipod_pod_active_alerts_ack.isEnabled = false
}
}
private fun updatePulseLogButton() {
if (aapsOmnipodManager.isPodDebuggingOptionsEnabled) {
omnipod_pod_debug.visibility = View.VISIBLE
omnipod_pod_debug.isEnabled = podStateManager.isPodActivationCompleted && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
} else {
omnipod_pod_debug.visibility = View.GONE
}
}
private fun updateResumeDeliveryButton() { private fun updateResumeDeliveryButton() {
val queueEmptyOrStartingPump = isQueueEmpty() || commandQueue.isRunning(Command.CommandType.START_PUMP) val queueEmptyOrStartingPump = isQueueEmpty() || commandQueue.isRunning(Command.CommandType.START_PUMP)
if (podStateManager.isPodActivationCompleted && podStateManager.isSuspended && queueEmptyOrStartingPump) { if (podStateManager.isPodActivationCompleted && podStateManager.isSuspended && queueEmptyOrStartingPump) {
omnipod_resume_delivery.visibility = View.VISIBLE omnipod_button_resume_delivery.visibility = View.VISIBLE
omnipod_resume_delivery.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty() omnipod_button_resume_delivery.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
} else { } else {
omnipod_resume_delivery.visibility = View.GONE omnipod_button_resume_delivery.visibility = View.GONE
}
}
private fun updateAcknowledgeAlertsButton() {
if (podStateManager.isPodInitialized && podStateManager.hasActiveAlerts() && !podStateManager.isPodDead) {
omnipod_button_acknowledge_active_alerts.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
} else {
omnipod_button_acknowledge_active_alerts.isEnabled = false
}
}
private fun updateSuspendDeliveryButton() {
if (aapsOmnipodManager.isSuspendDeliveryButtonEnabled) {
omnipod_button_suspend_delivery.visibility = View.VISIBLE
omnipod_button_suspend_delivery.isEnabled = podStateManager.isPodRunning && !podStateManager.isSuspended && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
} else {
omnipod_button_suspend_delivery.visibility = View.GONE
}
}
private fun updatePulseLogButton() {
if (aapsOmnipodManager.isPulseLogButtonEnabled) {
omnipod_button_pulse_log.visibility = View.VISIBLE
omnipod_button_pulse_log.isEnabled = podStateManager.isPodActivationCompleted && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
} else {
omnipod_button_pulse_log.visibility = View.GONE
} }
} }

View file

@ -248,21 +248,21 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
PodHistoryEntryType entryType = PodHistoryEntryType.getByCode(historyEntry.getPodEntryTypeCode()); PodHistoryEntryType entryType = PodHistoryEntryType.getByCode(historyEntry.getPodEntryTypeCode());
switch (entryType) { switch (entryType) {
case SetTemporaryBasal: { case SET_TEMPORARY_BASAL: {
TempBasalPair tempBasalPair = aapsOmnipodUtil.getGsonInstance().fromJson(historyEntry.getData(), TempBasalPair.class); TempBasalPair tempBasalPair = aapsOmnipodUtil.getGsonInstance().fromJson(historyEntry.getData(), TempBasalPair.class);
valueView.setText(resourceHelper.gs(R.string.omnipod_cmd_tbr_value, tempBasalPair.getInsulinRate(), tempBasalPair.getDurationMinutes())); valueView.setText(resourceHelper.gs(R.string.omnipod_cmd_tbr_value, tempBasalPair.getInsulinRate(), tempBasalPair.getDurationMinutes()));
} }
break; break;
case FillCannulaSetBasalProfile: case FILL_CANNULA_SET_BASAL_PROFILE:
case SetBasalSchedule: { case SET_BASAL_SCHEDULE: {
if (historyEntry.getData() != null) { if (historyEntry.getData() != null) {
setProfileValue(historyEntry.getData(), valueView); setProfileValue(historyEntry.getData(), valueView);
} }
} }
break; break;
case SetBolus: { case SET_BOLUS: {
if (historyEntry.getData().contains(";")) { if (historyEntry.getData().contains(";")) {
String[] splitVal = historyEntry.getData().split(";"); String[] splitVal = historyEntry.getData().split(";");
valueView.setText(resourceHelper.gs(R.string.omnipod_cmd_bolus_value_with_carbs, Double.valueOf(splitVal[0]), Double.valueOf(splitVal[1]))); valueView.setText(resourceHelper.gs(R.string.omnipod_cmd_bolus_value_with_carbs, Double.valueOf(splitVal[0]), Double.valueOf(splitVal[1])));
@ -272,20 +272,20 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
} }
break; break;
case GetPodStatus: case GET_POD_STATUS:
case GetPodInfo: case GET_POD_INFO:
case SetTime: case SET_TIME:
case PairAndPrime: case PAIR_AND_PRIME:
case CancelTemporaryBasal: case CANCEL_TEMPORARY_BASAL_BY_DRIVER:
case CancelTemporaryBasalForce: case CANCEL_TEMPORARY_BASAL:
case ConfigureAlerts: case CONFIGURE_ALERTS:
case CancelBolus: case CANCEL_BOLUS:
case DeactivatePod: case DEACTIVATE_POD:
case ResetPodState: case RESET_POD_STATE:
case AcknowledgeAlerts: case ACKNOWLEDGE_ALERTS:
case SuspendDelivery: case SUSPEND_DELIVERY:
case ResumeDelivery: case RESUME_DELIVERY:
case UnknownEntryType: case UNKNOWN_ENTRY_TYPE:
default: default:
valueView.setText(""); valueView.setText("");
break; break;

View file

@ -59,11 +59,11 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
} }
initpod_remove_pod.setOnClickListener { initpod_remove_pod.setOnClickListener {
removePodAction() deactivatePodAction()
} }
initpod_reset_pod.setOnClickListener { initpod_reset_pod.setOnClickListener {
resetPodAction() discardPodAction()
} }
initpod_pod_history.setOnClickListener { initpod_pod_history.setOnClickListener {
@ -93,7 +93,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
private fun initPodAction() { private fun initPodAction() {
val pagerSettings = WizardPagerSettings() val pagerSettings = WizardPagerSettings()
var refreshAction = InitPodRefreshAction(injector, PodActionType.InitPod) var refreshAction = InitPodRefreshAction(injector, PodActionType.INIT_POD)
pagerSettings.setWizardStepsWayType(WizardStepsWayType.CancelNext) pagerSettings.setWizardStepsWayType(WizardStepsWayType.CancelNext)
pagerSettings.setFinishStringResourceId(R.string.close) pagerSettings.setFinishStringResourceId(R.string.close)
@ -119,9 +119,9 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
this@PodManagementActivity.startActivity(myIntent) this@PodManagementActivity.startActivity(myIntent)
} }
private fun removePodAction() { private fun deactivatePodAction() {
val pagerSettings = WizardPagerSettings() val pagerSettings = WizardPagerSettings()
var refreshAction = InitPodRefreshAction(injector, PodActionType.RemovePod) var refreshAction = InitPodRefreshAction(injector, PodActionType.DEACTIVATE_POD)
pagerSettings.setWizardStepsWayType(WizardStepsWayType.CancelNext) pagerSettings.setWizardStepsWayType(WizardStepsWayType.CancelNext)
pagerSettings.setFinishStringResourceId(R.string.close) pagerSettings.setFinishStringResourceId(R.string.close)
@ -143,10 +143,10 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
} }
private fun resetPodAction() { private fun discardPodAction() {
OKDialog.showConfirmation(this, OKDialog.showConfirmation(this,
resourceHelper.gs(R.string.omnipod_cmd_reset_pod_desc), Thread { resourceHelper.gs(R.string.omnipod_cmd_discard_pod_desc), Thread {
aapsOmnipodManager.resetPodStatus() aapsOmnipodManager.discardPodState()
rxBus.send(EventOmnipodPumpValuesChanged()) rxBus.send(EventOmnipodPumpValuesChanged())
}) })
} }

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.defs; package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.defs;
public enum PodActionType { public enum PodActionType {
InitPod, INIT_POD,
RemovePod, DEACTIVATE_POD,
ResetPod DISCARD_POD
} }

View file

@ -118,9 +118,9 @@ public class InitActionFragment extends DaggerFragment implements PodInitReceive
mapCheckBoxes.put(child, checkBox1); mapCheckBoxes.put(child, checkBox1);
} }
if (podInitActionType == PodInitActionType.FillCannulaSetBasalProfileWizardStep) { if (podInitActionType == PodInitActionType.FILL_CANNULA_SET_BASAL_PROFILE_WIZARD_STEP) {
headerView.setText(R.string.omnipod_init_pod_wizard_step4_action_header); headerView.setText(R.string.omnipod_init_pod_wizard_step4_action_header);
} else if (podInitActionType == PodInitActionType.DeactivatePodWizardStep) { } else if (podInitActionType == PodInitActionType.DEACTIVATE_POD_WIZARD_STEP) {
headerView.setText(R.string.omnipod_remove_pod_wizard_step2_action_header); headerView.setText(R.string.omnipod_remove_pod_wizard_step2_action_header);
} }

View file

@ -37,18 +37,18 @@ public class InitPodTask extends AsyncTask<Void, Void, String> {
@Override @Override
protected String doInBackground(Void... params) { protected String doInBackground(Void... params) {
if (initActionFragment.podInitActionType == PodInitActionType.PairAndPrimeWizardStep) { if (initActionFragment.podInitActionType == PodInitActionType.PAIR_AND_PRIME_WIZARD_STEP) {
initActionFragment.callResult = aapsOmnipodManager.pairAndPrime( initActionFragment.callResult = aapsOmnipodManager.pairAndPrime(
initActionFragment.podInitActionType, initActionFragment.podInitActionType,
initActionFragment initActionFragment
); );
} else if (initActionFragment.podInitActionType == PodInitActionType.FillCannulaSetBasalProfileWizardStep) { } else if (initActionFragment.podInitActionType == PodInitActionType.FILL_CANNULA_SET_BASAL_PROFILE_WIZARD_STEP) {
initActionFragment.callResult = aapsOmnipodManager.setInitialBasalScheduleAndInsertCannula( initActionFragment.callResult = aapsOmnipodManager.setInitialBasalScheduleAndInsertCannula(
initActionFragment.podInitActionType, initActionFragment.podInitActionType,
initActionFragment, initActionFragment,
profileFunction.getProfile() profileFunction.getProfile()
); );
} else if (initActionFragment.podInitActionType == PodInitActionType.DeactivatePodWizardStep) { } else if (initActionFragment.podInitActionType == PodInitActionType.DEACTIVATE_POD_WIZARD_STEP) {
initActionFragment.callResult = aapsOmnipodManager.deactivatePod(initActionFragment); initActionFragment.callResult = aapsOmnipodManager.deactivatePod(initActionFragment);
} }

View file

@ -31,7 +31,7 @@ public class FullInitPodWizardModel extends InitPodWizardModel {
new InitActionPage(this, new InitActionPage(this,
R.string.omnipod_init_pod_wizard_step2_title, R.string.omnipod_init_pod_wizard_step2_title,
PodInitActionType.PairAndPrimeWizardStep PodInitActionType.PAIR_AND_PRIME_WIZARD_STEP
).setRequired(true).setCancelReason("Cancel"), ).setRequired(true).setCancelReason("Cancel"),
new DisplayTextPage(this, new DisplayTextPage(this,
@ -41,7 +41,7 @@ public class FullInitPodWizardModel extends InitPodWizardModel {
new InitActionPage(this, new InitActionPage(this,
R.string.omnipod_init_pod_wizard_step4_title, R.string.omnipod_init_pod_wizard_step4_title,
PodInitActionType.FillCannulaSetBasalProfileWizardStep PodInitActionType.FILL_CANNULA_SET_BASAL_PROFILE_WIZARD_STEP
).setRequired(true).setCancelReason("Cancel") ).setRequired(true).setCancelReason("Cancel")
); );
} }

View file

@ -48,7 +48,7 @@ public class RemovePodWizardModel extends AbstractWizardModel {
new RemovePodActionPage(this, new RemovePodActionPage(this,
R.string.omnipod_remove_pod_wizard_step2_title, R.string.omnipod_remove_pod_wizard_step2_title,
PodInitActionType.DeactivatePodWizardStep PodInitActionType.DEACTIVATE_POD_WIZARD_STEP
).setRequired(true).setCancelReason("Cancel") ).setRequired(true).setCancelReason("Cancel")
); );

View file

@ -31,7 +31,7 @@ public class ShortInitPodWizardModel extends InitPodWizardModel {
new InitActionPage(this, new InitActionPage(this,
R.string.omnipod_init_pod_wizard_step4_title, R.string.omnipod_init_pod_wizard_step4_title,
PodInitActionType.FillCannulaSetBasalProfileWizardStep PodInitActionType.FILL_CANNULA_SET_BASAL_PROFILE_WIZARD_STEP
).setRequired(true).setCancelReason("Cancel") ).setRequired(true).setCancelReason("Cancel")
); );

View file

@ -48,7 +48,7 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
@Override @Override
public void execute() { public void execute() {
if (actionType == PodActionType.InitPod) { if (actionType == PodActionType.INIT_POD) {
if (podStateManager.isPodRunning()) { if (podStateManager.isPodRunning()) {
uploadCareportalEvent(System.currentTimeMillis(), CareportalEvent.SITECHANGE); uploadCareportalEvent(System.currentTimeMillis(), CareportalEvent.SITECHANGE);
} }

View file

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M24,9.343l-5.781,-3.968l-1.328,6.688l2.102,-1.757c0.014,0.056 0.03,0.111 0.043,0.168c0.116,0.512 0.183,1.042 0.183,1.589c0,3.952 -3.204,7.156 -7.156,7.156s-7.156,-3.204 -7.156,-7.156s3.204,-7.156 7.156,-7.156c1.072,0 2.085,0.242 2.998,0.665c0.325,0.151 0.639,0.321 0.936,0.517l0.002,-0.002l-0.352,-1.784l1.876,-0.538c-1.567,-1.033 -3.442,-1.639 -5.46,-1.639c-5.488,0 -9.938,4.449 -9.938,9.938S6.574,22 12.063,22S22,17.551 22,12.063c0,-0.759 -0.093,-1.496 -0.254,-2.206c-0.04,-0.176 -0.085,-0.35 -0.134,-0.523L24,9.343L24,9.343z"
android:fillColor="#FF1313"/>
<path
android:pathData="M10.2429,8.7408l5.0162,5.0162l-1.5026,1.5026l-5.0162,-5.0162z"
android:fillColor="#FF1313"/>
<path
android:pathData="M8.7408,13.7571l5.0162,-5.0162l1.5026,1.5026l-5.0162,5.0162z"
android:fillColor="#FF1313"/>
</vector>

View file

@ -715,7 +715,7 @@
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
android:id="@+id/omnipod_resume_delivery" android:id="@+id/omnipod_button_resume_delivery"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -723,10 +723,11 @@
android:drawableTop="@drawable/ic_local_activate" android:drawableTop="@drawable/ic_local_activate"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:paddingRight="0dp" android:paddingRight="0dp"
android:text="@string/omnipod_resume_delivery" /> android:text="@string/omnipod_resume_delivery"
android:visibility="gone" />
<Button <Button
android:id="@+id/omnipod_refresh" android:id="@+id/omnipod_button_refresh_status"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -736,9 +737,8 @@
android:paddingRight="0dp" android:paddingRight="0dp"
android:text="@string/omnipod_refresh" /> android:text="@string/omnipod_refresh" />
<Button <Button
android:id="@+id/omnipod_pod_mgmt" android:id="@+id/omnipod_button_pod_mgmt"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -749,7 +749,7 @@
android:text="@string/omnipod_pod_mgmt" /> android:text="@string/omnipod_pod_mgmt" />
<Button <Button
android:id="@+id/omnipod_pod_active_alerts_ack" android:id="@+id/omnipod_button_acknowledge_active_alerts"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -757,10 +757,10 @@
android:drawableTop="@drawable/ic_cp_aaps_offline" android:drawableTop="@drawable/ic_cp_aaps_offline"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:paddingRight="0dp" android:paddingRight="0dp"
android:text="@string/omnipod_ack_short" /> android:text="@string/omnipod_acknowledge_active_alerts_short" />
<Button <Button
android:id="@+id/omnipod_rileylink_stats" android:id="@+id/omnipod_button_rileylink_stats"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -771,7 +771,7 @@
android:text="@string/omnipod_rl_stats" /> android:text="@string/omnipod_rl_stats" />
<Button <Button
android:id="@+id/omnipod_pod_debug" android:id="@+id/omnipod_button_pulse_log"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -779,7 +779,20 @@
android:drawableTop="@drawable/ic_cp_bolus_correction" android:drawableTop="@drawable/ic_cp_bolus_correction"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:paddingRight="0dp" android:paddingRight="0dp"
android:text="@string/omnipod_read_pulse_log_short" /> android:text="@string/omnipod_read_pulse_log_short"
android:visibility="gone" />
<Button
android:id="@+id/omnipod_button_suspend_delivery"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableTop="@drawable/ic_loop_disabled"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/omnipod_suspend_delivery_short"
android:visibility="gone" />
</LinearLayout> </LinearLayout>

View file

@ -111,7 +111,7 @@
android:layout_marginBottom="3dp" android:layout_marginBottom="3dp"
android:layout_weight="0.5" android:layout_weight="0.5"
android:drawableTop="@drawable/ic_cp_pump_canula" android:drawableTop="@drawable/ic_cp_pump_canula"
android:text="@string/omnipod_cmd_reset_pod" android:text="@string/omnipod_cmd_discard_pod"
android:textAllCaps="false" /> android:textAllCaps="false" />
<TextView <TextView

View file

@ -9,18 +9,20 @@
<string name="description_pump_omnipod">Pump integration for Omnipod, requires RileyLink (with at least 2.0 firmware) device.</string> <string name="description_pump_omnipod">Pump integration for Omnipod, requires RileyLink (with at least 2.0 firmware) device.</string>
<!-- Omnipod Configuration --> <!-- Omnipod Configuration -->
<string name="key_omnipod_beep_bolus_enabled" translatable="false">pref_omnipod_beep_bolus_enabled</string> <string name="key_omnipod_bolus_beeps_enabled" translatable="false">AAPS.Omnipod.bolus_beeps_enabled</string>
<string name="key_omnipod_beep_basal_enabled" translatable="false">pref_omnipod_beep_basal_enabled</string> <string name="key_omnipod_basal_beeps_enabled" translatable="false">AAPS.Omnipod.basal_beeps_enabled</string>
<string name="key_omnipod_beep_smb_enabled" translatable="false">pref_omnipod_beep_smb_enabled</string> <string name="key_omnipod_smb_beeps_enabled" translatable="false">AAPS.Omnipod.smb_beeps_enabled</string>
<string name="key_omnipod_beep_tbr_enabled" translatable="false">pref_omnipod_beep_tbr_enabled</string> <string name="key_omnipod_tbr_beeps_enabled" translatable="false">AAPS.Omnipod.tbr_beeps_enabled</string>
<string name="key_omnipod_pod_debugging_options_enabled" translatable="false">pref_omnipod_pod_debugging_options_enabled</string> <string name="key_omnipod_suspend_delivery_button_enabled" translatable="false">AAPS.Omnipod.suspend_delivery_button_enabled</string>
<string name="key_omnipod_timechange_enabled" translatable="false">pref_omnipod_timechange_enabled</string> <string name="key_omnipod_pulse_log_button_enabled" translatable="false">AAPS.Omnipod.pulse_log_button_enabled</string>
<string name="omnipod_config_beep_bolus_enabled">Bolus beep enabled</string> <string name="key_omnipod_time_change_event_enabled" translatable="false">AAPS.Omnipod.time_change_enabled</string>
<string name="omnipod_config_beep_basal_enabled">Basal beep enabled</string> <string name="omnipod_config_bolus_beeps_enabled">Bolus beeps enabled</string>
<string name="omnipod_config_beep_smb_enabled">SMB beep enabled</string> <string name="omnipod_config_basal_beeps_enabled">Basal beeps enabled</string>
<string name="omnipod_config_beep_tbr_enabled">TBR beep enabled</string> <string name="omnipod_config_smb_beeps_enabled">SMB beeps enabled</string>
<string name="omnipod_config_pod_debugging_options_enabled">Pod debugging options enabled</string> <string name="omnipod_config_tbr_beeps_enabled">TBR beeps enabled</string>
<string name="omnipod_config_timechange_enabled">DST/Time zone detection enabled</string> <string name="omnipod_config_suspend_delivery_button_enabled">Suspend Delivery button enabled</string>
<string name="omnipod_config_pulse_log_button_enabled">Pulse Log button enabled</string>
<string name="omnipod_config_time_change_enabled">DST/Time zone detection enabled</string>
<!-- Omnipod - Fragment --> <!-- Omnipod - Fragment -->
<string name="omnipod_moments_ago">Moments ago</string> <string name="omnipod_moments_ago">Moments ago</string>
@ -43,9 +45,8 @@
<string name="omnipod_pod_status_inactive">Inactive</string> <string name="omnipod_pod_status_inactive">Inactive</string>
<string name="omnipod_pod_status_pod_fault_description">Pod fault: %1$s %2$s</string> <string name="omnipod_pod_status_pod_fault_description">Pod fault: %1$s %2$s</string>
<string name="omnipod_pod_active_alerts">Active Pod alerts</string> <string name="omnipod_pod_active_alerts">Active Pod alerts</string>
<string name="omnipod_ack_short">Ack alerts</string> <string name="omnipod_acknowledge_active_alerts_short">Ack alerts</string>
<string name="omnipod_last_bolus" translatable="false">%1$.2f %2$s (%3$s)</string> <string name="omnipod_last_bolus" translatable="false">%1$.2f %2$s (%3$s)</string>
<string name="omnipod_pod_status_initalizing">Initializing</string>
<!-- Omnipod - Dialogs --> <!-- Omnipod - Dialogs -->
@ -80,13 +81,13 @@
<string name="omnipod_pod_mgmt_title">Pod management</string> <string name="omnipod_pod_mgmt_title">Pod management</string>
<string name="omnipod_cmd_init_pod">Init Pod</string> <string name="omnipod_cmd_init_pod">Init Pod</string>
<string name="omnipod_cmd_deactivate_pod">Deactivate Pod</string> <string name="omnipod_cmd_deactivate_pod">Deactivate Pod</string>
<string name="omnipod_cmd_reset_pod">Reset Pod</string> <string name="omnipod_cmd_discard_pod">Discard Pod</string>
<string name="omnipod_cmd_pod_history">Pod history</string> <string name="omnipod_cmd_pod_history">Pod history</string>
<string name="omnipod_cmd_set_bolus">Set bolus</string> <string name="omnipod_cmd_set_bolus">Set bolus</string>
<string name="omnipod_cmd_cancel_bolus">Cancel bolus</string> <string name="omnipod_cmd_cancel_bolus">Cancel bolus</string>
<string name="omnipod_cmd_set_tbr">Set temporary basal</string> <string name="omnipod_cmd_set_tbr">Set temporary basal</string>
<string name="omnipod_cmd_cancel_tbr">Cancel temporary basal (internally by driver)</string> <string name="omnipod_cmd_cancel_tbr_by_driver">Cancel temporary basal (internally by driver)</string>
<string name="omnipod_cmd_cancel_tbr_forced">Cancel temporary casal (forced by user)</string> <string name="omnipod_cmd_cancel_tbr">Cancel temporary basal</string>
<string name="omnipod_cmd_set_basal_schedule">Set basal schedule</string> <string name="omnipod_cmd_set_basal_schedule">Set basal schedule</string>
<string name="omnipod_cmd_get_pod_status">Get Pod status</string> <string name="omnipod_cmd_get_pod_status">Get Pod status</string>
<string name="omnipod_cmd_get_pod_info">Get Pod info</string> <string name="omnipod_cmd_get_pod_info">Get Pod info</string>
@ -99,7 +100,7 @@
<string name="omnipod_cmd_bolus_value">%1$.2f U</string> <string name="omnipod_cmd_bolus_value">%1$.2f U</string>
<string name="omnipod_cmd_bolus_value_with_carbs">%1$.2f U, CH=%2$.1f g</string> <string name="omnipod_cmd_bolus_value_with_carbs">%1$.2f U, CH=%2$.1f g</string>
<string name="omnipod_cmd_tbr_value">Rate: %1$.2f U, duration: %2$d min</string> <string name="omnipod_cmd_tbr_value">Rate: %1$.2f U, duration: %2$d min</string>
<string name="omnipod_cmd_reset_pod_desc">If you press <b>OK</b>, the Pod state will be forcibly reset and you will not be able to communicate with the Pod anymore. Do this only if you can not communicate with the Pod anymore. If you can still communicate with the Pod, please use the <b>Deactivate Pod</b> option.</string> <string name="omnipod_cmd_discard_pod_desc">If you press <b>OK</b>, the Pod state will be forcibly reset and you will not be able to communicate with the Pod anymore. Do this only if you can not communicate with the Pod anymore. If you can still communicate with the Pod, please use the <b>Deactivate Pod</b> option.</string>
<string name="omnipod_cmd_pod_history_na">Pod History not available at the moment.</string> <string name="omnipod_cmd_pod_history_na">Pod History not available at the moment.</string>
<string name="omnipod_init_pod_wizard_step1_title">Fill the Pod</string> <string name="omnipod_init_pod_wizard_step1_title">Fill the Pod</string>
<string name="omnipod_init_pod_wizard_step1_desc">\nFill the new Pod with enough insulin for 3 days.\n\nListen for two beeps from the Pod during the filling process. These indicate that the minimum amount of 85U has been inserted. Be sure to completely empty the fill syringe, even after hearing the two beeps.\n\nAfter filling the Pod, please press <b>Next</b>.\n\n<b>Note:</b> do not remove the Pod\'s needle cap at this time.</string> <string name="omnipod_init_pod_wizard_step1_desc">\nFill the new Pod with enough insulin for 3 days.\n\nListen for two beeps from the Pod during the filling process. These indicate that the minimum amount of 85U has been inserted. Be sure to completely empty the fill syringe, even after hearing the two beeps.\n\nAfter filling the Pod, please press <b>Next</b>.\n\n<b>Note:</b> do not remove the Pod\'s needle cap at this time.</string>
@ -114,7 +115,7 @@
<string name="omnipod_remove_pod_wizard_step1_title">Deactivate Pod</string> <string name="omnipod_remove_pod_wizard_step1_title">Deactivate Pod</string>
<string name="omnipod_remove_pod_wizard_step1_desc">\nPress <b>Next</b> to deactivate the Pod.\n\n<b>Note:</b> This will suspend all insulin delivery and deactivate the Pod.</string> <string name="omnipod_remove_pod_wizard_step1_desc">\nPress <b>Next</b> to deactivate the Pod.\n\n<b>Note:</b> This will suspend all insulin delivery and deactivate the Pod.</string>
<string name="omnipod_remove_pod_wizard_step2_title">Deactivating the Pod</string> <string name="omnipod_remove_pod_wizard_step2_title">Deactivating the Pod</string>
<string name="omnipod_remove_pod_wizard_step2_action_header">Deactivating the Pod.\n\nWhen all items are checked, you can press <b>Next</b>.\n\n<b>Note:</b> If deactivating continuously fails, please press <b>Cancel</b> and use the <b>Reset Pod</b> option to forcibly reset the Pod state.</string> <string name="omnipod_remove_pod_wizard_step2_action_header">Deactivating the Pod.\n\nWhen all items are checked, you can press <b>Next</b>.\n\n<b>Note:</b> If deactivating continuously fails, please press <b>Cancel</b> and use the <b>Discard Pod</b> option to forcibly reset the Pod state.</string>
<string name="omnipod_init_pod_wizard_pod_info_remove_pod_description">Pod deactivated.\n\nPlease remove the Pod from your body and discard it.</string> <string name="omnipod_init_pod_wizard_pod_info_remove_pod_description">Pod deactivated.\n\nPlease remove the Pod from your body and discard it.</string>
<string name="omnipod_init_pod_pair_pod">Pair Pod</string> <string name="omnipod_init_pod_pair_pod">Pair Pod</string>
<string name="omnipod_init_pod_prime_pod">Prime Pod</string> <string name="omnipod_init_pod_prime_pod">Prime Pod</string>
@ -153,6 +154,10 @@
<string name="omnipod_resume_delivery">Resume delivery</string> <string name="omnipod_resume_delivery">Resume delivery</string>
<string name="omnipod_error_pod_suspended">Pod suspended</string> <string name="omnipod_error_pod_suspended">Pod suspended</string>
<string name="omnipod_less_than_a_minute_ago">Less than a minute ago</string> <string name="omnipod_less_than_a_minute_ago">Less than a minute ago</string>
<string name="omnipod_suspend_delivery_short">Suspend</string>
<string name="omnipod_cmd_pair_and_prime">Pair and prime</string>
<string name="omnipod_cmd_fill_cannula_set_basal_profile">Fill cannula and set basal profile</string>
<string name="omnipod_cmd_get_pulse_log">Get pulse log</string>
<plurals name="omnipod_minutes"> <plurals name="omnipod_minutes">
<item quantity="one">%1$d minute</item> <item quantity="one">%1$d minute</item>

View file

@ -16,33 +16,38 @@
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_omnipod_beep_bolus_enabled" android:key="@string/key_omnipod_bolus_beeps_enabled"
android:title="@string/omnipod_config_beep_bolus_enabled" /> android:title="@string/omnipod_config_bolus_beeps_enabled" />
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_omnipod_beep_basal_enabled" android:key="@string/key_omnipod_basal_beeps_enabled"
android:title="@string/omnipod_config_beep_basal_enabled" /> android:title="@string/omnipod_config_basal_beeps_enabled" />
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_omnipod_beep_smb_enabled" android:key="@string/key_omnipod_smb_beeps_enabled"
android:title="@string/omnipod_config_beep_smb_enabled" /> android:title="@string/omnipod_config_smb_beeps_enabled" />
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_omnipod_beep_tbr_enabled" android:key="@string/key_omnipod_tbr_beeps_enabled"
android:title="@string/omnipod_config_beep_tbr_enabled" /> android:title="@string/omnipod_config_tbr_beeps_enabled" />
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_omnipod_pod_debugging_options_enabled" android:key="@string/key_omnipod_suspend_delivery_button_enabled"
android:title="@string/omnipod_config_pod_debugging_options_enabled" /> android:title="@string/omnipod_config_suspend_delivery_button_enabled" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_omnipod_pulse_log_button_enabled"
android:title="@string/omnipod_config_pulse_log_button_enabled" />
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_omnipod_timechange_enabled" android:key="@string/key_omnipod_time_change_event_enabled"
android:title="@string/omnipod_config_timechange_enabled" /> android:title="@string/omnipod_config_time_change_enabled" />
</PreferenceCategory> </PreferenceCategory>
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>