Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): Enhance how ENTER key is handled for FV and KMSample2 #12745

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ public void onStartInput(EditorInfo attribute, boolean restarting) {
super.onStartInput(attribute, restarting);
KMManager.onStartInput(attribute, restarting);
KMManager.resetContext(KeyboardType.KEYBOARD_TYPE_SYSTEM);

// Determine special handling for ENTER key
int inputType = attribute.inputType;
KMManager.setEnterMode(attribute.imeOptions, inputType);

// User switched to a new input field so we should extract the text from input field
// and pass it to Keyman Engine together with selection range
InputConnection ic = getCurrentInputConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ public void onStartInput(EditorInfo attribute, boolean restarting) {
KMManager.setBannerOptions(mayPredict);
}
}

// Determine special handling for ENTER key
KMManager.setEnterMode(attribute.imeOptions, inputType);

// User switched to a new input field so we should extract the text from input field
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though you are only adding a couple lines to the code here, it would be nice to break up the functionality of onStartInput into several methods. It is about 50 lines long and is checking several conditions with discrete tasks. Rather than having blocks of code with nice comments, it would be better to extract these into small well-named methods. Even if the methods are not used anywhere else, it will be more readable and unit-testable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - that's a good suggestion (maybe can do some in early 19.0).

A lot of the Android code could use refactoring (SystemKeyboard and the main culprit KMManager).

// and pass it to Keyman Engine together with selection range
InputConnection ic = getCurrentInputConnection();
Expand Down