Merge pull request #274 from AdrianLxM/wear-oaps-reason-result

wear show oaps result/reason
This commit is contained in:
Milos Kozak 2017-07-04 12:01:47 +02:00 committed by GitHub
commit 31e9f3f55c
3 changed files with 46 additions and 1 deletions

View file

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

View file

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

View file

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