diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiLanguageType.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiLanguageType.java
new file mode 100644
index 000000000..c021e46f6
--- /dev/null
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiLanguageType.java
@@ -0,0 +1,44 @@
+/* Copyright (C) 2020-2021 Andreas Shimokawa, TinfoilSubmarine
+
+ This file is part of Gadgetbridge.
+
+ Gadgetbridge is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Gadgetbridge is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see . */
+package nodomain.freeyourgadget.gadgetbridge.service.devices.huami;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class HuamiLanguageType {
+ public static final Map idLookup = new HashMap() {{
+ put("zh_CN", 0x00);
+ put("zh_TW", 0x01);
+ put("zh_HK", 0x01);
+ put("en_US", 0x02);
+ put("en_GB", 0x02);
+ put("en_AU", 0x02);
+ put("es_ES", 0x03);
+ put("ru_RU", 0x04);
+ put("ko_KO", 0x05);
+ put("fr_FR", 0x06);
+ put("de_DE", 0x07);
+ put("de_AT", 0x07);
+ put("de_CH", 0x07);
+ put("pl_PL", 0x09);
+ put("it_IT", 0x0a);
+ put("pt_PT", 0x0f);
+ put("tr_TR", 0x11);
+ put("pt_BR", 0x14);
+ put("cs_CZ", 0x16);
+ }};
+}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipu/AmazfitBipUSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipu/AmazfitBipUSupport.java
index 449bcd3e1..f6ec6dd7d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipu/AmazfitBipUSupport.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipu/AmazfitBipUSupport.java
@@ -21,15 +21,42 @@ import android.content.Context;
import android.net.Uri;
import java.io.IOException;
+import java.util.Locale;
+import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbipu.AmazfitBipUFWHelper;
+import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
+import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiLanguageType;
+import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2020;
public class AmazfitBipUSupport extends AmazfitBipSSupport {
+ @Override
+ protected HuamiSupport setLanguage(TransactionBuilder builder) {
+ byte language_code = 0x02; // english default
+
+ String localeString = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString("language", "auto");
+ if (localeString == null || localeString.equals("auto")) {
+ String language = Locale.getDefault().getLanguage();
+ String country = Locale.getDefault().getCountry();
+
+ localeString = language + "_" + country.toUpperCase();
+ }
+
+ Integer id = HuamiLanguageType.idLookup.get(localeString);
+ if (id != null) {
+ language_code = id.byteValue();
+ }
+
+ final byte[] command = new byte[]{0x06, 0x3b, 0x00, language_code, 0x03};
+ writeToConfiguration(builder, command);
+ return this;
+ }
+
@Override
public boolean supportsSunriseSunsetWindHumidity() {
return true;
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipupro/AmazfitBipUProSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipupro/AmazfitBipUProSupport.java
index 098d91938..b8a237a63 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipupro/AmazfitBipUProSupport.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipupro/AmazfitBipUProSupport.java
@@ -24,29 +24,12 @@ import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbipupro.AmazfitBipUProFWHelper;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSSupport;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2020;
+import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbipu.AmazfitBipUSupport;
-public class AmazfitBipUProSupport extends AmazfitBipSSupport {
-
- @Override
- public boolean supportsSunriseSunsetWindHumidity() {
- return true;
- }
+public class AmazfitBipUProSupport extends AmazfitBipUSupport {
@Override
public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
return new AmazfitBipUProFWHelper(uri, context);
}
-
- @Override
- public UpdateFirmwareOperation createUpdateFirmwareOperation(Uri uri) {
- return new UpdateFirmwareOperation2020(uri, this);
- }
-
- @Override
- public int getActivitySampleSize() {
- return 8;
- }
}