ignore dbaccess if nsclient not enabled
This commit is contained in:
parent
8a374f1b35
commit
31364ff07b
4 changed files with 24 additions and 2 deletions
|
@ -42,6 +42,7 @@ public class NSClientInternalFragment extends Fragment implements FragmentBase,
|
||||||
private TextView queueTextView;
|
private TextView queueTextView;
|
||||||
private TextView urlTextView;
|
private TextView urlTextView;
|
||||||
private TextView statusTextView;
|
private TextView statusTextView;
|
||||||
|
private TextView clearlog;
|
||||||
private TextView restart;
|
private TextView restart;
|
||||||
private TextView delivernow;
|
private TextView delivernow;
|
||||||
private TextView clearqueue;
|
private TextView clearqueue;
|
||||||
|
@ -67,6 +68,9 @@ public class NSClientInternalFragment extends Fragment implements FragmentBase,
|
||||||
urlTextView = (TextView) view.findViewById(R.id.nsclientinternal_url);
|
urlTextView = (TextView) view.findViewById(R.id.nsclientinternal_url);
|
||||||
statusTextView = (TextView) view.findViewById(R.id.nsclientinternal_status);
|
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 = (TextView) view.findViewById(R.id.nsclientinternal_restart);
|
||||||
restart.setOnClickListener(this);
|
restart.setOnClickListener(this);
|
||||||
restart.setPaintFlags(restart.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
restart.setPaintFlags(restart.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
|
@ -93,9 +97,12 @@ public class NSClientInternalFragment extends Fragment implements FragmentBase,
|
||||||
case R.id.nsclientinternal_delivernow:
|
case R.id.nsclientinternal_delivernow:
|
||||||
getPlugin().resend("GUI");
|
getPlugin().resend("GUI");
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_clearqueue:
|
case R.id.nsclientinternal_clearlog:
|
||||||
getPlugin().clearLog();
|
getPlugin().clearLog();
|
||||||
break;
|
break;
|
||||||
|
case R.id.nsclientinternal_clearqueue:
|
||||||
|
getPlugin().queue().reset();
|
||||||
|
break;
|
||||||
case R.id.nsclientinternal_showqueue:
|
case R.id.nsclientinternal_showqueue:
|
||||||
MainApp.bus().post(new EventNSClientNewLog("QUEUE", getPlugin().queue().textList()));
|
MainApp.bus().post(new EventNSClientNewLog("QUEUE", getPlugin().queue().textList()));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.DbRequest;
|
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 powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||||
"sendQueue");
|
"sendQueue");
|
||||||
|
NSClientInternalPlugin nsClientInternalPlugin = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
|
||||||
|
if (!nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
wakeLock.acquire();
|
wakeLock.acquire();
|
||||||
try {
|
try {
|
||||||
Bundle bundles = intent.getExtras();
|
Bundle bundles = intent.getExtras();
|
||||||
|
@ -46,10 +51,10 @@ public class DBAccessReceiver extends BroadcastReceiver {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark by id
|
|
||||||
if (action.equals("dbRemove")) {
|
if (action.equals("dbRemove")) {
|
||||||
data = new JSONObject();
|
data = new JSONObject();
|
||||||
}
|
}
|
||||||
|
// mark by id
|
||||||
try {
|
try {
|
||||||
data.put("NSCLIENT_ID", (new Date()).getTime());
|
data.put("NSCLIENT_ID", (new Date()).getTime());
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
|
|
@ -97,6 +97,15 @@
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:orientation="horizontal">
|
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
|
<TextView
|
||||||
android:id="@+id/nsclientinternal_restart"
|
android:id="@+id/nsclientinternal_restart"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -536,4 +536,5 @@
|
||||||
<string name="key_danar_password" translatable="false">danar_password</string>
|
<string name="key_danar_password" translatable="false">danar_password</string>
|
||||||
<string name="key_danar_useextended" translatable="false">danar_useextended</string>
|
<string name="key_danar_useextended" translatable="false">danar_useextended</string>
|
||||||
<string name="key_danarprofile_dia" translatable="false">danarprofile_dia</string>
|
<string name="key_danarprofile_dia" translatable="false">danarprofile_dia</string>
|
||||||
|
<string name="clearlog">Clear log</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue