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 d4a46d7f3a..bce19e96a5 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java @@ -9,7 +9,6 @@ import android.text.format.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; -import java.util.Date; import java.util.GregorianCalendar; import java.util.List; import java.util.TimeZone; @@ -51,7 +50,7 @@ public class BgGraphBuilder { public int gridColour; public int basalCenterColor; public int basalBackgroundColor; - private int bolusColor; + private int bolusInvalidColor; public boolean singleLine = false; private List inRangeValues = new ArrayList(); @@ -61,7 +60,7 @@ public class BgGraphBuilder { //used for low resolution screen. - public BgGraphBuilder(Context context, List aBgList, List predictionsList, List tempWatchDataList, ArrayList basalWatchDataList, ArrayList bolusWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusColor, int timespan) { + public BgGraphBuilder(Context context, List aBgList, List predictionsList, List tempWatchDataList, ArrayList basalWatchDataList, ArrayList bolusWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusInvalidColor, int timespan) { this.start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago this.bgDataList = aBgList; this.predictionsList = predictionsList; @@ -80,13 +79,13 @@ public class BgGraphBuilder { this.gridColour = gridColour; this.basalCenterColor = basalCenterColor; this.basalBackgroundColor = basalBackgroundColor; - this.bolusColor = bolusColor; + this.bolusInvalidColor = bolusInvalidColor; this.end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) this.predictionEndTime = getPredictionEndTime(); this.end_time = (predictionEndTime>end_time)?predictionEndTime:end_time; } - public BgGraphBuilder(Context context, List aBgList, List predictionsList, List tempWatchDataList, ArrayList basalWatchDataList, ArrayList bolusWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusColor, int timespan) { + public BgGraphBuilder(Context context, List aBgList, List predictionsList, List tempWatchDataList, ArrayList basalWatchDataList, ArrayList bolusWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusInvalidColor, int timespan) { this.start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago this.bgDataList = aBgList; this.predictionsList = predictionsList; @@ -104,7 +103,7 @@ public class BgGraphBuilder { this.gridColour = gridColour; this.basalCenterColor = basalCenterColor; this.basalBackgroundColor = basalBackgroundColor; - this.bolusColor = bolusColor; + this.bolusInvalidColor = bolusInvalidColor; this.end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) this.predictionEndTime = getPredictionEndTime(); this.end_time = (predictionEndTime>end_time)?predictionEndTime:end_time; @@ -172,6 +171,7 @@ public class BgGraphBuilder { lines.add(basalLine((float) minChart, factor, highlight)); lines.add(bolusLine((float) minChart)); + lines.add(bolusInvalidLine((float) minChart)); lines.add(smbLine((float) minChart)); lines.add(predictionLine()); @@ -206,12 +206,12 @@ public class BgGraphBuilder { List pointValues = new ArrayList(); for (BolusWatchData bwd: bolusWatchDataList) { - if(bwd.date > start_time && !bwd.isSMB && !bwd.isValid && bwd.bolus > 0) { + if(bwd.date > start_time && !bwd.isSMB && bwd.isValid && bwd.bolus > 0) { pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2)); } } Line line = new Line(pointValues); - line.setColor(bolusColor); + line.setColor(bolusInvalidColor); line.setHasLines(false); line.setPointRadius(pointSize*2); line.setHasPoints(true); @@ -223,7 +223,7 @@ public class BgGraphBuilder { List pointValues = new ArrayList(); for (BolusWatchData bwd: bolusWatchDataList) { - if(bwd.date > start_time && bwd.isSMB && !bwd.isValid && bwd.bolus > 0) { + if(bwd.date > start_time && bwd.isSMB && bwd.isValid && bwd.bolus > 0) { pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2)); } } @@ -235,6 +235,24 @@ public class BgGraphBuilder { return line; } + private Line bolusInvalidLine(float offset) { + + List pointValues = new ArrayList(); + + for (BolusWatchData bwd: bolusWatchDataList) { + if(!(bwd.isValid && bwd.bolus > 0)) { + pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2)); + } + } + Line line = new Line(pointValues); + line.setColor(bolusInvalidColor); + line.setHasLines(false); + line.setPointRadius(pointSize); + line.setHasPoints(true); + return line; + } + + private Line predictionLine() { List pointValues = new ArrayList();