implement setTime. handle timezone changes

This commit is contained in:
Andrei Vereha 2021-10-15 18:09:31 +02:00
parent 1f65ee38c7
commit 72f819b80d
3 changed files with 19 additions and 16 deletions

View file

@ -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 {
@ -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

@ -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>