From ef0e30b2b35e03e5f03a34dce8684785b3c2ea86 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 22 Nov 2016 03:07:10 +0100 Subject: [PATCH] wear big chart avgDelta working --- .../wearintegration/WatchUpdaterService.java | 4 ++-- .../info/nightscout/androidaps/BIGChart.java | 24 +++++++++++++++---- .../res/layout/rect_activity_bigchart.xml | 15 ++++++++++-- .../res/layout/round_activity_bigchart.xml | 13 +++++++++- wear/src/main/res/xml/preferences.xml | 5 ++++ 5 files changed, 51 insertions(+), 10 deletions(-) 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 b5e141124b..9df048d15a 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 @@ -169,9 +169,11 @@ public class WatchUpdaterService extends WearableListenerService implements if(glucoseStatus == null) { dataMap.putString("slopeArrow", "" ); dataMap.putString("delta", ""); + dataMap.putString("avgDelta", ""); } else { dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.delta)); dataMap.putString("delta", deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, profile.getUnits())); + dataMap.putString("avgDelta", deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, profile.getUnits())); } dataMap.putString("battery", "" + battery); dataMap.putLong("sgvLevel", sgvLevel); @@ -179,8 +181,6 @@ public class WatchUpdaterService extends WearableListenerService implements dataMap.putDouble("sgvDouble", lastBG.value); dataMap.putDouble("high", highMark); dataMap.putDouble("low", lowMark); - //TODO Adrian use for status string? - //dataMap.putString("rawString", threeRaw((prefs.getString("units", "mgdl").equals("mgdl")))); return dataMap; } diff --git a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java index 668542b4a0..e3ee12da9c 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java +++ b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java @@ -45,10 +45,8 @@ import lecho.lib.hellocharts.view.LineChartView; */ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener { public final static IntentFilter INTENT_FILTER; - public static final long[] vibratePattern = {0,400,300,400,300,400}; - public TextView mTime, mSgv, mTimestamp, mDelta; + public TextView mTime, mSgv, mTimestamp, mDelta, mAvgDelta; public RelativeLayout mRelativeLayout; - //public LinearLayout mLinearLayout; public long sgvLevel = 0; public int batteryLevel = 1; public int ageLevel = 1; @@ -58,7 +56,6 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre public int pointSize = 2; public boolean singleLine = false; public boolean layoutSet = false; - public int missed_readings_alert_id = 818; public BgGraphBuilder bgGraphBuilder; public LineChartView chart; public double datetime; @@ -66,7 +63,6 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre public ArrayList tempWatchDataList = new ArrayList<>(); public ArrayList basalWatchDataList = new ArrayList<>(); public PowerManager.WakeLock wakeLock; - // related endTime manual layout public View layoutView; private final Point displaySize = new Point(); private int specW, specH; @@ -124,6 +120,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre mSgv = (TextView) stub.findViewById(R.id.sgv); mTimestamp = (TextView) stub.findViewById(R.id.timestamp); mDelta = (TextView) stub.findViewById(R.id.delta); + mAvgDelta = (TextView) stub.findViewById(R.id.avgdelta); mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout); chart = (LineChartView) stub.findViewById(R.id.chart); statusView = (TextView) stub.findViewById(R.id.aps_status); @@ -241,6 +238,17 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre mDelta.setText(delta); } + + String avgDelta = dataMap.getString("avgDelta"); + + if (delta.endsWith(" mg/dl")) { + mAvgDelta.setText(avgDelta.substring(0, avgDelta.length() - 6)); + } else if (avgDelta.endsWith(" mmol/l")||avgDelta.endsWith(" mmol")) { + mAvgDelta.setText(avgDelta.substring(0, avgDelta.length() - 5)); + } else { + mAvgDelta.setText(avgDelta); + } + if (chart != null) { addToWatchSet(dataMap); setupCharts(); @@ -323,7 +331,13 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre } boolean showStatus = sharedPrefs.getBoolean("showExternalStatus", true); + boolean showAvgDelta = sharedPrefs.getBoolean("showAvgDelta", true); + if(showAvgDelta){ + mAvgDelta.setVisibility(View.VISIBLE); + } else { + mAvgDelta.setVisibility(View.GONE); + } if(showStatus){ statusView.setText(externalStatusString); diff --git a/wear/src/main/res/layout/rect_activity_bigchart.xml b/wear/src/main/res/layout/rect_activity_bigchart.xml index e91e848e0c..9fa101227c 100644 --- a/wear/src/main/res/layout/rect_activity_bigchart.xml +++ b/wear/src/main/res/layout/rect_activity_bigchart.xml @@ -25,7 +25,7 @@ + + - \ No newline at end of file + diff --git a/wear/src/main/res/layout/round_activity_bigchart.xml b/wear/src/main/res/layout/round_activity_bigchart.xml index 58d89205c5..9fa101227c 100644 --- a/wear/src/main/res/layout/round_activity_bigchart.xml +++ b/wear/src/main/res/layout/round_activity_bigchart.xml @@ -25,7 +25,7 @@ + + + +