bg value colored

This commit is contained in:
Milos Kozak 2017-04-27 21:26:53 +02:00
parent 0aad00808c
commit 3552d6aa40
2 changed files with 50 additions and 27 deletions

View file

@ -892,10 +892,27 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
String units = profile.getUnits(); String units = profile.getUnits();
Double lowLine = SP.getDouble("low_mark", 0d);
Double highLine = SP.getDouble("high_mark", 0d);
if (lowLine < 1) {
lowLine = NSProfile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units);
}
if (highLine < 1) {
highLine = NSProfile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units);
}
// **** BG value **** // **** BG value ****
if (lastBG != null) { if (lastBG != null) {
int color = MainApp.sResources.getColor(R.color.inrange);
if (lastBG.valueToUnits(units) < lowLine)
color = MainApp.sResources.getColor(R.color.low);
else if (lastBG.valueToUnits(units) > highLine)
color = MainApp.sResources.getColor(R.color.high);
bgView.setText(lastBG.valueToUnitsToString(profile.getUnits())); bgView.setText(lastBG.valueToUnitsToString(profile.getUnits()));
arrowView.setText(lastBG.directionToSymbol()); arrowView.setText(lastBG.directionToSymbol());
bgView.setTextColor(color);
arrowView.setTextColor(color);
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
if (glucoseStatus != null) { if (glucoseStatus != null) {
deltaView.setText("Δ " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units); deltaView.setText("Δ " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units);
@ -971,24 +988,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
endTime = toTime; endTime = toTime;
} }
Double lowLine = SP.getDouble("low_mark", 0d);
Double highLine = SP.getDouble("high_mark", 0d);
if (lowLine < 1) {
lowLine = NSProfile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units);
}
if (highLine < 1) {
highLine = NSProfile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units);
}
LineGraphSeries<DataPoint> basalsLineSeries = null; LineGraphSeries<DataPoint> basalsLineSeries = null;
LineGraphSeries<DataPoint> baseBasalsSeries = null; LineGraphSeries<DataPoint> baseBasalsSeries = null;
LineGraphSeries<DataPoint> tempBasalsSeries = null; LineGraphSeries<DataPoint> tempBasalsSeries = null;
AreaGraphSeries<DoubleDataPoint> areaSeries; AreaGraphSeries<DoubleDataPoint> areaSeries;
LineGraphSeries<DataPoint> seriesNow, seriesNow2; LineGraphSeries<DataPoint> seriesNow, seriesNow2;
PointsGraphSeries<BgReading> seriesInRage; PointsGraphSeries<BgReading> seriesInRage;
PointsGraphSeries<BgReading> seriesOutOfRange; PointsGraphSeries<BgReading> seriesLow;
PointsGraphSeries<BgReading> seriesHigh;
PointsGraphSeries<BgReading> predSeries; PointsGraphSeries<BgReading> predSeries;
PointsWithLabelGraphSeries<Treatment> seriesTreatments; PointsWithLabelGraphSeries<Treatment> seriesTreatments;
@ -1139,7 +1146,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
public void setViewport(Viewport viewport) { public void setViewport(Viewport viewport) {
} }
}); });
*/ } */
}
iobGraphLayout.setVisibility(View.VISIBLE); iobGraphLayout.setVisibility(View.VISIBLE);
} else { } else {
iobGraphLayout.setVisibility(View.GONE); iobGraphLayout.setVisibility(View.GONE);
@ -1173,8 +1181,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// **** BG graph **** // **** BG graph ****
List<BgReading> bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true); List<BgReading> bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
List<BgReading> inRangeArray = new ArrayList<BgReading>(); List<BgReading> inRangeArray = new ArrayList<>();
List<BgReading> outOfRangeArray = new ArrayList<BgReading>(); List<BgReading> lowArray = new ArrayList<>();
List<BgReading> highArray = new ArrayList<>();
if (bgReadingsArray.size() == 0) if (bgReadingsArray.size() == 0)
return; return;
@ -1184,8 +1193,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
while (it.hasNext()) { while (it.hasNext()) {
BgReading bg = it.next(); BgReading bg = it.next();
if (bg.value > maxBgValue) maxBgValue = bg.value; if (bg.value > maxBgValue) maxBgValue = bg.value;
if (bg.valueToUnits(units) < lowLine || bg.valueToUnits(units) > highLine) if (bg.valueToUnits(units) < lowLine)
outOfRangeArray.add(bg); lowArray.add(bg);
else if (bg.valueToUnits(units) > highLine)
highArray.add(bg);
else else
inRangeArray.add(bg); inRangeArray.add(bg);
} }
@ -1195,23 +1206,32 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
Integer numOfHorizLines = units.equals(Constants.MGDL) ? (int) (maxBgValue / 40 + 1) : (int) (maxBgValue / 2 + 1); Integer numOfHorizLines = units.equals(Constants.MGDL) ? (int) (maxBgValue / 40 + 1) : (int) (maxBgValue / 2 + 1);
BgReading[] inRange = new BgReading[inRangeArray.size()]; BgReading[] inRange = new BgReading[inRangeArray.size()];
BgReading[] outOfRange = new BgReading[outOfRangeArray.size()]; BgReading[] low = new BgReading[lowArray.size()];
BgReading[] high = new BgReading[highArray.size()];
inRange = inRangeArray.toArray(inRange); inRange = inRangeArray.toArray(inRange);
outOfRange = outOfRangeArray.toArray(outOfRange); low = lowArray.toArray(low);
high = highArray.toArray(high);
if (inRange.length > 0) { if (inRange.length > 0) {
bgGraph.addSeries(seriesInRage = new PointsGraphSeries<BgReading>(inRange)); bgGraph.addSeries(seriesInRage = new PointsGraphSeries<>(inRange));
seriesInRage.setShape(PointsGraphSeries.Shape.POINT); seriesInRage.setShape(PointsGraphSeries.Shape.POINT);
seriesInRage.setSize(5); seriesInRage.setSize(5);
seriesInRage.setColor(Color.GREEN); seriesInRage.setColor(MainApp.sResources.getColor(R.color.inrange));
} }
if (outOfRange.length > 0) { if (low.length > 0) {
bgGraph.addSeries(seriesOutOfRange = new PointsGraphSeries<BgReading>(outOfRange)); bgGraph.addSeries(seriesLow = new PointsGraphSeries<>(low));
seriesOutOfRange.setShape(PointsGraphSeries.Shape.POINT); seriesLow.setShape(PointsGraphSeries.Shape.POINT);
seriesOutOfRange.setSize(5); seriesLow.setSize(5);
seriesOutOfRange.setColor(Color.RED); seriesLow.setColor(MainApp.sResources.getColor(R.color.low));
}
if (high.length > 0) {
bgGraph.addSeries(seriesHigh = new PointsGraphSeries<>(low));
seriesHigh.setShape(PointsGraphSeries.Shape.POINT);
seriesHigh.setSize(5);
seriesHigh.setColor(MainApp.sResources.getColor(R.color.high));
} }
if (showPrediction) { if (showPrediction) {

View file

@ -3,7 +3,10 @@
<color name="prediction">#ff00ff</color> <color name="prediction">#ff00ff</color>
<color name="basal">#00ffff</color> <color name="basal">#00ffff</color>
<color name="iob">#FFFB8C00</color> <color name="iob">#FFFB8C00</color>
<color name="cob">#fbf300</color> <color name="cob">#8BC34A</color>
<color name="inrange">#00FF00</color>
<color name="low">#FF0000</color>
<color name="high">#FFFF00</color>
<color name="colorPrimary">#3F51B5</color> <color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color> <color name="colorPrimaryDark">#303F9F</color>