-
Notifications
You must be signed in to change notification settings - Fork 118
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
Fix predictive text issue with Samsung devices on Android 13 #1024
Fix predictive text issue with Samsung devices on Android 13 #1024
Conversation
…id into issue/1023-fix-predictive-text-issue-on-samsung-devices
…ssue-on-samsung-devices' into issue/1023-fix-predictive-text-issue-on-samsung-devices
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a brilliant fix @khaykov ! Thank you for taking care of this. We should plan to circle back in a few months to see if it's still an issue since Samsung may fix these issues in a future release. I don't have an Android 13 Samsung device, but I do have one on Android 12. I tested on a Samsung Galaxy S21 FE 5G with the following keyboards:
- Samsung Keyboard
- Gboard
- Grammarly Keyboard
All passed with flying colors 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM, awesome work!
I also tested on my Samsung Galaxy S21+ with Android 13 (One UI 5.0) and it's very buggy on trunk
version but everything works correctly after this change! 🎉
I added a fix for paragraph spans (like heading) leaking on the next line.
|
Fixes #1023
This PR fixes the predictive text (Grammarly) issue present in default Samsung keyboard on devices with Android 13 (api 33).
Problem:
When Grammarly kick-in and marks issues in the text, content of the editor is replaced with malformed content, where some of the existing spans are removed from editor, and cursor sometimes moves to the end of the text.
Video from the issue to illustrate it:
https://user-images.githubusercontent.com/728822/211878346-1d296b47-8031-4f18-841a-23fb2a190172.mp4
In addition, we can't debug the Android source code, since it is different on Samsung.
Solution:
I tried multiple approaches using
InputFilters
andTextWatchers
to detect when the issue is happening, and remedy it. While they do work to some extent, they are not very reliable, and there is one problem I was not able to adress - cursor moving to the end of the text (and scrolling the editor as well).My last resort was trying to implement a custom
InputConnection
, but I realized that I don't necessarily need to do it - I can make a wrapper around Samsung version, and direct/intercept all the calls to it to see what is up. This worked well, and If found out that Samsung is using Extracted Text (one you usually see in EditText when it expands in landscape mode) for Grammarly, and returning null from it (default behavior of BaseInputConnection) disables the Grammarly, but still keeps regular suggestions and spellchecker.Unfortunately, I was not able to make Grammarly work without messing up content of the editor, but in my opinion that's fine.
The fix is disabled by default in a library, but enable in Demo App.
Test device targeting
Overriding predictive text behavior on Samsung device with API 33
Test the fix
strings.xml
as a part of the integration PR.