mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 05:16:51 +01:00
Amazfit GTS2 mini: Fix language selection
This commit is contained in:
parent
2e8f44cd85
commit
a917d3786f
@ -2907,6 +2907,30 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
Some newer devices seem to support setting the language by id again instead of a locale string
|
||||
Amazfit Bip U and GTS 2 mini tested so far
|
||||
*/
|
||||
protected HuamiSupport setLanguageByIdNew(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;
|
||||
}
|
||||
|
||||
private HuamiSupport setExposeHRThridParty(TransactionBuilder builder) {
|
||||
boolean enable = HuamiCoordinator.getExposeHRThirdParty(gbDevice.getAddress());
|
||||
|
@ -21,13 +21,10 @@ 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;
|
||||
@ -37,24 +34,7 @@ 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;
|
||||
return setLanguageByIdNew(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,9 +24,16 @@ import java.io.IOException;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts2.AmazfitGTS2MiniFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport;
|
||||
|
||||
public class AmazfitGTS2MiniSupport extends AmazfitGTS2Support {
|
||||
|
||||
@Override
|
||||
protected HuamiSupport setLanguage(TransactionBuilder builder) {
|
||||
return setLanguageByIdNew(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
|
||||
return new AmazfitGTS2MiniFWHelper(uri, context);
|
||||
|
Loading…
Reference in New Issue
Block a user