From a0f77c1392a33f76bd207fc861dbca7422b00c66 Mon Sep 17 00:00:00 2001 From: Helium314 Date: Fri, 16 May 2025 21:20:34 +0200 Subject: [PATCH] don't suggest unsuported emojis and invert isSupported to isUnsupported to avoid confusion what happens when asking about non-emojis --- .../helium314/keyboard/keyboard/emoji/SupportedEmojis.kt | 2 +- .../keyboard/internal/keyboard_parser/EmojiParser.kt | 6 +++--- .../helium314/keyboard/latin/DictionaryFacilitatorImpl.java | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/keyboard/emoji/SupportedEmojis.kt b/app/src/main/java/helium314/keyboard/keyboard/emoji/SupportedEmojis.kt index fcc304ebe..f3ffb5bfd 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/emoji/SupportedEmojis.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/emoji/SupportedEmojis.kt @@ -22,5 +22,5 @@ object SupportedEmojis { Log.i("test", "have ${unsupportedEmojis.size}, longest emoji: ${unsupportedEmojis.maxOfOrNull { it.length }}") } - fun isSupported(emoji: String) = emoji !in unsupportedEmojis + fun isUnsupported(emoji: String) = emoji in unsupportedEmojis } diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/EmojiParser.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/EmojiParser.kt index 414f7cc2b..81d34170e 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/EmojiParser.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/EmojiParser.kt @@ -78,13 +78,13 @@ class EmojiParser(private val params: KeyboardParams, private val context: Conte private fun parseEmojiKeyNew(line: String): KeyParams? { if (!line.contains(" ") || params.mId.mElementId == KeyboardId.ELEMENT_EMOJI_CATEGORY10) { // single emoji without popups, or emoticons (there is one that contains space...) - return if (!SupportedEmojis.isSupported(line)) null + return if (SupportedEmojis.isUnsupported(line)) null else KeyParams(line, line.getCode(), null, null, Key.LABEL_FLAGS_FONT_NORMAL, params) } val split = line.split(" ") val label = split.first() - if (!SupportedEmojis.isSupported(label)) return null - val popupKeysSpec = split.drop(1).filter { SupportedEmojis.isSupported(it) } + if (SupportedEmojis.isUnsupported(label)) return null + val popupKeysSpec = split.drop(1).filterNot { SupportedEmojis.isUnsupported(it) } .takeIf { it.isNotEmpty() }?.joinToString(",") return KeyParams( label, diff --git a/app/src/main/java/helium314/keyboard/latin/DictionaryFacilitatorImpl.java b/app/src/main/java/helium314/keyboard/latin/DictionaryFacilitatorImpl.java index aa96e5b74..2bd17f62e 100644 --- a/app/src/main/java/helium314/keyboard/latin/DictionaryFacilitatorImpl.java +++ b/app/src/main/java/helium314/keyboard/latin/DictionaryFacilitatorImpl.java @@ -34,6 +34,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import helium314.keyboard.keyboard.Keyboard; +import helium314.keyboard.keyboard.emoji.SupportedEmojis; import helium314.keyboard.latin.NgramContext.WordInfo; import helium314.keyboard.latin.SuggestedWords.SuggestedWordInfo; import helium314.keyboard.latin.common.ComposedData; @@ -885,7 +886,7 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator { final boolean checkForGarbage = composedData.mIsBatchMode && (dictType.equals(Dictionary.TYPE_USER_HISTORY) || dictType.equals(Dictionary.TYPE_MAIN)); for (SuggestedWordInfo info : dictionarySuggestions) { final String word = info.getWord(); - if (!isBlacklisted(word)) { // don't add blacklisted words + if (!isBlacklisted(word) && !SupportedEmojis.INSTANCE.isUnsupported(word)) { // don't add blacklisted words and unsupported emojis if (checkForGarbage // only check history and "main main dictionary" // consider the user might use custom main dictionary containing shortcuts