From b79beda9714a43d22eb2c21c489fe4eab6036d23 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 15 Jul 2017 16:02:08 +0200 Subject: [PATCH] wear pass through overview notifications --- .../plugins/Overview/NotificationStore.java | 7 +++++++ .../androidaps/plugins/Wear/ActionStringHandler.java | 11 +++++++++++ .../androidaps/plugins/Wear/WearPlugin.java | 6 ++++++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/pref_wear.xml | 7 +++++++ 5 files changed, 33 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java index b836f99be5..45393f3659 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java @@ -14,6 +14,7 @@ import java.util.List; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.Services.AlarmSoundService; +import info.nightscout.androidaps.plugins.Wear.WearPlugin; /** @@ -53,6 +54,12 @@ public class NotificationStore { MainApp.instance().startService(alarm); } store.add(n); + + WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class); + if(wearPlugin!= null && wearPlugin.isEnabled()) { + wearPlugin.overviewNotification(n.id, "OverviewNotification:\n" + n.text); + } + Collections.sort(store, new NotificationComparator()); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index 096b5b5cda..a881464e82 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -24,6 +24,7 @@ import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog; import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.data.Profile; +import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin; import info.nightscout.utils.BolusWizard; import info.nightscout.utils.DateUtil; @@ -415,6 +416,8 @@ public class ActionStringHandler { int timeshift = SafeParse.stringToInt(act[1]); int percentage = SafeParse.stringToInt(act[2]); setCPP(percentage, timeshift); + } else if ("dismissoverviewnotification".equals(act[0])){ + MainApp.bus().post(new EventDismissNotification(SafeParse.stringToInt(act[1]))); } lastBolusWizard = null; } @@ -502,4 +505,12 @@ public class ActionStringHandler { lastConfirmActionString = null; lastBolusWizard = null; } + + public synchronized static void expectNotificationAction(String message, int id) { + String actionstring = "dismissoverviewnotification " + id; + WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation("DISMISS", message, actionstring); + lastSentTimestamp = System.currentTimeMillis(); + lastConfirmActionString = actionstring; + lastBolusWizard = null; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java index f24de4ff53..c115819f0d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java @@ -21,6 +21,7 @@ import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService; +import info.nightscout.utils.SP; /** * Created by adrian on 17/11/16. @@ -228,5 +229,10 @@ public class WearPlugin implements PluginBase { watchUS = null; } + public void overviewNotification(int id, String message) { + if(SP.getBoolean("wear_overview_notification", false)){ + ActionStringHandler.expectNotificationAction(message, id); + } + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f266668671..a44e5ef758 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -683,4 +683,6 @@ needs to be activated to send values to the pump! Not all profiles loaded! Values not stored! + Overview Notifications + Pass the Overview Notifications through as wear confirmation messages. diff --git a/app/src/main/res/xml/pref_wear.xml b/app/src/main/res/xml/pref_wear.xml index a2458f76f0..4b80c0446d 100644 --- a/app/src/main/res/xml/pref_wear.xml +++ b/app/src/main/res/xml/pref_wear.xml @@ -15,6 +15,13 @@ android:key="wear_showbgi" android:title="@string/wear_showbgi_title" android:summary="@string/wear_showbgi_summary"/> + + + \ No newline at end of file