smb and bolus on wear

This commit is contained in:
AdrianLxM 2018-02-21 01:56:06 +01:00
parent f6253284de
commit 8ee7309d86
3 changed files with 32 additions and 13 deletions

View file

@ -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());

View file

@ -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());

View file

@ -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<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) {
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> 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<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) {
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> 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<PointValue> pointValues = new ArrayList<PointValue>();
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<PointValue> pointValues = new ArrayList<PointValue>();
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;
}