From 31364ff07b7ce57151a37e278cce77e687d63075 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 17 Feb 2017 16:41:28 +0100 Subject: [PATCH] ignore dbaccess if nsclient not enabled --- .../NSClientInternal/NSClientInternalFragment.java | 9 ++++++++- .../NSClientInternal/receivers/DBAccessReceiver.java | 7 ++++++- app/src/main/res/layout/nsclientinternal_fragment.xml | 9 +++++++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java index d101b3f5fe..a30571d4d1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java @@ -42,6 +42,7 @@ public class NSClientInternalFragment extends Fragment implements FragmentBase, private TextView queueTextView; private TextView urlTextView; private TextView statusTextView; + private TextView clearlog; private TextView restart; private TextView delivernow; private TextView clearqueue; @@ -67,6 +68,9 @@ public class NSClientInternalFragment extends Fragment implements FragmentBase, urlTextView = (TextView) view.findViewById(R.id.nsclientinternal_url); statusTextView = (TextView) view.findViewById(R.id.nsclientinternal_status); + clearlog = (TextView) view.findViewById(R.id.nsclientinternal_clearlog); + clearlog.setOnClickListener(this); + clearlog.setPaintFlags(clearlog.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); restart = (TextView) view.findViewById(R.id.nsclientinternal_restart); restart.setOnClickListener(this); restart.setPaintFlags(restart.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); @@ -93,9 +97,12 @@ public class NSClientInternalFragment extends Fragment implements FragmentBase, case R.id.nsclientinternal_delivernow: getPlugin().resend("GUI"); break; - case R.id.nsclientinternal_clearqueue: + case R.id.nsclientinternal_clearlog: getPlugin().clearLog(); break; + case R.id.nsclientinternal_clearqueue: + getPlugin().queue().reset(); + break; case R.id.nsclientinternal_showqueue: MainApp.bus().post(new EventNSClientNewLog("QUEUE", getPlugin().queue().textList())); break; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java index 1cf0d27b77..cf9c7ea673 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java @@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue; import info.nightscout.androidaps.plugins.NSClientInternal.data.DbRequest; @@ -27,6 +28,10 @@ public class DBAccessReceiver extends BroadcastReceiver { PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "sendQueue"); + NSClientInternalPlugin nsClientInternalPlugin = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class); + if (!nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) { + return; + } wakeLock.acquire(); try { Bundle bundles = intent.getExtras(); @@ -46,10 +51,10 @@ public class DBAccessReceiver extends BroadcastReceiver { return; } - // mark by id if (action.equals("dbRemove")) { data = new JSONObject(); } + // mark by id try { data.put("NSCLIENT_ID", (new Date()).getTime()); } catch (JSONException e) { diff --git a/app/src/main/res/layout/nsclientinternal_fragment.xml b/app/src/main/res/layout/nsclientinternal_fragment.xml index 27f9267dd1..064d369253 100644 --- a/app/src/main/res/layout/nsclientinternal_fragment.xml +++ b/app/src/main/res/layout/nsclientinternal_fragment.xml @@ -97,6 +97,15 @@ android:layout_marginRight="5dp" android:orientation="horizontal"> + + danar_password danar_useextended danarprofile_dia + Clear log