Fix Enter key sending message in Discord
Some checks failed
Make Apk CI / Build-Apk (push) Has been cancelled
Check translations / check-translations (push) Has been cancelled
Check layouts / check_layout.output (push) Has been cancelled
Check layouts / Generated files (push) Has been cancelled

Set the flag FLAG_SOFT_KEYBOARD when sending key events stops Discord
from sending message when typing Enter.
The other values are the same that are sent when using sendDownUpKeyEvents().
This commit is contained in:
Jules Aguillon 2025-01-25 23:20:05 +01:00
parent 188c68279d
commit e1191f3add

View File

@ -3,6 +3,7 @@ package juloo.keyboard2;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.os.Looper; import android.os.Looper;
import android.text.InputType; import android.text.InputType;
import android.view.KeyCharacterMap;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedText;
@ -196,7 +197,9 @@ public final class KeyEventHandler
InputConnection conn = _recv.getCurrentInputConnection(); InputConnection conn = _recv.getCurrentInputConnection();
if (conn == null) if (conn == null)
return; return;
conn.sendKeyEvent(new KeyEvent(1, 1, eventAction, eventCode, 0, _meta_state)); conn.sendKeyEvent(new KeyEvent(1, 1, eventAction, eventCode, 0,
_meta_state, KeyCharacterMap.VIRTUAL_KEYBOARD, 0,
KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
if (eventAction == KeyEvent.ACTION_UP) if (eventAction == KeyEvent.ACTION_UP)
_autocap.event_sent(eventCode, _meta_state); _autocap.event_sent(eventCode, _meta_state);
} }