Merge pull request #546 from andrew-warrington/dev

Always show basal rates on watch, whether temporary or normal.
This commit is contained in:
AdrianLxM 2017-12-27 23:17:52 +01:00 committed by GitHub
commit bd4e51e1f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View file

@ -533,7 +533,7 @@ public class WatchUpdaterService extends WearableListenerService implements
String iobSum = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob); String iobSum = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
String iobDetail = "(" + DecimalFormatter.to2Decimal(bolusIob.iob) + "|" + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")"; String iobDetail = "(" + DecimalFormatter.to2Decimal(bolusIob.iob) + "|" + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
String cobString = generateCOBString(); String cobString = generateCOBString();
String tempBasal = generateBasalString(treatmentsInterface); String currentBasal = generateBasalString(treatmentsInterface);
//bgi //bgi
String bgiString = ""; String bgiString = "";
@ -543,7 +543,7 @@ public class WatchUpdaterService extends WearableListenerService implements
bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to1Decimal(bgi); bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to1Decimal(bgi);
} }
String status = generateStatusString(profile, tempBasal,iobSum, iobDetail, bgiString); String status = generateStatusString(profile, currentBasal,iobSum, iobDetail, bgiString);
//batteries //batteries
int phoneBattery = getBatteryLevel(getApplicationContext()); int phoneBattery = getBatteryLevel(getApplicationContext());
@ -567,7 +567,7 @@ public class WatchUpdaterService extends WearableListenerService implements
dataMapRequest.getDataMap().putString("iobDetail", iobDetail); dataMapRequest.getDataMap().putString("iobDetail", iobDetail);
dataMapRequest.getDataMap().putBoolean("detailedIob", mPrefs.getBoolean("wear_detailediob", false)); dataMapRequest.getDataMap().putBoolean("detailedIob", mPrefs.getBoolean("wear_detailediob", false));
dataMapRequest.getDataMap().putString("cob", cobString); dataMapRequest.getDataMap().putString("cob", cobString);
dataMapRequest.getDataMap().putString("tempBasal", tempBasal); dataMapRequest.getDataMap().putString("currentBasal", currentBasal);
dataMapRequest.getDataMap().putString("battery", "" + phoneBattery); dataMapRequest.getDataMap().putString("battery", "" + phoneBattery);
dataMapRequest.getDataMap().putString("rigBattery", rigBattery); dataMapRequest.getDataMap().putString("rigBattery", rigBattery);
dataMapRequest.getDataMap().putLong("openApsStatus", openApsStatus); dataMapRequest.getDataMap().putLong("openApsStatus", openApsStatus);
@ -598,7 +598,7 @@ public class WatchUpdaterService extends WearableListenerService implements
} }
@NonNull @NonNull
private String generateStatusString(Profile profile, String tempBasal, String iobSum, String iobDetail, String bgiString) { private String generateStatusString(Profile profile, String currentBasal, String iobSum, String iobDetail, String bgiString) {
String status = ""; String status = "";
@ -623,7 +623,7 @@ public class WatchUpdaterService extends WearableListenerService implements
iobString = iobSum + "U"; iobString = iobSum + "U";
} }
status += tempBasal + " " + iobString; status += currentBasal + " " + iobString;
//add BGI if shown, otherwise return //add BGI if shown, otherwise return
if (mPrefs.getBoolean("wear_showbgi", false)) { if (mPrefs.getBoolean("wear_showbgi", false)) {
@ -636,10 +636,16 @@ public class WatchUpdaterService extends WearableListenerService implements
@NonNull @NonNull
private String generateBasalString(TreatmentsInterface treatmentsInterface) { private String generateBasalString(TreatmentsInterface treatmentsInterface) {
String basalStringResult = "-.--U/h"; String basalStringResult;
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis()); TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) { if (activeTemp != null) {
basalStringResult = activeTemp.toStringShort(); basalStringResult = activeTemp.toStringShort();
} else {
if (SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false)) {
basalStringResult = "100%";
} else {
basalStringResult = DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + "U/h";
}
} }
return basalStringResult; return basalStringResult;
} }

View file

@ -257,7 +257,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
if (layoutSet && bundle != null) { if (layoutSet && bundle != null) {
DataMap dataMap = DataMap.fromBundle(bundle); DataMap dataMap = DataMap.fromBundle(bundle);
wakeLock.acquire(50); wakeLock.acquire(50);
sBasalRate = dataMap.getString("tempBasal"); sBasalRate = dataMap.getString("currentBasal");
sUploaderBattery = dataMap.getString("battery"); sUploaderBattery = dataMap.getString("battery");
sRigBattery = dataMap.getString("rigBattery"); sRigBattery = dataMap.getString("rigBattery");
detailedIOB = dataMap.getBoolean("detailedIob"); detailedIOB = dataMap.getBoolean("detailedIob");