diff --git a/app/build.gradle b/app/build.gradle index 0bdf1b6f3..dd93f3e49 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -204,7 +204,7 @@ dependencies { } buildscript { - ext.kotlin_version = '1.0.5-2' + ext.kotlin_version = '1.0.6' repositories { mavenCentral() } 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 1e8568b4d..b3dd5fb41 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/LocaleHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/LocaleHelper.kt @@ -30,6 +30,12 @@ object LocaleHelper { */ private var appLocale = getLocaleFromString(preferences.lang()) + /** + * The currently applied locale. Used to avoid losing the selected language after a non locale + * configuration change to the application. + */ + private var currentLocale: Locale? = null + /** * Returns the locale for the value stored in preferences, or null if it's system language. * @@ -72,15 +78,16 @@ object LocaleHelper { if (systemLocale == null) { systemLocale = getConfigLocale(config) } - // In API 16 and lower the system locale can't be changed. + // In API 16 and lower [systemLocale] can't be changed. if (configChange && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - val newLocale = getConfigLocale(config) - if (systemLocale == newLocale) { + val configLocale = getConfigLocale(config) + if (currentLocale == configLocale) { return } - systemLocale = newLocale + systemLocale = configLocale } - val newConfig = updateConfigLocale(config, appLocale ?: systemLocale ?: Locale.getDefault()) + currentLocale = appLocale ?: systemLocale ?: Locale.getDefault() + val newConfig = updateConfigLocale(config, currentLocale!!) val resources = app.resources resources.updateConfiguration(newConfig, resources.displayMetrics) }