mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Add defaults for script/text font pairings and guessing of script based on body contents.
Co-authored-by: Alex Hart <alex@signal.org>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import androidx.core.os.LocaleListCompat
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.util.dynamiclanguage.LanguageString
|
||||
import java.util.Locale
|
||||
|
||||
object LocaleUtil {
|
||||
|
||||
fun getFirstLocale(): Locale {
|
||||
return getLocaleDefaults().firstOrNull() ?: Locale.getDefault()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user priority list of locales supported on the device, with the locale set via Signal settings
|
||||
* as highest priority over system settings.
|
||||
*/
|
||||
fun getLocaleDefaults(): List<Locale> {
|
||||
val locales: MutableList<Locale> = mutableListOf()
|
||||
val signalLocale: Locale? = LanguageString.parseLocale(SignalStore.settings().language)
|
||||
val localeList: LocaleListCompat = LocaleListCompat.getDefault()
|
||||
|
||||
if (signalLocale != null) {
|
||||
locales += signalLocale
|
||||
}
|
||||
|
||||
for (index in 0 until localeList.size()) {
|
||||
locales += localeList.get(index)
|
||||
}
|
||||
|
||||
return locales
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user