ignore dbaccess if nsclient not enabled

This commit is contained in:
Milos Kozak 2017-02-17 16:41:28 +01:00
parent 8a374f1b35
commit 31364ff07b
4 changed files with 24 additions and 2 deletions

View file

@ -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;

View file

@ -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) {

View file

@ -97,6 +97,15 @@
android:layout_marginRight="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/nsclientinternal_clearlog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/clearlog"
android:textAlignment="center"
android:textColor="@android:color/holo_orange_light" />
<TextView
android:id="@+id/nsclientinternal_restart"
android:layout_width="wrap_content"

View file

@ -536,4 +536,5 @@
<string name="key_danar_password" translatable="false">danar_password</string>
<string name="key_danar_useextended" translatable="false">danar_useextended</string>
<string name="key_danarprofile_dia" translatable="false">danarprofile_dia</string>
<string name="clearlog">Clear log</string>
</resources>