Display sleep HR average for in past 24h mode

This commit is contained in:
José Rebelo 2024-12-23 18:48:21 +00:00
parent b608478ade
commit 22063f07e3

View File

@ -268,9 +268,7 @@ public class DaySleepChartFragment extends AbstractActivityChartFragment<DaySlee
movementIntensityTextWrapper.setVisibility(intensityTotal > 0 ? View.VISIBLE : View.GONE); movementIntensityTextWrapper.setVisibility(intensityTotal > 0 ? View.VISIBLE : View.GONE);
dummyTile.setVisibility(intensityTotal > 0 ? View.VISIBLE : View.GONE); dummyTile.setVisibility(intensityTotal > 0 ? View.VISIBLE : View.GONE);
if (!CHARTS_SLEEP_RANGE_24H if (supportsHeartrate(getChartsHost().getDevice()) && SHOW_CHARTS_AVERAGE) {
&& supportsHeartrate(getChartsHost().getDevice())
&& SHOW_CHARTS_AVERAGE) {
if (mcd.getHeartRateAxisMax() != 0 || mcd.getHeartRateAxisMin() != 0) { if (mcd.getHeartRateAxisMax() != 0 || mcd.getHeartRateAxisMin() != 0) {
mActivityChart.getAxisRight().setAxisMaximum(mcd.getHeartRateAxisMax() + (mcd.getHeartRateAxisMin() / 2f)); mActivityChart.getAxisRight().setAxisMaximum(mcd.getHeartRateAxisMax() + (mcd.getHeartRateAxisMin() / 2f));
mActivityChart.getAxisRight().setAxisMinimum(mcd.getHeartRateAxisMin() / 2f); mActivityChart.getAxisRight().setAxisMinimum(mcd.getHeartRateAxisMin() / 2f);
@ -292,7 +290,7 @@ public class DaySleepChartFragment extends AbstractActivityChartFragment<DaySlee
List<Integer> heartRateValues = new ArrayList<>(); List<Integer> heartRateValues = new ArrayList<>();
HeartRateUtils heartRateUtilsInstance = HeartRateUtils.getInstance(); HeartRateUtils heartRateUtilsInstance = HeartRateUtils.getInstance();
for (ActivitySample sample : samples) { for (ActivitySample sample : samples) {
if (sample.getKind() == ActivityKind.LIGHT_SLEEP || sample.getKind() == ActivityKind.DEEP_SLEEP) { if (ActivityKind.isSleep(sample.getKind())) {
int heartRate = sample.getHeartRate(); int heartRate = sample.getHeartRate();
if (heartRateUtilsInstance.isValidHeartRateValue(heartRate)) { if (heartRateUtilsInstance.isValidHeartRateValue(heartRate)) {
heartRateValues.add(heartRate); heartRateValues.add(heartRate);
@ -490,7 +488,7 @@ public class DaySleepChartFragment extends AbstractActivityChartFragment<DaySlee
hrEntry.label = HEARTRATE_LABEL; hrEntry.label = HEARTRATE_LABEL;
hrEntry.formColor = HEARTRATE_COLOR; hrEntry.formColor = HEARTRATE_COLOR;
legendEntries.add(hrEntry); legendEntries.add(hrEntry);
if (!CHARTS_SLEEP_RANGE_24H && SHOW_CHARTS_AVERAGE) { if (SHOW_CHARTS_AVERAGE) {
LegendEntry hrAverageEntry = new LegendEntry(); LegendEntry hrAverageEntry = new LegendEntry();
hrAverageEntry.label = HEARTRATE_AVERAGE_LABEL; hrAverageEntry.label = HEARTRATE_AVERAGE_LABEL;
hrAverageEntry.formColor = Color.RED; hrAverageEntry.formColor = Color.RED;