Dismiss carb notifications automatically if no longer needed, crossfingers fix double wear OS notifications
This commit is contained in:
parent
2391ebe399
commit
c4a317f515
1 changed files with 16 additions and 4 deletions
|
@ -108,6 +108,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
private boolean isDisconnected;
|
private boolean isDisconnected;
|
||||||
|
|
||||||
private long carbsSuggestionsSuspendedUntil = 0;
|
private long carbsSuggestionsSuspendedUntil = 0;
|
||||||
|
private int prevCarbsreq = 0;
|
||||||
|
|
||||||
@Nullable private LastRun lastRun = null;
|
@Nullable private LastRun lastRun = null;
|
||||||
|
|
||||||
|
@ -396,7 +397,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
}
|
}
|
||||||
result.percent = (int) (result.rate / profile.getBasal() * 100);
|
result.percent = (int) (result.rate / profile.getBasal() * 100);
|
||||||
|
|
||||||
// check rate for constrais
|
// check rate for constraints
|
||||||
final APSResult resultAfterConstraints = result.newAndClone(injector);
|
final APSResult resultAfterConstraints = result.newAndClone(injector);
|
||||||
resultAfterConstraints.rateConstraint = new Constraint<>(resultAfterConstraints.rate);
|
resultAfterConstraints.rateConstraint = new Constraint<>(resultAfterConstraints.rate);
|
||||||
resultAfterConstraints.rate = constraintChecker.applyBasalConstraints(resultAfterConstraints.rateConstraint, profile).value();
|
resultAfterConstraints.rate = constraintChecker.applyBasalConstraints(resultAfterConstraints.rateConstraint, profile).value();
|
||||||
|
@ -414,6 +415,10 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
resultAfterConstraints.smb = 0;
|
resultAfterConstraints.smb = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastRun != null) {
|
||||||
|
prevCarbsreq = lastRun.getConstraintsProcessed().carbsReq;
|
||||||
|
}
|
||||||
|
|
||||||
if (lastRun == null) lastRun = new LastRun();
|
if (lastRun == null) lastRun = new LastRun();
|
||||||
lastRun.setRequest(result);
|
lastRun.setRequest(result);
|
||||||
lastRun.setConstraintsProcessed(resultAfterConstraints);
|
lastRun.setConstraintsProcessed(resultAfterConstraints);
|
||||||
|
@ -494,12 +499,19 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
mNotificationManager.notify(Constants.notificationID, builder.build());
|
mNotificationManager.notify(Constants.notificationID, builder.build());
|
||||||
rxBus.send(new EventNewOpenLoopNotification());
|
rxBus.send(new EventNewOpenLoopNotification());
|
||||||
|
|
||||||
// Send to Wear
|
//only send to wear if Native notifications are turned off
|
||||||
actionStringHandler.get().handleInitiate("changeRequest");
|
if (!sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, false)) {
|
||||||
|
// Send to Wear
|
||||||
|
actionStringHandler.get().handleInitiate("changeRequest");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dismissSuggestion();
|
//If carbs were required previously, but are no longer needed, dismiss notifications
|
||||||
|
if ( prevCarbsreq > 0 ) {
|
||||||
|
dismissSuggestion();
|
||||||
|
rxBus.send(new EventDismissNotification(Notification.CARBS_REQUIRED));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue