From f46274923386d63d21bad2760c2fa76fcd2107b5 Mon Sep 17 00:00:00 2001 From: bugy Date: Sat, 22 Apr 2017 13:47:54 +0200 Subject: [PATCH] #101 improved behaviour of automatic language setting --- .../main/java/net/buggy/shoplist/ShopListActivity.java | 10 +++++++--- .../java/net/buggy/shoplist/units/SettingsUnit.java | 1 + shop-list/src/main/res/values-ru/strings.xml | 2 +- shop-list/src/main/res/values/strings.xml | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/shop-list/src/main/java/net/buggy/shoplist/ShopListActivity.java b/shop-list/src/main/java/net/buggy/shoplist/ShopListActivity.java index 43e7975..fd6c2e9 100644 --- a/shop-list/src/main/java/net/buggy/shoplist/ShopListActivity.java +++ b/shop-list/src/main/java/net/buggy/shoplist/ShopListActivity.java @@ -203,11 +203,15 @@ protected void onPostExecute(Object o) { protected void attachBaseContext(Context newContext) { final Settings settings = getDataStorage().getSettings(); final Language language = settings.getLanguage(); + + final Locale locale; if (language != null) { - Locale locale = new Locale(language.getLocale()); - Locale.setDefault(locale); - newContext = ViewUtils.wrap(newContext, locale); + locale = new Locale(language.getLocale()); + } else { + locale = ViewUtils.getSystemLocale(); } + Locale.setDefault(locale); + newContext = ViewUtils.wrap(newContext, locale); super.attachBaseContext(CalligraphyContextWrapper.wrap(newContext)); } diff --git a/shop-list/src/main/java/net/buggy/shoplist/units/SettingsUnit.java b/shop-list/src/main/java/net/buggy/shoplist/units/SettingsUnit.java index cbabcf4..e4b17a8 100644 --- a/shop-list/src/main/java/net/buggy/shoplist/units/SettingsUnit.java +++ b/shop-list/src/main/java/net/buggy/shoplist/units/SettingsUnit.java @@ -44,6 +44,7 @@ public void renderTo(ViewGroup parentView, final ShopListActivity activity) { languageField.setSelectedItem(settings.getLanguage()); languageField.setStringConverter(new LanguageEnumStringifier(activity)); languageField.setNullString(activity.getString(R.string.unit_settings_system_language)); + languageField.setShowNullValue(true); final FloatingActionButton applyButton = (FloatingActionButton) parentView.findViewById( diff --git a/shop-list/src/main/res/values-ru/strings.xml b/shop-list/src/main/res/values-ru/strings.xml index 5556151..aa5cb11 100644 --- a/shop-list/src/main/res/values-ru/strings.xml +++ b/shop-list/src/main/res/values-ru/strings.xml @@ -108,7 +108,7 @@ Нужно указать название Настройки Язык приложения - Язык системы + Автоматический Не указано Яблоки diff --git a/shop-list/src/main/res/values/strings.xml b/shop-list/src/main/res/values/strings.xml index 2a91bac..04e1593 100644 --- a/shop-list/src/main/res/values/strings.xml +++ b/shop-list/src/main/res/values/strings.xml @@ -105,7 +105,7 @@ English Русский App language - System language + Automatic None Apples