Merge pull request #274 from AdrianLxM/wear-oaps-reason-result
wear show oaps result/reason
This commit is contained in:
commit
31e9f3f55c
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
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.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
|
@ -159,6 +160,9 @@ public class ActionStringHandler {
|
||||||
} else if ("targets".equals(act[1])) {
|
} else if ("targets".equals(act[1])) {
|
||||||
rTitle += " TARGETS";
|
rTitle += " TARGETS";
|
||||||
rMessage = getTargetsStatus();
|
rMessage = getTargetsStatus();
|
||||||
|
} else if ("oapsresult".equals(act[1])) {
|
||||||
|
rTitle += " OAPS RESULT";
|
||||||
|
rMessage = getOAPSResultStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ("wizard".equals(act[0])) {
|
} else if ("wizard".equals(act[0])) {
|
||||||
|
@ -298,6 +302,40 @@ public class ActionStringHandler {
|
||||||
return ret;
|
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) {
|
public synchronized static void handleConfirmation(String actionString) {
|
||||||
|
|
||||||
|
|
|
@ -336,6 +336,8 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
.setContentIntent(actionPendingIntent)
|
.setContentIntent(actionPendingIntent)
|
||||||
.setPriority(NotificationCompat.PRIORITY_MAX)
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||||
.setVibrate(vibratePattern)
|
.setVibrate(vibratePattern)
|
||||||
|
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
|
||||||
|
.extend(new NotificationCompat.WearableExtender())
|
||||||
.addAction(R.drawable.ic_confirm, title, actionPendingIntent);
|
.addAction(R.drawable.ic_confirm, title, actionPendingIntent);
|
||||||
|
|
||||||
NotificationManagerCompat notificationManager =
|
NotificationManagerCompat notificationManager =
|
||||||
|
|
|
@ -14,7 +14,9 @@ public class StatusMenuActivity extends MenuListActivity {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"Pump",
|
"Pump",
|
||||||
"Loop",
|
"Loop",
|
||||||
"Targets"};
|
"Targets",
|
||||||
|
"OAPS Result"};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,6 +32,9 @@ public class StatusMenuActivity extends MenuListActivity {
|
||||||
case 2:
|
case 2:
|
||||||
ListenerService.initiateAction(this, "status targets");
|
ListenerService.initiateAction(this, "status targets");
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
ListenerService.initiateAction(this, "status oapsresult");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue