mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 07:22:45 +00:00
don't offer locales without any own dictionary for multilingual typing
This commit is contained in:
parent
7d2dad3862
commit
907c307c2b
1 changed files with 5 additions and 2 deletions
|
@ -25,7 +25,7 @@ fun getDictionaryLocales(context: Context): MutableSet<Locale> {
|
||||||
if (cachedDirectoryList != null) {
|
if (cachedDirectoryList != null) {
|
||||||
for (directory in cachedDirectoryList) {
|
for (directory in cachedDirectoryList) {
|
||||||
if (!directory.isDirectory) continue
|
if (!directory.isDirectory) continue
|
||||||
if (directory.list()?.isNotEmpty() != true) continue
|
if (!hasAnythingOtherThanExtractedMainDictionary(directory)) continue
|
||||||
val dirLocale = DictionaryInfoUtils.getWordListIdFromFileName(directory.name)
|
val dirLocale = DictionaryInfoUtils.getWordListIdFromFileName(directory.name)
|
||||||
val locale = dirLocale.toLocale()
|
val locale = dirLocale.toLocale()
|
||||||
locales.add(locale)
|
locales.add(locale)
|
||||||
|
@ -84,10 +84,13 @@ fun cleanUnusedMainDicts(context: Context) {
|
||||||
for (dir in dirs) {
|
for (dir in dirs) {
|
||||||
if (!dir.isDirectory) continue
|
if (!dir.isDirectory) continue
|
||||||
if (dir.name in usedLocales) continue
|
if (dir.name in usedLocales) continue
|
||||||
if (dir.listFiles()?.any { it.name != DictionaryInfoUtils.getMainDictFilename(dir.name) } != false)
|
if (hasAnythingOtherThanExtractedMainDictionary(dir))
|
||||||
continue
|
continue
|
||||||
dir.deleteRecursively()
|
dir.deleteRecursively()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun hasAnythingOtherThanExtractedMainDictionary(dir: File) =
|
||||||
|
dir.listFiles()?.any { it.name != DictionaryInfoUtils.getMainDictFilename(dir.name) } != false
|
||||||
|
|
||||||
const val DICTIONARY_URL = "https://codeberg.org/Helium314/aosp-dictionaries"
|
const val DICTIONARY_URL = "https://codeberg.org/Helium314/aosp-dictionaries"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue