@@ -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
0 commit comments