From d8f4de8b22c6629a33ff3fb4f7ceb1be370ab8ec Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 20 Nov 2016 02:31:15 +0100 Subject: [PATCH] wear highlight basals --- .../info/nightscout/androidaps/BIGChart.java | 4 +-- .../nightscout/androidaps/BaseWatchFace.java | 4 +-- .../nightscout/androidaps/BgGraphBuilder.java | 30 ++++++++++++----- wear/src/main/res/xml/preferences.xml | 33 ++++++++----------- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java index 2eb6718553..668542b4a0 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java +++ b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java @@ -322,7 +322,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre mTimestamp.setText(readingAge(true)); } - boolean showStatus = sharedPrefs.getBoolean("showExternalStatus", false); + boolean showStatus = sharedPrefs.getBoolean("showExternalStatus", true); if(showStatus){ @@ -556,7 +556,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre public void setupCharts() { if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things - int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "5")); + int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); if (singleLine) { bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, timeframe); } else { diff --git a/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java index 1663d25b37..99e70a6dc0 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java @@ -267,7 +267,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen || (sharedPrefs.getBoolean("showRawNoise", true) && sgvString.equals("???")); - boolean showStatus = sharedPrefs.getBoolean("showExternalStatus", false); + boolean showStatus = sharedPrefs.getBoolean("showExternalStatus", true); if(showRaw || showStatus){ //use short forms @@ -374,7 +374,7 @@ protected abstract void setColorDark(); public void setupCharts() { if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things - int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "5")); + int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); if (singleLine) { bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, new ArrayList(), new ArrayList(), pointSize, midColor, timeframe); } else { diff --git a/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java b/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java index 7577c97256..459e48a77b 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java +++ b/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java @@ -3,6 +3,7 @@ package info.nightscout.androidaps; import android.content.Context; import android.graphics.Color; import android.graphics.DashPathEffect; +import android.preference.PreferenceManager; import android.text.format.DateFormat; import java.text.SimpleDateFormat; @@ -125,18 +126,26 @@ public class BgGraphBuilder { double factor = (maxChart-minChart)/maxTemp; // in case basal is the highest, don't paint it totally at the top. factor = Math.min(factor, ((maxChart-minChart)/maxBasal)*(2/3d)); + + boolean highlight = PreferenceManager + .getDefaultSharedPreferences(context) + .getBoolean("highlight_basals", false); + for (TempWatchData twd: tempWatchDataList) { if(twd.endTime > start_time) { - lines.add(tempValuesLine(twd, (float) minChart, factor)); + lines.add(tempValuesLine(twd, (float) minChart, factor, false, highlight?3:2)); + if(highlight){ + lines.add(tempValuesLine(twd, (float) minChart, factor, true, 1)); + } } } - lines.add(basalLine((float) minChart, factor)); + lines.add(basalLine((float) minChart, factor, highlight)); return lines; } - private Line basalLine(float offset, double factor) { + private Line basalLine(float offset, double factor, boolean highlight) { List pointValues = new ArrayList(); @@ -152,7 +161,7 @@ public class BgGraphBuilder { basalLine.setHasPoints(false); basalLine.setColor(Color.parseColor("#00BFFF")); basalLine.setPathEffect(new DashPathEffect(new float[]{4f, 3f}, 4f)); - basalLine.setStrokeWidth(1); + basalLine.setStrokeWidth(highlight?2:1); return basalLine; @@ -192,7 +201,7 @@ public class BgGraphBuilder { } - public Line tempValuesLine(TempWatchData twd, float offset, double factor) { + public Line tempValuesLine(TempWatchData twd, float offset, double factor, boolean isHighlightLine, int strokeWidth) { List lineValues = new ArrayList(); long begin = (long) Math.max(start_time, twd.startTime); lineValues.add(new PointValue(fuzz(begin), offset + (float) (factor * twd.startBasal))); @@ -201,9 +210,14 @@ public class BgGraphBuilder { lineValues.add(new PointValue(fuzz(twd.endTime), offset + (float) (factor * twd.endBasal))); Line valueLine = new Line(lineValues); valueLine.setHasPoints(false); - valueLine.setColor(Color.BLUE); - valueLine.setStrokeWidth(1); - valueLine.setFilled(true); + if (isHighlightLine){ + valueLine.setColor(Color.parseColor("#00BFFF")); + valueLine.setStrokeWidth(1); + }else { + valueLine.setColor(Color.BLUE); + valueLine.setStrokeWidth(strokeWidth); + valueLine.setFilled(true); + } return valueLine; } diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml index c3e40eb052..1f4ac3ea18 100644 --- a/wear/src/main/res/xml/preferences.xml +++ b/wear/src/main/res/xml/preferences.xml @@ -5,26 +5,9 @@ android:key="category" android:selectable="false"> - - - - - + android:defaultValue="3" /> + + + +