LP: Don't notify about invalid values during editing.

This commit is contained in:
Johannes Mockenhaupt 2018-05-07 01:33:16 +02:00
parent 3385a23bdb
commit 785c402848
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 8 additions and 3 deletions

View file

@ -180,6 +180,10 @@ public class Profile {
}
public synchronized boolean isValid(String from) {
return isValid(from, true);
}
public synchronized boolean isValid(String from, boolean notify) {
if (!isValid)
return false;
if (!isValidated) {
@ -207,7 +211,7 @@ public class Profile {
if (pump != null && !pump.getPumpDescription().is30minBasalRatesCapable) {
for (int index = 0; index < basal_v.size(); index++) {
long secondsFromMidnight = basal_v.keyAt(index);
if (secondsFromMidnight % 3600 != 0) {
if (notify && secondsFromMidnight % 3600 != 0) {
Notification notification = new Notification(Notification.BASAL_PROFILE_NOT_ALIGNED_TO_HOURS, String.format(MainApp.gs(R.string.basalprofilenotaligned), from), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
}
@ -220,7 +224,8 @@ public class Profile {
for (int i = 0; i < basal_v.size(); i++) {
if (basal_v.valueAt(i) < description.basalMinimumRate) {
basal_v.setValueAt(i, description.basalMinimumRate);
sendBelowMinimumNotification(from);
if (notify)
sendBelowMinimumNotification(from);
}
}
} else {

View file

@ -177,7 +177,7 @@ public class LocalProfilePlugin extends PluginBase implements ProfileInterface {
}
public synchronized boolean isValidEditState() {
return createProfileStore().getDefaultProfile().isValid(MainApp.gs(R.string.localprofile));
return createProfileStore().getDefaultProfile().isValid(MainApp.gs(R.string.localprofile), false);
}
@NonNull