Skip to content

Commit

Permalink
Merge pull request #182 from nightscout/rn.broadcast
Browse files Browse the repository at this point in the history
add ability to broadcast to other apps
  • Loading branch information
ktind committed Jun 20, 2015
2 parents 1a6dedf + 9c43f36 commit 19a8894
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/src/main/java/com/nightscout/android/ProcessorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,18 @@ public void incomingData(G4Download download) {
response.success = uploadSuccess && initalized && uploader.areAllUploadersInitalized() && uploadersDefined;
lastUploadStatus = (response.success) ? 1 : 2;
bus.post(response);

if (preferences.isBroadcastEnabled()) {
// TODO: make this work for gap sync or a way to request for data (having a db for this would be great)
Intent broadcastIntent = new Intent();
broadcastIntent.setAction("com.nightscout.action.PROCESS_RESPONSE");
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
SensorGlucoseValueEntry sgv = download.sgv.get(download.sgv.size() - 1);
EGVRecord currentEGVrecord = new EGVRecord(sgv, rcvrTime, refTime);
broadcastIntent.putExtra("nsSgv", currentEGVrecord.getBgMgdl());
broadcastIntent.putExtra("nsTimestampMs", currentEGVrecord.getDisplayTime().getMillis());
sendBroadcast(broadcastIntent);
}
}

private <T extends Message> List<T> filterRecords(List<T> recordList, Class clazz, long lastSysTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ public boolean isCampingModeEnabled() {
return preferences.getBoolean(context.getString(R.string.camping_enable), false);
}

public boolean isBroadcastEnabled() {
return preferences.getBoolean(context.getString(R.string.broadcast_enable), false);
}

@Override
public long getLastMeterSysTime() {
return preferences.getLong(context.getString(R.string.last_download_meter_sys_time), 0);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@
<string name="pref_summary_raw_data">Data required to calculate raw values</string>
<string name="pref_summary_camping_enabled">Enable camping mode</string>
<string name="pref_title_camping_enabled">Camping mode</string>
<string name="pref_summary_broadcast_enabled">Enable broadcast of data so other apps can receive it</string>
<string name="pref_title_broadcast_enabled">Broadcast data</string>
<string name="pref_category_title_config_backup">Configuration backups</string>
<string name="pref_backup_title">Backup configuration</string>
<string name="pref_restore_title">Restore configuration</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/pref_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<string name="share_bluetooth_address" translatable="false">share_bluetooth_address</string>
<string name="bt_scan_share2" translatable="false">bt_scan_share2</string>
<string name="camping_enable" translatable="false">camping_enable</string>
<string name="broadcast_enable" translatable="false">broadcast_enable</string>
<string name="pref_backup_config_key" translatable="false">backup_conf</string>
<string name="pref_restore_config_key" translatable="false">restore_config</string>
<string name="last_download_meter_sys_time" translatable="false">last_download_meter_sys_time</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
<string name="pref_summary_raw_data">Data required to calculate raw values</string>
<string name="pref_summary_camping_enabled">Enable camping mode</string>
<string name="pref_title_camping_enabled">Camping mode</string>
<string name="pref_summary_broadcast_enabled">Enable broadcast of data so other apps can receive it</string>
<string name="pref_title_broadcast_enabled">Broadcast data</string>
<string name="pref_category_title_config_backup">Configuration backups</string>
<string name="pref_backup_title">Backup configuration</string>
<string name="pref_restore_title">Restore configuration</string>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/pref_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@
android:disableDependentsState="false"
android:summary="@string/pref_summary_camping_enabled" />

<com.nightscout.android.settings.CustomSwitchPreference
android:title="@string/pref_title_broadcast_enabled"
android:key="@string/broadcast_enable"
android:disableDependentsState="false"
android:summary="@string/pref_summary_broadcast_enabled" />

<PreferenceCategory android:title="@string/pref_header_display_options">
<ListPreference
android:title="@string/pref_title_chart_units_options"
Expand Down

0 comments on commit 19a8894

Please sign in to comment.