mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 15:32:48 +00:00
mostly fix that bug for latin
still happens for the first word after language switch (also breaks korean) more precisely: until first reset of combinerChain
This commit is contained in:
parent
baa7df8cda
commit
7bd960e1a7
3 changed files with 15 additions and 4 deletions
|
@ -2,6 +2,7 @@ package org.dslul.openboard.inputmethod.event
|
|||
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.TextUtils
|
||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher
|
||||
import org.dslul.openboard.inputmethod.latin.common.Constants
|
||||
import java.util.*
|
||||
|
||||
|
@ -37,12 +38,20 @@ class CombinerChain(initialText: String) {
|
|||
init {
|
||||
// The dead key combiner is always active, and always first
|
||||
mCombiners.add(DeadKeyCombiner())
|
||||
mCombiners.add(HangulCombiner())
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
mCombinedText.setLength(0)
|
||||
mStateFeedback.clear()
|
||||
// todo: the first word after language switch is still affected
|
||||
if (KeyboardSwitcher.getInstance().keyboard?.mId?.mSubtype?.locale?.language == "ko") {
|
||||
// if the hangul combiner is added for other keyboards, it leads to weird behavior,
|
||||
// e.g. for latin script, period is seen as part of a word
|
||||
if (mCombiners.none { it is HangulCombiner })
|
||||
mCombiners.add(HangulCombiner())
|
||||
} else {
|
||||
mCombiners.removeAll { it is HangulCombiner }
|
||||
}
|
||||
for (c in mCombiners) {
|
||||
c.reset()
|
||||
}
|
||||
|
|
|
@ -1888,7 +1888,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
}
|
||||
final Event event;
|
||||
if (mRichImm.getCurrentSubtypeLocale().getLanguage().equals("ko")) {
|
||||
event = HangulEventDecoder.decodeHardwareKeyEvent(mRichImm.getCurrentSubtype(), keyEvent,
|
||||
final RichInputMethodSubtype subtype = mKeyboardSwitcher.getKeyboard() == null
|
||||
? mRichImm.getCurrentSubtype()
|
||||
: mKeyboardSwitcher.getKeyboard().mId.mSubtype;
|
||||
event = HangulEventDecoder.decodeHardwareKeyEvent(subtype, keyEvent,
|
||||
() -> getHardwareKeyEventDecoder(keyEvent.getDeviceId()).decodeHardwareKey(keyEvent));
|
||||
} else {
|
||||
event = getHardwareKeyEventDecoder(keyEvent.getDeviceId()).decodeHardwareKey(keyEvent);
|
||||
|
|
|
@ -104,8 +104,7 @@ public final class WordComposer {
|
|||
public void restartCombining(final String combiningSpec) {
|
||||
final String nonNullCombiningSpec = null == combiningSpec ? "" : combiningSpec;
|
||||
if (!nonNullCombiningSpec.equals(mCombiningSpec)) {
|
||||
mCombinerChain = new CombinerChain(
|
||||
mCombinerChain.getComposingWordWithCombiningFeedback().toString());
|
||||
mCombinerChain = new CombinerChain(mCombinerChain.getComposingWordWithCombiningFeedback().toString());
|
||||
mCombiningSpec = nonNullCombiningSpec;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue