Mi Band 3: Support setting language to German, Italian, French, Polish, Japanese, Korean

NOTE:
- Needs latest firmware
- Setting to Japanese or Korean leads to empty menus on the device. When
  reconnecting you, will get a sceen which telling you to update. I highly
  suspect it requires flashing Mili_wuhan.ft.kj (kj=korean,japanese)
This commit is contained in:
Andreas Shimokawa 2018-08-13 00:00:46 +02:00
parent 3af7b1dd3a
commit 74f47c8e2e
7 changed files with 71 additions and 6 deletions

View File

@ -148,6 +148,7 @@ public class HuamiService {
public static final byte[] DISPLAY_YYY = new byte[] {ENDPOINT_DISPLAY, 0x10, 0x0, 0x1, 0x1 };
public static final byte[] COMMAND_DISTANCE_UNIT_METRIC = new byte[] { ENDPOINT_DISPLAY, 0x03, 0x00, 0x00 };
public static final byte[] COMMAND_DISTANCE_UNIT_IMPERIAL = new byte[] { ENDPOINT_DISPLAY, 0x03, 0x00, 0x01 };
public static final byte[] COMMAND_SET_LANGUAGE_NEW_TEMPLATE = new byte[]{ENDPOINT_DISPLAY, 0x17, 0x00, 0, 0, 0, 0, 0};
// The third byte controls the threshold, in minutes
// The last 8 bytes represent 2 separate time intervals for the inactivity warnings

View File

@ -35,8 +35,6 @@ public class AmazfitBipService {
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};
public static final byte[] COMMAND_SET_LANGUAGE_SPANISH = new byte[]{ENDPOINT_DISPLAY, 0x13, 0x00, 0x03};
public static final byte[] COMMAND_SET_LANGUAGE_NEW_TEMPLATE = new byte[]{ENDPOINT_DISPLAY, 0x17, 0x00, 0, 0, 0, 0, 0};
public static final byte COMMAND_ACTIVITY_DATA_TYPE_SPORTS_SUMMARIES = 0x05;
public static final byte COMMAND_ACTIVITY_DATA_TYPE_SPORTS_DETAILS = 0x06;

View File

@ -411,7 +411,7 @@ public class AmazfitBipSupport extends HuamiSupport {
return this;
}
private AmazfitBipSupport setLanguage(TransactionBuilder builder) {
protected AmazfitBipSupport setLanguage(TransactionBuilder builder) {
String language = Locale.getDefault().getLanguage();
String country = Locale.getDefault().getCountry();
@ -468,14 +468,13 @@ public class AmazfitBipSupport extends HuamiSupport {
break;
}
}
command_new = AmazfitBipService.COMMAND_SET_LANGUAGE_NEW_TEMPLATE;
command_new = HuamiService.COMMAND_SET_LANGUAGE_NEW_TEMPLATE.clone();
System.arraycopy(localeString.getBytes(), 0, command_new, 3, localeString.getBytes().length);
builder.add(new ConditionalWriteAction(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION)) {
@Override
protected byte[] checkCondition() {
if (gbDevice.getType() == DeviceType.MIBAND3 ||
(gbDevice.getType() == DeviceType.AMAZFITBIP && new Version(gbDevice.getFirmwareVersion()).compareTo(new Version("0.1.0.77")) >= 0) ||
if ((gbDevice.getType() == DeviceType.AMAZFITBIP && new Version(gbDevice.getFirmwareVersion()).compareTo(new Version("0.1.0.77")) >= 0) ||
(gbDevice.getType() == DeviceType.AMAZFITCOR && new Version(gbDevice.getFirmwareVersion()).compareTo(new Version("1.0.7.23")) >= 0)) {
return command_new;
} else {

View File

@ -24,6 +24,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Locale;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
@ -103,6 +104,29 @@ public class MiBand3Support extends AmazfitBipSupport {
}
}
@Override
protected MiBand3Support setLanguage(TransactionBuilder builder) {
String localeString = GBApplication.getPrefs().getString("miband3_language", "auto");
if (localeString.equals("auto")) {
String language = Locale.getDefault().getLanguage();
String country = Locale.getDefault().getCountry();
if (country == null) {
// sometimes country is null, no idea why, guess it.
country = language;
}
localeString = language + "_" + country.toUpperCase();
}
LOG.info("Setting device to locale: " + localeString);
byte[] command_new = HuamiService.COMMAND_SET_LANGUAGE_NEW_TEMPLATE.clone();
System.arraycopy(localeString.getBytes(), 0, command_new, 3, localeString.getBytes().length);
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), command_new);
return this;
}
private MiBand3Support setBandScreenUnlock(TransactionBuilder builder) {
boolean enable = MiBand3Coordinator.getBandScreenUnlock();
LOG.info("Setting band screen unlock to " + enable);

View File

@ -340,6 +340,36 @@
<item>4</item>
</string-array>
<string-array name="pref_miband3_language">
<item name="auto">@string/automatic</item>
<item name="zh_CH">@string/simplified_chinese</item>
<item name="zh_TW">@string/traditional_chinese</item>
<item name="en_US">@string/english</item>
<item name="es_ES">@string/spanish</item>
<item name="ru_RU">@string/russian</item>
<item name="de_DE">@string/german</item>
<item name="it_IT">@string/italian</item>
<item name="fr_FR">@string/french</item>
<item name="pl_PL">@string/polish</item>
<item name="ja_JP">@string/japanese</item>
<item name="ko_KO">@string/korean</item>
</string-array>
<string-array name="pref_miband3_language_values">
<item>auto</item>
<item>zh_CH</item>
<item>zh_TW</item>
<item>en_US</item>
<item>es_ES</item>
<item>ru_RU</item>
<item>de_DE</item>
<item>it_IT</item>
<item>fr_FR</item>
<item>pl_PL</item>
<item>ja_JP</item>
<item>ko_KO</item>
</string-array>
<string-array name="prefs_heartrate_measurement_interval">
<item name="0">@string/off</item>
<item name="60">@string/interval_one_minute</item>

View File

@ -434,6 +434,12 @@
<string name="english">English</string>
<string name="spanish">Spanish</string>
<string name="russian">Russian</string>
<string name="german">German</string>
<string name="italian">Italian</string>
<string name="french">French</string>
<string name="polish">Polish</string>
<string name="korean">Korean</string>
<string name="japanese">Japanese</string>
<string name="FetchActivityOperation_about_to_transfer_since">About to transfer data since %1$s</string>

View File

@ -212,6 +212,13 @@
<PreferenceScreen
android:icon="@drawable/ic_device_miband2"
android:title="@string/preferences_miband3_settings">
<ListPreference
android:defaultValue="auto"
android:entries="@array/pref_miband3_language"
android:entryValues="@array/pref_miband3_language_values"
android:key="miband3_language"
android:summary="%s"
android:title="@string/pref_title_language" />
<CheckBoxPreference
android:defaultValue="false"
android:key="mi3_band_screen_unlock"