wear big chart avgDelta working

This commit is contained in:
AdrianLxM 2016-11-22 03:07:10 +01:00
parent 5e3fddcc05
commit ef0e30b2b3
5 changed files with 51 additions and 10 deletions

View file

@ -169,9 +169,11 @@ public class WatchUpdaterService extends WearableListenerService implements
if(glucoseStatus == null) { if(glucoseStatus == null) {
dataMap.putString("slopeArrow", "" ); dataMap.putString("slopeArrow", "" );
dataMap.putString("delta", ""); dataMap.putString("delta", "");
dataMap.putString("avgDelta", "");
} else { } else {
dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.delta)); dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.delta));
dataMap.putString("delta", deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, profile.getUnits())); 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.putString("battery", "" + battery);
dataMap.putLong("sgvLevel", sgvLevel); dataMap.putLong("sgvLevel", sgvLevel);
@ -179,8 +181,6 @@ public class WatchUpdaterService extends WearableListenerService implements
dataMap.putDouble("sgvDouble", lastBG.value); dataMap.putDouble("sgvDouble", lastBG.value);
dataMap.putDouble("high", highMark); dataMap.putDouble("high", highMark);
dataMap.putDouble("low", lowMark); dataMap.putDouble("low", lowMark);
//TODO Adrian use for status string?
//dataMap.putString("rawString", threeRaw((prefs.getString("units", "mgdl").equals("mgdl"))));
return dataMap; return dataMap;
} }

View file

@ -45,10 +45,8 @@ import lecho.lib.hellocharts.view.LineChartView;
*/ */
public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener { public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
public final static IntentFilter INTENT_FILTER; public final static IntentFilter INTENT_FILTER;
public static final long[] vibratePattern = {0,400,300,400,300,400}; public TextView mTime, mSgv, mTimestamp, mDelta, mAvgDelta;
public TextView mTime, mSgv, mTimestamp, mDelta;
public RelativeLayout mRelativeLayout; public RelativeLayout mRelativeLayout;
//public LinearLayout mLinearLayout;
public long sgvLevel = 0; public long sgvLevel = 0;
public int batteryLevel = 1; public int batteryLevel = 1;
public int ageLevel = 1; public int ageLevel = 1;
@ -58,7 +56,6 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
public int pointSize = 2; public int pointSize = 2;
public boolean singleLine = false; public boolean singleLine = false;
public boolean layoutSet = false; public boolean layoutSet = false;
public int missed_readings_alert_id = 818;
public BgGraphBuilder bgGraphBuilder; public BgGraphBuilder bgGraphBuilder;
public LineChartView chart; public LineChartView chart;
public double datetime; public double datetime;
@ -66,7 +63,6 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>(); public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>();
public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>(); public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>();
public PowerManager.WakeLock wakeLock; public PowerManager.WakeLock wakeLock;
// related endTime manual layout
public View layoutView; public View layoutView;
private final Point displaySize = new Point(); private final Point displaySize = new Point();
private int specW, specH; private int specW, specH;
@ -124,6 +120,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
mSgv = (TextView) stub.findViewById(R.id.sgv); mSgv = (TextView) stub.findViewById(R.id.sgv);
mTimestamp = (TextView) stub.findViewById(R.id.timestamp); mTimestamp = (TextView) stub.findViewById(R.id.timestamp);
mDelta = (TextView) stub.findViewById(R.id.delta); mDelta = (TextView) stub.findViewById(R.id.delta);
mAvgDelta = (TextView) stub.findViewById(R.id.avgdelta);
mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout); mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
chart = (LineChartView) stub.findViewById(R.id.chart); chart = (LineChartView) stub.findViewById(R.id.chart);
statusView = (TextView) stub.findViewById(R.id.aps_status); statusView = (TextView) stub.findViewById(R.id.aps_status);
@ -241,6 +238,17 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
mDelta.setText(delta); 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) { if (chart != null) {
addToWatchSet(dataMap); addToWatchSet(dataMap);
setupCharts(); setupCharts();
@ -323,7 +331,13 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
} }
boolean showStatus = sharedPrefs.getBoolean("showExternalStatus", true); 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){ if(showStatus){
statusView.setText(externalStatusString); statusView.setText(externalStatusString);

View file

@ -25,7 +25,7 @@
<TextView <TextView
android:id="@+id/delta" android:id="@+id/delta"
android:textSize="30sp" android:textSize="30sp"
android:text="--- mg/dl" android:text="---"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
@ -43,6 +43,17 @@
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:gravity="center_horizontal" /> android:gravity="center_horizontal" />
<TextView
android:id="@+id/avgdelta"
android:textSize="30sp"
android:text="---"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_gravity="bottom"
android:gravity="center_horizontal|bottom"
android:layout_marginLeft="5dp" />
</LinearLayout> </LinearLayout>
<lecho.lib.hellocharts.view.LineChartView <lecho.lib.hellocharts.view.LineChartView
@ -94,4 +105,4 @@
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -25,7 +25,7 @@
<TextView <TextView
android:id="@+id/delta" android:id="@+id/delta"
android:textSize="30sp" android:textSize="30sp"
android:text="--- mg/dl" android:text="---"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
@ -43,6 +43,17 @@
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:gravity="center_horizontal" /> android:gravity="center_horizontal" />
<TextView
android:id="@+id/avgdelta"
android:textSize="30sp"
android:text="---"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_gravity="bottom"
android:gravity="center_horizontal|bottom"
android:layout_marginLeft="5dp" />
</LinearLayout> </LinearLayout>
<lecho.lib.hellocharts.view.LineChartView <lecho.lib.hellocharts.view.LineChartView

View file

@ -23,6 +23,11 @@
android:summary="Better visible basal rate and temp basals" android:summary="Better visible basal rate and temp basals"
android:key="highlight_basals" /> android:key="highlight_basals" />
<CheckBoxPreference android:title="Show AvgDelta"
android:defaultValue="true"
android:summary="Show the avgDelta."
android:key="showAvgDelta" />
<CheckBoxPreference android:title="Dark" <CheckBoxPreference android:title="Dark"
android:defaultValue="true" android:defaultValue="true"
android:summary="Dark theme" android:summary="Dark theme"