From ac002f8db945cedfa223fa6e511c92a0d56725f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Sun, 19 Mar 2023 22:11:39 +0000 Subject: [PATCH] Zepp OS: Fix activate display upon lift wrist smart mode --- .../devices/huami/ActivateDisplayOnLift.java | 3 +- .../devices/huami/Huami2021Coordinator.java | 2 +- .../service/devices/huami/HuamiSupport.java | 3 ++ .../zeppos/services/ZeppOsConfigService.java | 1 + app/src/main/res/values/arrays.xml | 13 +++++++ app/src/main/res/values/values.xml | 1 + ...ftwrist_display_sensitivity_with_smart.xml | 39 +++++++++++++++++++ 7 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/xml/devicesettings_liftwrist_display_sensitivity_with_smart.xml diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/ActivateDisplayOnLift.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/ActivateDisplayOnLift.java index e291f25a9..7373f3b8b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/ActivateDisplayOnLift.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/ActivateDisplayOnLift.java @@ -19,5 +19,6 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami; public enum ActivateDisplayOnLift { ON, OFF, - SCHEDULED + SCHEDULED, + SMART } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021Coordinator.java index 4f896e14c..f1fe2cd50 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021Coordinator.java @@ -193,7 +193,7 @@ public abstract class Huami2021Coordinator extends HuamiCoordinator { } settings.add(R.xml.devicesettings_nightmode); settings.add(R.xml.devicesettings_sleep_mode); - settings.add(R.xml.devicesettings_liftwrist_display_sensitivity); + settings.add(R.xml.devicesettings_liftwrist_display_sensitivity_with_smart); settings.add(R.xml.devicesettings_password); settings.add(R.xml.devicesettings_always_on_display); settings.add(R.xml.devicesettings_screen_timeout); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java index 14ca54b64..e006359f3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java @@ -3311,6 +3311,9 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements cmd[7] = (byte) calendar.get(Calendar.MINUTE); writeToConfiguration(builder, cmd); + break; + default: + LOG.warn("Unknown display on lift mode {}", displayOnLift); } return this; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsConfigService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsConfigService.java index 44f4082e1..639c070db 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsConfigService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsConfigService.java @@ -1683,6 +1683,7 @@ public class ZeppOsConfigService extends AbstractZeppOsService { put((byte) 0x00, ActivateDisplayOnLift.OFF); put((byte) 0x01, ActivateDisplayOnLift.SCHEDULED); put((byte) 0x02, ActivateDisplayOnLift.ON); + put((byte) 0x03, ActivateDisplayOnLift.SMART); }}; private static final Map> LIFT_WRIST_SENSITIVITY_MAP = new HashMap>() {{ diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 7e7cf03e3..75c69b02b 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -321,6 +321,19 @@ @string/p_scheduled + + @string/off + @string/on + @string/mi2_dnd_scheduled + @string/smart + + + @string/p_off + @string/p_on + @string/p_scheduled + @string/p_smart + + @string/normal @string/sensitive diff --git a/app/src/main/res/values/values.xml b/app/src/main/res/values/values.xml index 6bc2ec737..5e68e7c07 100644 --- a/app/src/main/res/values/values.xml +++ b/app/src/main/res/values/values.xml @@ -75,6 +75,7 @@ always automatic scheduled + smart normal sensitive diff --git a/app/src/main/res/xml/devicesettings_liftwrist_display_sensitivity_with_smart.xml b/app/src/main/res/xml/devicesettings_liftwrist_display_sensitivity_with_smart.xml new file mode 100644 index 000000000..8b0002f2e --- /dev/null +++ b/app/src/main/res/xml/devicesettings_liftwrist_display_sensitivity_with_smart.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file