From f751638a7f3182ac06d9499e08fafcce6fa8243d Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 12 Oct 2017 18:01:10 +0200 Subject: [PATCH] enabling wearcontrols from preferences --- app/build.gradle | 3 +-- .../wearintegration/WatchUpdaterService.java | 19 +++++++++++++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/pref_wear.xml | 6 +++++ wear/build.gradle | 27 ------------------- .../androidaps/data/ListenerService.java | 11 ++++++++ .../interaction/menus/MainMenuActivity.java | 3 ++- wear/src/main/res/values/strings.xml | 8 +++++- 8 files changed, 48 insertions(+), 31 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0f01fd3fa8..867d84d4ff 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -140,8 +140,7 @@ allprojects { } dependencies { - wearWearApp project(path: ':wear', configuration: 'restrictedRelease') - wearcontrolWearApp project(path: ':wear', configuration: 'fullRelease') + wearApp project(':wear') compile fileTree(include: ['*.jar'], dir: 'libs') compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 09d1adf9d3..394ff9fbe8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -42,6 +42,7 @@ import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; import info.nightscout.androidaps.plugins.Wear.ActionStringHandler; import info.nightscout.androidaps.plugins.Wear.WearPlugin; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.SP; import info.nightscout.utils.SafeParse; import info.nightscout.utils.ToastUtils; @@ -65,6 +66,7 @@ public class WatchUpdaterService extends WearableListenerService implements private static final String OPEN_SETTINGS_PATH = "/openwearsettings"; private static final String NEW_STATUS_PATH = "/sendstatustowear"; + private static final String NEW_PREFERENCES_PATH = "/sendpreferencestowear"; 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"; @@ -326,6 +328,7 @@ public class WatchUpdaterService extends WearableListenerService implements entries.putDataMapArrayList("entries", dataMaps); new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).execute(entries); } + sendPreferences(); sendBasals(); sendStatus(); } @@ -527,6 +530,22 @@ public class WatchUpdaterService extends WearableListenerService implements } } + private void sendPreferences() { + if (googleApiClient.isConnected()) { + + boolean wearcontrol = SP.getBoolean("wearcontrol",false); + + PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_PREFERENCES_PATH); + //unique content + dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis()); + dataMapRequest.getDataMap().putBoolean("wearcontrol", wearcontrol); + PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest(); + Wearable.DataApi.putDataItem(googleApiClient, putDataRequest); + } else { + Log.e("SendStatus", "No connection to wearable available!"); + } + } + @NonNull private String generateStatusString() { String status = ""; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 66f19963d4..a414df6300 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -743,5 +743,7 @@ Gettings pump settings Getting pump time reuse + Controls from Watch + Set Temp-Targets and enter Treatments from the watch. diff --git a/app/src/main/res/xml/pref_wear.xml b/app/src/main/res/xml/pref_wear.xml index 4b80c0446d..3ccde55678 100644 --- a/app/src/main/res/xml/pref_wear.xml +++ b/app/src/main/res/xml/pref_wear.xml @@ -4,6 +4,12 @@ android:key="wearplugin" android:title="@string/wear_settings"> + + - + AAPS + AAPS(Large) + AAPS(BigChart) + AAPS(NoChart) + AAPS(Circle) + AAPS + AAPS Settings BolusActivity Hello Round World!