mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 23:42:55 +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.SpannableStringBuilder
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
|
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher
|
||||||
import org.dslul.openboard.inputmethod.latin.common.Constants
|
import org.dslul.openboard.inputmethod.latin.common.Constants
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@ -37,12 +38,20 @@ class CombinerChain(initialText: String) {
|
||||||
init {
|
init {
|
||||||
// The dead key combiner is always active, and always first
|
// The dead key combiner is always active, and always first
|
||||||
mCombiners.add(DeadKeyCombiner())
|
mCombiners.add(DeadKeyCombiner())
|
||||||
mCombiners.add(HangulCombiner())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reset() {
|
fun reset() {
|
||||||
mCombinedText.setLength(0)
|
mCombinedText.setLength(0)
|
||||||
mStateFeedback.clear()
|
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) {
|
for (c in mCombiners) {
|
||||||
c.reset()
|
c.reset()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1888,7 +1888,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
final Event event;
|
final Event event;
|
||||||
if (mRichImm.getCurrentSubtypeLocale().getLanguage().equals("ko")) {
|
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));
|
() -> getHardwareKeyEventDecoder(keyEvent.getDeviceId()).decodeHardwareKey(keyEvent));
|
||||||
} else {
|
} else {
|
||||||
event = getHardwareKeyEventDecoder(keyEvent.getDeviceId()).decodeHardwareKey(keyEvent);
|
event = getHardwareKeyEventDecoder(keyEvent.getDeviceId()).decodeHardwareKey(keyEvent);
|
||||||
|
|
|
@ -104,8 +104,7 @@ public final class WordComposer {
|
||||||
public void restartCombining(final String combiningSpec) {
|
public void restartCombining(final String combiningSpec) {
|
||||||
final String nonNullCombiningSpec = null == combiningSpec ? "" : combiningSpec;
|
final String nonNullCombiningSpec = null == combiningSpec ? "" : combiningSpec;
|
||||||
if (!nonNullCombiningSpec.equals(mCombiningSpec)) {
|
if (!nonNullCombiningSpec.equals(mCombiningSpec)) {
|
||||||
mCombinerChain = new CombinerChain(
|
mCombinerChain = new CombinerChain(mCombinerChain.getComposingWordWithCombiningFeedback().toString());
|
||||||
mCombinerChain.getComposingWordWithCombiningFeedback().toString());
|
|
||||||
mCombiningSpec = nonNullCombiningSpec;
|
mCombiningSpec = nonNullCombiningSpec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue