Restore ns_noupload function. Thanks to @twain47

This commit is contained in:
Milos Kozak 2020-02-01 23:46:23 +01:00
parent b8ce236717
commit 4b07adb2a8

View file

@ -14,10 +14,12 @@ import org.slf4j.LoggerFactory;
import java.sql.SQLException; import java.sql.SQLException;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.DbRequest; import info.nightscout.androidaps.db.DbRequest;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService; import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService;
import info.nightscout.androidaps.utils.SP;
/** /**
* Created by mike on 21.02.2016. * Created by mike on 21.02.2016.
@ -42,21 +44,22 @@ public class UploadQueue {
} }
public static void add(final DbRequest dbr) { public static void add(final DbRequest dbr) {
if (SP.getBoolean(R.string.key_ns_noupload, false)) return;
startService(); startService();
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(L.NSCLIENT))
log.debug("Adding to queue: " + dbr.log()); log.debug("Adding to queue: " + dbr.log());
try { try {
MainApp.getDbHelper().create(dbr); MainApp.getDbHelper().create(dbr);
} catch (Exception e) { } catch (Exception e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }
NSClientPlugin plugin = NSClientPlugin.getPlugin(); NSClientPlugin plugin = NSClientPlugin.getPlugin();
if (plugin != null) { if (plugin != null) {
plugin.resend("newdata"); plugin.resend("newdata");
} }
} }
public static void clearQueue() { static void clearQueue() {
startService(); startService();
if (NSClientService.handler != null) { if (NSClientService.handler != null) {
NSClientService.handler.post(() -> { NSClientService.handler.post(() -> {
@ -104,7 +107,7 @@ public class UploadQueue {
} }
} }
public String textList() { String textList() {
String result = ""; String result = "";
CloseableIterator<DbRequest> iterator; CloseableIterator<DbRequest> iterator;
try { try {