mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-16 14:07:28 +01:00
Remove ability to set in-app language differently from system's
This commit is contained in:
@@ -1,15 +1,9 @@
|
||||
package eu.kanade.tachiyomi.util.system
|
||||
|
||||
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 eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.browse.source.SourcePresenter
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
@@ -17,8 +11,6 @@ import java.util.Locale
|
||||
*/
|
||||
object LocaleHelper {
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
/**
|
||||
* Returns Display name of a string language code
|
||||
*/
|
||||
@@ -50,21 +42,6 @@ object LocaleHelper {
|
||||
return locale.getDisplayName(locale).replaceFirstChar { it.uppercase(locale) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a ContextWrapper using selected Locale
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@@ -76,16 +53,4 @@ object LocaleHelper {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user