mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 12:47:26 +01:00
Format fixes. Move lang setting to the first entry (looks better IMO)
This commit is contained in:
parent
cc9fd53abb
commit
32511149d1
@ -5,9 +5,10 @@ import eu.kanade.tachiyomi.util.LocaleHelper
|
|||||||
|
|
||||||
abstract class BaseActivity : AppCompatActivity(), ActivityMixin {
|
abstract class BaseActivity : AppCompatActivity(), ActivityMixin {
|
||||||
|
|
||||||
override fun getActivity() = this
|
|
||||||
init {
|
init {
|
||||||
LocaleHelper.updateCfg(this)
|
LocaleHelper.updateCfg(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getActivity() = this
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
|
|
||||||
object LocaleHelper {
|
object LocaleHelper {
|
||||||
|
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
private val preferences: PreferencesHelper by injectLazy()
|
||||||
private var pLocale = Locale(LocaleHelper.intToLangCode(preferences.lang()))
|
|
||||||
|
private var pLocale = Locale(intToLangCode(preferences.lang()))
|
||||||
|
|
||||||
fun setLocale(locale: Locale) {
|
fun setLocale(locale: Locale) {
|
||||||
pLocale = locale
|
pLocale = locale
|
||||||
@ -20,7 +20,7 @@ object LocaleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateCfg(wrapper: ContextThemeWrapper) {
|
fun updateCfg(wrapper: ContextThemeWrapper) {
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1){
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||||
val config = Configuration()
|
val config = Configuration()
|
||||||
config.setLocale(pLocale)
|
config.setLocale(pLocale)
|
||||||
wrapper.applyOverrideConfiguration(config)
|
wrapper.applyOverrideConfiguration(config)
|
||||||
@ -28,20 +28,19 @@ object LocaleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateCfg(app: Application, config: Configuration){
|
fun updateCfg(app: Application, config: Configuration){
|
||||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||||
config.locale = pLocale
|
config.locale = pLocale
|
||||||
app.baseContext.resources.updateConfiguration(config, app.baseContext.resources.displayMetrics)
|
app.baseContext.resources.updateConfiguration(config, app.baseContext.resources.displayMetrics)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun intToLangCode(i: Int): String {
|
fun intToLangCode(i: Int): String {
|
||||||
return when(i){
|
return when(i) {
|
||||||
1 -> "en"
|
1 -> "en"
|
||||||
2 -> "es"
|
2 -> "es"
|
||||||
3 -> "it"
|
3 -> "it"
|
||||||
4 -> "pt"
|
4 -> "pt"
|
||||||
// System Language
|
else -> "" // System Language
|
||||||
else -> ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,14 @@
|
|||||||
android:title="@string/pref_category_general"
|
android:title="@string/pref_category_general"
|
||||||
app:asp_tintEnabled="true">
|
app:asp_tintEnabled="true">
|
||||||
|
|
||||||
|
<eu.kanade.tachiyomi.widget.preference.IntListPreference
|
||||||
|
android:defaultValue="0"
|
||||||
|
android:entries="@array/languages"
|
||||||
|
android:entryValues="@array/languages_values"
|
||||||
|
android:key="@string/pref_language_key"
|
||||||
|
android:summary="%s"
|
||||||
|
android:title="@string/pref_language" />
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.preference.IntListPreference
|
<eu.kanade.tachiyomi.widget.preference.IntListPreference
|
||||||
android:defaultValue="1"
|
android:defaultValue="1"
|
||||||
android:entries="@array/themes"
|
android:entries="@array/themes"
|
||||||
@ -56,14 +64,6 @@
|
|||||||
android:key="@string/pref_update_only_non_completed_key"
|
android:key="@string/pref_update_only_non_completed_key"
|
||||||
android:title="@string/pref_update_only_non_completed" />
|
android:title="@string/pref_update_only_non_completed" />
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.preference.IntListPreference
|
|
||||||
android:defaultValue="0"
|
|
||||||
android:entries="@array/languages"
|
|
||||||
android:entryValues="@array/languages_values"
|
|
||||||
android:key="@string/pref_language_key"
|
|
||||||
android:summary="%s"
|
|
||||||
android:title="@string/pref_language" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user