bgi on watch status (optional)
This commit is contained in:
parent
63b9a06431
commit
1fa3a2a697
5 changed files with 75 additions and 36 deletions
|
@ -7,6 +7,7 @@ import android.content.SharedPreferences;
|
|||
import android.os.BatteryManager;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
|
@ -503,6 +504,21 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
private void sendStatus() {
|
||||
if (googleApiClient.isConnected()) {
|
||||
|
||||
String status = generateStatusString();
|
||||
|
||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_STATUS_PATH);
|
||||
//unique content
|
||||
dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
|
||||
dataMapRequest.getDataMap().putString("externalStatusString", status);
|
||||
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
|
||||
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
|
||||
} else {
|
||||
Log.e("SendStatus", "No connection to wearable available!");
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String generateStatusString() {
|
||||
String status = "";
|
||||
boolean shortString = true;
|
||||
|
||||
|
@ -539,16 +555,16 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
+ DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
|
||||
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
||||
}
|
||||
|
||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_STATUS_PATH);
|
||||
//unique content
|
||||
dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
|
||||
dataMapRequest.getDataMap().putString("externalStatusString", status);
|
||||
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
|
||||
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
|
||||
} else {
|
||||
Log.e("SendStatus", "No connection to wearable available!");
|
||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
if (!mPrefs.getBoolean("wear_showbgi", false) ||profile == null || profile.getIsf(NSProfile.secondsFromMidnight()) == null || profile.getIc(NSProfile.secondsFromMidnight()) == null) {
|
||||
return status;
|
||||
}
|
||||
|
||||
double bgi = -(bolusIob.activity + basalIob.activity)*5*profile.getIsf(NSProfile.secondsFromMidnight());
|
||||
|
||||
status += " " + ((bgi>=0)?"+":"") + DecimalFormatter.to2Decimal(bgi);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
|
|||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
||||
/**
|
||||
|
@ -181,6 +182,15 @@ public class StatuslinePlugin implements PluginBase {
|
|||
+ DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
|
||||
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
||||
}
|
||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
if (!mPrefs.getBoolean("xdripstatus_showbgi", false) ||profile == null || profile.getIsf(NSProfile.secondsFromMidnight()) == null || profile.getIc(NSProfile.secondsFromMidnight()) == null) {
|
||||
return status;
|
||||
}
|
||||
|
||||
double bgi = -(bolusIob.activity + basalIob.activity)*5*profile.getIsf(NSProfile.secondsFromMidnight());
|
||||
|
||||
status += " " + ((bgi>=0)?"+":"") + DecimalFormatter.to2Decimal(bgi);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -603,4 +603,6 @@
|
|||
<string name="xdripstatus_settings">xDrip Status (watch)</string>
|
||||
<string name="xdripstatus">xDrip Statusline (watch)</string>
|
||||
<string name="xdripstatus_shortname">xds</string>
|
||||
<string name="wear_showbgi_title">Show BGI</string>
|
||||
<string name="wear_showbgi_summary">Add BGI to status line</string>
|
||||
</resources>
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
android:key="wear_detailediob"
|
||||
android:title="@string/wear_detailedIOB_title"
|
||||
android:summary="@string/wear_detailedIOB_summary"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="wear_showbgi"
|
||||
android:title="@string/wear_showbgi_title"
|
||||
android:summary="@string/wear_showbgi_summary"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -9,6 +9,11 @@
|
|||
android:key="xdripstatus_detailediob"
|
||||
android:title="@string/wear_detailedIOB_title"
|
||||
android:summary="@string/wear_detailedIOB_summary"/>
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="xdripstatus_showbgi"
|
||||
android:title="@string/wear_showbgi_title"
|
||||
android:summary="@string/wear_showbgi_summary"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in a new issue