use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.
the class ListenerService method sendPrefSettings.
private void sendPrefSettings() {
// KS
Log.d(TAG, "sendPrefSettings enter");
forceGoogleApiConnect();
DataMap dataMap = new DataMap();
boolean enable_wearG5 = mPrefs.getBoolean("enable_wearG5", false);
boolean force_wearG5 = mPrefs.getBoolean("force_wearG5", false);
String node_wearG5 = mPrefs.getString("node_wearG5", "");
String dex_txid = mPrefs.getString("dex_txid", "ABCDEF");
boolean show_wear_treatments = mPrefs.getBoolean("show_wear_treatments", false);
if (localnode == null || (localnode != null && localnode.isEmpty()))
setLocalNodeName();
Log.d(TAG, "sendPrefSettings enable_wearG5: " + enable_wearG5 + " force_wearG5:" + force_wearG5 + " node_wearG5:" + node_wearG5 + " localnode:" + localnode + " dex_txid:" + dex_txid + " show_wear_treatments:" + show_wear_treatments);
// MOST IMPORTANT LINE FOR TIMESTAMP
dataMap.putLong("time", new Date().getTime());
dataMap.putBoolean("enable_wearG5", enable_wearG5);
dataMap.putBoolean("force_wearG5", force_wearG5);
if (force_wearG5) {
dataMap.putString("node_wearG5", localnode);
} else {
if (node_wearG5.equals(localnode)) {
dataMap.putString("node_wearG5", "");
} else {
dataMap.putString("node_wearG5", node_wearG5);
}
}
dataMap.putString("dex_txid", dex_txid);
// Used in DexCollectionService
dataMap.putInt("bridge_battery", mPrefs.getInt("bridge_battery", -1));
// Used in DexCollectionService for LimiTTer
dataMap.putInt("nfc_sensor_age", mPrefs.getInt("nfc_sensor_age", -1));
dataMap.putBoolean("bg_notifications_watch", mPrefs.getBoolean("bg_notifications", false));
dataMap.putBoolean("persistent_high_alert_enabled_watch", mPrefs.getBoolean("persistent_high_alert_enabled", false));
dataMap.putBoolean("show_wear_treatments", show_wear_treatments);
sendData(WEARABLE_PREF_DATA_PATH, dataMap.toByteArray());
SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(this).edit();
if (!node_wearG5.equals(dataMap.getString("node_wearG5", ""))) {
Log.d(TAG, "sendPrefSettings save to SharedPreferences - node_wearG5:" + dataMap.getString("node_wearG5", ""));
prefs.putString("node_wearG5", dataMap.getString("node_wearG5", ""));
prefs.commit();
}
}
use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.
the class ListenerService method showTreatments.
public static void showTreatments(Context context, String extra) {
Log.d(TAG, "showTreatments enter");
// Max Chart time?
long startTime = new Date().getTime() - (60000 * 60 * 5);
Intent messageIntent = new Intent();
messageIntent.setAction(Intent.ACTION_SEND);
messageIntent.putExtra("message", "ACTION_G5BG");
DataMap treatsDataMap = null;
if (Pref.getBooleanDefaultFalse("show_wear_treatments")) {
switch(extra) {
case "all":
treatsDataMap = getTreatments(startTime);
if (treatsDataMap != null) {
messageIntent.putExtra("treats", treatsDataMap.toBundle());
}
treatsDataMap = getCalibrations(startTime);
if (treatsDataMap != null) {
messageIntent.putExtra("cals", treatsDataMap.toBundle());
}
treatsDataMap = getBloodTests(startTime);
if (treatsDataMap != null) {
messageIntent.putExtra("bts", treatsDataMap.toBundle());
}
break;
case "treats":
treatsDataMap = getTreatments(startTime);
if (treatsDataMap != null) {
messageIntent.putExtra("treats", treatsDataMap.toBundle());
}
break;
case "cals":
treatsDataMap = getCalibrations(startTime);
if (treatsDataMap != null) {
messageIntent.putExtra("cals", treatsDataMap.toBundle());
}
break;
case "bts":
treatsDataMap = getBloodTests(startTime);
if (treatsDataMap != null) {
messageIntent.putExtra("bts", treatsDataMap.toBundle());
}
break;
}
mPrefs = PreferenceManager.getDefaultSharedPreferences(xdrip.getAppContext());
if (mPrefs.getBoolean("extra_status_line", false)) {
messageIntent.putExtra("extra_status_line", extraStatusLine(mPrefs));
}
LocalBroadcastManager.getInstance(context).sendBroadcast(messageIntent);
}
}
use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.
the class ListenerService method dataMap.
private DataMap dataMap(UserError bg) {
DataMap dataMap = new DataMap();
String json = bg.toS();
// Log.d(TAG, "dataMap BG GSON: " + json);
dataMap.putString("entry", json);
return dataMap;
}
use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.
the class ListenerService method dataMapForWatchface.
private static DataMap dataMapForWatchface(Calibration data) {
DataMap dataMap = new DataMap();
dataMap.putDouble("timestamp", data.timestamp);
dataMap.putDouble("sgvDouble", data.bg);
return dataMap;
}
use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.
the class ListenerService method sendCollectorStatus.
private void sendCollectorStatus(Context context, String path) {
String msg;
// long last_timestamp = 0;
DataMap dataMap = new DataMap();
switch(DexCollectionType.getDexCollectionType()) {
case DexcomG5:
if (DexCollectionType.getCollectorServiceClass() == G5CollectionService.class) {
// msg, last_timestamp
dataMap = G5CollectionService.getWatchStatus();
} else {
// msg, last_timestamp
dataMap = Ob1G5CollectionService.getWatchStatus();
}
break;
case // TODO getLastState() in non-G5 Services
DexcomShare:
BluetoothManager mBluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
ActiveBluetoothDevice activeBluetoothDevice = ActiveBluetoothDevice.first();
boolean connected = false;
if (mBluetoothManager != null && activeBluetoothDevice != null) {
for (BluetoothDevice bluetoothDevice : mBluetoothManager.getConnectedDevices(BluetoothProfile.GATT)) {
if (bluetoothDevice.getAddress().compareTo(activeBluetoothDevice.address) == 0) {
connected = true;
}
}
}
if (connected) {
msg = "Connected on watch";
} else {
msg = "Not Connected";
}
dataMap.putString("lastState", msg);
break;
default:
dataMap = DexCollectionService.getWatchStatus();
break;
}
if (dataMap != null) {
dataMap.putString("action_path", path);
}
// sendReplyMsg (msg, last_timestamp, path, false);
sendData(WEARABLE_REPLYMSG_PATH, dataMap.toByteArray());
}
Aggregations