This commit is contained in:
Milos Kozak 2021-10-16 13:02:42 +02:00
commit 94cc26ffea
4 changed files with 23 additions and 25 deletions

View file

@ -1031,7 +1031,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
DateFormat.format("HH:mm", Date(this.startTime)) DateFormat.format("HH:mm", Date(this.startTime))
) + "\n" ) + "\n"
} }
val (temporaryBasal, extendedBolus, _, profile) = pumpSync.expectedPumpState() val temporaryBasal = pumpSync.expectedPumpState().temporaryBasal
temporaryBasal?.run { temporaryBasal?.run {
ret += resourceHelper.gs( ret += resourceHelper.gs(
R.string.omnipod_common_short_status_temp_basal, R.string.omnipod_common_short_status_temp_basal,
@ -1169,8 +1169,9 @@ class OmnipodDashPumpPlugin @Inject constructor(
} }
private fun handleTimeChange(): PumpEnactResult { private fun handleTimeChange(): PumpEnactResult {
// TODO return profileFunction.getProfile()?.let {
return PumpEnactResult(injector).success(false).enacted(false).comment("NOT IMPLEMENTED") setNewBasalProfile(it)
} ?: PumpEnactResult(injector).success(true).enacted(false).comment("No profile active")
} }
private fun updateAlertConfiguration(): PumpEnactResult { private fun updateAlertConfiguration(): PumpEnactResult {
@ -1229,7 +1230,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
expirationReminderEnabled, expirationReminderEnabled,
expirationHours expirationHours
).andThen( ).andThen(
podStateManager.updateExpirationAlertSettings( podStateManager.updateLowReservoirAlertSettings(
lowReservoirAlertEnabled, lowReservoirAlertEnabled,
lowReservoirAlertUnits lowReservoirAlertUnits
) )
@ -1252,14 +1253,20 @@ class OmnipodDashPumpPlugin @Inject constructor(
"Time, Date and/or TimeZone changed. [timeChangeType=" + timeChangeType.name + ", eventHandlingEnabled=" + eventHandlingEnabled + "]" "Time, Date and/or TimeZone changed. [timeChangeType=" + timeChangeType.name + ", eventHandlingEnabled=" + eventHandlingEnabled + "]"
) )
if (timeChangeType == TimeChangeType.TimeChanged) { when {
aapsLogger.info(LTag.PUMP, "Ignoring time change because it is not a DST or TZ change") !eventHandlingEnabled -> {
return aapsLogger.info(LTag.PUMP, "Ignoring time change because automatic time handling is disabled in configuration")
} else if (!podStateManager.isPodRunning) { return
aapsLogger.info(LTag.PUMP, "Ignoring time change because no Pod is active") }
return timeChangeType == TimeChangeType.TimeChanged -> {
aapsLogger.info(LTag.PUMP, "Ignoring time change because it is not a DST or TZ change")
return
}
!podStateManager.isPodRunning -> {
aapsLogger.info(LTag.PUMP, "Ignoring time change because no Pod is active")
return
}
} }
aapsLogger.info(LTag.PUMP, "Handling time change") aapsLogger.info(LTag.PUMP, "Handling time change")
commandQueue.customCommand(CommandHandleTimeChange(false), null) commandQueue.customCommand(CommandHandleTimeChange(false), null)

View file

@ -631,15 +631,12 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
} }
private fun updateSetTimeButton() { private fun updateSetTimeButton() {
// TODO if (podStateManager.isActivationCompleted && !podStateManager.sameTimeZone) {
/*
if (podStateManager.isPodRunning && (podStateManager.timeDeviatesMoreThan(Duration.standardMinutes(5)) || commandQueue.isCustomCommandInQueue(CommandHandleTimeChange::class.java))) {
buttonBinding.buttonSetTime.visibility = View.VISIBLE buttonBinding.buttonSetTime.visibility = View.VISIBLE
buttonBinding.buttonSetTime.isEnabled = !podStateManager.isSuspended && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty() buttonBinding.buttonSetTime.isEnabled = !podStateManager.isSuspended && isQueueEmpty()
} else { } else {
buttonBinding.buttonSetTime.visibility = View.GONE buttonBinding.buttonSetTime.visibility = View.GONE
} }
*/
} }
private fun isAutomaticallySilenceAlertsEnabled(): Boolean { private fun isAutomaticallySilenceAlertsEnabled(): Boolean {

View file

@ -65,13 +65,9 @@ class DashInsertCannulaViewModel @Inject constructor(
null null
super.disposable += omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown) super.disposable += omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown)
.ignoreElements()
.andThen(podStateManager.updateExpirationAlertSettings(expirationReminderEnabled, expirationHours))
.subscribeBy( .subscribeBy(
onNext = { podEvent ->
logger.debug(
LTag.PUMP,
"Received PodEvent in Pod activation part 2: $podEvent"
)
},
onError = { throwable -> onError = { throwable ->
logger.error(LTag.PUMP, "Error in Pod activation part 2", throwable) logger.error(LTag.PUMP, "Error in Pod activation part 2", throwable)
source.onSuccess(PumpEnactResult(injector).success(false).comment(I8n.textFromException(throwable, resourceHelper))) source.onSuccess(PumpEnactResult(injector).success(false).comment(I8n.textFromException(throwable, resourceHelper)))
@ -103,7 +99,6 @@ class DashInsertCannulaViewModel @Inject constructor(
pumpSerial = podStateManager.uniqueId?.toString() ?: "n/a" pumpSerial = podStateManager.uniqueId?.toString() ?: "n/a"
) )
podStateManager.updateExpirationAlertSettings(expirationReminderEnabled, expirationHours)
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED)) rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED))
source.onSuccess(PumpEnactResult(injector).success(true)) source.onSuccess(PumpEnactResult(injector).success(true))
} }

View file

@ -109,12 +109,11 @@
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_omnipod_common_suspend_delivery_button_enabled" android:key="@string/key_omnipod_common_suspend_delivery_button_enabled"
android:title="@string/omnipod_common_preferences_suspend_delivery_button_enabled" /> android:title="@string/omnipod_common_preferences_suspend_delivery_button_enabled" />
<!--
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_omnipod_common_time_change_event_enabled" android:key="@string/key_omnipod_common_time_change_event_enabled"
android:title="@string/omnipod_common_preferences_time_change_enabled" /> android:title="@string/omnipod_common_preferences_time_change_enabled" />
-->
</PreferenceCategory> </PreferenceCategory>
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>