From e81b217c94ba44134a3bc29f664347a9d9628c3a Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 3 Jul 2017 01:43:08 +0200 Subject: [PATCH] wear show oaps result/reason --- .../plugins/Wear/ActionStringHandler.java | 38 +++++++++++++++++++ .../androidaps/data/ListenerService.java | 2 + .../interaction/menus/StatusMenuActivity.java | 7 +++- 3 files changed, 46 insertions(+), 1 deletion(-) 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 0027889783..858bd653f5 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 @@ -21,6 +21,7 @@ import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.PluginBase; 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.utils.BolusWizard; @@ -159,6 +160,9 @@ public class ActionStringHandler { } else if ("targets".equals(act[1])) { rTitle += " TARGETS"; rMessage = getTargetsStatus(); + } else if ("oapsresult".equals(act[1])) { + rTitle += " OAPS RESULT"; + rMessage = getOAPSResultStatus(); } } else if ("wizard".equals(act[0])) { @@ -298,6 +302,40 @@ public class ActionStringHandler { return ret; } + private static String getOAPSResultStatus() { + String ret = ""; + if (!Config.APS) { + return "Only apply in APS mode!"; + } + Profile profile = MainApp.getConfigBuilder().getProfile(); + if (profile == null) { + return "No profile set :("; + } + + APSInterface usedAPS = MainApp.getConfigBuilder().getActiveAPS(); + if (usedAPS == null) { + return "No active APS :(!"; + } + + APSResult result = usedAPS.getLastAPSResult(); + if (result == null) { + return "Last result not available!"; + } + + if (!result.changeRequested) { + ret += MainApp.sResources.getString(R.string.nochangerequested) + "\n"; + } else if (result.rate == 0 && result.duration == 0) { + ret += MainApp.sResources.getString(R.string.canceltemp)+ "\n"; + } else { + ret += MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(result.rate) + " U/h " + + "(" + DecimalFormatter.to2Decimal(result.rate / MainApp.getConfigBuilder().getBaseBasalRate() * 100) + "%)\n" + + MainApp.sResources.getString(R.string.duration) + ": " + DecimalFormatter.to0Decimal(result.duration) + " min\n"; + } + ret += "\n" + MainApp.sResources.getString(R.string.reason) + ": " + result.reason; + + return ret; + } + public synchronized static void handleConfirmation(String actionString) { diff --git a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java index 88c334d07a..3d66508fa7 100644 --- a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java @@ -336,6 +336,8 @@ public class ListenerService extends WearableListenerService implements GoogleAp .setContentIntent(actionPendingIntent) .setPriority(NotificationCompat.PRIORITY_MAX) .setVibrate(vibratePattern) + .setStyle(new NotificationCompat.BigTextStyle().bigText(message)) + .extend(new NotificationCompat.WearableExtender()) .addAction(R.drawable.ic_confirm, title, actionPendingIntent); NotificationManagerCompat notificationManager = diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java index b8301400e2..5e4c221e9d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java @@ -14,7 +14,9 @@ public class StatusMenuActivity extends MenuListActivity { return new String[] { "Pump", "Loop", - "Targets"}; + "Targets", + "OAPS Result"}; + } @Override @@ -30,6 +32,9 @@ public class StatusMenuActivity extends MenuListActivity { case 2: ListenerService.initiateAction(this, "status targets"); break; + case 3: + ListenerService.initiateAction(this, "status oapsresult"); + break; } }