Set keyboard language hint breaks if you type in a language other than the hint language
Checked for duplicates?
- [x] This issue is not a duplicate
Does it also happen in the desktop version?
- [x] This bug does not occur in the latest version of Anki Desktop
What are the steps to reproduce this bug?
Obvious details
- To set the keyboard hint language, go to the deck screen -> 3 dot menu -> manage note types -> tap on a note type -> tap on a field -> set keyboard language hint
- Add the Arabic, English, French, and Japanese languages to your keyboard (I tested on Gboard).
- You can check the feature in the note editor without adding cards. Just tap the different fields to observe the language of the keyboard.
- Use a fresh collection and fresh v2.23.1 install for testing, to match the behavior I'm going to describe.
Steps to reproduce 1: One note type & one field with a hint
- Set the keyboard language hint for the front field of the "Basic" note type to Arabic.
- Check that it works.
- Switch the keyboard to French and type in the front field.
Now it's as if the language hint is French.
Typing some Arabic text into the front field fixes it.
Steps to reproduce 2: Two note types & one field with a hint each
- Set the keyboard language hint for the front field of the "Basic" note type to Arabic.
- Set the keyboard language hint for the front field of the "Basic (and reversed)" note type to Japanese.
- Open the note editor.
I tried this several times (each time doing a fresh install) and got different results, but each time, it preselects the "Basic (and reversed)" note type.
Sometimes, it shows the Japanese keyboard, other times it shows the English keyboard, even other times still, it shows the Arabic keyboard. Also, switching to the "Basic" note type sometimes shows the Japanese keyboard.
Typing French in the front fields makes it the hint language for both note types.
Typing some Arabic in the front field of the "Basic" note type and some English in the back field, (sometimes) fixes the issue for both note types. Doing the same with Japanese in the "Basic (and reversed)" note type doesn't fix it, but makes it the hint language like French.
Here is a recording in v2.23.1 demonstrating the bug (using the second reproduction steps): https://drive.google.com/file/d/1rIC_D6ibX9gtMICp0yvKoNDi9Qow2oT7/view?usp=drivesdk
This also affects type-in cards for both the old and new study screen: the language shown in the study screen is the same as the one in the note editor for the same field.
The same thing happens in v2.20.1 and v2.22.2.
Expected behaviour
It should work.
Debug info
AnkiDroid Version = 2.23.1 (3f3133b496b531383e9a6494f5a7704634935308)
Backend Version = 0.1.62-anki25.09.2 (25.09.2 3890e12c9e48c028c3f12aa58cb64bd9f8895e30)
Android Version = 13 (SDK 33)
ProductFlavor = full
Device Info = Xiaomi | POCO | mondrian | mondrian_global | 23013PC75G | qcom
Webview User Agent = Mozilla/5.0 (Linux; Android 13; 23013PC75G Build/TKQ1.220905.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/142.0.7444.171 Mobile Safari/537.36
ACRA UUID = 4afc3b3f-e93f-4a66-bc71-2b9476ef9eb0
FSRS = 5.1.0 (Enabled: false)
Crash Reports Enabled = true
(Optional) Anything else you want to share?
I'm using Gboard. Screenshot from the Gboard's "About" section:
Research
- [x] I have checked the manual and the FAQ and could not find a solution to my issue
- [x] (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)
@ZornHadNoChoice New or old study screen? Is this a regression from 2.22?
The option is supposed to work in the note editor so I don't know how the study screen is related. But, just in case, I tested and it doesn't work whether the new reviewer is on or not.
~~Yes. The feature works as expected in v2.22.3 parallel C, though it didn't work on the v2.22.3 Google Play release when I tested it a while ago.~~
Nevermind, it worked once then it stopped working in v2.22.3 parallel C.
Hmmm. I downloaded v2.20.1 and it the feature worked, then I updated to v2.21.1 and it still worked, then I updated to v2.22.2 and it still worked. I then tried adding a note and after typing in English (not the hinted language), it stopped working. I tried reinstalled v2.20.1 and it still didn't work. I tried setting the language hint to other fields/note types and it didn't work. I even tried deleting the app and the collection and installing v2.20.1 fresh and it still doesn't work!
I'll try to pinpoint the issue and summarize this.
Ah, apologies. Thanks.
The feature was updated to also work with 'type the answer'. If you could test here, it'd be useful
I updated the description.
This may not be fixable - we can only provide a hint to the IME, the IME is responsible for selection and persistence.
https://developer.android.com/reference/android/widget/TextView#setImeHintLocales(android.os.LocaleList)
We should test if InputMethodManager.restartInput(View) can be used, but I suspect it will cause a flicker.
I would like to work on this
Hi! I’m new to contributing but I reproduced the issue on Gboard I’m exploring whether re-applying the IME hint and calling InputMethodManager.restartInput() on focus change helps
@DDurgeshmahajan This issue is already assigned, you should check with @nagarjunahp88-byte before working on it.
@nagarjunahp88-byte are you still working on this? If not, then I'd like to look into it.
@Alok-Silswal You can work on it.
@david-allison Please assign it to me. @nagarjunahp88-byte has allowed for the same.
Hello, @Alok-Silswal , are you still working on it? I would like to look into it if you are not.
Yes, I am working on it.
Hey, @Alok-Silswal, could you please pass this to me if you are no longer looking into it?
Please be patient. I am looking into this.
We should test if InputMethodManager.restartInput(View) can be used, but I suspect it will cause a flicker.
I am configuring this to test out things properly.
Hi @maintainers 👋
I’d like to work on this issue. Please assign it to me. I’ll start by investigating the relevant files and will update here with my findings soon.
Thanks!
Thanks for the response, @Alok-Silswal let me know in case you want to pass on.
I see this issue is already assigned, but I wanted to share a quick preliminary investigation in case it’s helpful:
- In
ReviewerFragment.kt, the code appears to reapplyimeHintLocalesand callrestartInput()on every card update, which likely forces the keyboard back to the hinted language. - This seems to override the user’s manual keyboard language choice.
If it’s useful, I’m happy to help test a fix, review a patch, or investigate further.
Thanks!
@shivamatram If you don't see a PR opened for this in the next 2-3 days you can post a PR.
Hi 👋
I would like to work on this issue.
Can you please assign it to me?