Amazfit Bip: Switch language on the watch automatically according to the phone locale

Supported:
- Simplified Chinese
- Traditional Chinese
- English
master
Andreas Shimokawa 2017-09-28 15:44:07 +02:00
parent 770c8a482d
commit 3d09b9dc97
2 changed files with 28 additions and 0 deletions

View File

@ -19,6 +19,8 @@ package nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip;
import java.util.UUID;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBand2Service.ENDPOINT_DISPLAY;
public class AmazfitBipService {
public static final UUID UUID_CHARACTERISTIC_WEATHER = UUID.fromString("0000000e-0000-3512-2118-0009af100700");
@ -26,4 +28,8 @@ public class AmazfitBipService {
public static final byte[] COMMAND_REQUEST_GPS_VERSION = new byte[]{0x0e};
public static final byte COMMAND_ACTIVITY_DATA_TYPE_DEBUGLOGS = 0x07;
public static final byte[] COMMAND_SET_LANGUAGE_SIMPLIFIED_CHINESE = new byte[]{ENDPOINT_DISPLAY, 0x13, 0x00, 0x00};
public static final byte[] COMMAND_SET_LANGUAGE_TRADITIONAL_CHINESE = new byte[]{ENDPOINT_DISPLAY, 0x13, 0x00, 0x01};
public static final byte[] COMMAND_SET_LANGUAGE_ENGLISH = new byte[]{ENDPOINT_DISPLAY, 0x13, 0x00, 0x02};
}

View File

@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Locale;
import java.util.SimpleTimeZone;
import java.util.UUID;
@ -271,10 +272,31 @@ public class AmazfitBipSupport extends MiBand2Support {
return this;
}
private AmazfitBipSupport setLanguage(TransactionBuilder builder) {
String language = Locale.getDefault().getLanguage();
String country = Locale.getDefault().getCountry();
LOG.info("Setting watch language, phone language = " + language + " country = " + country);
byte[] command;
if (language.equals("zh")) {
if (country.equals("TW") || country.equals("HK") || country.equals("MO")) { // Taiwan, Hong Kong, Macao
command = AmazfitBipService.COMMAND_SET_LANGUAGE_TRADITIONAL_CHINESE;
} else {
command = AmazfitBipService.COMMAND_SET_LANGUAGE_SIMPLIFIED_CHINESE;
}
} else {
command = AmazfitBipService.COMMAND_SET_LANGUAGE_ENGLISH;
}
builder.write(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_3_CONFIGURATION), command);
return this;
}
@Override
public void phase2Initialize(TransactionBuilder builder) {
super.phase2Initialize(builder);
LOG.info("phase2Initialize...");
setLanguage(builder);
requestGPSVersion(builder);
}
}