mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Remember selecting emoji suggestions, improve emoji alias picking
This commit is contained in:
parent
10c08ebda6
commit
efac63ac10
@ -45,6 +45,7 @@ import org.futo.inputmethod.latin.common.Constants
|
||||
import org.futo.inputmethod.latin.uix.BasicThemeProvider
|
||||
import org.futo.inputmethod.latin.uix.DynamicThemeProvider
|
||||
import org.futo.inputmethod.latin.uix.DynamicThemeProviderOwner
|
||||
import org.futo.inputmethod.latin.uix.EmojiTracker.useEmoji
|
||||
import org.futo.inputmethod.latin.uix.SUGGESTION_BLACKLIST
|
||||
import org.futo.inputmethod.latin.uix.THEME_KEY
|
||||
import org.futo.inputmethod.latin.uix.UixManager
|
||||
@ -537,4 +538,12 @@ class LatinIME : InputMethodService(), LifecycleOwner, ViewModelStoreOwner, Save
|
||||
|
||||
refreshSuggestions()
|
||||
}
|
||||
|
||||
fun rememberEmojiSuggestion(suggestion: SuggestedWordInfo) {
|
||||
if(suggestion.mKindAndFlags == SuggestedWordInfo.KIND_EMOJI_SUGGESTION) {
|
||||
lifecycleScope.launch {
|
||||
useEmoji(suggestion.mWord)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1661,6 +1661,10 @@ public class LatinIMELegacy implements KeyboardActionListener,
|
||||
mKeyboardSwitcher.getCurrentKeyboardScriptId(),
|
||||
mHandler);
|
||||
updateStateAfterInputTransaction(completeInputTransaction);
|
||||
|
||||
if(suggestionInfo.isKindOf(SuggestedWordInfo.KIND_EMOJI_SUGGESTION)) {
|
||||
((LatinIME)mInputMethodService).rememberEmojiSuggestion(suggestionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,6 +68,7 @@ import androidx.compose.ui.unit.sp
|
||||
import org.futo.inputmethod.latin.R
|
||||
import org.futo.inputmethod.latin.SuggestedWords
|
||||
import org.futo.inputmethod.latin.SuggestedWords.SuggestedWordInfo
|
||||
import org.futo.inputmethod.latin.SuggestedWords.SuggestedWordInfo.KIND_EMOJI_SUGGESTION
|
||||
import org.futo.inputmethod.latin.SuggestedWords.SuggestedWordInfo.KIND_TYPED
|
||||
import org.futo.inputmethod.latin.suggestions.SuggestionStripView
|
||||
import org.futo.inputmethod.latin.uix.actions.ClipboardAction
|
||||
@ -306,7 +307,7 @@ fun RowScope.SuggestionItems(words: SuggestedWords, onClick: (i: Int) -> Unit, o
|
||||
try {
|
||||
for(i in 0 until words.size()) {
|
||||
val info = words.getInfo(i)
|
||||
if(info.mKindAndFlags == SuggestedWordInfo.KIND_EMOJI_SUGGESTION) {
|
||||
if(info.mKindAndFlags == KIND_EMOJI_SUGGESTION && i > 2) {
|
||||
suggestionOrder[0] = i
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ object EmojiTracker {
|
||||
suspend fun Context.useEmoji(emoji: String) {
|
||||
dataStore.edit {
|
||||
val combined = emoji + "<|>" + (it[lastUsedEmoji] ?: "")
|
||||
it[lastUsedEmoji] = combined.split("<|>").take(512).joinToString("<|>")
|
||||
it[lastUsedEmoji] = combined.split("<|>").take(128).joinToString("<|>")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,12 +463,25 @@ class PersistentEmojiState : PersistentActionState {
|
||||
}
|
||||
|
||||
emojiAliases = HashMap<String, EmojiItem>().apply {
|
||||
// Add absolute alias matches first (e.g. "joy") and only later put first-word tag/alias matches (e.g. "joy_cat")
|
||||
emojis.value!!.forEach { emoji ->
|
||||
emoji.tags.forEach { put(it.split("_").first(), emoji) }
|
||||
emoji.aliases.forEach { put(it.split("_").first(), emoji) }
|
||||
emoji.aliases.forEach {
|
||||
val x = it
|
||||
if (!containsKey(x)) {
|
||||
put(x, emoji)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emojis.value!!.forEach { emoji ->
|
||||
(emoji.tags + emoji.aliases).forEach {
|
||||
val x = it.split("_").first()
|
||||
if (!containsKey(x)) {
|
||||
put(x, emoji)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user