From 39ce23ec86db4580f0527f498b0251b76a3a9599 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Tue, 7 Jan 2020 22:37:37 +0100 Subject: [PATCH] - notification that pod is not available... Will be refreshed every 15 minutes. --- .../overview/notifications/Notification.java | 2 +- .../pump/omnipod/OmnipodPumpPlugin.java | 19 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + gradle.properties | 10 ++-------- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java index dd82ae8c0d..68639a0525 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java @@ -80,7 +80,7 @@ public class Notification { public static final int INVALID_VERSION = 55; public static final int OMNIPOD_PUMP_ALARM = 56; public static final int TIME_OR_TIMEZONE_CHANGE = 57; - + public static final int OMNIPOD_POD_NOT_ATTACHED = 58; public int id; public Date date; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index d0d10ff733..8e52626370 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -39,6 +39,7 @@ import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction; import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType; import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity; +import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract; @@ -103,6 +104,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump private Profile currentProfile; + private long nextPodCheck = 0L; + private OmnipodPumpPlugin() { @@ -264,11 +267,27 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } } + doPodCheck(); + } while (serviceRunning); }).start(); } + private void doPodCheck() { + + if (System.currentTimeMillis() > this.nextPodCheck) { + if (!getPodPumpStatusObject().podAvailable) { + Notification notification = new Notification(Notification.OMNIPOD_POD_NOT_ATTACHED, MainApp.gs(R.string.omnipod_error_pod_not_attached), Notification.NORMAL); + RxBus.INSTANCE.send(new EventNewNotification(notification)); + } else { + RxBus.INSTANCE.send(new EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED)); + } + + this.nextPodCheck = DateTimeUtil.getTimeInFutureFromMinutes(15); + } + } + @Override public Class getServiceClass() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5411f3925f..16b55ef3ac 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1677,6 +1677,7 @@ Operation is not possible.\n\n You need to configure Omnipod first, before you can use this operation. Operation is not possible.\n\n You need to wait few minutes, until AAPS tries to set profile for first time. Illegal PodInitActionType: %1$s + No active pod. Command verification failed. An unexpected error occured. Please report! (type: %1$s). diff --git a/gradle.properties b/gradle.properties index 1bc51c91af..35638f217b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,23 +1,17 @@ # Project-wide Gradle settings. - # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. - # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html - # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true - org.gradle.jvmargs=-Xmx2g - -android.enableJetifier=true -android.useAndroidX=true \ No newline at end of file +android.useAndroidX=true +android.enableJetifier=true \ No newline at end of file