1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-04 09:17:29 +01:00

Amazfit Bip: add manual language selection

This commit is contained in:
Andreas Shimokawa 2017-11-01 23:32:54 +01:00
parent e2546f772a
commit dd440f51df
4 changed files with 53 additions and 7 deletions

View File

@ -31,6 +31,7 @@ import java.util.Locale;
import java.util.SimpleTimeZone;
import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiWeatherConditions;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipFWHelper;
@ -229,15 +230,28 @@ public class AmazfitBipSupport extends MiBand2Support {
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 {
switch (GBApplication.getPrefs().getInt("amazfitbip_language", -1)) {
case 0:
command = AmazfitBipService.COMMAND_SET_LANGUAGE_SIMPLIFIED_CHINESE;
}
} else {
command = AmazfitBipService.COMMAND_SET_LANGUAGE_ENGLISH;
break;
case 1:
command = AmazfitBipService.COMMAND_SET_LANGUAGE_TRADITIONAL_CHINESE;
break;
case 2:
command = AmazfitBipService.COMMAND_SET_LANGUAGE_ENGLISH;
break;
default:
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;
}

View File

@ -202,4 +202,18 @@
<item>@string/p_call_privacy_mode_complete</item>
</string-array>
<string-array name="pref_amazfitbip_language">
<item name="-1">@string/automatic</item>
<item name="0">@string/simplified_chinese</item>
<item name="1">@string/traditional_chinese</item>
<item name="2">@string/english</item>
</string-array>
<string-array name="pref_amazfitbip_language_values">
<item>-1</item>
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
</resources>

View File

@ -226,6 +226,7 @@
<string name="message_cannot_pair_no_mac">No MAC address passed, cannot pair.</string>
<string name="preferences_category_device_specific_settings">Device specific settings</string>
<string name="preferences_miband_settings">Mi Band / Amazfit settings</string>
<string name="preferences_amazfitbip_settings">Amazfit Bip settings</string>
<string name="male">Male</string>
<string name="female">Female</string>
<string name="other">Other</string>
@ -386,6 +387,12 @@
<string name="mi2_prefs_inactivity_warnings_dnd_summary">Disable the inactivity warnings for a time interval</string>
<string name="mi2_prefs_do_not_disturb_start">Start time</string>
<string name="mi2_prefs_do_not_disturb_end">End time</string>
<string name="automatic">Automatic</string>
<string name="simplified_chinese">Simplified Chinese</string>
<string name="traditional_chinese">Traditional Chinese</string>
<string name="english">English</string>
<string name="FetchActivityOperation_about_to_transfer_since">About to transfer data since %1$s</string>
<string name="waiting_for_reconnect">Waiting for reconnect</string>

View File

@ -178,6 +178,17 @@
android:icon="@drawable/ic_device_miband"
android:key="pref_key_miband"
android:title="@string/preferences_miband_settings" />
<PreferenceScreen
android:icon="@drawable/ic_device_hplus"
android:title="@string/preferences_amazfitbip_settings">
<ListPreference
android:defaultValue="-1"
android:entries="@array/pref_amazfitbip_language"
android:entryValues="@array/pref_amazfitbip_language_values"
android:key="amazfitbip_language"
android:summary="%s"
android:title="@string/pref_title_language" />
</PreferenceScreen>
<PreferenceScreen
android:icon="@drawable/ic_device_pebble"
android:key="pref_key_pebble"