mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 04:46:51 +01:00
Fix sleep charts for devices without REM sleep
This commit is contained in:
parent
fc450882cb
commit
3a778a9f2a
@ -54,17 +54,17 @@ public abstract class AbstractActivityChartFragment<D extends ChartsData> extend
|
||||
|
||||
public boolean supportsHeartrate(GBDevice device) {
|
||||
DeviceCoordinator coordinator = device.getDeviceCoordinator();
|
||||
return coordinator != null && coordinator.supportsHeartRateMeasurement(device);
|
||||
return coordinator.supportsHeartRateMeasurement(device);
|
||||
}
|
||||
|
||||
public boolean supportsRemSleep(GBDevice device) {
|
||||
DeviceCoordinator coordinator = device.getDeviceCoordinator();
|
||||
return coordinator != null && coordinator.supportsRemSleep();
|
||||
return coordinator.supportsRemSleep();
|
||||
}
|
||||
|
||||
public boolean supportsAwakeSleep(GBDevice device) {
|
||||
DeviceCoordinator coordinator = device.getDeviceCoordinator();
|
||||
return coordinator != null && coordinator.supportsAwakeSleep();
|
||||
return coordinator.supportsAwakeSleep();
|
||||
}
|
||||
|
||||
protected static final class ActivityConfig {
|
||||
|
@ -189,7 +189,7 @@ public abstract class AbstractWeekChartFragment extends AbstractActivityChartFra
|
||||
PieDataSet set = new PieDataSet(entries, "");
|
||||
|
||||
ActivityAmounts amounts = getActivityAmountsForDay(db, day, device);
|
||||
float totalValues[] = getTotalsForActivityAmounts(amounts);
|
||||
float[] totalValues = getTotalsForActivityAmounts(amounts);
|
||||
String[] pieLabels = getPieLabels();
|
||||
float totalValue = 0;
|
||||
for (int i = 0; i < totalValues.length; i++) {
|
||||
|
@ -91,12 +91,14 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
||||
}
|
||||
|
||||
float[] totalAmounts = getTotalsForActivityAmounts(amounts);
|
||||
deepWeeklyTotal += (long) totalAmounts[0];
|
||||
lightWeeklyTotal += (long) totalAmounts[1];
|
||||
remWeeklyTotal += (long) totalAmounts[2];
|
||||
|
||||
int i = 0;
|
||||
deepWeeklyTotal += (long) totalAmounts[i++];
|
||||
lightWeeklyTotal += (long) totalAmounts[i++];
|
||||
if (supportsRemSleep(getChartsHost().getDevice())) {
|
||||
remWeeklyTotal += (long) totalAmounts[i++];
|
||||
}
|
||||
if (supportsAwakeSleep(getChartsHost().getDevice())) {
|
||||
awakeWeeklyTotal += (long) totalAmounts[3];
|
||||
awakeWeeklyTotal += (long) totalAmounts[i++];
|
||||
}
|
||||
|
||||
day.add(Calendar.DATE, 1);
|
||||
@ -273,7 +275,10 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
||||
int totalMinutesRemSleep = (int) (totalSecondsRemSleep / 60);
|
||||
int totalMinutesAwakeSleep = (int) (totalSecondsAwakeSleep / 60);
|
||||
|
||||
float[] activityAmountsTotals = {totalMinutesDeepSleep, totalMinutesLightSleep, totalMinutesRemSleep};
|
||||
float[] activityAmountsTotals = {totalMinutesDeepSleep, totalMinutesLightSleep};
|
||||
if (supportsRemSleep(getChartsHost().getDevice())) {
|
||||
activityAmountsTotals = ArrayUtils.add(activityAmountsTotals, totalMinutesRemSleep);
|
||||
}
|
||||
if (supportsAwakeSleep(getChartsHost().getDevice())) {
|
||||
activityAmountsTotals = ArrayUtils.add(activityAmountsTotals, totalMinutesAwakeSleep);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user