Merge pull request #733 from 0pen-dash/avereha/set-time

handle timezone changes
This commit is contained in:
Milos Kozak 2021-10-15 22:38:34 +02:00 committed by GitHub
commit fd2dff6b52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 16 deletions

View file

@ -1169,8 +1169,9 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
private fun handleTimeChange(): PumpEnactResult {
// TODO
return PumpEnactResult(injector).success(false).enacted(false).comment("NOT IMPLEMENTED")
return profileFunction.getProfile()?.let {
setNewBasalProfile(it)
} ?: PumpEnactResult(injector).success(true).enacted(false).comment("No profile active")
}
private fun updateAlertConfiguration(): PumpEnactResult {
@ -1252,14 +1253,20 @@ class OmnipodDashPumpPlugin @Inject constructor(
"Time, Date and/or TimeZone changed. [timeChangeType=" + timeChangeType.name + ", eventHandlingEnabled=" + eventHandlingEnabled + "]"
)
if (timeChangeType == TimeChangeType.TimeChanged) {
aapsLogger.info(LTag.PUMP, "Ignoring time change because it is not a DST or TZ change")
return
} else if (!podStateManager.isPodRunning) {
aapsLogger.info(LTag.PUMP, "Ignoring time change because no Pod is active")
return
when {
!eventHandlingEnabled -> {
aapsLogger.info(LTag.PUMP, "Ignoring time change because automatic time handling is disabled in configuration")
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")
commandQueue.customCommand(CommandHandleTimeChange(false), null)

View file

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

View file

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