From 2efc564d21e88924039a3d75adc1c852cd0d33a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Sat, 10 Sep 2022 14:35:50 +0100 Subject: [PATCH] Huami: Add preference to overwrite band settings on connection --- .../devices/huami/HuamiCoordinator.java | 5 ++ .../amazfitband5/AmazfitBand5Coordinator.java | 1 + .../amazfitbip/AmazfitBipCoordinator.java | 1 + .../amazfitbip/AmazfitBipLiteCoordinator.java | 1 + .../amazfitbips/AmazfitBipSCoordinator.java | 1 + .../amazfitbipu/AmazfitBipUCoordinator.java | 1 + .../AmazfitBipUProCoordinator.java | 1 + .../amazfitcor/AmazfitCorCoordinator.java | 1 + .../amazfitcor2/AmazfitCor2Coordinator.java | 1 + .../amazfitgtr/AmazfitGTRCoordinator.java | 1 + .../amazfitgtr/AmazfitGTRLiteCoordinator.java | 1 + .../amazfitgtr2/AmazfitGTR2Coordinator.java | 1 + .../amazfitgtr2/AmazfitGTR2eCoordinator.java | 1 + .../amazfitgts/AmazfitGTSCoordinator.java | 1 + .../amazfitgts2/AmazfitGTS2Coordinator.java | 1 + .../AmazfitGTS2MiniCoordinator.java | 1 + .../amazfitgts2/AmazfitGTS2eCoordinator.java | 1 + .../amazfitneo/AmazfitNeoCoordinator.java | 1 + .../amazfittrex/AmazfitTRexCoordinator.java | 1 + .../AmazfitTRexProCoordinator.java | 1 + .../AmazfitVergeLCoordinator.java | 1 + .../huami/amazfitx/AmazfitXCoordinator.java | 1 + .../huami/miband2/MiBand2Coordinator.java | 1 + .../huami/miband2/MiBand2HRXCoordinator.java | 1 + .../huami/miband3/MiBand3Coordinator.java | 1 + .../huami/miband4/MiBand4Coordinator.java | 1 + .../huami/miband5/MiBand5Coordinator.java | 1 + .../huami/miband6/MiBand6Coordinator.java | 1 + .../devices/huami/zeppe/ZeppECoordinator.java | 1 + .../service/devices/huami/HuamiSupport.java | 62 ++++++++++--------- .../amazfitband5/AmazfitBand5Support.java | 17 ----- .../huami/amazfitbip/AmazfitBipSupport.java | 7 ++- .../amazfitgtr/AmazfitGTRLiteSupport.java | 6 +- .../devices/huami/miband3/MiBand3Support.java | 21 +++---- .../devices/huami/miband4/MiBand4Support.java | 16 ++++- .../devices/huami/miband5/MiBand5Support.java | 6 +- app/src/main/res/values/strings.xml | 2 + ...tings_overwrite_settings_on_connection.xml | 9 +++ 38 files changed, 114 insertions(+), 65 deletions(-) create mode 100644 app/src/main/res/xml/devicesettings_overwrite_settings_on_connection.xml diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiCoordinator.java index c57d1a130..311737ac0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiCoordinator.java @@ -347,6 +347,11 @@ public abstract class HuamiCoordinator extends AbstractBLEDeviceCoordinator { return prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_BT_CONNECTED_ADVERTISEMENT, false); } + public static boolean getOverwriteSettingsOnConnection(String deviceAddress) { + Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(deviceAddress)); + return prefs.getBoolean("overwrite_settings_on_connection", true); + } + public static VibrationProfile getVibrationProfile(String deviceAddress, HuamiVibrationPatternNotificationType notificationType) { final String defaultVibrationProfileId; final int defaultVibrationCount; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband5/AmazfitBand5Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband5/AmazfitBand5Coordinator.java index 5ffa3bcb0..0a565c71b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband5/AmazfitBand5Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband5/AmazfitBand5Coordinator.java @@ -119,6 +119,7 @@ public class AmazfitBand5Coordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipCoordinator.java index 19413d34c..15b9a7c69 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipCoordinator.java @@ -94,6 +94,7 @@ public class AmazfitBipCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_buttonactions_with_longpress, R.xml.devicesettings_device_actions, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipLiteCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipLiteCoordinator.java index c78dc1504..a0e0211bb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipLiteCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipLiteCoordinator.java @@ -84,6 +84,7 @@ public class AmazfitBipLiteCoordinator extends AmazfitBipCoordinator { R.xml.devicesettings_buttonactions_with_longpress, R.xml.devicesettings_device_actions, R.xml.devicesettings_relax_firmware_checks, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbips/AmazfitBipSCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbips/AmazfitBipSCoordinator.java index 659656300..f49dfb514 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbips/AmazfitBipSCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbips/AmazfitBipSCoordinator.java @@ -110,6 +110,7 @@ public class AmazfitBipSCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_high_mtu, R.xml.devicesettings_device_actions, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipu/AmazfitBipUCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipu/AmazfitBipUCoordinator.java index 2c6d59716..fdcf1c603 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipu/AmazfitBipUCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipu/AmazfitBipUCoordinator.java @@ -125,6 +125,7 @@ public class AmazfitBipUCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_high_mtu, R.xml.devicesettings_device_actions, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipupro/AmazfitBipUProCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipupro/AmazfitBipUProCoordinator.java index 5d385fdd0..ae60e1b19 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipupro/AmazfitBipUProCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipupro/AmazfitBipUProCoordinator.java @@ -122,6 +122,7 @@ public class AmazfitBipUProCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_high_mtu, R.xml.devicesettings_device_actions, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor/AmazfitCorCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor/AmazfitCorCoordinator.java index afb6929fa..34a9329c1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor/AmazfitCorCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor/AmazfitCorCoordinator.java @@ -102,6 +102,7 @@ public class AmazfitCorCoordinator extends HuamiCoordinator { R.xml.devicesettings_reserve_reminders_calendar, R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor2/AmazfitCor2Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor2/AmazfitCor2Coordinator.java index 46ca33651..d8a670a5f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor2/AmazfitCor2Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor2/AmazfitCor2Coordinator.java @@ -104,6 +104,7 @@ public class AmazfitCor2Coordinator extends HuamiCoordinator { R.xml.devicesettings_reserve_reminders_calendar, R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr/AmazfitGTRCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr/AmazfitGTRCoordinator.java index 3b01b97aa..22f9bc33d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr/AmazfitGTRCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr/AmazfitGTRCoordinator.java @@ -103,6 +103,7 @@ public class AmazfitGTRCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr/AmazfitGTRLiteCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr/AmazfitGTRLiteCoordinator.java index 25f20dde6..77d6cb892 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr/AmazfitGTRLiteCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr/AmazfitGTRLiteCoordinator.java @@ -102,6 +102,7 @@ public class AmazfitGTRLiteCoordinator extends HuamiCoordinator { R.xml.devicesettings_reserve_reminders_calendar, R.xml.devicesettings_expose_hr_thirdparty, R.xml.devicesettings_bt_connected_advertisement, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr2/AmazfitGTR2Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr2/AmazfitGTR2Coordinator.java index 7ca88a74f..8702a2ffd 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr2/AmazfitGTR2Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr2/AmazfitGTR2Coordinator.java @@ -109,6 +109,7 @@ public class AmazfitGTR2Coordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr2/AmazfitGTR2eCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr2/AmazfitGTR2eCoordinator.java index ee7036c6f..1f3186712 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr2/AmazfitGTR2eCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr2/AmazfitGTR2eCoordinator.java @@ -109,6 +109,7 @@ public class AmazfitGTR2eCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts/AmazfitGTSCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts/AmazfitGTSCoordinator.java index b594737ef..1a2874a7b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts/AmazfitGTSCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts/AmazfitGTSCoordinator.java @@ -103,6 +103,7 @@ public class AmazfitGTSCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2Coordinator.java index 26fd55e1e..dfde1558b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2Coordinator.java @@ -109,6 +109,7 @@ public class AmazfitGTS2Coordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2MiniCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2MiniCoordinator.java index 91bbe1668..c6f3d745a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2MiniCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2MiniCoordinator.java @@ -78,6 +78,7 @@ public class AmazfitGTS2MiniCoordinator extends AmazfitGTS2Coordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2eCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2eCoordinator.java index 5517fa589..ef1c4132b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2eCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts2/AmazfitGTS2eCoordinator.java @@ -109,6 +109,7 @@ public class AmazfitGTS2eCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitneo/AmazfitNeoCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitneo/AmazfitNeoCoordinator.java index 2c0318a41..1e8adde31 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitneo/AmazfitNeoCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitneo/AmazfitNeoCoordinator.java @@ -102,6 +102,7 @@ public class AmazfitNeoCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex/AmazfitTRexCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex/AmazfitTRexCoordinator.java index 63487a9da..6d3c1f64a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex/AmazfitTRexCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex/AmazfitTRexCoordinator.java @@ -103,6 +103,7 @@ public class AmazfitTRexCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexpro/AmazfitTRexProCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexpro/AmazfitTRexProCoordinator.java index d9cbbee72..d280e30ea 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexpro/AmazfitTRexProCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexpro/AmazfitTRexProCoordinator.java @@ -103,6 +103,7 @@ public class AmazfitTRexProCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitvergel/AmazfitVergeLCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitvergel/AmazfitVergeLCoordinator.java index f3a7d74de..53b7c3314 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitvergel/AmazfitVergeLCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitvergel/AmazfitVergeLCoordinator.java @@ -103,6 +103,7 @@ public class AmazfitVergeLCoordinator extends HuamiCoordinator { R.xml.devicesettings_disconnectnotification, R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_buttonactions_with_longpress, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitx/AmazfitXCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitx/AmazfitXCoordinator.java index 9238b83c2..0fd325b8c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitx/AmazfitXCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitx/AmazfitXCoordinator.java @@ -109,6 +109,7 @@ public class AmazfitXCoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2Coordinator.java index e2319caaa..a19b7c92d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2Coordinator.java @@ -94,6 +94,7 @@ public class MiBand2Coordinator extends HuamiCoordinator { R.xml.devicesettings_buttonactions, R.xml.devicesettings_reserve_alarms_calendar, R.xml.devicesettings_bt_connected_advertisement, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2HRXCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2HRXCoordinator.java index 8dd87738a..9e130f1f2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2HRXCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2HRXCoordinator.java @@ -96,6 +96,7 @@ public class MiBand2HRXCoordinator extends HuamiCoordinator { R.xml.devicesettings_liftwrist_display, R.xml.devicesettings_inactivity_dnd, R.xml.devicesettings_rotatewrist_cycleinfo, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3Coordinator.java index 8b07fddc6..b0cbdfea4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3Coordinator.java @@ -118,6 +118,7 @@ public class MiBand3Coordinator extends HuamiCoordinator { R.xml.devicesettings_expose_hr_thirdparty, R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java index 6d35b0f6c..533f836b9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java @@ -114,6 +114,7 @@ public class MiBand4Coordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband5/MiBand5Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband5/MiBand5Coordinator.java index 310c6186d..8d5d90651 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband5/MiBand5Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband5/MiBand5Coordinator.java @@ -128,6 +128,7 @@ public class MiBand5Coordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband6/MiBand6Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband6/MiBand6Coordinator.java index c71a96bad..2f870cbc0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband6/MiBand6Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband6/MiBand6Coordinator.java @@ -109,6 +109,7 @@ public class MiBand6Coordinator extends HuamiCoordinator { R.xml.devicesettings_reserve_reminders_calendar, R.xml.devicesettings_expose_hr_thirdparty, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppe/ZeppECoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppe/ZeppECoordinator.java index 69369e3f8..325b7bf48 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppe/ZeppECoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppe/ZeppECoordinator.java @@ -102,6 +102,7 @@ public class ZeppECoordinator extends HuamiCoordinator { R.xml.devicesettings_bt_connected_advertisement, R.xml.devicesettings_device_actions, R.xml.devicesettings_high_mtu, + R.xml.devicesettings_overwrite_settings_on_connection, R.xml.devicesettings_transliteration }; } 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 ac7dbf8ca..27efd4710 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 @@ -4024,36 +4024,40 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice); LOG.info("phase3Initialize..."); - setDateDisplay(builder); - setTimeFormat(builder); - setUserInfo(builder); - setDistanceUnit(builder); - setWearLocation(builder); - setFitnessGoal(builder); - setDisplayItems(builder); - setDoNotDisturb(builder); - setRotateWristToSwitchInfo(builder); - setActivateDisplayOnLiftWrist(builder); - setDisplayCaller(builder); - setGoalNotification(builder); - setInactivityWarnings(builder); - setHourlyChime(builder); - setHeartrateSleepSupport(builder); - setHeartrateActivityMonitoring(builder); - setHeartrateAlert(builder); - setHeartrateStressMonitoring(builder); - setDisconnectNotification(builder); - setExposeHRThirdParty(builder); - setHeartrateMeasurementInterval(builder, HuamiCoordinator.getHeartRateMeasurementInterval(getDevice().getAddress())); - sendReminders(builder); - setWorldClocks(builder); - for (final HuamiVibrationPatternNotificationType type : HuamiVibrationPatternNotificationType.values()) { - final String typeKey = type.name().toLowerCase(Locale.ROOT); - setVibrationPattern(builder, HuamiConst.PREF_HUAMI_VIBRATION_PROFILE_PREFIX + typeKey); - } - if (!PasswordCapabilityImpl.Mode.NONE.equals(coordinator.getPasswordCapability())) { - setPassword(builder); + + if (HuamiCoordinator.getOverwriteSettingsOnConnection(getDevice().getAddress())) { + setDateDisplay(builder); + setTimeFormat(builder); + setUserInfo(builder); + setDistanceUnit(builder); + setWearLocation(builder); + setFitnessGoal(builder); + setDisplayItems(builder); + setDoNotDisturb(builder); + setRotateWristToSwitchInfo(builder); + setActivateDisplayOnLiftWrist(builder); + setDisplayCaller(builder); + setGoalNotification(builder); + setInactivityWarnings(builder); + setHourlyChime(builder); + setHeartrateSleepSupport(builder); + setHeartrateActivityMonitoring(builder); + setHeartrateAlert(builder); + setHeartrateStressMonitoring(builder); + setDisconnectNotification(builder); + setExposeHRThirdParty(builder); + setHeartrateMeasurementInterval(builder, HuamiCoordinator.getHeartRateMeasurementInterval(getDevice().getAddress())); + sendReminders(builder); + setWorldClocks(builder); + for (final HuamiVibrationPatternNotificationType type : HuamiVibrationPatternNotificationType.values()) { + final String typeKey = type.name().toLowerCase(Locale.ROOT); + setVibrationPattern(builder, HuamiConst.PREF_HUAMI_VIBRATION_PROFILE_PREFIX + typeKey); + } + if (!PasswordCapabilityImpl.Mode.NONE.equals(coordinator.getPasswordCapability())) { + setPassword(builder); + } } + requestAlarms(builder); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband5/AmazfitBand5Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband5/AmazfitBand5Support.java index 6b3a410de..d844e8ceb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband5/AmazfitBand5Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband5/AmazfitBand5Support.java @@ -19,9 +19,6 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband5; import android.content.Context; import android.net.Uri; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.IOException; import nodomain.freeyourgadget.gadgetbridge.R; @@ -31,8 +28,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband5.MiBand5Support; public class AmazfitBand5Support extends MiBand5Support { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitBand5Support.class); - @Override protected AmazfitBand5Support setDisplayItems(TransactionBuilder builder) { setDisplayItemsNew(builder, false, true, R.array.pref_amazfitband5_display_items_default); @@ -49,16 +44,4 @@ public class AmazfitBand5Support extends MiBand5Support { public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException { return new AmazfitBand5FWHelper(uri, context); } - @Override - public boolean supportsSunriseSunsetWindHumidity() { - return true; - } - - @Override - public void phase3Initialize(TransactionBuilder builder) { - super.phase3Initialize(builder); - LOG.info("phase3Initialize..."); - setActivateDisplayOnLiftWristSensitivity(builder); // TODO? Move this to HuamiSupport? - setWorkoutActivityTypes(builder); // TODO: Supported by other bands? - } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipSupport.java index bf1d0ef9b..f210ad2e6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipSupport.java @@ -28,6 +28,7 @@ import java.util.LinkedHashMap; import java.util.Map; import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipFWHelper; import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; @@ -109,7 +110,11 @@ public class AmazfitBipSupport extends HuamiSupport { public void phase2Initialize(TransactionBuilder builder) { super.phase2Initialize(builder); LOG.info("phase2Initialize..."); - setLanguage(builder); + + if (HuamiCoordinator.getOverwriteSettingsOnConnection(getDevice().getAddress())) { + setLanguage(builder); + } + requestGPSVersion(builder); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr/AmazfitGTRLiteSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr/AmazfitGTRLiteSupport.java index 9c1be69cb..ae0e8d05d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr/AmazfitGTRLiteSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr/AmazfitGTRLiteSupport.java @@ -21,6 +21,7 @@ import android.net.Uri; import java.io.IOException; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr.AmazfitGTRLiteFWHelper; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; @@ -40,7 +41,10 @@ public class AmazfitGTRLiteSupport extends AmazfitGTSSupport { @Override public void phase2Initialize(TransactionBuilder builder) { super.phase2Initialize(builder); - setLanguage(builder); + + if (HuamiCoordinator.getOverwriteSettingsOnConnection(getDevice().getAddress())) { + setLanguage(builder); + } } @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband3/MiBand3Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband3/MiBand3Support.java index f1cd8257c..be62b79c2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband3/MiBand3Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband3/MiBand3Support.java @@ -18,31 +18,22 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband3; import android.content.Context; import android.net.Uri; -import android.widget.Toast; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; import java.util.LinkedHashMap; import java.util.Map; import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband3.MiBand3Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband3.MiBand3FWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband3.MiBand3Service; -import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipSupport; -import nodomain.freeyourgadget.gadgetbridge.util.GB; public class MiBand3Support extends AmazfitBipSupport { - private static final Logger LOG = LoggerFactory.getLogger(MiBand3Support.class); @Override @@ -70,10 +61,12 @@ public class MiBand3Support extends AmazfitBipSupport { public void phase2Initialize(TransactionBuilder builder) { super.phase2Initialize(builder); LOG.info("phase2Initialize..."); - setLanguage(builder); - setBandScreenUnlock(builder); - setNightMode(builder); - setDateFormat(builder); + if (HuamiCoordinator.getOverwriteSettingsOnConnection(getDevice().getAddress())) { + setLanguage(builder); + setBandScreenUnlock(builder); + setNightMode(builder); + setDateFormat(builder); + } } @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband4/MiBand4Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband4/MiBand4Support.java index 24e9b8cad..6da5e95a5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband4/MiBand4Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband4/MiBand4Support.java @@ -19,16 +19,21 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband4; import android.content.Context; import android.net.Uri; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.IOException; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband4.MiBand4FWHelper; -import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec; +import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband3.MiBand3Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperationNew; public class MiBand4Support extends MiBand3Support { + private static final Logger LOG = LoggerFactory.getLogger(MiBand4Support.class); @Override public byte getCryptFlags() { @@ -49,4 +54,13 @@ public class MiBand4Support extends MiBand3Support { public UpdateFirmwareOperation createUpdateFirmwareOperation(Uri uri) { return new UpdateFirmwareOperationNew(uri, this); } + + @Override + public void phase3Initialize(TransactionBuilder builder) { + super.phase3Initialize(builder); + LOG.info("phase3Initialize..."); + if (HuamiCoordinator.getOverwriteSettingsOnConnection(getDevice().getAddress())) { + setActivateDisplayOnLiftWristSensitivity(builder); // TODO? Move this to HuamiSupport? + } + } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband5/MiBand5Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband5/MiBand5Support.java index e38fd3861..99b3ca1b6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband5/MiBand5Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband5/MiBand5Support.java @@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband5.MiBand5FWHelper; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; @@ -64,7 +65,8 @@ public class MiBand5Support extends MiBand4Support { public void phase3Initialize(TransactionBuilder builder) { super.phase3Initialize(builder); LOG.info("phase3Initialize..."); - setActivateDisplayOnLiftWristSensitivity(builder); // TODO? Move this to HuamiSupport? - setWorkoutActivityTypes(builder); // TODO: Supported by other bands? + if (HuamiCoordinator.getOverwriteSettingsOnConnection(getDevice().getAddress())) { + setWorkoutActivityTypes(builder); // TODO: Supported by other bands? + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0598bf629..c9c14dc71 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -304,6 +304,8 @@ Enable this if your device has a custom font firmware for emoji support Allow high MTU Increases transfer speed, but might not work on some Android devices. + Overwrite settings on connection + When connecting to the band, overwrite all the settings on it. Allow Internet Access Allow apps on this device to access the internet Allow Intents diff --git a/app/src/main/res/xml/devicesettings_overwrite_settings_on_connection.xml b/app/src/main/res/xml/devicesettings_overwrite_settings_on_connection.xml new file mode 100644 index 000000000..114410b30 --- /dev/null +++ b/app/src/main/res/xml/devicesettings_overwrite_settings_on_connection.xml @@ -0,0 +1,9 @@ + + + +