Merge branch 'nsclient' of https://github.com/MilosKozak/AndroidAPS into nsclient
This commit is contained in:
commit
de124b8e3e
5 changed files with 61 additions and 4 deletions
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
||||||
import info.nightscout.utils.LocaleHelper;
|
import info.nightscout.utils.LocaleHelper;
|
||||||
|
|
||||||
public class PreferencesActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
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_others);
|
||||||
addPreferencesFromResource(R.xml.pref_advanced);
|
addPreferencesFromResource(R.xml.pref_advanced);
|
||||||
initSummary(getPreferenceScreen());
|
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) {
|
public Preference getPreference (String key) {
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -120,8 +121,10 @@ public class WearPlugin implements PluginBase {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventPreferenceChange ev) {
|
public void onStatusEvent(final EventPreferenceChange ev) {
|
||||||
//possibly new high or low mark
|
// possibly new high or low mark
|
||||||
resendDataToWatch();
|
resendDataToWatch();
|
||||||
|
// status may be formated differently
|
||||||
|
sendDataToWatch(true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -144,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) {
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
@ -520,9 +532,13 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round();
|
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round();
|
||||||
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB();
|
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB();
|
||||||
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round();
|
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round();
|
||||||
status += (shortString?"":(getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + 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(bolusIob.iob) + "|"
|
||||||
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
||||||
|
}
|
||||||
|
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_STATUS_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_STATUS_PATH);
|
||||||
//unique content
|
//unique content
|
||||||
|
@ -551,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);
|
||||||
|
|
|
@ -540,4 +540,7 @@
|
||||||
<string name="key_nsclientinternal_autoscroll">nsclientinternal_autoscroll</string>
|
<string name="key_nsclientinternal_autoscroll">nsclientinternal_autoscroll</string>
|
||||||
<string name="key_nsclientinternal_paused">nsclientinternal_paused</string>
|
<string name="key_nsclientinternal_paused">nsclientinternal_paused</string>
|
||||||
<string name="nowritepermission">NSCLIENT has no write permission</string>
|
<string name="nowritepermission">NSCLIENT has no write permission</string>
|
||||||
|
<string name="wear_settings">Wear settings</string>
|
||||||
|
<string name="wear_detailedIOB_title">Show detailed IOB</string>
|
||||||
|
<string name="wear_detailedIOB_summary">Break down IOB into bolus and basal IOB on the watchface</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
14
app/src/main/res/xml/pref_wear.xml
Normal file
14
app/src/main/res/xml/pref_wear.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="wearplugin"
|
||||||
|
android:title="@string/wear_settings">
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="wear_detailediob"
|
||||||
|
android:title="@string/wear_detailedIOB_title"
|
||||||
|
android:summary="@string/wear_detailedIOB_summary"/>
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
Loading…
Reference in a new issue