mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-28 19:59:55 +00:00
don't pre-select unavailable locale when adding dictionary
This commit is contained in:
parent
7b0c511857
commit
77a728e390
1 changed files with 1 additions and 1 deletions
|
@ -47,12 +47,12 @@ fun NewDictionaryDialog(
|
||||||
} else if (header != null) {
|
} else if (header != null) {
|
||||||
val ctx = LocalContext.current
|
val ctx = LocalContext.current
|
||||||
val dictLocale = header.mLocaleString.constructLocale()
|
val dictLocale = header.mLocaleString.constructLocale()
|
||||||
var locale by remember { mutableStateOf(mainLocale ?: dictLocale) }
|
|
||||||
val enabledLanguages = SubtypeSettings.getEnabledSubtypes().map { it.locale().language }
|
val enabledLanguages = SubtypeSettings.getEnabledSubtypes().map { it.locale().language }
|
||||||
val comparer = compareBy<Locale>({ it != mainLocale }, { it != dictLocale }, { it.language !in enabledLanguages }, { it.script() != dictLocale.script() })
|
val comparer = compareBy<Locale>({ it != mainLocale }, { it != dictLocale }, { it.language !in enabledLanguages }, { it.script() != dictLocale.script() })
|
||||||
val locales = SubtypeSettings.getAvailableSubtypeLocales()
|
val locales = SubtypeSettings.getAvailableSubtypeLocales()
|
||||||
.filter { it.script() == dictLocale.script() || it.script() == mainLocale?.script() }
|
.filter { it.script() == dictLocale.script() || it.script() == mainLocale?.script() }
|
||||||
.sortedWith(comparer)
|
.sortedWith(comparer)
|
||||||
|
var locale by remember { mutableStateOf(mainLocale ?: dictLocale.takeIf { it in locales } ?: locales.first()) }
|
||||||
val cacheDir = DictionaryInfoUtils.getCacheDirectoryForLocale(locale, ctx)
|
val cacheDir = DictionaryInfoUtils.getCacheDirectoryForLocale(locale, ctx)
|
||||||
val dictFile = File(cacheDir, header.mIdString.substringBefore(":") + "_" + DictionaryInfoUtils.USER_DICTIONARY_SUFFIX)
|
val dictFile = File(cacheDir, header.mIdString.substringBefore(":") + "_" + DictionaryInfoUtils.USER_DICTIONARY_SUFFIX)
|
||||||
val type = header.mIdString.substringBefore(":")
|
val type = header.mIdString.substringBefore(":")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue