mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
ZeTime: Fix setting the watch language and make the setting accessible from the per-device configuration menu
This did not work at all before, it was supposed to take the language from Gadgetbridge App settings or the phone's default settings, but nothing was ever sent to the watch.
This commit is contained in:
parent
ad1e519723
commit
fefcf2d2b9
@ -17,6 +17,7 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities.devicesettings;
|
||||
|
||||
public class DeviceSettingsPreferenceConst {
|
||||
public static final String PREF_LANGUAGE = "language";
|
||||
public static final String PREF_DATEFORMAT = "dateformat";
|
||||
public static final String PREF_TIMEFORMAT = "timeformat";
|
||||
public static final String PREF_WEARLOCATION = "wearlocation";
|
||||
|
@ -39,25 +39,26 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.XTimePreference;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.XTimePreferenceFragment;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALTITUDE_CALIBRATE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BUTTON_1_FUNCTION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BUTTON_2_FUNCTION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BUTTON_3_FUNCTION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BUTTON_BP_CALIBRATE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DATEFORMAT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DISCONNECTNOTIF_NOSHED;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HYBRID_HR_DRAW_WIDGET_CIRCLES;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HYBRID_HR_FORCE_WHITE_COLOR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HYBRID_HR_SAVE_RAW_ACTIVITY_FILES;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_LANGUAGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_LIFTWRIST_NOSHED;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DISCONNECTNOTIF_NOSHED;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_POWER_MODE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BUTTON_BP_CALIBRATE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALTITUDE_CALIBRATE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_LONGSIT_PERIOD;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_LONGSIT_SWITCH;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_POWER_MODE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SCREEN_ORIENTATION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_VIBRATION_STRENGH_PERCENTAGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_NOAUTO;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION_END;
|
||||
@ -66,7 +67,6 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISPLAY_ON_LIFT_END;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISPLAY_ON_LIFT_START;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_EXPOSE_HR_THIRDPARTY;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_LANGUAGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB_END;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_DO_NOT_DISTURB_OFF;
|
||||
|
@ -59,7 +59,6 @@ public class HuamiConst {
|
||||
public static final String PREF_DISCONNECT_NOTIFICATION_END = "disconnect_notification_end";
|
||||
|
||||
public static final String PREF_DISPLAY_ITEMS = "display_items";
|
||||
public static final String PREF_LANGUAGE = "language";
|
||||
public static final String PREF_EXPOSE_HR_THIRDPARTY = "expose_hr_thirdparty";
|
||||
public static final String PREF_USE_CUSTOM_FONT = "use_custom_font";
|
||||
|
||||
|
@ -163,6 +163,7 @@ public class ZeTimeCoordinator extends AbstractDeviceCoordinator {
|
||||
@Override
|
||||
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
||||
return new int[]{
|
||||
R.xml.devicesettings_zetime,
|
||||
R.xml.devicesettings_timeformat,
|
||||
R.xml.devicesettings_wearlocation,
|
||||
};
|
||||
|
@ -136,6 +136,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.Version;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALLOW_HIGH_MTU;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DATEFORMAT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_LANGUAGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SYNC_CALENDAR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
|
||||
@ -1829,7 +1830,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
case PREF_DATEFORMAT:
|
||||
setDateFormat(builder);
|
||||
break;
|
||||
case HuamiConst.PREF_LANGUAGE:
|
||||
case PREF_LANGUAGE:
|
||||
setLanguage(builder);
|
||||
break;
|
||||
case HuamiConst.PREF_EXPOSE_HR_THIRDPARTY:
|
||||
|
@ -154,6 +154,9 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
case DeviceSettingsPreferenceConst.PREF_WEARLOCATION:
|
||||
setWrist(builder);
|
||||
break;
|
||||
case DeviceSettingsPreferenceConst.PREF_LANGUAGE:
|
||||
setLanguage(builder);
|
||||
break;
|
||||
case ZeTimeConstants.PREF_SCREENTIME:
|
||||
setScreenTime(builder);
|
||||
break;
|
||||
@ -2154,33 +2157,36 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
private void setLanguage(TransactionBuilder builder) {
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
String language = prefs.getString("language", "default");
|
||||
Locale locale;
|
||||
String localeString = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_LANGUAGE, "auto");
|
||||
|
||||
byte[] languageMsg = {
|
||||
ZeTimeConstants.CMD_PREAMBLE,
|
||||
ZeTimeConstants.CMD_LANGUAGE_SETTINGS,
|
||||
ZeTimeConstants.CMD_REQUEST,
|
||||
ZeTimeConstants.CMD_SEND,
|
||||
(byte) 0x1,
|
||||
(byte) 0x0,
|
||||
(byte) 0x0,
|
||||
ZeTimeConstants.CMD_END
|
||||
};
|
||||
|
||||
if (language == null || language.equals("default")) {
|
||||
locale = Locale.getDefault();
|
||||
language = locale.getLanguage();
|
||||
if (localeString == null || 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();
|
||||
}
|
||||
|
||||
switch (language) {
|
||||
switch (localeString.substring(0, 2)) {
|
||||
case "zh":
|
||||
languageMsg[5] = 1;
|
||||
break;
|
||||
case "tw":
|
||||
case "hk":
|
||||
case "mo":
|
||||
languageMsg[5] = 2;
|
||||
if (localeString.equals("zh_CN")) {
|
||||
languageMsg[5] = 1;
|
||||
} else {
|
||||
languageMsg[5] = 2;
|
||||
}
|
||||
break;
|
||||
case "ko":
|
||||
languageMsg[5] = 3;
|
||||
@ -2225,5 +2231,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
default:
|
||||
languageMsg[5] = 0;
|
||||
}
|
||||
sendMsgToWatch(builder, languageMsg);
|
||||
}
|
||||
}
|
||||
|
@ -551,6 +551,46 @@
|
||||
<item>ko_KO</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_zetime_language">
|
||||
<item name="auto">@string/automatic</item>
|
||||
<item name="zh_CN">@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="de_DE">@string/german</item>
|
||||
<item name="it_IT">@string/italian</item>
|
||||
<item name="fr_FR">@string/french</item>
|
||||
<item name="pt_PT">@string/portuguese</item>
|
||||
<item name="nl_NL">@string/dutch</item>
|
||||
<item name="hu_HU">@string/hungarian</item>
|
||||
<item name="ro_RO">@string/romanian</item>
|
||||
<item name="pl_PL">@string/polish</item>
|
||||
<item name="ru_RU">@string/russian</item>
|
||||
<item name="ja_JP">@string/japanese</item>
|
||||
<item name="ko_KO">@string/korean</item>
|
||||
<item name="th_TH">@string/thai</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_zetime_language_values">
|
||||
<item>auto</item>
|
||||
<item>zh_CN</item>
|
||||
<item>zh_TW</item>
|
||||
<item>en_US</item>
|
||||
<item>es_ES</item>
|
||||
<item>de_DE</item>
|
||||
<item>it_IT</item>
|
||||
<item>fr_FR</item>
|
||||
<item>pt_PT</item>
|
||||
<item>nl_NL</item>
|
||||
<item>hu_HU</item>
|
||||
<item>ro_RO</item>
|
||||
<item>pl_PL</item>
|
||||
<item>ru_RU</item>
|
||||
<item>ja_JP</item>
|
||||
<item>ko_KO</item>
|
||||
<item>th_TH</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="prefs_heartrate_measurement_interval">
|
||||
<item name="0">@string/off</item>
|
||||
<item name="60">@string/interval_one_minute</item>
|
||||
|
@ -558,6 +558,8 @@
|
||||
<string name="thai">Thai</string>
|
||||
<string name="vietnamese">Vietnamese</string>
|
||||
<string name="portuguese">Portuguese</string>
|
||||
<string name="romanian">Romanian</string>
|
||||
<string name="hungarian">Hungarian</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>
|
||||
<string name="activity_prefs_about_you">About you</string>
|
||||
|
11
app/src/main/res/xml/devicesettings_zetime.xml
Normal file
11
app/src/main/res/xml/devicesettings_zetime.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_language"
|
||||
android:defaultValue="auto"
|
||||
android:entries="@array/pref_zetime_language"
|
||||
android:entryValues="@array/pref_zetime_language_values"
|
||||
android:key="language"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_title_language" />
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user