[Android] Handle Android IME text sequences#3692
Open
winsvega wants to merge 3 commits into
Open
Conversation
3 tasks
Author
|
Hmm, shall add backward compatibility as now it requires to override activity class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intro
I tried to vibecode this issue out. And found a solution that works for me. Please review and comment if it can be merged to android example or if it breaks any logic, I tried to make it as minimum as possible to the original src code.
Motivation
This PR is related to the issue #3102
Android IME input (especially non-Latin/composed text such as Chinese or Russian) is not reliably represented through raw native key Unicode APIs. This change adds a Java-to-native text path so committed IME text can still be delivered as sf::Event::TextEntered.

Description
Added a native JNI text callback in Android main glue:
nativeOnTextInput(JNIEnv*, jobject, jstring) decodes UTF-16 Java text to Unicode codepoints and appends them to shared activity state.
registerTextInputCallback(ANativeActivity*) registers nativeOnTextInput(String) on the activity class and logs errors if registration fails.
Callback registration is invoked during ANativeActivity_onCreate.
Added textEvents queue storage to ActivityStates for cross-module transfer of IME codepoints.
Updated Android window event processing to flush queued codepoints as Event::TextEntered and clear the queue each frame.
Updated Android example to extend NativeActivity and intercept IME text input into hidden text input. Call new callback from there into SFML
Added free font unifont-17.0.04.otf that supports many languages
Codex Task
Tasks
How to test this PR?
Compile and run updated android example