Fix per-app locale selection

master
Koitharu 12 months ago
parent 7cf7a62881
commit beba4f029a
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -19,8 +19,8 @@ android {
applicationId 'org.koitharu.kotatsu' applicationId 'org.koitharu.kotatsu'
minSdk = 21 minSdk = 21
targetSdk = 35 targetSdk = 35
versionCode = 1011 versionCode = 1012
versionName = '8.1.5' versionName = '8.1.6'
generatedDensities = [] generatedDensities = []
testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner' testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner'
ksp { ksp {

@ -52,6 +52,7 @@
android:hasFragileUserData="true" android:hasFragileUserData="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:localeConfig="@xml/locales_config"
android:largeHeap="true" android:largeHeap="true"
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"

@ -1,7 +1,6 @@
package org.koitharu.kotatsu.core.util.ext package org.koitharu.kotatsu.core.util.ext
import android.Manifest import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.app.ActivityManager import android.app.ActivityManager
import android.app.ActivityManager.MemoryInfo import android.app.ActivityManager.MemoryInfo
@ -53,6 +52,7 @@ import okio.use
import org.json.JSONException import org.json.JSONException
import org.jsoup.internal.StringUtil.StringJoiner import org.jsoup.internal.StringUtil.StringJoiner
import org.koitharu.kotatsu.BuildConfig import org.koitharu.kotatsu.BuildConfig
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.main.ui.MainActivity import org.koitharu.kotatsu.main.ui.MainActivity
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable import org.koitharu.kotatsu.parsers.util.runCatchingCancellable
import org.xmlpull.v1.XmlPullParser import org.xmlpull.v1.XmlPullParser
@ -140,7 +140,6 @@ val Context.ramAvailable: Long
return result.availMem return result.availMem
} }
@SuppressLint("DiscouragedApi")
fun Context.getLocalesConfig(): LocaleListCompat { fun Context.getLocalesConfig(): LocaleListCompat {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
LocaleConfig(this).supportedLocales?.let { LocaleConfig(this).supportedLocales?.let {
@ -149,8 +148,7 @@ fun Context.getLocalesConfig(): LocaleListCompat {
} }
val tagsList = StringJoiner(",") val tagsList = StringJoiner(",")
try { try {
val resId = resources.getIdentifier("_generated_res_locale_config", "xml", packageName) val xpp: XmlPullParser = resources.getXml(R.xml.locales_config)
val xpp: XmlPullParser = resources.getXml(resId)
while (xpp.eventType != XmlPullParser.END_DOCUMENT) { while (xpp.eventType != XmlPullParser.END_DOCUMENT) {
if (xpp.eventType == XmlPullParser.START_TAG) { if (xpp.eventType == XmlPullParser.START_TAG) {
if (xpp.name == "locale") { if (xpp.name == "locale") {

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<locale-config xmlns:android="http://schemas.android.com/apk/res/android"> <locale-config
xmlns:android="http://schemas.android.com/apk/res/android">
<locale android:name="ab" /> <locale android:name="ab" />
<locale android:name="ar" /> <locale android:name="ar" />
<locale android:name="arq" /> <locale android:name="arq" />
@ -21,10 +22,12 @@
<locale android:name="fr" /> <locale android:name="fr" />
<locale android:name="frp" /> <locale android:name="frp" />
<locale android:name="gu" /> <locale android:name="gu" />
<locale android:name="he"/> <locale android:name="hi"/> <locale android:name="he" />
<locale android:name="hi" />
<locale android:name="hr" /> <locale android:name="hr" />
<locale android:name="hu" /> <locale android:name="hu" />
<locale android:name="id"/> <locale android:name="it"/> <locale android:name="id" />
<locale android:name="it" />
<locale android:name="ja" /> <locale android:name="ja" />
<locale android:name="kk" /> <locale android:name="kk" />
<locale android:name="km" /> <locale android:name="km" />

Loading…
Cancel
Save