From 4fcb3a969bf1cf3747ae7445690f211126e66ec3 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Thu, 8 May 2025 20:46:58 +0300 Subject: [PATCH] Fix per-app locale selection --- app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 1 + .../koitharu/kotatsu/core/util/ext/Android.kt | 6 +- app/src/main/res/xml/locales_config.xml | 117 +++++++++--------- 4 files changed, 65 insertions(+), 63 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 28a32b34d..6a5bd8d0d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ android { applicationId 'org.koitharu.kotatsu' minSdk = 21 targetSdk = 35 - versionCode = 1011 - versionName = '8.1.5' + versionCode = 1012 + versionName = '8.1.6' generatedDensities = [] testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner' ksp { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 90cd28ace..8b6cb7942 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -52,6 +52,7 @@ android:hasFragileUserData="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:localeConfig="@xml/locales_config" android:largeHeap="true" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Android.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Android.kt index 9f301b28f..cfd5c5967 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Android.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Android.kt @@ -1,7 +1,6 @@ package org.koitharu.kotatsu.core.util.ext import android.Manifest -import android.annotation.SuppressLint import android.app.Activity import android.app.ActivityManager import android.app.ActivityManager.MemoryInfo @@ -53,6 +52,7 @@ import okio.use import org.json.JSONException import org.jsoup.internal.StringUtil.StringJoiner import org.koitharu.kotatsu.BuildConfig +import org.koitharu.kotatsu.R import org.koitharu.kotatsu.main.ui.MainActivity import org.koitharu.kotatsu.parsers.util.runCatchingCancellable import org.xmlpull.v1.XmlPullParser @@ -140,7 +140,6 @@ val Context.ramAvailable: Long return result.availMem } -@SuppressLint("DiscouragedApi") fun Context.getLocalesConfig(): LocaleListCompat { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { LocaleConfig(this).supportedLocales?.let { @@ -149,8 +148,7 @@ fun Context.getLocalesConfig(): LocaleListCompat { } val tagsList = StringJoiner(",") try { - val resId = resources.getIdentifier("_generated_res_locale_config", "xml", packageName) - val xpp: XmlPullParser = resources.getXml(resId) + val xpp: XmlPullParser = resources.getXml(R.xml.locales_config) while (xpp.eventType != XmlPullParser.END_DOCUMENT) { if (xpp.eventType == XmlPullParser.START_TAG) { if (xpp.name == "locale") { diff --git a/app/src/main/res/xml/locales_config.xml b/app/src/main/res/xml/locales_config.xml index b26cc38d0..90a9c202b 100644 --- a/app/src/main/res/xml/locales_config.xml +++ b/app/src/main/res/xml/locales_config.xml @@ -1,59 +1,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +