Use preferences
This commit is contained in:
parent
a501b37159
commit
efc25ddcd5
1 changed files with 48 additions and 36 deletions
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.aps.loop;
|
package info.nightscout.androidaps.plugins.aps.loop;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
@ -54,6 +53,9 @@ import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotifi
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
|
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.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
|
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
@ -90,6 +92,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
private final ReceiverStatusStore receiverStatusStore;
|
private final ReceiverStatusStore receiverStatusStore;
|
||||||
private final FabricPrivacy fabricPrivacy;
|
private final FabricPrivacy fabricPrivacy;
|
||||||
private final HardLimits hardLimits;
|
private final HardLimits hardLimits;
|
||||||
|
private Notification notification;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -439,6 +442,14 @@ public class LoopPlugin extends PluginBase {
|
||||||
&& resultAfterConstraints.carbsReq >= sp.getInt(R.string.key_smb_enable_carbs_suggestions_threshold, 0)
|
&& resultAfterConstraints.carbsReq >= sp.getInt(R.string.key_smb_enable_carbs_suggestions_threshold, 0)
|
||||||
&& carbsSuggestionsSuspendedUntil < System.currentTimeMillis()) {
|
&& carbsSuggestionsSuspendedUntil < System.currentTimeMillis()) {
|
||||||
|
|
||||||
|
if (sp.getBoolean(R.string.key_enable_carbs_required_alert_local,true)) {
|
||||||
|
Notification carbreqlocal = new Notification(Notification.CARBS_REQUIRED, resultAfterConstraints.getCarbsRequiredText(), Notification.NORMAL);
|
||||||
|
rxBus.send(new EventNewNotification(carbreqlocal));
|
||||||
|
}
|
||||||
|
if (sp.getBoolean(R.string.key_ns_create_announcements_from_carbs_req, false)) {
|
||||||
|
NSUpload.uploadError(resultAfterConstraints.getCarbsRequiredText());
|
||||||
|
}
|
||||||
|
if (sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, false)){
|
||||||
Intent intentAction5m = new Intent(context, CarbSuggestionReceiver.class);
|
Intent intentAction5m = new Intent(context, CarbSuggestionReceiver.class);
|
||||||
intentAction5m.putExtra("ignoreDuration", 5);
|
intentAction5m.putExtra("ignoreDuration", 5);
|
||||||
PendingIntent pendingIntent5m = PendingIntent.getBroadcast(context, 1, intentAction5m, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pendingIntent5m = PendingIntent.getBroadcast(context, 1, intentAction5m, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
@ -462,7 +473,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
.setContentTitle(resourceHelper.gs(R.string.carbssuggestion))
|
.setContentTitle(resourceHelper.gs(R.string.carbssuggestion))
|
||||||
.setContentText(resultAfterConstraints.getCarbsRequiredText())
|
.setContentText(resultAfterConstraints.getCarbsRequiredText())
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setPriority(Notification.PRIORITY_MAX)
|
.setPriority(Notification.IMPORTANCE_HIGH)
|
||||||
.setCategory(Notification.CATEGORY_ALARM)
|
.setCategory(Notification.CATEGORY_ALARM)
|
||||||
.addAction(actionIgnore5m)
|
.addAction(actionIgnore5m)
|
||||||
.addAction(actionIgnore15m)
|
.addAction(actionIgnore15m)
|
||||||
|
@ -479,6 +490,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
// Send to Wear
|
// Send to Wear
|
||||||
actionStringHandler.get().handleInitiate("changeRequest");
|
actionStringHandler.get().handleInitiate("changeRequest");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dismissSuggestion();
|
dismissSuggestion();
|
||||||
|
@ -537,7 +549,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
.setContentTitle(resourceHelper.gs(R.string.openloop_newsuggestion))
|
.setContentTitle(resourceHelper.gs(R.string.openloop_newsuggestion))
|
||||||
.setContentText(resultAfterConstraints.toString())
|
.setContentText(resultAfterConstraints.toString())
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setPriority(Notification.PRIORITY_HIGH)
|
.setPriority(Notification.IMPORTANCE_HIGH)
|
||||||
.setCategory(Notification.CATEGORY_ALARM)
|
.setCategory(Notification.CATEGORY_ALARM)
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
||||||
if (sp.getBoolean("wearcontrol", false)) {
|
if (sp.getBoolean("wearcontrol", false)) {
|
||||||
|
|
Loading…
Reference in a new issue