1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-03 11:33:19 +02:00

As a test, draw limit lines for sleep/activity changes.

Unfortunately it looks like the labels for it don't get rendered ;-(
This commit is contained in:
cpfeiffer 2015-06-18 23:41:54 +02:00
parent 83079b0456
commit 03fa05756e

View File

@ -13,6 +13,7 @@ import android.view.MenuItem;
import com.github.mikephil.charting.animation.Easing; import com.github.mikephil.charting.animation.Easing;
import com.github.mikephil.charting.charts.BarLineChartBase; import com.github.mikephil.charting.charts.BarLineChartBase;
import com.github.mikephil.charting.components.LimitLine;
import com.github.mikephil.charting.components.XAxis; import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis; import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.BarData; import com.github.mikephil.charting.data.BarData;
@ -131,6 +132,7 @@ public class SleepChartActivity extends Activity {
// x.setTypeface(tf); // x.setTypeface(tf);
x.setEnabled(true); x.setEnabled(true);
x.setTextColor(Color.WHITE); x.setTextColor(Color.WHITE);
x.setDrawLimitLinesBehindData(true);
YAxis y = mChart.getAxisLeft(); YAxis y = mChart.getAxisLeft();
y.setDrawGridLines(false); y.setDrawGridLines(false);
@ -289,18 +291,21 @@ public class SleepChartActivity extends Activity {
} }
String xLabel = ""; String xLabel = "";
boolean annotate_this = false;
if (annotate) { if (annotate) {
if (true || type != GBActivitySample.TYPE_DEEP_SLEEP && type != GBActivitySample.TYPE_LIGHT_SLEEP && cal.setTimeInMillis(sample.getTimestamp() * 1000L);
(last_type == GBActivitySample.TYPE_DEEP_SLEEP || last_type == GBActivitySample.TYPE_LIGHT_SLEEP)) { date = cal.getTime();
// seems that we woke up String dateString = annotationDateFormat.format(date);
annotate_this = true; xLabel = dateString;
} if (last_type != type) {
if (annotate_this) { if (isSleep(last_type) && !isSleep(type)) {
cal.setTimeInMillis(sample.getTimestamp() * 1000L); // woken up
date = cal.getTime(); LimitLine line = new LimitLine(i, dateString);
String dateString = annotationDateFormat.format(date); mChart.getXAxis().addLimitLine(line);
xLabel = dateString; } else if (!isSleep(last_type) && isSleep(type)) {
// fallen asleep
LimitLine line = new LimitLine(i, dateString);
mChart.getXAxis().addLimitLine(line);
}
} }
last_type = type; last_type = type;
} }
@ -336,6 +341,10 @@ public class SleepChartActivity extends Activity {
} }
} }
private boolean isSleep(byte type) {
return type == GBActivitySample.TYPE_DEEP_SLEEP || type == GBActivitySample.TYPE_LIGHT_SLEEP;
}
private void setupLegend(BarLineChartBase chart) { private void setupLegend(BarLineChartBase chart) {
List<Integer> legendColors = new ArrayList<>(3); List<Integer> legendColors = new ArrayList<>(3);
List<String> legendLabels = new ArrayList<>(3); List<String> legendLabels = new ArrayList<>(3);