summaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2019-12-20 10:40:34 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2020-01-22 08:47:02 +0100
commit5bf2ec9ed8728a2042e110122ea2b0e4ff55104a (patch)
treed1eee48c253ed81eba7f21b2d4b9a9a188dcdf29 /android
parentAndroid Viewer: Add German localization (diff)
downloadcore-5bf2ec9ed8728a2042e110122ea2b0e4ff55104a.tar.gz
core-5bf2ec9ed8728a2042e110122ea2b0e4ff55104a.zip
android: Use system locale by default
Instead of hard-coding the use of English as default locale and allowing manually selecting another language, this now makes the system's default locale to be used by default in the Android Viewer. It's still possible to explicitly select another language to override that. In case there is no localization for the system locale, an automatic fallback to English happens anyway, so there should be no need to explicitly set the locale to English in that case either. Change-Id: I0b8cfafea6a4659c3657522cfd5895c00f25f054 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85583 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r--android/source/res/values/arrays.xml2
-rw-r--r--android/source/res/xml/libreoffice_preferences.xml2
-rw-r--r--android/source/src/java/org/libreoffice/LibreOfficeApplication.java2
-rw-r--r--android/source/src/java/org/libreoffice/LocaleHelper.java14
-rw-r--r--android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java4
5 files changed, 14 insertions, 10 deletions
diff --git a/android/source/res/values/arrays.xml b/android/source/res/values/arrays.xml
index b1b61ef89b2f..edea6443b419 100644
--- a/android/source/res/values/arrays.xml
+++ b/android/source/res/values/arrays.xml
@@ -14,6 +14,7 @@
<item >3</item>
</string-array>
<string-array name="SupportedLanguagesValues">
+ <item>SYSTEM_DEFAULT_LANGUAGE</item>
<item >de</item>
<item >en</item>
<item >tr</item>
@@ -43,6 +44,7 @@
<item>@string/filter_drawings</item>
</string-array>
<string-array name="SupportedLanguages">
+ <item>(System Default)</item>
<item>Deutsch</item>
<item>English</item>
<item>Turkçe</item>
diff --git a/android/source/res/xml/libreoffice_preferences.xml b/android/source/res/xml/libreoffice_preferences.xml
index cf1d306866cf..d02c9d5cccbc 100644
--- a/android/source/res/xml/libreoffice_preferences.xml
+++ b/android/source/res/xml/libreoffice_preferences.xml
@@ -30,7 +30,7 @@
android:summary="@string/display_language_summary"
android:entries="@array/SupportedLanguages"
android:entryValues="@array/SupportedLanguagesValues"
- android:defaultValue="en"
+ android:defaultValue="SYSTEM_DEFAULT_LANGUAGE"
android:key="DISPLAY_LANGUAGE"
/>
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeApplication.java b/android/source/src/java/org/libreoffice/LibreOfficeApplication.java
index 07c14663860e..cb79219fc999 100644
--- a/android/source/src/java/org/libreoffice/LibreOfficeApplication.java
+++ b/android/source/src/java/org/libreoffice/LibreOfficeApplication.java
@@ -28,6 +28,6 @@ public class LibreOfficeApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
- super.attachBaseContext(LocaleHelper.onAttach(base, "en"));
+ super.attachBaseContext(LocaleHelper.onAttach(base));
}
}
diff --git a/android/source/src/java/org/libreoffice/LocaleHelper.java b/android/source/src/java/org/libreoffice/LocaleHelper.java
index 26a31e431397..8c0e9b3fbbed 100644
--- a/android/source/src/java/org/libreoffice/LocaleHelper.java
+++ b/android/source/src/java/org/libreoffice/LocaleHelper.java
@@ -12,17 +12,14 @@ import java.util.Locale;
public class LocaleHelper {
private static final String SELECTED_LANG = "org.libreoffice.selected.lang";
+ // value for language that indicates that system's default language should be used
+ public static final String SYSTEM_DEFAULT_LANGUAGE = "SYSTEM_DEFAULT_LANGUAGE";
public static Context onAttach(Context context){
String lang = getPersistedData(context, Locale.getDefault().getLanguage());
return setLocale(context, lang);
}
- public static Context onAttach(Context context, String defLang){
- String lang = getPersistedData(context, defLang);
- return setLocale(context, lang);
- }
-
public static Context setLocale(Context context, String lang) {
persist(context, lang);
return updateResources(context, lang);
@@ -30,7 +27,12 @@ public class LocaleHelper {
@SuppressWarnings("deprecation")
private static Context updateResources(Context context, String lang) {
- Locale locale = new Locale(lang);
+ Locale locale;
+ if (lang.equals(SYSTEM_DEFAULT_LANGUAGE)) {
+ locale = Locale.getDefault();
+ } else {
+ locale = new Locale(lang);
+ }
Locale.setDefault(locale);
Resources res = context.getResources();
diff --git a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
index 3fb715e46778..a9d797c4bf28 100644
--- a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -178,7 +178,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
@Override
protected void attachBaseContext(Context newBase) {
- super.attachBaseContext(LocaleHelper.onAttach(newBase,"en"));
+ super.attachBaseContext(LocaleHelper.onAttach(newBase));
}
public void createUI() {
@@ -842,7 +842,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
viewMode = Integer.valueOf(defaultPrefs.getString(EXPLORER_VIEW_TYPE_KEY, ""+ GRID_VIEW));
filterMode = Integer.valueOf(defaultPrefs.getString(FILTER_MODE_KEY , "-1"));
showHiddenFiles = defaultPrefs.getBoolean(ENABLE_SHOW_HIDDEN_FILES_KEY, false);
- displayLanguage = defaultPrefs.getString(DISPLAY_LANGUAGE, "en");
+ displayLanguage = defaultPrefs.getString(DISPLAY_LANGUAGE, LocaleHelper.SYSTEM_DEFAULT_LANGUAGE);
Intent i = this.getIntent();
if (i.hasExtra(CURRENT_DIRECTORY_KEY)) {