diff --git a/java/src/org/futo/inputmethod/latin/uix/Settings.kt b/java/src/org/futo/inputmethod/latin/uix/Settings.kt index 28677c6c3..111bf1c28 100644 --- a/java/src/org/futo/inputmethod/latin/uix/Settings.kt +++ b/java/src/org/futo/inputmethod/latin/uix/Settings.kt @@ -124,7 +124,7 @@ val SUGGESTION_BLACKLIST = SettingsKey( default = setOf() ) -val BLACKLIST_BADWORDS = SettingsKey( - key = booleanPreferencesKey("blacklistBadWords"), +val SHOW_EMOJI_SUGGESTIONS = SettingsKey( + key = booleanPreferencesKey("suggestEmojis"), default = true ) \ No newline at end of file diff --git a/java/src/org/futo/inputmethod/latin/uix/settings/pages/Typing.kt b/java/src/org/futo/inputmethod/latin/uix/settings/pages/Typing.kt index 6587a2f36..95438a9ba 100644 --- a/java/src/org/futo/inputmethod/latin/uix/settings/pages/Typing.kt +++ b/java/src/org/futo/inputmethod/latin/uix/settings/pages/Typing.kt @@ -9,8 +9,10 @@ import androidx.navigation.NavHostController import androidx.navigation.compose.rememberNavController import org.futo.inputmethod.latin.R import org.futo.inputmethod.latin.settings.Settings +import org.futo.inputmethod.latin.uix.SHOW_EMOJI_SUGGESTIONS import org.futo.inputmethod.latin.uix.settings.ScreenTitle import org.futo.inputmethod.latin.uix.settings.ScrollableList +import org.futo.inputmethod.latin.uix.settings.SettingToggleDataStore import org.futo.inputmethod.latin.uix.settings.SettingToggleSharedPrefs @Preview @@ -20,6 +22,11 @@ fun TypingScreen(navController: NavHostController = rememberNavController()) { ScrollableList { ScreenTitle("Typing Preferences", showBack = true, navController) + SettingToggleDataStore( + title = "Emoji Suggestions", + subtitle = "Suggest emojis while you're typing", + setting = SHOW_EMOJI_SUGGESTIONS + ) SettingToggleSharedPrefs( title = stringResource(R.string.auto_cap), subtitle = stringResource(R.string.auto_cap_summary), diff --git a/java/src/org/futo/inputmethod/latin/xlm/LanguageModelFacilitator.kt b/java/src/org/futo/inputmethod/latin/xlm/LanguageModelFacilitator.kt index 2ca222196..511d24483 100644 --- a/java/src/org/futo/inputmethod/latin/xlm/LanguageModelFacilitator.kt +++ b/java/src/org/futo/inputmethod/latin/xlm/LanguageModelFacilitator.kt @@ -29,6 +29,7 @@ import org.futo.inputmethod.latin.common.Constants import org.futo.inputmethod.latin.inputlogic.InputLogic import org.futo.inputmethod.latin.settings.Settings import org.futo.inputmethod.latin.settings.SettingsValuesForSuggestion +import org.futo.inputmethod.latin.uix.SHOW_EMOJI_SUGGESTIONS import org.futo.inputmethod.latin.uix.SettingsKey import org.futo.inputmethod.latin.uix.USE_TRANSFORMER_FINETUNING import org.futo.inputmethod.latin.uix.actions.PersistentEmojiState @@ -81,6 +82,7 @@ public class LanguageModelFacilitator( private val userDictionary = UserDictionaryObserver(context) private val emojiData = PersistentEmojiState() + private var shouldSuggestEmojis = SHOW_EMOJI_SUGGESTIONS.default private var languageModel: LanguageModel? = null data class PredictionInputValues( val composedData: ComposedData, @@ -267,7 +269,7 @@ public class LanguageModelFacilitator( } } - if(values.composedData.mTypedWord.isNotEmpty()) { + if(values.composedData.mTypedWord.isNotEmpty() && shouldSuggestEmojis) { (getEmojiCandidate(values.composedData.mTypedWord) ?: maxWord?.let { getEmojiCandidate(it.mWord) } ?: maxWordDict?.let { getEmojiCandidate(it.mWord) })?.let { @@ -348,6 +350,12 @@ public class LanguageModelFacilitator( emojiData.loadEmojis(context) } + launch { + withContext(Dispatchers.Default) { + context.getSettingFlow(SHOW_EMOJI_SUGGESTIONS).collect { shouldSuggestEmojis = it } + } + } + scheduleTrainingWorkerBackground(context) }