Skip to content

fix(android): restore Chinese IME input - #2862

Open
Degrace15 wants to merge 1 commit into
Acode-Foundation:mainfrom
Degrace15:fix/chinese-input-2493
Open

fix(android): restore Chinese IME input#2862
Degrace15 wants to merge 1 commit into
Acode-Foundation:mainfrom
Degrace15:fix/chinese-input-2493

Conversation

@Degrace15

Copy link
Copy Markdown
Contributor

Description

Fixes #2493.

Chinese IME input was not working correctly on Android.

The issue was caused by the aggressive keyboard input configuration using
TYPE_TEXT_VARIATION_VISIBLE_PASSWORD, which interfered with IME composition.

This change:

  • removes the password-like input variation;
  • preserves TYPE_TEXT_FLAG_NO_SUGGESTIONS;
  • applies the Android WebView modification after Cordova preparation.

Testing

  • Android build succeeds with npx cordova build android.
  • Verified that TYPE_TEXT_VARIATION_VISIBLE_PASSWORD is no longer present.
  • Verified that onCreateInputConnection is present only once.

@github-actions github-actions Bot added the translations Anything related to Translations Whether a Issue or PR label Sep 7, 2026
@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves the Android Java modification hook after Cordova preparation, changes the aggressive keyboard mode to avoid the password-like input variation, and adds Lingala localization.

  • Reworks generated SystemWebView.java handling for the IME fix.
  • Registers a new Lingala language catalog.
  • Updates typo-checker exclusions for the new catalog.
  • The method-removal implementation can break upgraded Android workspaces, and two Lingala localization keys are unusable.

Confidence Score: 3/5

This PR is not safe to merge until the generated Java method is removed without corrupting nested blocks and the Lingala catalog retains the canonical lookup keys.

The method-removal regex can break Android builds in realistically upgraded workspaces, while the translated Lingala keys cause pending-purchase messages to resolve to undefined.

Files Needing Attention: hooks/modify-java-files.js, src/lang/ln-ln.json

Important Files Changed

Filename Overview
hooks/modify-java-files.js Changes IME flags and generated-method handling, but the new regex can leave syntactically invalid Java in previously patched workspaces.
config.xml Moves the Java modification hook to after_prepare, before the Android compilation phase.
src/lang/ln-ln.json Adds the Lingala catalog, with two translated lookup keys that do not match canonical localization keys.
src/lib/lang.js Registers the Lingala locale and its dynamic JSON import.
_typos.toml Excludes the new Lingala catalog from typo checking.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Cordova prepare] --> B[after_prepare hook]
    B --> C[Load generated SystemWebView.java]
    C --> D{Existing patched input method?}
    D -->|Yes| E[Regex removes only first nested block]
    E --> F[Invalid Java / Android build failure]
    D -->|No| G[Continue Java modifications]
    G --> H[Android compile]
Loading

Reviews (1): Last reviewed commit: "fix(android): restore Chinese IME input" | Re-trigger Greptile

