nsclient sgv local
This commit is contained in:
parent
38100e758e
commit
7a171bd949
|
@ -57,7 +57,6 @@
|
|||
android:exported="true">
|
||||
<intent-filter>
|
||||
<!-- Receiver from NSClient -->
|
||||
<action android:name="info.nightscout.client.NEW_SGV" />
|
||||
<action android:name="info.nightscout.client.NEW_PROFILE" />
|
||||
<action android:name="info.nightscout.client.NEW_STATUS" />
|
||||
<action android:name="info.nightscout.client.NEW_MBG" />
|
||||
|
|
|
@ -172,6 +172,8 @@ public class MainApp extends Application {
|
|||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_TREATMENT));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_CHANGED_TREATMENT));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_REMOVED_TREATMENT));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_SGV));
|
||||
|
||||
}
|
||||
|
||||
private void startKeepAliveService() {
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
@ -12,6 +13,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
|
@ -23,16 +25,24 @@ public class BroadcastSgvs {
|
|||
|
||||
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);
|
||||
Intent intent = new Intent(Intents.ACTION_NEW_SGV);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
if(SP.getBoolean("nsclient_localbroadcasts", true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("sgv", sgv.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_NEW_SGV);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleNewSgv(JSONArray sgvs, Context context, boolean isDelta) {
|
||||
Bundle bundle = new Bundle();
|
||||
|
@ -41,7 +51,17 @@ public class BroadcastSgvs {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_SGV);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
if(SP.getBoolean("nsclient_localbroadcasts", true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("sgvs", sgvs.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_NEW_SGV);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue