mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-16 14:49:17 +01:00
Reinstate in-app language picker (#7493)
Also add required config for android 13 system picker
This commit is contained in:
parent
29348677b8
commit
2d690a09b3
@ -27,8 +27,8 @@
|
|||||||
android:hardwareAccelerated="true"
|
android:hardwareAccelerated="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:localeConfig="@xml/locales_config"
|
||||||
android:requestLegacyExternalStorage="true"
|
android:requestLegacyExternalStorage="true"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:theme="@style/Theme.Tachiyomi"
|
android:theme="@style/Theme.Tachiyomi"
|
||||||
@ -201,6 +201,15 @@
|
|||||||
<service android:name=".extension.util.ExtensionInstallService"
|
<service android:name=".extension.util.ExtensionInstallService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
|
||||||
|
android:enabled="false"
|
||||||
|
android:exported="false">
|
||||||
|
<meta-data
|
||||||
|
android:name="autoStoreLocales"
|
||||||
|
android:value="true" />
|
||||||
|
</service>
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.provider"
|
android:authorities="${applicationId}.provider"
|
||||||
|
@ -3,14 +3,20 @@ package eu.kanade.tachiyomi.ui.setting
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import androidx.core.os.LocaleListCompat
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||||
|
import eu.kanade.tachiyomi.util.preference.listPreference
|
||||||
|
import eu.kanade.tachiyomi.util.preference.onChange
|
||||||
import eu.kanade.tachiyomi.util.preference.onClick
|
import eu.kanade.tachiyomi.util.preference.onClick
|
||||||
import eu.kanade.tachiyomi.util.preference.preference
|
import eu.kanade.tachiyomi.util.preference.preference
|
||||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||||
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
|
import org.xmlpull.v1.XmlPullParser
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||||
|
|
||||||
class SettingsGeneralController : SettingsController() {
|
class SettingsGeneralController : SettingsController() {
|
||||||
@ -39,5 +45,44 @@ class SettingsGeneralController : SettingsController() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
listPreference {
|
||||||
|
key = "app_lang"
|
||||||
|
isPersistent = false
|
||||||
|
titleRes = R.string.pref_app_language
|
||||||
|
|
||||||
|
val langs = mutableListOf<Pair<String, String>>()
|
||||||
|
|
||||||
|
val parser = context.resources.getXml(R.xml.locales_config)
|
||||||
|
var eventType = parser.eventType
|
||||||
|
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||||
|
if (eventType == XmlPullParser.START_TAG && parser.name == "locale") {
|
||||||
|
for (i in 0 until parser.attributeCount) {
|
||||||
|
if (parser.getAttributeName(i) == "name") {
|
||||||
|
val langTag = parser.getAttributeValue(i)
|
||||||
|
langs.add(Pair(langTag, LocaleHelper.getDisplayName(langTag)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eventType = parser.next()
|
||||||
|
}
|
||||||
|
|
||||||
|
langs.sortBy { it.second }
|
||||||
|
langs.add(0, Pair("", context.getString(R.string.label_default)))
|
||||||
|
|
||||||
|
entryValues = langs.map { it.first }.toTypedArray()
|
||||||
|
entries = langs.map { it.second }.toTypedArray()
|
||||||
|
summary = "%s"
|
||||||
|
value = AppCompatDelegate.getApplicationLocales().get(0)?.toLanguageTag() ?: ""
|
||||||
|
|
||||||
|
onChange { newValue ->
|
||||||
|
val locale = if ((newValue as String).isEmpty()) {
|
||||||
|
LocaleListCompat.getEmptyLocaleList()
|
||||||
|
} else {
|
||||||
|
LocaleListCompat.forLanguageTags(newValue)
|
||||||
|
}
|
||||||
|
AppCompatDelegate.setApplicationLocales(locale)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ lifecycle_version = "2.5.1"
|
|||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
annotation = "androidx.annotation:annotation:1.4.0"
|
annotation = "androidx.annotation:annotation:1.4.0"
|
||||||
appcompat = "androidx.appcompat:appcompat:1.5.0"
|
appcompat = "androidx.appcompat:appcompat:1.6.0-beta01"
|
||||||
biometricktx = "androidx.biometric:biometric-ktx:1.2.0-alpha04"
|
biometricktx = "androidx.biometric:biometric-ktx:1.2.0-alpha04"
|
||||||
constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4"
|
constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4"
|
||||||
coordinatorlayout = "androidx.coordinatorlayout:coordinatorlayout:1.2.0"
|
coordinatorlayout = "androidx.coordinatorlayout:coordinatorlayout:1.2.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user