Skip to content

Commit 9702659

Browse files
committed
fix: recognize locally imported main_user.dict as valid main dictionary
1 parent ee5d90c commit 9702659

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

app/src/main/java/helium314/keyboard/latin/suggestions/SuggestionStripLayoutHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ public int layoutAndReturnStartIndexOfMoreSuggestions(
371371
suggestedWords, mSuggestionsCountInStrip);
372372
final TextView centerWordView = mWordViews.get(mCenterPositionInStrip);
373373
final int stripWidth = stripView.getWidth();
374+
374375
final int centerWidth = getSuggestionWidth(mCenterPositionInStrip, stripWidth);
375376
if (wordCountToShow == 1 || getTextScaleX(centerWordView.getText(), centerWidth,
376377
centerWordView.getPaint()) < MIN_TEXT_XSCALE) {

app/src/main/java/helium314/keyboard/latin/suggestions/SuggestionStripView.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ class SuggestionStripView(context: Context, attrs: AttributeSet?, defStyle: Int)
370370
}
371371

372372
fun setSuggestions(suggestions: SuggestedWords, isRtlLanguage: Boolean) {
373+
373374
if (isShowingEmojiSuggestions && !helium314.keyboard.keyboard.KeyboardSwitcher.getInstance().isShowingEmojiPalettes) {
374375
isShowingEmojiSuggestions = false
375376
}

app/src/main/java/helium314/keyboard/latin/utils/DictionaryUtils.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,16 +372,16 @@ fun isMainDictionaryMissing(context: Context, locale: Locale): Boolean {
372372
}
373373
if (best != null) return false
374374
}
375-
// 2. check if cache directory has a main.dict file
375+
// 2. check if cache directory has a main.dict or main_user.dict file
376376
var cacheDir = DictionaryInfoUtils.getCacheDirectoryForLocale(locale, context)?.let { File(it) }
377-
var hasMain = cacheDir?.exists() == true && cacheDir.isDirectory && cacheDir.listFiles()?.any { it.name == "main.dict" } == true
377+
var hasMain = cacheDir?.exists() == true && cacheDir.isDirectory && cacheDir.listFiles()?.any { it.name.startsWith("main") && it.name.endsWith(".dict") } == true
378378
if (!hasMain && (locale.country.isNotEmpty() || locale.variant.isNotEmpty())) {
379379
val fallbackLocale = Locale(locale.language)
380380
cacheDir = DictionaryInfoUtils.getCacheDirectoryForLocale(fallbackLocale, context)?.let { File(it) }
381-
hasMain = cacheDir?.exists() == true && cacheDir.isDirectory && cacheDir.listFiles()?.any { it.name == "main.dict" } == true
381+
hasMain = cacheDir?.exists() == true && cacheDir.isDirectory && cacheDir.listFiles()?.any { it.name.startsWith("main") && it.name.endsWith(".dict") } == true
382382
if (!hasMain) {
383383
val variantDir = DictionaryInfoUtils.getFallbackVariantDirectory(locale, context)
384-
hasMain = variantDir?.exists() == true && variantDir.isDirectory && variantDir.listFiles()?.any { it.name == "main.dict" } == true
384+
hasMain = variantDir?.exists() == true && variantDir.isDirectory && variantDir.listFiles()?.any { it.name.startsWith("main") && it.name.endsWith(".dict") } == true
385385
}
386386
}
387387
if (hasMain) return false

0 commit comments

Comments
 (0)