Fix following the system locale

Fixes https://github.com/SchildiChat/SchildiChat-android/issues/157

Change-Id: Idcf4bb84e5a0ec5bcd3d73c81447e13f3fd0e9e3
This commit is contained in:
SpiritCroc 2022-10-21 09:23:06 +02:00
parent 23a96329d6
commit 3d39699542

View File

@ -33,9 +33,16 @@ class VectorLocaleProvider @Inject constructor(
* SharedPref values has been initialized in [VectorLocale.init]
*/
val applicationLocale: Locale
get() = Locale(
preferences.getString(VectorLocale.APPLICATION_LOCALE_LANGUAGE_KEY, "")!!,
preferences.getString(VectorLocale.APPLICATION_LOCALE_COUNTRY_KEY, "")!!,
preferences.getString(VectorLocale.APPLICATION_LOCALE_VARIANT_KEY, "")!!
)
get() {
val followSystemLocale = preferences.getBoolean(VectorPreferences.SETTINGS_FOLLOW_SYSTEM_LOCALE, false)
return if (followSystemLocale) {
Locale.getDefault()
} else {
Locale(
preferences.getString(VectorLocale.APPLICATION_LOCALE_LANGUAGE_KEY, "")!!,
preferences.getString(VectorLocale.APPLICATION_LOCALE_COUNTRY_KEY, "")!!,
preferences.getString(VectorLocale.APPLICATION_LOCALE_VARIANT_KEY, "")!!
)
}
}
}