Comment on lines +477 to +480
const regex = new RegExp(
`\\n\\s*@Override\\s*\\n\\s*public\\s+[^\\s]+\\s+${methodName}\\s*\\([^)]*\\)\\s*\\{[^]*?\\n\\s*\\}`,
'm',
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Method removal corrupts Java

When upgrading an Android platform previously patched by version 2, this regex processes an onCreateInputConnection method containing nested if blocks. Its lazy match stops at the first inner closing brace, leaving the else if, else, and return statements behind. This produces invalid SystemWebView.java source and causes the Android build to fail during formatting or compilation.

Comment thread src/lang/ln-ln.json
Comment on lines +275 to +276
"Kosomba ezali kozela": "Kosomba ezali kozela",
"Ebengami": "Ebengami",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Translated keys break lookups

These entries translate the lookup keys instead of only their values. The purchase handler requests strings["purchase pending"], but this catalog defines "Kosomba ezali kozela", so a pending purchase under the Lingala locale passes undefined to the error UI. The adjacent entry similarly replaces the canonical "cancelled" key and cannot be resolved by normal localization lookups.

Suggested change
"Kosomba ezali kozela": "Kosomba ezali kozela",
"Ebengami": "Ebengami",
"purchase pending": "Kosomba ezali kozela",
"cancelled": "Ebengami",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do not mix my PRs or changes from different branches.

The Lingala translation PR was already merged and must NOT be modified, reverted, cherry-picked, or included in my current PR.

My current PR is "fix/chinese-input-2493" and is only for fixing the Chinese IME issue described in #2493.

Please keep this PR completely independent from the previous Lingala translation work. Remove any unrelated Lingala changes from this PR while preserving all changes related to the Chinese IME fix.

The final PR should contain only the changes necessary to fix #2493.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Understood. The Lingala work is unrelated to PR #2862 and this review comment should not apply to the Chinese IME fix.

The unrelated changes to remove are:

  • src/lang/ln-ln.json
  • The corresponding src/lang/ln-ln.json exclusion in _typos.toml

The Android IME changes to preserve are in config.xml and hooks/modify-java-files.js, including moving the hook to after_prepare, removing TYPE_TEXT_VARIATION_VISIBLE_PASSWORD, and ensuring onCreateInputConnection is applied only once.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, exactly. Please proceed with those changes.

Keep the Chinese IME fix only in PR #2862. Remove the unrelated Lingala changes from the PR, including the "src/lang/ln-ln.json" changes and its "_typos.toml" exclusion.

Do not modify, revert, or alter the already-merged Lingala translation PR.

Preserve the Android IME changes in "config.xml" and "hooks/modify-java-files.js".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Understood. The Lingala work is unrelated to PR #2862 and this review comment should not apply to the Chinese IME fix.

The unrelated changes to remove are:

  • src/lang/ln-ln.json
  • The corresponding src/lang/ln-ln.json exclusion in _typos.toml

The Android IME changes to preserve are in config.xml and hooks/modify-java-files.js, including moving the hook to after_prepare, removing TYPE_TEXT_VARIATION_VISIBLE_PASSWORD, and ensuring onCreateInputConnection is applied only once.

Yes, exactly. Please proceed with those changes.

Keep the Chinese IME fix only in PR #2862. Remove the unrelated Lingala changes from the PR, including the "src/lang/ln-ln.json" changes and its "_typos.toml" exclusion.

Do not modify, revert, or alter the already-merged Lingala translation PR.

Preserve the Android IME changes in "config.xml" and "hooks/modify-java-files.js".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please rerun the review/checks for PR #2862 now.

This time, review only PR #2862 (Chinese IME fix) and do not mix it with the already-merged Lingala translation PR or any unrelated changes.

Please verify the final diff before reviewing so that only the intended Chinese IME changes are considered.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review complete. The final diff is not yet limited to the Chinese IME fix: it still contains the unrelated src/lang/ln-ln.json addition and _typos.toml exclusion. I excluded those translation contents from the functional IME review, but they remain scope blockers for this PR.

Findings in the intended Android changes:

  • P1 — onCreateInputConnection is removed but never re-added (hooks/modify-java-files.js, the methods.filter(...) block). The code calls removeMethod(newContent, 'onCreateInputConnection'), then filters that same method out of contentToAddTo.methods. On a platform previously patched by version 2, patch version 3 therefore leaves SystemWebView.java without the override, so neither the no-suggestions flag nor the IME behavior is applied.
  • P1 — method removal can still corrupt Java (hooks/modify-java-files.js:480). The removeMethod regex uses a non-balanced lazy match and stops at the first nested closing brace inside onCreateInputConnection, leaving the remaining else, return, and method structure behind. This can make the generated Java fail formatting or compilation.

The intended changes themselves are present: the hook is moved to after_prepare, TYPE_TEXT_VARIATION_VISIBLE_PASSWORD is removed, and TYPE_TEXT_FLAG_NO_SUGGESTIONS is applied with |=. GitHub currently reports the commit status as pending with no checks reported. This PR is not ready for approval until the two hook issues are fixed and the Lingala files are removed from the final diff.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re-review complete. The final diff is not yet limited to the Chinese IME fix: it still contains the unrelated src/lang/ln-ln.json addition and _typos.toml exclusion. I excluded those translation contents from the functional IME review, but they remain scope blockers for this PR.

Findings in the intended Android changes:

  • P1 — onCreateInputConnection is removed but never re-added (hooks/modify-java-files.js, the methods.filter(...) block). The code calls removeMethod(newContent, 'onCreateInputConnection'), then filters that same method out of contentToAddTo.methods. On a platform previously patched by version 2, patch version 3 therefore leaves SystemWebView.java without the override, so neither the no-suggestions flag nor the IME behavior is applied.
  • P1 — method removal can still corrupt Java (hooks/modify-java-files.js:480). The removeMethod regex uses a non-balanced lazy match and stops at the first nested closing brace inside onCreateInputConnection, leaving the remaining else, return, and method structure behind. This can make the generated Java fail formatting or compilation.

The intended changes themselves are present: the hook is moved to after_prepare, TYPE_TEXT_VARIATION_VISIBLE_PASSWORD is removed, and TYPE_TEXT_FLAG_NO_SUGGESTIONS is applied with |=. GitHub currently reports the commit status as pending with no checks reported. This PR is not ready for approval until the two hook issues are fixed and the Lingala files are removed from the final diff.

Please fix all three blockers before the next review:

  1. Remove "src/lang/ln-ln.json" completely from PR fix(android): restore Chinese IME input #2862 and remove its corresponding exclusion from "_typos.toml". Do not modify or revert the already-merged Lingala translation.

  2. Fix "hooks/modify-java-files.js" so "onCreateInputConnection" is actually re-added after being removed/replaced. The current "methods.filter(...)" logic removes it but never adds the corrected method back. Make sure the generated "SystemWebView.java" contains exactly one correct "onCreateInputConnection" override.

  3. Fix "removeMethod()" so it correctly removes a Java method with nested braces. The current lazy regex stops at the first nested "}", which can leave broken Java code behind. Use balanced-brace parsing or another safe method-removal approach instead of the current non-balanced regex.

After making the fixes, verify that:

  • "TYPE_TEXT_VARIATION_VISIBLE_PASSWORD" is absent.
  • "TYPE_TEXT_FLAG_NO_SUGGESTIONS" is applied with "|=".
  • "onCreateInputConnection" exists exactly once.
  • "npx cordova build android" succeeds.
  • The final PR diff contains no Lingala translation changes or unrelated "_typos.toml" changes.

Then rerun the review/checks for PR #2862.

@Degrace15 Degrace15 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Before the next review, please clean up PR #2862 completely.

For every modified file, check whether the change is directly related to the Chinese IME fix for issue #2493. If a file contains changes that are not related to this PR, remove those unrelated changes from the PR.

Do not keep unrelated modifications just because they are in the current diff.

The final PR must contain only the changes necessary for the Chinese IME fix. Do not modify or revert the already-merged Lingala translation work.

@Degrace15

Copy link
Copy Markdown
Contributor Author

I see 14 commits in PR #2862, but this PR should only contain the 2 commits related to issue #2493.

Please clean up the branch history so that the PR contains only the 2 commits that are directly related to the Chinese IME fix.

Remove/rebase any unrelated commits from this PR. Do not modify, revert, or include the already-merged Lingala translation work.

After cleaning the history, verify that the final PR contains only the changes necessary for issue #2493.

@UnschooledGamer

Copy link
Copy Markdown
Collaborator

@Degrace15 Hey, Just for your information, Greptile is just a Review Agent, Its not intended for this, and will only lead to errors and worse reviews in return if its context fills up for such tasks.

Thanks,
UG.

@Degrace15

Copy link
Copy Markdown
Contributor Author

@Degrace15 Hey, Just for your information, Greptile is just a Review Agent, Its not intended for this, and will only lead to errors and worse reviews in return if its context fills up for such tasks.

Thanks,
UG.

Thanks for the clarification, UG. Understood.

I’ll use Greptile only for reviewing the changes, not for cleaning up or restructuring the PR history.

I’ll handle the commit and scope cleanup separately so the PR contains only the changes related to issue #2493.

Thanks for pointing that out.

@Degrace15
Degrace15 force-pushed the fix/chinese-input-2493 branch from a44b7ce to d49ea10 Compare September 7, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

translations Anything related to Translations Whether a Issue or PR

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Unable to input Chinese characters; I've tried various methods, but the problem persists.

2 participants