wear show on status when loop is disabled

This commit is contained in:
AdrianLxM 2017-02-18 18:52:09 +01:00
parent d113d39916
commit abaafb87eb
2 changed files with 28 additions and 0 deletions

View file

@ -15,6 +15,7 @@ import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PluginBase; 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.Loop.events.EventNewOpenLoopNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService; import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService;
@ -146,6 +147,17 @@ public class WearPlugin implements PluginBase {
sendDataToWatch(false, true, false); 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 @Subscribe
public void onStatusEvent(final EventOverviewBolusProgress ev) { public void onStatusEvent(final EventOverviewBolusProgress ev) {

View file

@ -28,8 +28,10 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.TempBasal; import info.nightscout.androidaps.db.TempBasal;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.data.IobTotal; 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.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Wear.ActionStringHandler; import info.nightscout.androidaps.plugins.Wear.ActionStringHandler;
import info.nightscout.androidaps.plugins.Wear.WearPlugin; import info.nightscout.androidaps.plugins.Wear.WearPlugin;
@ -66,6 +68,7 @@ public class WatchUpdaterService extends WearableListenerService implements
boolean wear_integration = false; boolean wear_integration = false;
SharedPreferences mPrefs; SharedPreferences mPrefs;
private static boolean lastLoopStatus;
@Override @Override
public void onCreate() { public void onCreate() {
@ -503,6 +506,15 @@ public class WatchUpdaterService extends WearableListenerService implements
String status = ""; String status = "";
boolean shortString = true; 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 //Temp basal
PumpInterface pump = MainApp.getConfigBuilder(); PumpInterface pump = MainApp.getConfigBuilder();
@ -555,6 +567,10 @@ public class WatchUpdaterService extends WearableListenerService implements
public void onConnectionFailed(ConnectionResult connectionResult) { public void onConnectionFailed(ConnectionResult connectionResult) {
} }
public static boolean shouldReportLoopStatus(boolean enabled){
return (lastLoopStatus != enabled);
}
public static int getBatteryLevel(Context context) { public static int getBatteryLevel(Context context) {
Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);