From 607e837d50bb3a8605ef20d3db39c5ebe425225b Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 24 Oct 2021 14:00:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/base/AppContextWrapper.kt | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/AppContextWrapper.kt b/app/src/main/java/io/legado/app/base/AppContextWrapper.kt index 04ce0e86e..5fd9e7725 100644 --- a/app/src/main/java/io/legado/app/base/AppContextWrapper.kt +++ b/app/src/main/java/io/legado/app/base/AppContextWrapper.kt @@ -18,25 +18,17 @@ object AppContextWrapper { if (fontScale !in 0.8f..1.6f) { fontScale = 0f } - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - val resources: Resources = context.resources - val configuration: Configuration = resources.configuration - val targetLocale = getSetLocale(context) + val resources: Resources = context.resources + val configuration: Configuration = resources.configuration + val targetLocale = getSetLocale(context) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { configuration.setLocale(targetLocale) configuration.setLocales(LocaleList(targetLocale)) - configuration.fontScale = fontScale - context.createConfigurationContext(configuration) } else { - val resources: Resources = context.resources - val targetLocale = getSetLocale(context) - val configuration: Configuration = resources.configuration - @Suppress("DEPRECATION") configuration.locale = targetLocale - configuration.fontScale = fontScale - @Suppress("DEPRECATION") - resources.updateConfiguration(configuration, resources.displayMetrics) - context } + configuration.fontScale = fontScale + return context.createConfigurationContext(configuration) } /**