Uh oh!
There was an error while loading. Please reload this page.
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
AmandaRiu
left a comment
There was a problem hiding this comment.
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 👍🏻
thomashorta
left a comment
There was a problem hiding this comment.
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
InputFiltersandTextWatchersto 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 33Test the fix
strings.xmlas a part of the integration PR.