mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Remove ability to set in-app language differently from system's
This commit is contained in:
parent
1fe97a06d4
commit
912d405473
9 changed files with 2 additions and 150 deletions
|
@ -139,9 +139,6 @@ object Migrations {
|
||||||
remove("show_manga_app_shortcuts")
|
remove("show_manga_app_shortcuts")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (preferences.lang().get() in listOf("en-US", "en-GB")) {
|
|
||||||
preferences.lang().set("en")
|
|
||||||
}
|
|
||||||
// Handle removed every 1 or 2 hour library updates
|
// Handle removed every 1 or 2 hour library updates
|
||||||
val updateInterval = preferences.libraryUpdateInterval().get()
|
val updateInterval = preferences.libraryUpdateInterval().get()
|
||||||
if (updateInterval == 1 || updateInterval == 2) {
|
if (updateInterval == 1 || updateInterval == 2) {
|
||||||
|
|
|
@ -171,8 +171,6 @@ object PreferenceKeys {
|
||||||
|
|
||||||
const val uniformGrid = "uniform_grid"
|
const val uniformGrid = "uniform_grid"
|
||||||
|
|
||||||
const val lang = "app_language"
|
|
||||||
|
|
||||||
const val dateFormat = "app_date_format"
|
const val dateFormat = "app_date_format"
|
||||||
|
|
||||||
const val defaultCategory = "default_category"
|
const val defaultCategory = "default_category"
|
||||||
|
|
|
@ -315,8 +315,6 @@ class PreferencesHelper(val context: Context) {
|
||||||
fun downloadNewCategories() = flowPrefs.getStringSet(Keys.downloadNewCategories, emptySet())
|
fun downloadNewCategories() = flowPrefs.getStringSet(Keys.downloadNewCategories, emptySet())
|
||||||
fun downloadNewCategoriesExclude() = flowPrefs.getStringSet(Keys.downloadNewCategoriesExclude, emptySet())
|
fun downloadNewCategoriesExclude() = flowPrefs.getStringSet(Keys.downloadNewCategoriesExclude, emptySet())
|
||||||
|
|
||||||
fun lang() = flowPrefs.getString(Keys.lang, "")
|
|
||||||
|
|
||||||
fun defaultCategory() = prefs.getInt(Keys.defaultCategory, -1)
|
fun defaultCategory() = prefs.getInt(Keys.defaultCategory, -1)
|
||||||
|
|
||||||
fun skipRead() = prefs.getBoolean(Keys.skipRead, false)
|
fun skipRead() = prefs.getBoolean(Keys.skipRead, false)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package eu.kanade.tachiyomi.ui.base.activity
|
package eu.kanade.tachiyomi.ui.base.activity
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
@ -9,7 +8,6 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.main.SearchActivity
|
import eu.kanade.tachiyomi.ui.main.SearchActivity
|
||||||
import eu.kanade.tachiyomi.ui.security.BiometricActivity
|
import eu.kanade.tachiyomi.ui.security.BiometricActivity
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
|
||||||
import eu.kanade.tachiyomi.util.system.getThemeWithExtras
|
import eu.kanade.tachiyomi.util.system.getThemeWithExtras
|
||||||
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
@ -22,10 +20,6 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||||
|
|
||||||
private var updatedTheme: Resources.Theme? = null
|
private var updatedTheme: Resources.Theme? = null
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context) {
|
|
||||||
super.attachBaseContext(LocaleHelper.createLocaleWrapper(newBase))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
updatedTheme = null
|
updatedTheme = null
|
||||||
setThemeAndNight(preferences)
|
setThemeAndNight(preferences)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package eu.kanade.tachiyomi.ui.base.activity
|
package eu.kanade.tachiyomi.ui.base.activity
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
@ -8,7 +7,6 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||||
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
|
||||||
import eu.kanade.tachiyomi.util.system.getThemeWithExtras
|
import eu.kanade.tachiyomi.util.system.getThemeWithExtras
|
||||||
import nucleus.view.NucleusAppCompatActivity
|
import nucleus.view.NucleusAppCompatActivity
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
@ -19,10 +17,6 @@ abstract class BaseRxActivity<P : BasePresenter<*>> : NucleusAppCompatActivity<P
|
||||||
private val preferences by injectLazy<PreferencesHelper>()
|
private val preferences by injectLazy<PreferencesHelper>()
|
||||||
private var updatedTheme: Resources.Theme? = null
|
private var updatedTheme: Resources.Theme? = null
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context) {
|
|
||||||
super.attachBaseContext(LocaleHelper.createLocaleWrapper(newBase))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
updatedTheme = null
|
updatedTheme = null
|
||||||
setThemeAndNight(preferences)
|
setThemeAndNight(preferences)
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package eu.kanade.tachiyomi.ui.base.activity
|
package eu.kanade.tachiyomi.ui.base.activity
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
|
||||||
import eu.kanade.tachiyomi.util.system.getThemeWithExtras
|
import eu.kanade.tachiyomi.util.system.getThemeWithExtras
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
|
@ -15,10 +13,6 @@ abstract class BaseThemedActivity : AppCompatActivity() {
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
val preferences: PreferencesHelper by injectLazy()
|
||||||
private var updatedTheme: Resources.Theme? = null
|
private var updatedTheme: Resources.Theme? = null
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context) {
|
|
||||||
super.attachBaseContext(LocaleHelper.createLocaleWrapper(newBase))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
updatedTheme = null
|
updatedTheme = null
|
||||||
setThemeAndNight(preferences)
|
setThemeAndNight(preferences)
|
||||||
|
|
|
@ -10,7 +10,6 @@ import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
||||||
import eu.kanade.tachiyomi.data.updater.AutoUpdaterJob
|
import eu.kanade.tachiyomi.data.updater.AutoUpdaterJob
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
|
||||||
import eu.kanade.tachiyomi.util.system.appDelegateNightMode
|
import eu.kanade.tachiyomi.util.system.appDelegateNightMode
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.getPrefTheme
|
import eu.kanade.tachiyomi.util.system.getPrefTheme
|
||||||
|
@ -175,90 +174,6 @@ class SettingsGeneralController : SettingsController() {
|
||||||
|
|
||||||
preferenceCategory {
|
preferenceCategory {
|
||||||
titleRes = R.string.locale
|
titleRes = R.string.locale
|
||||||
|
|
||||||
listPreference(activity) {
|
|
||||||
key = Keys.lang
|
|
||||||
titleRes = R.string.language
|
|
||||||
val langs = mutableListOf<Pair<String, String>>()
|
|
||||||
langs += Pair(
|
|
||||||
"",
|
|
||||||
"${context.getString(R.string.system_default)} (${LocaleHelper.getDisplayName("")})"
|
|
||||||
)
|
|
||||||
// Due to compatibility issues:
|
|
||||||
// - Hebrew: `he` is copied into `iw` at build time
|
|
||||||
langs += arrayOf(
|
|
||||||
"am",
|
|
||||||
"ar",
|
|
||||||
"be",
|
|
||||||
"bg",
|
|
||||||
"bn",
|
|
||||||
"ca",
|
|
||||||
"cs",
|
|
||||||
"cv",
|
|
||||||
"de",
|
|
||||||
"el",
|
|
||||||
"eo",
|
|
||||||
"es",
|
|
||||||
"es-419",
|
|
||||||
"en",
|
|
||||||
"fa",
|
|
||||||
"fi",
|
|
||||||
"fil",
|
|
||||||
"fr",
|
|
||||||
"gl",
|
|
||||||
"he",
|
|
||||||
"hi",
|
|
||||||
"hr",
|
|
||||||
"hu",
|
|
||||||
"in",
|
|
||||||
"it",
|
|
||||||
"ja",
|
|
||||||
"jv",
|
|
||||||
"ka-rGE",
|
|
||||||
"kn",
|
|
||||||
"ko",
|
|
||||||
"lt",
|
|
||||||
"lv",
|
|
||||||
"mr",
|
|
||||||
"ms",
|
|
||||||
"my",
|
|
||||||
"nb-rNO",
|
|
||||||
"ne",
|
|
||||||
"nl",
|
|
||||||
"pl",
|
|
||||||
"pt",
|
|
||||||
"pt-BR",
|
|
||||||
"ro",
|
|
||||||
"ru",
|
|
||||||
"sah",
|
|
||||||
"sc",
|
|
||||||
"sk",
|
|
||||||
"sr",
|
|
||||||
"sv",
|
|
||||||
"te",
|
|
||||||
"th",
|
|
||||||
"tr",
|
|
||||||
"uk",
|
|
||||||
"ur-rPK",
|
|
||||||
"vi",
|
|
||||||
"uz",
|
|
||||||
"zh-rCN",
|
|
||||||
"zh-rTW"
|
|
||||||
)
|
|
||||||
.map {
|
|
||||||
Pair(it, LocaleHelper.getDisplayName(it))
|
|
||||||
}
|
|
||||||
.sortedBy { it.second }
|
|
||||||
|
|
||||||
entryValues = langs.map { it.first }
|
|
||||||
entries = langs.map { it.second }
|
|
||||||
defaultValue = ""
|
|
||||||
|
|
||||||
onChange { newValue ->
|
|
||||||
activity?.recreate()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
listPreference(activity) {
|
listPreference(activity) {
|
||||||
key = Keys.dateFormat
|
key = Keys.dateFormat
|
||||||
titleRes = R.string.date_format
|
titleRes = R.string.date_format
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
package eu.kanade.tachiyomi.util.system
|
package eu.kanade.tachiyomi.util.system
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.ContextWrapper
|
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.LocaleList
|
|
||||||
import androidx.core.os.LocaleListCompat
|
import androidx.core.os.LocaleListCompat
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
||||||
import eu.kanade.tachiyomi.ui.source.SourcePresenter
|
import eu.kanade.tachiyomi.ui.source.SourcePresenter
|
||||||
import uy.kohesive.injekt.injectLazy
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,11 +11,6 @@ import java.util.Locale
|
||||||
*/
|
*/
|
||||||
object LocaleHelper {
|
object LocaleHelper {
|
||||||
|
|
||||||
/**
|
|
||||||
* Preferences helper.
|
|
||||||
*/
|
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns Display name of a string language code
|
* Returns Display name of a string language code
|
||||||
*/
|
*/
|
||||||
|
@ -54,22 +43,7 @@ object LocaleHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a ContextWrapper using selected Locale
|
* Return Locale from string language code
|
||||||
*/
|
|
||||||
fun createLocaleWrapper(context: Context): ContextWrapper {
|
|
||||||
val appLocale = getLocaleFromString(preferences.lang().get())
|
|
||||||
val newConfiguration = Configuration(context.resources.configuration)
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
val localeList = LocaleList(appLocale)
|
|
||||||
newConfiguration.setLocales(localeList)
|
|
||||||
} else {
|
|
||||||
newConfiguration.setLocale(appLocale)
|
|
||||||
}
|
|
||||||
return ContextWrapper(context.createConfigurationContext(newConfiguration))
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Return Locale from string language code
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
private fun getLocale(lang: String): Locale {
|
private fun getLocale(lang: String): Locale {
|
||||||
val sp = lang.split("_", "-")
|
val sp = lang.split("_", "-")
|
||||||
|
@ -79,16 +53,4 @@ object LocaleHelper {
|
||||||
else -> Locale(lang)
|
else -> Locale(lang)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the locale for the value stored in preferences, defaults to main system language.
|
|
||||||
*
|
|
||||||
* @param pref the string value stored in preferences.
|
|
||||||
*/
|
|
||||||
private fun getLocaleFromString(pref: String?): Locale {
|
|
||||||
if (pref.isNullOrEmpty()) {
|
|
||||||
return LocaleListCompat.getDefault()[0]
|
|
||||||
}
|
|
||||||
return getLocale(pref)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -658,7 +658,6 @@
|
||||||
<string name="white_theme">Pure White</string>
|
<string name="white_theme">Pure White</string>
|
||||||
<string name="locale">Locale</string>
|
<string name="locale">Locale</string>
|
||||||
<string name="last_used_library_recents">Last used (Library or Recents)</string>
|
<string name="last_used_library_recents">Last used (Library or Recents)</string>
|
||||||
<string name="language">Language</string>
|
|
||||||
<string name="system_default">System default</string>
|
<string name="system_default">System default</string>
|
||||||
<string name="date_format">Date format</string>
|
<string name="date_format">Date format</string>
|
||||||
<string name="check_for_updates">Check for updates</string>
|
<string name="check_for_updates">Check for updates</string>
|
||||||
|
@ -971,6 +970,7 @@
|
||||||
<string name="name">Name</string>
|
<string name="name">Name</string>
|
||||||
<string name="recently_updated">Recently updated</string>
|
<string name="recently_updated">Recently updated</string>
|
||||||
<string name="recently_installed">Recently installed</string>
|
<string name="recently_installed">Recently installed</string>
|
||||||
|
<string name="language">Language</string>
|
||||||
<string name="never">Never</string>
|
<string name="never">Never</string>
|
||||||
<string name="newest">Newest</string>
|
<string name="newest">Newest</string>
|
||||||
<string name="next">Next</string>
|
<string name="next">Next</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue