diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BIGChart.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BIGChart.java index ea2e753ec8..b7a3c7769e 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BIGChart.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BIGChart.java @@ -66,6 +66,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre public int gridColour = Color.WHITE; public int basalBackgroundColor = Color.BLUE; public int basalCenterColor = Color.BLUE; + public int bolusColor = Color.MAGENTA; public int pointSize = 2; public boolean lowResMode = false; public boolean layoutSet = false; @@ -654,9 +655,9 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre 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", "3")); if (lowResMode) { - bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe); + bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, midColor, gridColour, basalBackgroundColor, basalCenterColor, bolusColor, timeframe); } else { - bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe); + bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, basalBackgroundColor, basalCenterColor, bolusColor, timeframe); } chart.setLineChartData(bgGraphBuilder.lineData()); diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index ae10062e4e..6b3df4b979 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -66,6 +66,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen public int gridColor = Color.WHITE; public int basalBackgroundColor = Color.BLUE; public int basalCenterColor = Color.BLUE; + public int bolusColor = Color.MAGENTA; public boolean lowResMode = false; public boolean layoutSet = false; public boolean bIsRound = false; @@ -628,9 +629,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen 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", "3")); if (lowResMode) { - bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, null, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe); + bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, null, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, timeframe); } else { - bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, null, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe); + bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, null, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, timeframe); } chart.setLineChartData(bgGraphBuilder.lineData()); diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java index 87d5f39184..064c00bdcd 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java @@ -47,6 +47,7 @@ public class BgGraphBuilder { public int gridColour; public int basalCenterColor; public int basalBackgroundColor; + private int bolusColor; public boolean singleLine = false; private long endHour; @@ -57,7 +58,7 @@ public class BgGraphBuilder { //used for low resolution screen. - public BgGraphBuilder(Context context, List aBgList, List tempWatchDataList, ArrayList basalWatchDataList, ArrayList bolusWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) { + public BgGraphBuilder(Context context, List aBgList, List tempWatchDataList, ArrayList basalWatchDataList, ArrayList bolusWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusColor, int timespan) { end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago this.bgDataList = aBgList; @@ -76,9 +77,10 @@ public class BgGraphBuilder { this.gridColour = gridColour; this.basalCenterColor = basalCenterColor; this.basalBackgroundColor = basalBackgroundColor; + this.bolusColor = bolusColor; } - public BgGraphBuilder(Context context, List aBgList, List tempWatchDataList, ArrayList basalWatchDataList, ArrayList bolusWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) { + public BgGraphBuilder(Context context, List aBgList, List tempWatchDataList, ArrayList basalWatchDataList, ArrayList bolusWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusColor, int timespan) { end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago this.bgDataList = aBgList; @@ -96,6 +98,7 @@ public class BgGraphBuilder { this.gridColour = gridColour; this.basalCenterColor = basalCenterColor; this.basalBackgroundColor = basalBackgroundColor; + this.bolusColor = bolusColor; } public LineChartData lineData() { @@ -158,7 +161,9 @@ public class BgGraphBuilder { } lines.add(basalLine((float) minChart, factor, highlight)); - lines.add(bolusLine((float) minChart, factor)); + lines.add(bolusLine((float) minChart)); + lines.add(smbLine((float) minChart)); + return lines; } @@ -185,26 +190,38 @@ public class BgGraphBuilder { } - private Line bolusLine(float offset, double factor) { + private Line bolusLine(float offset) { List pointValues = new ArrayList(); for (BolusWatchData bwd: bolusWatchDataList) { - if(bwd.date > start_time) { - pointValues.add(new PointValue(fuzz(bwd.date), (float) offset+2)); + if(bwd.date > start_time && !bwd.isSMB) { + pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2)); } } + Line line = new Line(pointValues); + line.setColor(bolusColor); + line.setHasLines(false); + line.setPointRadius(pointSize); + line.setHasPoints(true); + return line; + } + private Line smbLine(float offset) { + List pointValues = new ArrayList(); + + for (BolusWatchData bwd: bolusWatchDataList) { + if(bwd.date > start_time && bwd.isSMB) { + pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2)); + } + } Line line = new Line(pointValues); line.setColor(basalCenterColor); line.setHasLines(false); line.setPointRadius(pointSize); line.setHasPoints(true); - return line; - - }