diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsActivity.java
index dcfa9bce1..87afb872d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsActivity.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsActivity.java
@@ -50,13 +50,20 @@ public class DeviceSettingsActivity extends AbstractGBActivity implements
if (fragment == null) {
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
int[] supportedSettings = coordinator.getSupportedDeviceSpecificSettings(device);
+ String[] supportedLanguages = coordinator.getSupportedLanguageSettings(device);
+
+ if (supportedLanguages != null) {
+ supportedSettings = ArrayUtils.insert(0, supportedSettings, R.xml.devicesettings_language_generic);
+ }
if (coordinator.supportsActivityTracking()) {
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_chartstabs);
}
+
+ // FIXME: this does not belong here
if (!ArrayUtils.contains(supportedSettings, R.xml.devicesettings_transliteration)) {
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_transliteration);
}
- fragment = DeviceSpecificSettingsFragment.newInstance(device.getAddress(), supportedSettings);
+ fragment = DeviceSpecificSettingsFragment.newInstance(device.getAddress(), supportedSettings, supportedLanguages);
}
getSupportFragmentManager()
.beginTransaction()
@@ -70,11 +77,17 @@ public class DeviceSettingsActivity extends AbstractGBActivity implements
public boolean onPreferenceStartScreen(PreferenceFragmentCompat caller, PreferenceScreen preferenceScreen) {
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
int[] supportedSettings = coordinator.getSupportedDeviceSpecificSettings(device);
+ String[] supportedLanguages = coordinator.getSupportedLanguageSettings(device);
+
+ if (supportedLanguages != null) {
+ supportedSettings = ArrayUtils.insert(0, supportedSettings, R.xml.devicesettings_language_generic);
+ }
+
if (coordinator.supportsActivityTracking()) {
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_chartstabs);
}
- PreferenceFragmentCompat fragment = DeviceSpecificSettingsFragment.newInstance(device.getAddress(), supportedSettings);
+ PreferenceFragmentCompat fragment = DeviceSpecificSettingsFragment.newInstance(device.getAddress(), supportedSettings, supportedLanguages);
Bundle args = fragment.getArguments();
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
fragment.setArguments(args);
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java
index effd93614..71ee4bfbe 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java
@@ -23,12 +23,14 @@ import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
import androidx.preference.EditTextPreference;
+import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import com.mobeta.android.dslv.DragSortListPreference;
import com.mobeta.android.dslv.DragSortListPreferenceFragment;
+import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,6 +38,7 @@ import java.util.ArrayList;
import java.util.Objects;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
+import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.makibeshr3.MakibesHR3Constants;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
@@ -145,10 +148,11 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
static final String FRAGMENT_TAG = "DEVICE_SPECIFIC_SETTINGS_FRAGMENT";
- private void setSettingsFileSuffix(String settingsFileSuffix, @NonNull int[] supportedSettings) {
+ private void setSettingsFileSuffix(String settingsFileSuffix, @NonNull int[] supportedSettings, String[] supportedLanguages) {
Bundle args = new Bundle();
args.putString("settingsFileSuffix", settingsFileSuffix);
args.putIntArray("supportedSettings", supportedSettings);
+ args.putStringArray("supportedLanguages", supportedLanguages);
setArguments(args);
}
@@ -161,6 +165,8 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
}
String settingsFileSuffix = arguments.getString("settingsFileSuffix", null);
int[] supportedSettings = arguments.getIntArray("supportedSettings");
+ String[] supportedLanguages = arguments.getStringArray("supportedLanguages");
+
if (settingsFileSuffix == null || supportedSettings == null) {
return;
}
@@ -177,6 +183,19 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
} else {
addPreferencesFromResource(setting);
}
+ if (setting == R.xml.devicesettings_language_generic) {
+ ListPreference languageListPreference = findPreference("language");
+ CharSequence[] entries = languageListPreference.getEntries();
+ CharSequence[] values = languageListPreference.getEntryValues();
+ for (int i=entries.length-1;i>=0;i--) {
+ if (!ArrayUtils.contains(supportedLanguages,values[i])) {
+ entries = ArrayUtils.remove(entries,i);
+ values = ArrayUtils.remove(values,i);
+ }
+ }
+ languageListPreference.setEntries(entries);
+ languageListPreference.setEntryValues(values);
+ }
}
} else {
// Now, this is ugly: search all the xml files for the rootKey
@@ -678,9 +697,9 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
}
}
- static DeviceSpecificSettingsFragment newInstance(String settingsFileSuffix, @NonNull int[] supportedSettings) {
+ static DeviceSpecificSettingsFragment newInstance(String settingsFileSuffix, @NonNull int[] supportedSettings, String[] supportedLanguages) {
DeviceSpecificSettingsFragment fragment = new DeviceSpecificSettingsFragment();
- fragment.setSettingsFileSuffix(settingsFileSuffix, supportedSettings);
+ fragment.setSettingsFileSuffix(settingsFileSuffix, supportedSettings, supportedLanguages);
return fragment;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java
index 25a128c2d..df3202a54 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java
@@ -236,6 +236,11 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
return null;
}
+ @Override
+ public String[] getSupportedLanguageSettings(GBDevice device) {
+ return null;
+ }
+
@Nullable
@Override
public Class extends Activity> getCalibrationActivity() {
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java
index a07416793..ce7c246fa 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java
@@ -342,4 +342,10 @@ public interface DeviceCoordinator {
* Indicates which device specific settings the device supports (not per device type or family, but unique per device).
*/
int[] getSupportedDeviceSpecificSettings(GBDevice device);
+
+ /**
+ * Indicates which device specific language the device supports
+ */
+ String[] getSupportedLanguageSettings(GBDevice device);
+
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipu/AmazfitBipUCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipu/AmazfitBipUCoordinator.java
index 55be94998..97ea091ff 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipu/AmazfitBipUCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbipu/AmazfitBipUCoordinator.java
@@ -105,6 +105,33 @@ public class AmazfitBipUCoordinator extends HuamiCoordinator {
};
}
+ @Override
+ public String[] getSupportedLanguageSettings(GBDevice device) {
+ return new String[]{
+ "auto",
+ "zh_CH",
+ "zh_TW",
+ "cs_CZ",
+ "de_DE",
+ "el_GR",
+ "en_US",
+ "es_ES",
+ "fr_FR",
+ "id_ID",
+ "it_IT",
+ "ja_JP",
+ "ko_KO",
+ "nl_NL",
+ "pl_PL",
+ "pt_BR",
+ "ru_RU",
+ "th_TH",
+ "uk_UA",
+ "vi_VN",
+ "tr_TR",
+ };
+ }
+
@Override
public int getBondingStyle() {
return BONDING_STYLE_REQUIRE_KEY;
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiLanguageType.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiLanguageType.java
index c021e46f6..3953d8080 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiLanguageType.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiLanguageType.java
@@ -34,11 +34,18 @@ public class HuamiLanguageType {
put("de_DE", 0x07);
put("de_AT", 0x07);
put("de_CH", 0x07);
+ put("id_ID", 0x08);
put("pl_PL", 0x09);
put("it_IT", 0x0a);
+ put("ja_JP", 0x0b);
+ put("th_TH", 0x0c);
+ put("vi_VN", 0x0e);
put("pt_PT", 0x0f);
+ put("nl_NL", 0x10);
put("tr_TR", 0x11);
+ put("uk_UA", 0x12);
put("pt_BR", 0x14);
put("cs_CZ", 0x16);
+ put("el_GR", 0x17);
}};
}
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 4e4ec872f..85c683784 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -1268,6 +1268,54 @@
- @string/p_call_privacy_mode_complete
+
+ - @string/automatic
+ - @string/simplified_chinese
+ - @string/traditional_chinese
+ - @string/english
+ - @string/spanish
+ - @string/german
+ - @string/italian
+ - @string/french
+ - @string/portuguese
+ - @string/dutch
+ - @string/polish
+ - @string/turkish
+ - @string/greek
+ - @string/russian
+ - @string/ukrainian
+ - @string/arabic
+ - @string/indonesian
+ - @string/thai
+ - @string/vietnamese
+ - @string/japanese
+ - @string/korean
+
+
+
+ - auto
+ - zh_CN
+ - zh_TW
+ - en_US
+ - es_ES
+ - de_DE
+ - it_IT
+ - fr_FR
+ - pt_BR
+ - nl_NL
+ - pl_PL
+ - tr_TR
+ - el_GR
+ - ru_RU
+ - uk_UA
+ - ar_SA
+ - id_ID
+ - th_TH
+ - vi_VN
+ - ja_JP
+ - ko_KO
+
+
- @string/automatic
- @string/simplified_chinese
diff --git a/app/src/main/res/xml/devicesettings_amazfitbipu.xml b/app/src/main/res/xml/devicesettings_amazfitbipu.xml
index 3356f829d..fe91aa5f0 100644
--- a/app/src/main/res/xml/devicesettings_amazfitbipu.xml
+++ b/app/src/main/res/xml/devicesettings_amazfitbipu.xml
@@ -10,12 +10,4 @@
android:persistent="true"
android:summary="@string/mi2_prefs_display_items_summary"
android:title="@string/mi2_prefs_display_items" />
-
diff --git a/app/src/main/res/xml/devicesettings_language_generic.xml b/app/src/main/res/xml/devicesettings_language_generic.xml
new file mode 100644
index 000000000..371bf3197
--- /dev/null
+++ b/app/src/main/res/xml/devicesettings_language_generic.xml
@@ -0,0 +1,11 @@
+
+
+
+