handle NS announcements properly

This commit is contained in:
Milos Kozak 2020-06-24 19:15:35 +02:00
parent a4df8d422b
commit 0b0b4fc637

View file

@ -11,6 +11,7 @@ import org.json.JSONObject;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.android.DaggerIntentService; import dagger.android.DaggerIntentService;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.CareportalEvent;
@ -55,6 +56,7 @@ public class DataService extends DaggerIntentService {
@Inject XdripPlugin xdripPlugin; @Inject XdripPlugin xdripPlugin;
@Inject NSProfilePlugin nsProfilePlugin; @Inject NSProfilePlugin nsProfilePlugin;
@Inject ActivePluginProvider activePlugin; @Inject ActivePluginProvider activePlugin;
@Inject Config config;
public DataService() { public DataService() {
super("DataService"); super("DataService");
@ -68,7 +70,6 @@ public class DataService extends DaggerIntentService {
boolean acceptNSData = !sp.getBoolean(R.string.key_ns_upload_only, false); boolean acceptNSData = !sp.getBoolean(R.string.key_ns_upload_only, false);
Bundle bundles = intent.getExtras();
final String action = intent.getAction(); final String action = intent.getAction();
if (Intents.ACTION_NEW_BG_ESTIMATE.equals(action)) { if (Intents.ACTION_NEW_BG_ESTIMATE.equals(action)) {
@ -234,11 +235,14 @@ public class DataService extends DaggerIntentService {
String notes = JsonHelper.safeGetString(json, "notes", ""); String notes = JsonHelper.safeGetString(json, "notes", "");
if (date > now - 15 * 60 * 1000L && !notes.isEmpty() if (date > now - 15 * 60 * 1000L && !notes.isEmpty()
&& !enteredBy.equals(sp.getString("careportal_enteredby", "AndroidAPS"))) { && !enteredBy.equals(sp.getString("careportal_enteredby", "AndroidAPS"))) {
boolean defaultVal = config.getNSCLIENT();
if (sp.getBoolean(R.string.key_ns_announcements, defaultVal)) {
Notification announcement = new Notification(Notification.NSANNOUNCEMENT, notes, Notification.ANNOUNCEMENT, 60); Notification announcement = new Notification(Notification.NSANNOUNCEMENT, notes, Notification.ANNOUNCEMENT, 60);
rxBus.send(new EventNewNotification(announcement)); rxBus.send(new EventNewNotification(announcement));
} }
} }
} }
}
private void storeMbg(JSONObject mbgJson) { private void storeMbg(JSONObject mbgJson) {
NSMbg nsMbg = new NSMbg(mbgJson); NSMbg nsMbg = new NSMbg(mbgJson);