Skip to content

Commit 8a4e9e6

Browse files
committed
fix: reload on download and boost predictions
1 parent 6b31be6 commit 8a4e9e6

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

app/src/main/java/helium314/keyboard/latin/DictionaryFacilitatorImpl.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
6464
private var mPrefs: SharedPreferences? = null
6565
private var mContext: Context? = null
6666
private var mEnabledDictionariesState: Map<String, Boolean> = emptyMap()
67+
private var mLoadedDownloadPrefs: Map<String, Any?> = emptyMap()
6768
private var dictionaryGroups = listOf(DictionaryGroup())
6869

6970
@Volatile
@@ -144,7 +145,8 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
144145
if (prefs != null) {
145146
val currentPrefs = prefs.all.filterKeys { it.startsWith("pref_dict_enabled_") }
146147
.mapValues { it.value as? Boolean ?: true }
147-
if (currentPrefs != mEnabledDictionariesState) {
148+
val currentDownloadPrefs = prefs.all.filterKeys { it.startsWith("pref_dict_download_link_") }
149+
if (currentPrefs != mEnabledDictionariesState || currentDownloadPrefs != mLoadedDownloadPrefs) {
148150
return false
149151
}
150152
}
@@ -180,6 +182,7 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
180182
mPrefs = prefs
181183
mEnabledDictionariesState = prefs.all.filterKeys { it.startsWith("pref_dict_enabled_") }
182184
.mapValues { it.value as? Boolean ?: true }
185+
mLoadedDownloadPrefs = prefs.all.filterKeys { it.startsWith("pref_dict_download_link_") }
183186

184187
// Initialize session word boost with context if not yet done
185188
if (sessionWordBoost == null) {
@@ -631,7 +634,16 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
631634
if (word.length == 1 && info.mSourceDict.mDictType == Dictionary.TYPE_EMOJI && !StringUtils.mightBeEmoji(word[0].code))
632635
continue
633636

634-
suggestions.add(info)
637+
if (composedData.mTypedWord.isEmpty() && (dictType == Dictionary.TYPE_USER_HISTORY || dictType == Dictionary.TYPE_USER)) {
638+
val boostedScore = info.mScore + 1000
639+
val boostedInfo = SuggestedWordInfo(
640+
info.mWord, info.mPrevWordsContext, boostedScore, info.mKindAndFlags,
641+
info.mSourceDict, info.mIndexOfTouchPointOfSecondWord, info.mAutoCommitFirstWordConfidence
642+
)
643+
suggestions.add(boostedInfo)
644+
} else {
645+
suggestions.add(info)
646+
}
635647
}
636648
}
637649
return suggestions

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,12 @@ class SuggestionStripView(context: Context, attrs: AttributeSet?, defStyle: Int)
504504
|| key == Settings.PREF_AUTO_HIDE_PINNED_KEYS
505505
|| key == Settings.PREF_SPLIT_TOOLBAR
506506
|| key == "pref_custom_ai_show_tags_on_toolbar"
507-
|| key?.startsWith("pref_custom_ai_tag_") == true) {
507+
|| key?.startsWith("pref_custom_ai_tag_") == true
508+
|| key?.startsWith("pref_dict_download_link_") == true) {
508509
rebuildToolbarKeys()
509510
// Update visibility with auto-hide logic
510511
setToolbarVisibility(isToolbarManuallyOpen, false)
512+
updateKeys()
511513
}
512514
}
513515

0 commit comments

Comments
 (0)