From 05c707bdfb1da5d83d8cfe04b17dffd3a551022c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Fri, 27 Sep 2024 20:32:47 +0100 Subject: [PATCH] Standardize and hide fake sleep movement intensity --- .../charts/AbstractActivityChartFragment.java | 29 ++++++++++++++++++- .../activities/charts/SleepChartFragment.java | 8 ++++- .../samples/CmfActivitySampleProvider.java | 14 ++------- .../garmin/GarminActivitySampleProvider.java | 17 ++--------- .../devices/xiaomi/XiaomiSampleProvider.java | 14 ++------- .../main/res/layout/fragment_sleepchart.xml | 2 ++ 6 files changed, 43 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractActivityChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractActivityChartFragment.java index c5a33000a..25ed4386a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractActivityChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractActivityChartFragment.java @@ -210,7 +210,34 @@ public abstract class AbstractActivityChartFragment extend ActivitySample sample = samples.get(i); ActivityKind type = sample.getKind(); int ts = tsTranslation.shorten(sample.getTimestamp()); - float value = type != ActivityKind.NOT_WORN ? sample.getIntensity() : Y_VALUE_DEEP_SLEEP; + final float value; + if (type != ActivityKind.NOT_WORN) { + if (ActivityKind.isSleep(type) && sample.getIntensity() <= 0) { + switch (type) { + case SLEEP_ANY: + case AWAKE_SLEEP: + value = 0.50f; + break; + case DEEP_SLEEP: + value = 0.20f; + break; + case LIGHT_SLEEP: + value = 0.30f; + break; + case REM_SLEEP: + value = 0.40f; + break; + default: + value = Y_VALUE_DEEP_SLEEP; + break; + } + } else { + value = sample.getIntensity(); + } + } else { + value = Y_VALUE_DEEP_SLEEP; + } + // do not interpolate NOT_WORN on any side boolean interpolate = !(last_type == ActivityKind.NOT_WORN || type == ActivityKind.NOT_WORN); float interpolation_value = interpolate ? value : last_value; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java index 09b39f030..5fb192ea9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java @@ -75,6 +75,8 @@ public class SleepChartFragment extends AbstractActivityChartFragment 0 ? new DecimalFormat("###.#").format(intensityTotal) : "-"); + movementIntensityTextWrapper.setVisibility(intensityTotal > 0 ? View.VISIBLE : View.GONE); + dummyTile.setVisibility(intensityTotal > 0 ? View.VISIBLE : View.GONE); mSleepAmountChart.setHoleRadius(85); mSleepAmountChart.setDrawEntryLabels(false); @@ -385,6 +389,8 @@ public class SleepChartFragment extends AbstractActivityChartFragment { private static final Logger LOG = LoggerFactory.getLogger(CmfActivitySampleProvider.class); @@ -166,18 +167,7 @@ public class CmfActivitySampleProvider extends AbstractSampleProvider { @@ -191,18 +192,7 @@ public class XiaomiSampleProvider extends AbstractSampleProvider