nsclient status local
This commit is contained in:
parent
759154e578
commit
82b99e1708
3 changed files with 22 additions and 4 deletions
|
@ -57,7 +57,6 @@
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<!-- Receiver from NSClient -->
|
<!-- Receiver from NSClient -->
|
||||||
<action android:name="info.nightscout.client.NEW_STATUS" />
|
|
||||||
<action android:name="info.nightscout.client.NEW_MBG" />
|
<action android:name="info.nightscout.client.NEW_MBG" />
|
||||||
<action android:name="info.nightscout.client.NEW_DEVICESTATUS" />
|
<action android:name="info.nightscout.client.NEW_DEVICESTATUS" />
|
||||||
<action android:name="info.nightscout.client.NEW_CAL" />
|
<action android:name="info.nightscout.client.NEW_CAL" />
|
||||||
|
|
|
@ -174,6 +174,8 @@ public class MainApp extends Application {
|
||||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_REMOVED_TREATMENT));
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_REMOVED_TREATMENT));
|
||||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_SGV));
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_SGV));
|
||||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_PROFILE));
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_PROFILE));
|
||||||
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_STATUS));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -25,8 +26,6 @@ public class BroadcastStatus {
|
||||||
|
|
||||||
public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) {
|
public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) {
|
||||||
|
|
||||||
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
|
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
try {
|
try {
|
||||||
bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName);
|
bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName);
|
||||||
|
@ -41,6 +40,24 @@ public class BroadcastStatus {
|
||||||
Intent intent = new Intent(Intents.ACTION_NEW_STATUS);
|
Intent intent = new Intent(Intents.ACTION_NEW_STATUS);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
|
|
||||||
|
if(SP.getBoolean("nsclient_localbroadcasts", true)) {
|
||||||
|
bundle = new Bundle();
|
||||||
|
try {
|
||||||
|
bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName);
|
||||||
|
bundle.putInt("nsclientversioncode", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
bundle.putString("nightscoutversionname", NSClientService.nightscoutVersionName);
|
||||||
|
bundle.putInt("nightscoutversioncode", NSClientService.nightscoutVersionCode);
|
||||||
|
bundle.putString("status", status.getData().toString());
|
||||||
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
intent = new Intent(Intents.ACTION_NEW_STATUS);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
context.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue