mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Add option for emoji suggestions
This commit is contained in:
parent
e209eefd48
commit
e424f36529
@ -124,7 +124,7 @@ val SUGGESTION_BLACKLIST = SettingsKey(
|
|||||||
default = setOf()
|
default = setOf()
|
||||||
)
|
)
|
||||||
|
|
||||||
val BLACKLIST_BADWORDS = SettingsKey(
|
val SHOW_EMOJI_SUGGESTIONS = SettingsKey(
|
||||||
key = booleanPreferencesKey("blacklistBadWords"),
|
key = booleanPreferencesKey("suggestEmojis"),
|
||||||
default = true
|
default = true
|
||||||
)
|
)
|
@ -9,8 +9,10 @@ import androidx.navigation.NavHostController
|
|||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
import org.futo.inputmethod.latin.R
|
import org.futo.inputmethod.latin.R
|
||||||
import org.futo.inputmethod.latin.settings.Settings
|
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.ScreenTitle
|
||||||
import org.futo.inputmethod.latin.uix.settings.ScrollableList
|
import org.futo.inputmethod.latin.uix.settings.ScrollableList
|
||||||
|
import org.futo.inputmethod.latin.uix.settings.SettingToggleDataStore
|
||||||
import org.futo.inputmethod.latin.uix.settings.SettingToggleSharedPrefs
|
import org.futo.inputmethod.latin.uix.settings.SettingToggleSharedPrefs
|
||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
@ -20,6 +22,11 @@ fun TypingScreen(navController: NavHostController = rememberNavController()) {
|
|||||||
ScrollableList {
|
ScrollableList {
|
||||||
ScreenTitle("Typing Preferences", showBack = true, navController)
|
ScreenTitle("Typing Preferences", showBack = true, navController)
|
||||||
|
|
||||||
|
SettingToggleDataStore(
|
||||||
|
title = "Emoji Suggestions",
|
||||||
|
subtitle = "Suggest emojis while you're typing",
|
||||||
|
setting = SHOW_EMOJI_SUGGESTIONS
|
||||||
|
)
|
||||||
SettingToggleSharedPrefs(
|
SettingToggleSharedPrefs(
|
||||||
title = stringResource(R.string.auto_cap),
|
title = stringResource(R.string.auto_cap),
|
||||||
subtitle = stringResource(R.string.auto_cap_summary),
|
subtitle = stringResource(R.string.auto_cap_summary),
|
||||||
|
@ -29,6 +29,7 @@ import org.futo.inputmethod.latin.common.Constants
|
|||||||
import org.futo.inputmethod.latin.inputlogic.InputLogic
|
import org.futo.inputmethod.latin.inputlogic.InputLogic
|
||||||
import org.futo.inputmethod.latin.settings.Settings
|
import org.futo.inputmethod.latin.settings.Settings
|
||||||
import org.futo.inputmethod.latin.settings.SettingsValuesForSuggestion
|
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.SettingsKey
|
||||||
import org.futo.inputmethod.latin.uix.USE_TRANSFORMER_FINETUNING
|
import org.futo.inputmethod.latin.uix.USE_TRANSFORMER_FINETUNING
|
||||||
import org.futo.inputmethod.latin.uix.actions.PersistentEmojiState
|
import org.futo.inputmethod.latin.uix.actions.PersistentEmojiState
|
||||||
@ -81,6 +82,7 @@ public class LanguageModelFacilitator(
|
|||||||
private val userDictionary = UserDictionaryObserver(context)
|
private val userDictionary = UserDictionaryObserver(context)
|
||||||
private val emojiData = PersistentEmojiState()
|
private val emojiData = PersistentEmojiState()
|
||||||
|
|
||||||
|
private var shouldSuggestEmojis = SHOW_EMOJI_SUGGESTIONS.default
|
||||||
private var languageModel: LanguageModel? = null
|
private var languageModel: LanguageModel? = null
|
||||||
data class PredictionInputValues(
|
data class PredictionInputValues(
|
||||||
val composedData: ComposedData,
|
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)
|
(getEmojiCandidate(values.composedData.mTypedWord)
|
||||||
?: maxWord?.let { getEmojiCandidate(it.mWord) }
|
?: maxWord?.let { getEmojiCandidate(it.mWord) }
|
||||||
?: maxWordDict?.let { getEmojiCandidate(it.mWord) })?.let {
|
?: maxWordDict?.let { getEmojiCandidate(it.mWord) })?.let {
|
||||||
@ -348,6 +350,12 @@ public class LanguageModelFacilitator(
|
|||||||
emojiData.loadEmojis(context)
|
emojiData.loadEmojis(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
launch {
|
||||||
|
withContext(Dispatchers.Default) {
|
||||||
|
context.getSettingFlow(SHOW_EMOJI_SUGGESTIONS).collect { shouldSuggestEmojis = it }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scheduleTrainingWorkerBackground(context)
|
scheduleTrainingWorkerBackground(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user