From 47b9e948583f6042c9b1737fbc1d5aadfc788015 Mon Sep 17 00:00:00 2001 From: vanous Date: Fri, 17 Sep 2021 17:58:40 +0200 Subject: [PATCH] exclude not worn sleep times also from sleep sessions This ensures that the sleep sessions times and the charts times are now equal (correct behavior). At the same time this causes the sleep sessions to be visually broken up into more small pieces and therefore it now more highlights the issue of the band (mostly) wrongly marking some samples as not worn. --- .../gadgetbridge/activities/charts/SleepAnalysis.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepAnalysis.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepAnalysis.java index d73b2e680..b8afe938b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepAnalysis.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepAnalysis.java @@ -45,6 +45,14 @@ public class SleepAnalysis { sleepEnd = getDateFromSample(sample); durationSinceLastSleep = 0; + } else { + //exclude "not worn" times from sleep sessions as this makes a discrepancy with the charts + if (lightSleepDuration + deepSleepDuration > MIN_SESSION_LENGTH) + result.add(new SleepSession(sleepStart, sleepEnd, lightSleepDuration, deepSleepDuration)); + sleepStart = null; + sleepEnd = null; + lightSleepDuration = 0; + deepSleepDuration = 0; } if (previousSample != null) {