From aefd7520f30341e5486de98973ad079fc82b4ee5 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Fri, 2 Aug 2019 00:11:11 +0200 Subject: [PATCH] Mi Band 3/4, Amazfit Cor/Bip: set language immediately when changing it (not only on connect) Helps testing --- .../DeviceSpecificSettingsFragment.java | 9 ++++++--- .../gadgetbridge/devices/huami/HuamiConst.java | 3 +++ .../gadgetbridge/devices/huami/HuamiService.java | 2 ++ .../service/devices/huami/HuamiSupport.java | 13 +++++++++---- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java index 33cadbb2e..83aa6ab2f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java @@ -16,18 +16,20 @@ import org.slf4j.LoggerFactory; import java.util.Objects; import nodomain.freeyourgadget.gadgetbridge.GBApplication; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.XTimePreference; import nodomain.freeyourgadget.gadgetbridge.util.XTimePreferenceFragment; import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT; +import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DATEFORMAT; import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION; import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION_END; import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION_START; +import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISPLAY_ITEMS; import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISPLAY_ON_LIFT_END; import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISPLAY_ON_LIFT_START; +import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_LANGUAGE; import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB; import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB_END; import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB_OFF; @@ -282,8 +284,9 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat { addPreferenceHandlerFor(PREF_SWIPE_UNLOCK); addPreferenceHandlerFor(PREF_MI2_DATEFORMAT); - addPreferenceHandlerFor("dateformat"); - addPreferenceHandlerFor(HuamiConst.PREF_DISPLAY_ITEMS); + addPreferenceHandlerFor(PREF_DATEFORMAT); + addPreferenceHandlerFor(PREF_DISPLAY_ITEMS); + addPreferenceHandlerFor(PREF_LANGUAGE); String displayOnLiftState = prefs.getString(PREF_ACTIVATE_DISPLAY_ON_LIFT, PREF_DO_NOT_DISTURB_OFF); boolean displayOnLiftScheduled = displayOnLiftState.equals(PREF_DO_NOT_DISTURB_SCHEDULED); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java index 3a6852621..d595f37f0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java @@ -59,6 +59,9 @@ public class HuamiConst { public static final String PREF_DISCONNECT_NOTIFICATION_END = "disconnect_notification_end"; public static final String PREF_DISPLAY_ITEMS = "display_items"; + public static final String PREF_LANGUAGE = "language"; + public static final String PREF_DATEFORMAT = "dateformat"; + public static int toActivityKind(int rawType) { switch (rawType) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiService.java index f87c31d78..86fd89ff2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiService.java @@ -49,6 +49,8 @@ public class HuamiService { // service uuid fee1 public static final UUID UUID_CHARACTERISTIC_AUTH = UUID.fromString("00000009-0000-3512-2118-0009af100700"); public static final UUID UUID_CHARACTERISTIC_DEVICEEVENT = UUID.fromString("00000010-0000-3512-2118-0009af100700"); + public static final UUID UUID_CHARACTERISTIC_AUDIO = UUID.fromString("00000012-0000-3512-2118-0009af100700"); + public static final UUID UUID_CHARACTERISTIC_AUDIODATA = UUID.fromString("00000013-0000-3512-2118-0009af100700"); public static final UUID UUID_CHARACTERISTIC_CHUNKEDTRANSFER = UUID.fromString("00000020-0000-3512-2118-0009af100700"); 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 ad7d815e1..9d0c5b14d 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 @@ -301,6 +301,8 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport { builder.notify(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), enable); builder.notify(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_6_BATTERY_INFO), enable); builder.notify(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_DEVICEEVENT), enable); + builder.notify(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_AUDIO), enable); + builder.notify(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_AUDIODATA), enable); return this; } @@ -682,7 +684,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport { sendCalendarEvents(builder); builder.queue(getQueue()); } catch (IOException ex) { - LOG.error("Unable to set time on MI device", ex); + LOG.error("Unable to set time on Huami device", ex); } } @@ -878,7 +880,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport { builder.write(characteristicHRControlPoint, startHeartMeasurementManual); builder.queue(getQueue()); } catch (IOException ex) { - LOG.error("Unable to read heart rate with MI2", ex); + LOG.error("Unable to read heart rate from Huami device", ex); } } @@ -939,7 +941,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport { try { new FetchActivityOperation(this).perform(); } catch (IOException ex) { - LOG.error("Unable to fetch MI activity data", ex); + LOG.error("Unable to fetch activity data", ex); } } @@ -1557,9 +1559,12 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport { case MiBandConst.PREF_SWIPE_UNLOCK: setBandScreenUnlock(builder); break; - case "dateformat": + case HuamiConst.PREF_DATEFORMAT: setDateFormat(builder); break; + case HuamiConst.PREF_LANGUAGE: + setLanguage(builder); + break; } builder.queue(getQueue()); } catch (IOException e) {