setting to disable local broadcasts in NSClient

This commit is contained in:
AdrianLxM 2017-07-18 22:15:17 +02:00
parent 0d1ff3d721
commit c753873769
15 changed files with 74 additions and 0 deletions

View file

@ -12,6 +12,7 @@ import java.util.List;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm;
import info.nightscout.utils.SP;
/**
* Created by mike on 11.06.2017.
@ -21,6 +22,7 @@ public class BroadcastAckAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastAckAlarm.class);
public static void handleClearAlarm(NSAlarm originalAlarm, Context context, long silenceTimeInMsec) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putInt("level", originalAlarm.getLevel());
bundle.putString("group", originalAlarm.getGroup());

View file

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
@ -20,6 +21,9 @@ public class BroadcastAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastAlarm.class);
public static void handleAlarm(JSONObject alarm, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("data", alarm.toString());
Intent intent = new Intent(Intents.ACTION_ALARM);

View file

@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
@ -21,6 +22,9 @@ public class BroadcastAnnouncement {
private static Logger log = LoggerFactory.getLogger(BroadcastAnnouncement.class);
public static void handleAnnouncement(JSONObject announcement, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("data", announcement.toString());
Intent intent = new Intent(Intents.ACTION_ANNOUNCEMENT);

View file

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
@ -20,6 +21,9 @@ public class BroadcastCals {
private static Logger log = LoggerFactory.getLogger(BroadcastCals.class);
public static void handleNewCal(JSONArray cals, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("cals", cals.toString());
bundle.putBoolean("delta", isDelta);

View file

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
@ -20,6 +21,9 @@ public class BroadcastClearAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastClearAlarm.class);
public static void handleClearAlarm(JSONObject clearalarm, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("data", clearalarm.toString());
Intent intent = new Intent(Intents.ACTION_CLEAR_ALARM);

View file

@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
public class BroadcastDeviceStatus {
@ -35,6 +36,11 @@ public class BroadcastDeviceStatus {
}
}
public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
List<JSONArray> splitted = BroadcastTreatment.splitArray(statuses);
for (JSONArray part: splitted) {
Bundle bundle = new Bundle();

View file

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
@ -20,6 +21,9 @@ public class BroadcastMbgs {
private static Logger log = LoggerFactory.getLogger(BroadcastMbgs.class);
public static void handleNewMbg(JSONArray mbgs, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("mbgs", mbgs.toString());
bundle.putBoolean("delta", isDelta);

View file

@ -12,6 +12,7 @@ import java.util.List;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.utils.SP;
/**
@ -21,6 +22,9 @@ public class BroadcastProfile {
private static Logger log = LoggerFactory.getLogger(BroadcastProfile.class);
public static void handleNewTreatment(ProfileStore profile, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("profile", profile.getData().toString());
bundle.putBoolean("delta", isDelta);

View file

@ -6,12 +6,16 @@ import android.os.Bundle;
import android.os.PowerManager;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 28.02.2016.
*/
public class BroadcastQueueStatus {
public static void handleNewStatus(int size, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"sendQueue");

View file

@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 22.02.2016.
@ -21,6 +22,9 @@ public class BroadcastSgvs {
private static Logger log = LoggerFactory.getLogger(BroadcastSgvs.class);
public static void handleNewSgv(JSONObject sgv, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("sgv", sgv.toString());
bundle.putBoolean("delta", isDelta);

View file

@ -15,6 +15,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
import info.nightscout.utils.SP;
/**
* Created by mike on 24.02.2016.
@ -23,6 +24,9 @@ public class BroadcastStatus {
private static Logger log = LoggerFactory.getLogger(BroadcastStatus.class);
public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
try {
bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName);

View file

@ -17,6 +17,7 @@ import java.util.List;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
import info.nightscout.utils.SP;
/**
* Created by mike on 20.02.2016.
@ -25,6 +26,9 @@ public class BroadcastTreatment {
private static Logger log = LoggerFactory.getLogger(BroadcastTreatment.class);
public static void handleNewTreatment(NSTreatment treatment, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.getData().toString());
bundle.putBoolean("delta", isDelta);
@ -42,6 +46,9 @@ public class BroadcastTreatment {
}
public static void handleNewTreatment(JSONArray treatments, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
List<JSONArray> splitted = splitArray(treatments);
for (JSONArray part: splitted) {
Bundle bundle = new Bundle();
@ -62,6 +69,9 @@ public class BroadcastTreatment {
}
public void handleChangedTreatment(JSONObject treatment, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.toString());
bundle.putBoolean("delta", isDelta);
@ -78,6 +88,9 @@ public class BroadcastTreatment {
}
public static void handleChangedTreatment(JSONArray treatments, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
List<JSONArray> splitted = splitArray(treatments);
for (JSONArray part: splitted) {
Bundle bundle = new Bundle();
@ -98,6 +111,9 @@ public class BroadcastTreatment {
}
public static void handleRemovedTreatment(JSONObject treatment, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.toString());
bundle.putBoolean("delta", isDelta);
@ -116,6 +132,9 @@ public class BroadcastTreatment {
}
public static void handleRemovedTreatment(JSONArray treatments, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("treatments", treatments.toString());
bundle.putBoolean("delta", isDelta);

View file

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/**
* Created by mike on 26.06.2016.
@ -20,6 +21,9 @@ public class BroadcastUrgentAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastUrgentAlarm.class);
public static void handleUrgentAlarm(JSONObject urgentalarm, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle();
bundle.putString("data", urgentalarm.toString());
Intent intent = new Intent(Intents.ACTION_URGENT_ALARM);

View file

@ -580,6 +580,7 @@
<string name="superbolus">Superbolus</string>
<string name="ns_logappstartedevent">Log app start to NS</string>
<string name="key_ns_logappstartedevent" translatable="false">ns_logappstartedevent</string>
<string name="key_ns_localbroadcasts" translatable="false">nsclient_localbroadcasts</string>
<string name="restartingapp">Exiting application to apply settings.</string>
<string name="danarv2pump">DanaRv2</string>
<string name="configbuilder_insulin">Insulin</string>
@ -685,4 +686,5 @@
<string name="cpp_valuesnotstored">Values not stored!</string>
<string name="wear_overviewnotifications">Overview Notifications</string>
<string name="wear_overviewnotifications_summary">Pass the Overview Notifications through as wear confirmation messages.</string>
<string name="ns_localbroadcasts">Enable loacal broadcasts to other apps (like xDrip).</string>
</resources>

View file

@ -27,6 +27,11 @@
android:key="@string/key_ns_logappstartedevent"
android:title="@string/ns_logappstartedevent" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_localbroadcasts"
android:title="@string/ns_localbroadcasts" />
<PreferenceScreen android:title="@string/ns_alarmoptions">
<SwitchPreference