From 32511149d13e82de9d435861bed8942cf7ba8bdc Mon Sep 17 00:00:00 2001 From: len Date: Tue, 13 Dec 2016 21:07:48 +0100 Subject: [PATCH] Format fixes. Move lang setting to the first entry (looks better IMO) --- .../tachiyomi/ui/base/activity/BaseActivity.kt | 3 ++- .../eu/kanade/tachiyomi/util/LocaleHelper.kt | 13 ++++++------- app/src/main/res/xml/pref_general.xml | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt index 8aac221881..751818c82e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt @@ -5,9 +5,10 @@ import eu.kanade.tachiyomi.util.LocaleHelper abstract class BaseActivity : AppCompatActivity(), ActivityMixin { - override fun getActivity() = this init { LocaleHelper.updateCfg(this) } + override fun getActivity() = this + } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/LocaleHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/util/LocaleHelper.kt index 70ade9b7d3..4fa048d2b5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/LocaleHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/LocaleHelper.kt @@ -8,11 +8,11 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import uy.kohesive.injekt.injectLazy import java.util.Locale - object LocaleHelper { private val preferences: PreferencesHelper by injectLazy() - private var pLocale = Locale(LocaleHelper.intToLangCode(preferences.lang())) + + private var pLocale = Locale(intToLangCode(preferences.lang())) fun setLocale(locale: Locale) { pLocale = locale @@ -20,7 +20,7 @@ object LocaleHelper { } fun updateCfg(wrapper: ContextThemeWrapper) { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { val config = Configuration() config.setLocale(pLocale) wrapper.applyOverrideConfiguration(config) @@ -28,20 +28,19 @@ object LocaleHelper { } fun updateCfg(app: Application, config: Configuration){ - if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { config.locale = pLocale app.baseContext.resources.updateConfiguration(config, app.baseContext.resources.displayMetrics) } } fun intToLangCode(i: Int): String { - return when(i){ + return when(i) { 1 -> "en" 2 -> "es" 3 -> "it" 4 -> "pt" - // System Language - else -> "" + else -> "" // System Language } } diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index d5d934ba70..2987841363 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -10,6 +10,14 @@ android:title="@string/pref_category_general" app:asp_tintEnabled="true"> + + - - \ No newline at end of file