diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
index d04615fc2f..99b7ee76bc 100644
--- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
@@ -21,6 +21,7 @@ import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpPlugin;
+import info.nightscout.androidaps.plugins.Wear.WearPlugin;
import info.nightscout.utils.LocaleHelper;
public class PreferencesActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
@@ -120,6 +121,11 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(R.xml.pref_others);
addPreferencesFromResource(R.xml.pref_advanced);
initSummary(getPreferenceScreen());
+
+ WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class);
+ if (wearPlugin != null && wearPlugin.isEnabled(PluginBase.GENERAL)) {
+ addPreferencesFromResource(R.xml.pref_wear);
+ }
}
public Preference getPreference (String key) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java
index 96f2b75062..c9520ac82c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java
@@ -15,6 +15,7 @@ import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PluginBase;
+import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService;
@@ -120,8 +121,10 @@ public class WearPlugin implements PluginBase {
@Subscribe
public void onStatusEvent(final EventPreferenceChange ev) {
- //possibly new high or low mark
+ // possibly new high or low mark
resendDataToWatch();
+ // status may be formated differently
+ sendDataToWatch(true, false, false);
}
@Subscribe
@@ -144,6 +147,17 @@ public class WearPlugin implements PluginBase {
sendDataToWatch(false, true, false);
}
+ @Subscribe
+ public void onStatusEvent(final EventRefreshGui ev) {
+
+ LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
+ if (activeloop == null) return;
+
+ if(WatchUpdaterService.shouldReportLoopStatus(activeloop.isEnabled(PluginBase.LOOP))) {
+ sendDataToWatch(true, false, false);
+ }
+ }
+
@Subscribe
public void onStatusEvent(final EventOverviewBolusProgress ev) {
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 ee36823878..5df62fd4dd 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
@@ -28,8 +28,10 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.TempBasal;
+import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.data.IobTotal;
+import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Wear.ActionStringHandler;
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
@@ -66,6 +68,7 @@ public class WatchUpdaterService extends WearableListenerService implements
boolean wear_integration = false;
SharedPreferences mPrefs;
+ private static boolean lastLoopStatus;
@Override
public void onCreate() {
@@ -503,6 +506,15 @@ public class WatchUpdaterService extends WearableListenerService implements
String status = "";
boolean shortString = true;
+ LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
+
+ if (activeloop != null && !activeloop.isEnabled(PluginBase.LOOP)) {
+ status += getString(R.string.disabledloop) + "\n";
+ lastLoopStatus = false;
+ } else if (activeloop != null && activeloop.isEnabled(PluginBase.LOOP)) {
+ lastLoopStatus = true;
+ }
+
//Temp basal
PumpInterface pump = MainApp.getConfigBuilder();
@@ -520,9 +532,13 @@ public class WatchUpdaterService extends WearableListenerService implements
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round();
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB();
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round();
- status += (shortString?"":(getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "("
- + DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
- + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
+ status += (shortString?"":(getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
+
+ if (mPrefs.getBoolean("wear_detailediob", true)) {
+ status += "("
+ + DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
+ + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
+ }
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_STATUS_PATH);
//unique content
@@ -551,6 +567,10 @@ public class WatchUpdaterService extends WearableListenerService implements
public void onConnectionFailed(ConnectionResult connectionResult) {
}
+ public static boolean shouldReportLoopStatus(boolean enabled){
+ return (lastLoopStatus != enabled);
+ }
+
public static int getBatteryLevel(Context context) {
Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 70b6ea72b7..3803aa1300 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -540,4 +540,7 @@
nsclientinternal_autoscroll
nsclientinternal_paused
NSCLIENT has no write permission
+ Wear settings
+ Show detailed IOB
+ Break down IOB into bolus and basal IOB on the watchface
diff --git a/app/src/main/res/xml/pref_wear.xml b/app/src/main/res/xml/pref_wear.xml
new file mode 100644
index 0000000000..bc5c475f9e
--- /dev/null
+++ b/app/src/main/res/xml/pref_wear.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
\ No newline at end of file