properly delete extracted internal main dictionary, and don't show empty dict folders

This commit is contained in:
Helium314 2023-08-27 18:34:51 +02:00
parent 2df1fb926e
commit 3ca932db19

View file

@ -258,8 +258,8 @@ class LanguageSettingsDialog(
} }
if (dictionaryType == DictionaryInfoUtils.DEFAULT_MAIN_DICT) { if (dictionaryType == DictionaryInfoUtils.DEFAULT_MAIN_DICT) {
// replaced main dict, remove the one created from internal data // replaced main dict, remove the one created from internal data
val internalMainDictFilename = DictionaryInfoUtils.getCacheDirectoryForLocale(this.toString(), context) + val internalMainDictFilename = DictionaryInfoUtils.getCacheDirectoryForLocale(mainLocaleString, context) +
File.separator + DictionaryInfoUtils.getMainDictFilename(this.toString()) File.separator + DictionaryInfoUtils.getMainDictFilename(mainLocaleString)
File(internalMainDictFilename).delete() File(internalMainDictFilename).delete()
} }
val newDictBroadcast = Intent(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION) val newDictBroadcast = Intent(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION)
@ -366,6 +366,7 @@ private fun getAvailableDictionaryLocales(context: Context, mainLocaleString: St
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
val dirLocale = DictionaryInfoUtils.getWordListIdFromFileName(directory.name) val dirLocale = DictionaryInfoUtils.getWordListIdFromFileName(directory.name)
if (dirLocale == mainLocaleString) continue if (dirLocale == mainLocaleString) continue
val locale = dirLocale.toLocale() val locale = dirLocale.toLocale()