feat: add per app language for devices running Android 13+ (#353)
This commit is contained in:
parent
ac88455a35
commit
69e3afc426
5 changed files with 54 additions and 2 deletions
|
@ -17,6 +17,7 @@
|
|||
android:fullBackupOnly="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:localeConfig="@xml/locales_config"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Findroid">
|
||||
|
@ -48,8 +49,7 @@
|
|||
<provider
|
||||
android:name="androidx.startup.InitializationProvider"
|
||||
android:authorities="${applicationId}.androidx-startup"
|
||||
tools:node="remove">
|
||||
</provider>
|
||||
tools:node="remove" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -1,6 +1,11 @@
|
|||
package dev.jdtech.jellyfin.fragments
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import dev.jdtech.jellyfin.core.R as CoreR
|
||||
|
||||
|
@ -8,5 +13,18 @@ import dev.jdtech.jellyfin.core.R as CoreR
|
|||
class SettingsLanguageFragment : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(CoreR.xml.fragment_settings_language, rootKey)
|
||||
findPreference<Preference>("pref_app_language")?.apply {
|
||||
isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
|
||||
summary = requireContext().resources.configuration.locales.get(0).displayName
|
||||
setOnPreferenceClickListener {
|
||||
startActivity(
|
||||
Intent(
|
||||
Settings.ACTION_APP_LOCALE_SETTINGS,
|
||||
Uri.parse("package:${requireContext().packageName}")
|
||||
)
|
||||
)
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
<string name="settings_category_language">Language</string>
|
||||
<string name="settings_preferred_audio_language">Preferred audio language</string>
|
||||
<string name="settings_preferred_subtitle_language">Preferred subtitle language</string>
|
||||
<string name="app_language">App language</string>
|
||||
<string name="initializing">Initializing…</string>
|
||||
<string name="settings_category_servers">Servers</string>
|
||||
<string name="settings_category_player">Player</string>
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<Preference
|
||||
app:icon="@drawable/ic_languages"
|
||||
app:isPreferenceVisible="false"
|
||||
app:key="pref_app_language"
|
||||
app:title="@string/app_language" />
|
||||
|
||||
<ListPreference
|
||||
app:defaultValue="null"
|
||||
app:entries="@array/languages"
|
||||
|
|
27
core/src/main/res/xml/locales_config.xml
Normal file
27
core/src/main/res/xml/locales_config.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<locale android:name="es-r419" /> <!-- Spanish (Latin America) -->
|
||||
<locale android:name="bg"/> <!-- Bulgarian -->
|
||||
<locale android:name="cs"/> <!-- Czech -->
|
||||
<locale android:name="de"/> <!-- German -->
|
||||
<locale android:name="en"/> <!-- English -->
|
||||
<locale android:name="es"/> <!-- Spanish (Spain) -->
|
||||
<locale android:name="es-MX"/> <!-- Spanish (Mexico) -->
|
||||
<locale android:name="fr"/> <!-- French (France) -->
|
||||
<locale android:name="hu"/> <!-- Hungarian -->
|
||||
<locale android:name="it"/> <!-- Italian -->
|
||||
<locale android:name="iw"/> <!-- Hebrew -->
|
||||
<locale android:name="ko"/> <!-- Korean -->
|
||||
<locale android:name="nl"/> <!-- Dutch -->
|
||||
<locale android:name="pl"/> <!-- Polish -->
|
||||
<locale android:name="pt"/> <!-- Portuguese -->
|
||||
<locale android:name="pt-BR"/> <!-- Portuguese (Brazil) -->
|
||||
<locale android:name="ru"/> <!-- Russian -->
|
||||
<locale android:name="sk"/> <!-- Slovak -->
|
||||
<locale android:name="sl"/> <!-- Slovenian -->
|
||||
<locale android:name="sv"/> <!-- Swedish -->
|
||||
<locale android:name="vi"/> <!-- Vietnamese -->
|
||||
<locale android:name="yue"/> <!-- Yue Chinese -->
|
||||
<locale android:name="zh-CN"/> <!-- Chinese (Simplified) -->
|
||||
<locale android:name="zh-TW"/> <!-- Chinese (Traditional) -->
|
||||
</locale-config>
|
Loading…
Reference in a new issue