share wear paths
This commit is contained in:
parent
a667ef7d5d
commit
665342f0ae
3 changed files with 59 additions and 65 deletions
|
@ -46,9 +46,6 @@ import info.nightscout.androidaps.interfaces.Loop;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.Profile;
|
import info.nightscout.androidaps.interfaces.Profile;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry;
|
|
||||||
import info.nightscout.shared.logging.AAPSLogger;
|
|
||||||
import info.nightscout.shared.logging.LTag;
|
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus;
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus;
|
||||||
|
@ -64,7 +61,11 @@ import info.nightscout.androidaps.utils.DefaultValueHelper;
|
||||||
import info.nightscout.androidaps.utils.TrendCalculator;
|
import info.nightscout.androidaps.utils.TrendCalculator;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.wizard.QuickWizard;
|
import info.nightscout.androidaps.utils.wizard.QuickWizard;
|
||||||
|
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry;
|
||||||
|
import info.nightscout.shared.logging.AAPSLogger;
|
||||||
|
import info.nightscout.shared.logging.LTag;
|
||||||
import info.nightscout.shared.sharedPreferences.SP;
|
import info.nightscout.shared.sharedPreferences.SP;
|
||||||
|
import info.nightscout.shared.weardata.WearUris;
|
||||||
|
|
||||||
public class WatchUpdaterService extends WearableListenerService implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
public class WatchUpdaterService extends WearableListenerService implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
||||||
@Inject public GlucoseStatusProvider glucoseStatusProvider;
|
@Inject public GlucoseStatusProvider glucoseStatusProvider;
|
||||||
|
@ -95,21 +96,6 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
public static final String ACTION_CANCEL_NOTIFICATION = WatchUpdaterService.class.getName().concat(".CancelNotification");
|
public static final String ACTION_CANCEL_NOTIFICATION = WatchUpdaterService.class.getName().concat(".CancelNotification");
|
||||||
|
|
||||||
private GoogleApiClient googleApiClient;
|
private GoogleApiClient googleApiClient;
|
||||||
public static final String WEARABLE_DATA_PATH = "/nightscout_watch_data";
|
|
||||||
public static final String WEARABLE_RESEND_PATH = "/nightscout_watch_data_resend";
|
|
||||||
private static final String WEARABLE_CANCELBOLUS_PATH = "/nightscout_watch_cancel_bolus";
|
|
||||||
public static final String WEARABLE_CONFIRM_ACTIONSTRING_PATH = "/nightscout_watch_confirmactionstring";
|
|
||||||
public static final String WEARABLE_INITIATE_ACTIONSTRING_PATH = "/nightscout_watch_initiateactionstring";
|
|
||||||
|
|
||||||
private static final String OPEN_SETTINGS_PATH = "/openwearsettings";
|
|
||||||
private static final String NEW_STATUS_PATH = "/sendstatustowear";
|
|
||||||
private static final String NEW_PREFERENCES_PATH = "/sendpreferencestowear";
|
|
||||||
private static final String QUICK_WIZARD_PATH = "/send_quick_wizard";
|
|
||||||
public static final String BASAL_DATA_PATH = "/nightscout_watch_basal";
|
|
||||||
public static final String BOLUS_PROGRESS_PATH = "/nightscout_watch_bolusprogress";
|
|
||||||
public static final String ACTION_CONFIRMATION_REQUEST_PATH = "/nightscout_watch_actionconfirmationrequest";
|
|
||||||
public static final String ACTION_CHANGECONFIRMATION_REQUEST_PATH = "/nightscout_watch_changeconfirmationrequest";
|
|
||||||
public static final String ACTION_CANCELNOTIFICATION_REQUEST_PATH = "/nightscout_watch_cancelnotificationrequest";
|
|
||||||
|
|
||||||
String TAG = "WatchUpdateService";
|
String TAG = "WatchUpdateService";
|
||||||
|
|
||||||
|
@ -259,21 +245,21 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
// Log.d(TAG, "onMessageRecieved: " + event);
|
// Log.d(TAG, "onMessageRecieved: " + event);
|
||||||
|
|
||||||
if (wearIntegration()) {
|
if (wearIntegration()) {
|
||||||
if (event != null && event.getPath().equals(WEARABLE_RESEND_PATH)) {
|
if (event != null && event.getPath().equals(WearUris.WEARABLE_RESEND_PATH)) {
|
||||||
resendData();
|
resendData();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event != null && event.getPath().equals(WEARABLE_CANCELBOLUS_PATH)) {
|
if (event != null && event.getPath().equals(WearUris.WEARABLE_CANCELBOLUS_PATH)) {
|
||||||
cancelBolus();
|
cancelBolus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event != null && event.getPath().equals(WEARABLE_INITIATE_ACTIONSTRING_PATH)) {
|
if (event != null && event.getPath().equals(WearUris.WEARABLE_INITIATE_ACTIONSTRING_PATH)) {
|
||||||
String actionstring = new String(event.getData());
|
String actionstring = new String(event.getData());
|
||||||
aapsLogger.debug(LTag.WEAR, "Wear: " + actionstring);
|
aapsLogger.debug(LTag.WEAR, "Wear: " + actionstring);
|
||||||
rxBus.send(new EventWearInitiateAction(actionstring));
|
rxBus.send(new EventWearInitiateAction(actionstring));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event != null && event.getPath().equals(WEARABLE_CONFIRM_ACTIONSTRING_PATH)) {
|
if (event != null && event.getPath().equals(WearUris.WEARABLE_CONFIRM_ACTIONSTRING_PATH)) {
|
||||||
String actionstring = new String(event.getData());
|
String actionstring = new String(event.getData());
|
||||||
aapsLogger.debug(LTag.WEAR, "Wear Confirm: " + actionstring);
|
aapsLogger.debug(LTag.WEAR, "Wear Confirm: " + actionstring);
|
||||||
rxBus.send(new EventWearConfirmAction(actionstring));
|
rxBus.send(new EventWearConfirmAction(actionstring));
|
||||||
|
@ -299,7 +285,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
|
|
||||||
final DataMap dataMap = dataMapSingleBG(lastBG, glucoseStatus);
|
final DataMap dataMap = dataMapSingleBG(lastBG, glucoseStatus);
|
||||||
|
|
||||||
(new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, dataMap);
|
(new SendToDataLayerThread(WearUris.WEARABLE_DATA_PATH, googleApiClient)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, dataMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,7 +375,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
dataMaps.add(dataMap);
|
dataMaps.add(dataMap);
|
||||||
}
|
}
|
||||||
entries.putDataMapArrayList("entries", dataMaps);
|
entries.putDataMapArrayList("entries", dataMaps);
|
||||||
(new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, entries);
|
(new SendToDataLayerThread(WearUris.WEARABLE_DATA_PATH, googleApiClient)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, entries);
|
||||||
}
|
}
|
||||||
sendBasals();
|
sendBasals();
|
||||||
sendStatus();
|
sendStatus();
|
||||||
|
@ -541,7 +527,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
dm.putDataMapArrayList("temps", temps);
|
dm.putDataMapArrayList("temps", temps);
|
||||||
dm.putDataMapArrayList("boluses", boluses);
|
dm.putDataMapArrayList("boluses", boluses);
|
||||||
dm.putDataMapArrayList("predictions", predictions);
|
dm.putDataMapArrayList("predictions", predictions);
|
||||||
(new SendToDataLayerThread(BASAL_DATA_PATH, googleApiClient)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, dm);
|
(new SendToDataLayerThread(WearUris.BASAL_DATA_PATH, googleApiClient)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, dm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataMap tempDatamap(long startTime, double startBasal, long to, double toBasal, double amount) {
|
private DataMap tempDatamap(long startTime, double startBasal, long to, double toBasal, double amount) {
|
||||||
|
@ -583,7 +569,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
|
|
||||||
private void sendNotification() {
|
private void sendNotification() {
|
||||||
if (googleApiClient != null && googleApiClient.isConnected()) {
|
if (googleApiClient != null && googleApiClient.isConnected()) {
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(OPEN_SETTINGS_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WearUris.OPEN_SETTINGS_PATH);
|
||||||
//unique content
|
//unique content
|
||||||
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
||||||
dataMapRequest.getDataMap().putString("openSettings", "openSettings");
|
dataMapRequest.getDataMap().putString("openSettings", "openSettings");
|
||||||
|
@ -596,7 +582,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
|
|
||||||
private void sendBolusProgress(int progresspercent, String status) {
|
private void sendBolusProgress(int progresspercent, String status) {
|
||||||
if (googleApiClient != null && googleApiClient.isConnected()) {
|
if (googleApiClient != null && googleApiClient.isConnected()) {
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(BOLUS_PROGRESS_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WearUris.BOLUS_PROGRESS_PATH);
|
||||||
//unique content
|
//unique content
|
||||||
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
||||||
dataMapRequest.getDataMap().putString("bolusProgress", "bolusProgress");
|
dataMapRequest.getDataMap().putString("bolusProgress", "bolusProgress");
|
||||||
|
@ -611,7 +597,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
|
|
||||||
private void sendActionConfirmationRequest(String title, String message, String actionstring) {
|
private void sendActionConfirmationRequest(String title, String message, String actionstring) {
|
||||||
if (googleApiClient != null && googleApiClient.isConnected()) {
|
if (googleApiClient != null && googleApiClient.isConnected()) {
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(ACTION_CONFIRMATION_REQUEST_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WearUris.ACTION_CONFIRMATION_REQUEST_PATH);
|
||||||
//unique content
|
//unique content
|
||||||
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
||||||
dataMapRequest.getDataMap().putString("actionConfirmationRequest", "actionConfirmationRequest");
|
dataMapRequest.getDataMap().putString("actionConfirmationRequest", "actionConfirmationRequest");
|
||||||
|
@ -630,7 +616,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
|
|
||||||
private void sendChangeConfirmationRequest(String title, String message, String actionstring) {
|
private void sendChangeConfirmationRequest(String title, String message, String actionstring) {
|
||||||
if (googleApiClient != null && googleApiClient.isConnected()) {
|
if (googleApiClient != null && googleApiClient.isConnected()) {
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(ACTION_CHANGECONFIRMATION_REQUEST_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WearUris.ACTION_CHANGECONFIRMATION_REQUEST_PATH);
|
||||||
//unique content
|
//unique content
|
||||||
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
||||||
dataMapRequest.getDataMap().putString("changeConfirmationRequest", "changeConfirmationRequest");
|
dataMapRequest.getDataMap().putString("changeConfirmationRequest", "changeConfirmationRequest");
|
||||||
|
@ -649,7 +635,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
|
|
||||||
private void sendCancelNotificationRequest(String actionstring) {
|
private void sendCancelNotificationRequest(String actionstring) {
|
||||||
if (googleApiClient != null && googleApiClient.isConnected()) {
|
if (googleApiClient != null && googleApiClient.isConnected()) {
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(ACTION_CANCELNOTIFICATION_REQUEST_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WearUris.ACTION_CANCELNOTIFICATION_REQUEST_PATH);
|
||||||
//unique content
|
//unique content
|
||||||
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
||||||
dataMapRequest.getDataMap().putString("cancelNotificationRequest", "cancelNotificationRequest");
|
dataMapRequest.getDataMap().putString("cancelNotificationRequest", "cancelNotificationRequest");
|
||||||
|
@ -705,7 +691,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
openApsStatus = nsDeviceStatus.getOpenApsTimestamp();
|
openApsStatus = nsDeviceStatus.getOpenApsTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_STATUS_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WearUris.NEW_STATUS_PATH);
|
||||||
//unique content
|
//unique content
|
||||||
dataMapRequest.getDataMap().putString("externalStatusString", status);
|
dataMapRequest.getDataMap().putString("externalStatusString", status);
|
||||||
dataMapRequest.getDataMap().putString("iobSum", iobSum);
|
dataMapRequest.getDataMap().putString("iobSum", iobSum);
|
||||||
|
@ -735,14 +721,14 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
int percentage = sp.getInt(R.string.key_boluswizard_percentage, 100);
|
int percentage = sp.getInt(R.string.key_boluswizard_percentage, 100);
|
||||||
int maxCarbs = sp.getInt(R.string.key_treatmentssafety_maxcarbs, 48);
|
int maxCarbs = sp.getInt(R.string.key_treatmentssafety_maxcarbs, 48);
|
||||||
double maxBolus = sp.getDouble(R.string.key_treatmentssafety_maxbolus, 3.0);
|
double maxBolus = sp.getDouble(R.string.key_treatmentssafety_maxbolus, 3.0);
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_PREFERENCES_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WearUris.NEW_PREFERENCES_PATH);
|
||||||
//unique content
|
//unique content
|
||||||
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
||||||
dataMapRequest.getDataMap().putBoolean(rh.gs(R.string.key_wear_control), wearcontrol);
|
dataMapRequest.getDataMap().putBoolean(rh.gs(R.string.key_wear_control), wearcontrol);
|
||||||
dataMapRequest.getDataMap().putBoolean(rh.gs(R.string.key_units_mgdl), mgdl);
|
dataMapRequest.getDataMap().putBoolean(rh.gs(R.string.key_units_mgdl), mgdl);
|
||||||
dataMapRequest.getDataMap().putInt(rh.gs(R.string.key_boluswizard_percentage), percentage);
|
dataMapRequest.getDataMap().putInt(rh.gs(R.string.key_boluswizard_percentage), percentage);
|
||||||
dataMapRequest.getDataMap().putInt(rh.gs(R.string.key_treatmentssafety_maxcarbs), maxCarbs);
|
dataMapRequest.getDataMap().putInt(rh.gs(R.string.key_treatmentssafety_maxcarbs), maxCarbs);
|
||||||
dataMapRequest.getDataMap().putDouble(rh.gs(R.string.key_treatmentssafety_maxbolus),maxBolus);
|
dataMapRequest.getDataMap().putDouble(rh.gs(R.string.key_treatmentssafety_maxbolus), maxBolus);
|
||||||
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
|
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
|
||||||
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
|
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
|
||||||
} else {
|
} else {
|
||||||
|
@ -754,14 +740,14 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
if (googleApiClient != null && googleApiClient.isConnected()) {
|
if (googleApiClient != null && googleApiClient.isConnected()) {
|
||||||
int size = quickWizard.size();
|
int size = quickWizard.size();
|
||||||
ArrayList<DataMap> entities = new ArrayList<>();
|
ArrayList<DataMap> entities = new ArrayList<>();
|
||||||
for(int i=0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
QuickWizardEntry q = quickWizard.get(i);
|
QuickWizardEntry q = quickWizard.get(i);
|
||||||
if (q.forDevice(QuickWizardEntry.DEVICE_WATCH)) {
|
if (q.forDevice(QuickWizardEntry.DEVICE_WATCH)) {
|
||||||
entities.add(quickMap(q));
|
entities.add(quickMap(q));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(QUICK_WIZARD_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WearUris.QUICK_WIZARD_PATH);
|
||||||
|
|
||||||
DataMap dm = dataMapRequest.getDataMap();
|
DataMap dm = dataMapRequest.getDataMap();
|
||||||
dm.putLong("timestamp", System.currentTimeMillis());
|
dm.putLong("timestamp", System.currentTimeMillis());
|
||||||
|
@ -795,7 +781,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!((PluginBase)loop).isEnabled()) {
|
if (!((PluginBase) loop).isEnabled()) {
|
||||||
status += rh.gs(R.string.disabledloop) + "\n";
|
status += rh.gs(R.string.disabledloop) + "\n";
|
||||||
lastLoopStatus = false;
|
lastLoopStatus = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package info.nightscout.shared.weardata
|
||||||
|
|
||||||
|
object WearUris {
|
||||||
|
|
||||||
|
const val WEARABLE_DATA_PATH = "/nightscout_watch_data"
|
||||||
|
const val WEARABLE_RESEND_PATH = "/nightscout_watch_data_resend"
|
||||||
|
const val WEARABLE_CANCELBOLUS_PATH = "/nightscout_watch_cancel_bolus"
|
||||||
|
const val WEARABLE_CONFIRM_ACTIONSTRING_PATH = "/nightscout_watch_confirmactionstring"
|
||||||
|
const val WEARABLE_INITIATE_ACTIONSTRING_PATH = "/nightscout_watch_initiateactionstring"
|
||||||
|
|
||||||
|
const val OPEN_SETTINGS_PATH = "/openwearsettings"
|
||||||
|
const val NEW_STATUS_PATH = "/sendstatustowear"
|
||||||
|
const val NEW_PREFERENCES_PATH = "/sendpreferencestowear"
|
||||||
|
const val QUICK_WIZARD_PATH = "/send_quick_wizard"
|
||||||
|
const val BASAL_DATA_PATH = "/nightscout_watch_basal"
|
||||||
|
const val BOLUS_PROGRESS_PATH = "/nightscout_watch_bolusprogress"
|
||||||
|
const val ACTION_CONFIRMATION_REQUEST_PATH = "/nightscout_watch_actionconfirmationrequest"
|
||||||
|
const val ACTION_CHANGECONFIRMATION_REQUEST_PATH = "/nightscout_watch_changeconfirmationrequest"
|
||||||
|
const val ACTION_CANCELNOTIFICATION_REQUEST_PATH = "/nightscout_watch_cancelnotificationrequest"
|
||||||
|
|
||||||
|
}
|
|
@ -50,6 +50,7 @@ import info.nightscout.androidaps.tile.ActionsTileService;
|
||||||
import info.nightscout.androidaps.tile.QuickWizardTileService;
|
import info.nightscout.androidaps.tile.QuickWizardTileService;
|
||||||
import info.nightscout.androidaps.tile.TempTargetTileService;
|
import info.nightscout.androidaps.tile.TempTargetTileService;
|
||||||
import info.nightscout.shared.SafeParse;
|
import info.nightscout.shared.SafeParse;
|
||||||
|
import info.nightscout.shared.weardata.WearUris;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by emmablack on 12/26/14.
|
* Created by emmablack on 12/26/14.
|
||||||
|
@ -60,21 +61,6 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
@Inject WearUtil wearUtil;
|
@Inject WearUtil wearUtil;
|
||||||
@Inject Persistence persistence;
|
@Inject Persistence persistence;
|
||||||
|
|
||||||
private static final String WEARABLE_RESEND_PATH = "/nightscout_watch_data_resend";
|
|
||||||
private static final String WEARABLE_CANCELBOLUS_PATH = "/nightscout_watch_cancel_bolus";
|
|
||||||
public static final String WEARABLE_CONFIRM_ACTIONSTRING_PATH = "/nightscout_watch_confirmactionstring";
|
|
||||||
public static final String WEARABLE_INITIATE_ACTIONSTRING_PATH = "/nightscout_watch_initiateactionstring";
|
|
||||||
|
|
||||||
private static final String OPEN_SETTINGS = "/openwearsettings";
|
|
||||||
private static final String NEW_STATUS_PATH = "/sendstatustowear";
|
|
||||||
private static final String NEW_PREFERENCES_PATH = "/sendpreferencestowear";
|
|
||||||
private static final String QUICK_WIZARD_PATH = "/send_quick_wizard";
|
|
||||||
public static final String BASAL_DATA_PATH = "/nightscout_watch_basal";
|
|
||||||
public static final String BOLUS_PROGRESS_PATH = "/nightscout_watch_bolusprogress";
|
|
||||||
public static final String ACTION_CONFIRMATION_REQUEST_PATH = "/nightscout_watch_actionconfirmationrequest";
|
|
||||||
public static final String NEW_CHANGECONFIRMATIONREQUEST_PATH = "/nightscout_watch_changeconfirmationrequest";
|
|
||||||
public static final String ACTION_CANCELNOTIFICATION_REQUEST_PATH = "/nightscout_watch_cancelnotificationrequest";
|
|
||||||
|
|
||||||
public static final int BOLUS_PROGRESS_NOTIF_ID = 1;
|
public static final int BOLUS_PROGRESS_NOTIF_ID = 1;
|
||||||
public static final int CONFIRM_NOTIF_ID = 2;
|
public static final int CONFIRM_NOTIF_ID = 2;
|
||||||
public static final int CHANGE_NOTIF_ID = 556677;
|
public static final int CHANGE_NOTIF_ID = 556677;
|
||||||
|
@ -121,7 +107,8 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
NodeApi.GetConnectedNodesResult nodes =
|
NodeApi.GetConnectedNodesResult nodes =
|
||||||
Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
|
Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
|
||||||
for (Node node : nodes.getNodes()) {
|
for (Node node : nodes.getNodes()) {
|
||||||
Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_CANCELBOLUS_PATH, null);
|
Wearable.MessageApi.sendMessage(googleApiClient, node.getId(),
|
||||||
|
WearUris.WEARABLE_CANCELBOLUS_PATH, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -179,7 +166,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
Log.i(TAG, "ResendDataTask.doInBackground: connected");
|
Log.i(TAG, "ResendDataTask.doInBackground: connected");
|
||||||
NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
|
NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
|
||||||
for (Node node : nodes.getNodes()) {
|
for (Node node : nodes.getNodes()) {
|
||||||
Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_RESEND_PATH, null);
|
Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WearUris.WEARABLE_RESEND_PATH, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "ResendDataTask.doInBackground: could not connect");
|
Log.i(TAG, "ResendDataTask.doInBackground: could not connect");
|
||||||
|
@ -198,11 +185,11 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendConfirmActionstring(String actionstring) {
|
private void sendConfirmActionstring(String actionstring) {
|
||||||
new MessageActionTask(this, WEARABLE_CONFIRM_ACTIONSTRING_PATH, actionstring).execute();
|
new MessageActionTask(this, WearUris.WEARABLE_CONFIRM_ACTIONSTRING_PATH, actionstring).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendInitiateActionstring(String actionstring) {
|
private void sendInitiateActionstring(String actionstring) {
|
||||||
new MessageActionTask(this, WEARABLE_INITIATE_ACTIONSTRING_PATH, actionstring).execute();
|
new MessageActionTask(this, WearUris.WEARABLE_INITIATE_ACTIONSTRING_PATH, actionstring).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void googleApiConnect() {
|
private void googleApiConnect() {
|
||||||
|
@ -295,15 +282,15 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
|
|
||||||
//Log.d(TAG, "WR: onDataChanged: Path: " + path + ", EventDataItem=" + event.getDataItem());
|
//Log.d(TAG, "WR: onDataChanged: Path: " + path + ", EventDataItem=" + event.getDataItem());
|
||||||
|
|
||||||
if (path.equals(OPEN_SETTINGS)) {
|
if (path.equals(WearUris.OPEN_SETTINGS_PATH)) {
|
||||||
Intent intent = new Intent(this, AAPSPreferences.class);
|
Intent intent = new Intent(this, AAPSPreferences.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (path.equals(BOLUS_PROGRESS_PATH)) {
|
} else if (path.equals(WearUris.BOLUS_PROGRESS_PATH)) {
|
||||||
int progress = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getInt("progresspercent", 0);
|
int progress = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getInt("progresspercent", 0);
|
||||||
String status = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("progressstatus", "");
|
String status = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("progressstatus", "");
|
||||||
showBolusProgress(progress, status);
|
showBolusProgress(progress, status);
|
||||||
} else if (path.equals(ACTION_CONFIRMATION_REQUEST_PATH)) {
|
} else if (path.equals(WearUris.ACTION_CONFIRMATION_REQUEST_PATH)) {
|
||||||
String title = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("title");
|
String title = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("title");
|
||||||
String message = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("message");
|
String message = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("message");
|
||||||
String actionstring = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("actionstring");
|
String actionstring = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("actionstring");
|
||||||
|
@ -322,21 +309,21 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
showConfirmationDialog(title, message, actionstring);
|
showConfirmationDialog(title, message, actionstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (path.equals(NEW_STATUS_PATH)) {
|
} else if (path.equals(WearUris.NEW_STATUS_PATH)) {
|
||||||
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
||||||
Intent messageIntent = new Intent();
|
Intent messageIntent = new Intent();
|
||||||
messageIntent.setAction(Intent.ACTION_SEND);
|
messageIntent.setAction(Intent.ACTION_SEND);
|
||||||
messageIntent.putExtra("status", dataMap.toBundle());
|
messageIntent.putExtra("status", dataMap.toBundle());
|
||||||
persistence.storeDataMap(RawDisplayData.STATUS_PERSISTENCE_KEY, dataMap);
|
persistence.storeDataMap(RawDisplayData.STATUS_PERSISTENCE_KEY, dataMap);
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
|
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
|
||||||
} else if (path.equals(BASAL_DATA_PATH)) {
|
} else if (path.equals(WearUris.BASAL_DATA_PATH)) {
|
||||||
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
||||||
Intent messageIntent = new Intent();
|
Intent messageIntent = new Intent();
|
||||||
messageIntent.setAction(Intent.ACTION_SEND);
|
messageIntent.setAction(Intent.ACTION_SEND);
|
||||||
messageIntent.putExtra("basals", dataMap.toBundle());
|
messageIntent.putExtra("basals", dataMap.toBundle());
|
||||||
persistence.storeDataMap(RawDisplayData.BASALS_PERSISTENCE_KEY, dataMap);
|
persistence.storeDataMap(RawDisplayData.BASALS_PERSISTENCE_KEY, dataMap);
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
|
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
|
||||||
} else if (path.equals(NEW_PREFERENCES_PATH)) {
|
} else if (path.equals(WearUris.NEW_PREFERENCES_PATH)) {
|
||||||
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
@ -370,12 +357,12 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
}
|
}
|
||||||
String keyMaxBolus = getString(R.string.key_treatmentssafety_maxbolus);
|
String keyMaxBolus = getString(R.string.key_treatmentssafety_maxbolus);
|
||||||
if (dataMap.containsKey(keyMaxBolus)) {
|
if (dataMap.containsKey(keyMaxBolus)) {
|
||||||
float maxBolus = (float)dataMap.getDouble(keyMaxBolus, 3.0f);
|
float maxBolus = (float) dataMap.getDouble(keyMaxBolus, 3.0f);
|
||||||
editor.putFloat(keyMaxBolus, maxBolus);
|
editor.putFloat(keyMaxBolus, maxBolus);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (path.equals(QUICK_WIZARD_PATH)) {
|
} else if (path.equals(WearUris.QUICK_WIZARD_PATH)) {
|
||||||
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
||||||
Log.i(TAG, "onDataChanged: QUICK_WIZARD_PATH" + dataMap);
|
Log.i(TAG, "onDataChanged: QUICK_WIZARD_PATH" + dataMap);
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
@ -395,12 +382,12 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "onDataChanged: ignore update");
|
Log.i(TAG, "onDataChanged: ignore update");
|
||||||
}
|
}
|
||||||
} else if (path.equals(NEW_CHANGECONFIRMATIONREQUEST_PATH)) {
|
} else if (path.equals(WearUris.ACTION_CHANGECONFIRMATION_REQUEST_PATH)) {
|
||||||
String title = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("title");
|
String title = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("title");
|
||||||
String message = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("message");
|
String message = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("message");
|
||||||
String actionstring = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("actionstring");
|
String actionstring = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("actionstring");
|
||||||
notifyChangeRequest(title, message, actionstring);
|
notifyChangeRequest(title, message, actionstring);
|
||||||
} else if (path.equals(ACTION_CANCELNOTIFICATION_REQUEST_PATH)) {
|
} else if (path.equals(WearUris.ACTION_CANCELNOTIFICATION_REQUEST_PATH)) {
|
||||||
String actionstring = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("actionstring");
|
String actionstring = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("actionstring");
|
||||||
cancelNotificationRequest(actionstring);
|
cancelNotificationRequest(actionstring);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue