Merge pull request #1026 from jotomo/lp-editing-without-the-noise

LP: Don't notify about invalid values during editing.
This commit is contained in:
AdrianLxM 2018-05-07 10:27:20 +02:00 committed by GitHub
commit 3f1469b211
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

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

View file

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