diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/KeyboardParser.kt b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/KeyboardParser.kt index 38e004cab..24c9a2579 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/KeyboardParser.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/KeyboardParser.kt @@ -20,9 +20,11 @@ import org.dslul.openboard.inputmethod.latin.common.Constants import org.dslul.openboard.inputmethod.latin.common.splitOnWhitespace import org.dslul.openboard.inputmethod.latin.define.DebugFlags import org.dslul.openboard.inputmethod.latin.settings.Settings +import org.dslul.openboard.inputmethod.latin.spellcheck.AndroidSpellCheckerService import org.dslul.openboard.inputmethod.latin.utils.InputTypeUtils import org.dslul.openboard.inputmethod.latin.utils.RunInLocale import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils +import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils import org.dslul.openboard.inputmethod.latin.utils.sumOf import java.util.Locale @@ -628,6 +630,13 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co private fun String.replaceIconWithLabelIfNoDrawable(): String { if (params.mIconsSet.getIconDrawable(KeyboardIconsSet.getIconId(this)) != null) return this + if (params.mId.mWidth == AndroidSpellCheckerService.SPELLCHECKER_DUMMY_KEYBOARD_WIDTH + && params.mId.mHeight == AndroidSpellCheckerService.SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT + && !params.mId.mSubtype.rawSubtype.extraValue.contains(Constants.Subtype.ExtraValue.EMOJI_CAPABLE) + ) + // fake keyboard that is used by spell checker (for key coordinates), but not shown to the user + // often this doesn't have any icons loaded, and there is no need to bother with this + return this val id = context.resources.getIdentifier("label_$this", "string", context.packageName) if (id == 0) { val message = "no resource for label $this in ${params.mId}" diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/app/src/main/java/org/dslul/openboard/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index 8e5cff2bd..2a4aae7b2 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -45,8 +45,8 @@ public final class AndroidSpellCheckerService extends SpellCheckerService public static final String PREF_USE_CONTACTS_KEY = "pref_spellcheck_use_contacts"; - private static final int SPELLCHECKER_DUMMY_KEYBOARD_WIDTH = 480; - private static final int SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT = 301; + public static final int SPELLCHECKER_DUMMY_KEYBOARD_WIDTH = 480; + public static final int SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT = 301; private static final String DICTIONARY_NAME_PREFIX = "spellcheck_"; @@ -156,8 +156,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService public boolean isValidWord(final Locale locale, final String word) { mSemaphore.acquireUninterruptibly(); try { - DictionaryFacilitator dictionaryFacilitatorForLocale = - mDictionaryFacilitatorCache.get(locale); + DictionaryFacilitator dictionaryFacilitatorForLocale = mDictionaryFacilitatorCache.get(locale); return dictionaryFacilitatorForLocale.isValidSpellingWord(word); } finally { mSemaphore.release();