Skip to content

Reapply imeHintLocales on text change to prevent IME override mid-session.#20323

Open
Alok-Silswal wants to merge 1 commit intoankidroid:mainfrom
Alok-Silswal:fix-ime-hint-clean
Open

Reapply imeHintLocales on text change to prevent IME override mid-session.#20323
Alok-Silswal wants to merge 1 commit intoankidroid:mainfrom
Alok-Silswal:fix-ime-hint-clean

Conversation

@Alok-Silswal
Copy link

Purpose / Description

When a field has a configured imeHintLocales, the IME may override it mid-session after learning from typed characters (e.g., switching from Arabic to English).
As a result, the keyboard no longer respects the configured hint for that field.

This PR ensures that the configured imeHintLocales continues to be respected while typing.

Fixes

Approach

A TextWatcher was added to the type-answer EditText in setupTypeAnswer().

Inside afterTextChanged, InputMethodManager.restartInput() is invoked.
This reinitializes the input connection and causes the IME to re-read the configured imeHintLocales on text change.

In testing, this prevents the IME from persisting the overridden language mid-session.

How Has This Been Tested?

Test Setup:

  • Android Emulator ( Pixel 6 API 33)
  • Gboard

Steps:

  • Set imeHintLocales of a field to Arabic.
  • Start typing in the field (Arabic layout shown).
  • Manually switch keyboard to English.
  • Type in English.
  • Click on 'Back' and come again on 'Front' field.

Observed:

  • The keyboard automatically switches back to Arabic even though we typed in English earlier.
  • No visible flicker.
  • No keyboard dismissal.
  • No composition reset.
  • No typing lag.

Video is attached as evidence.

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner
Keyboard.hint.resolve.evidence.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set keyboard language hint breaks if you type in a language other than the hint language

1 participant

Comments