Closed DDoSolitary closed 5 years ago
This only changes the variable, not the order of onKey and onKeyLongPress. Also, I cannot recreate issue #54
I'm quite surprised because I've observed this in a number of ROMs, including resurrection remix pie and MIUI(Xiaomi’s official ROM) pie. I can upload a screen record of this issue if you want.
I'm not an Android developer but from what I can see from the code, I guess the following happens when I long press the space button.
onPress
is called and a timer is started.onKeyLongPress
is called.onKey
is called but switchedKeyboard
hasn't been set yet, so a space is written.showInputMethodPicker
returns and switchedKeyboard
gets set.I don't know if showInputMethodPicker
returns after the picker is shown or after it is closed. But given that you can't reproduce this issue, I think it's reasonable to assume the former. If that is the case, then I guess there's some sort of racing happening here: on your device showInputMethodPicker
returns faster and the flag is set before onKey
reads it, while on my device onKey
runs faster.
Again, I'm not an Android developer, so I might have some mistakes in my theory and I can't test my patch because I don't know how to build and debug this app. Please let me know if you spotted any mistakes. And could you please build the app with the patch applied and upload the apk so that I can see if the patch actually fixes the issue on my device. Thanks!
PS: You said that "feel free to reopen it" in the issue I opened, but an issue can't be reopened by the original poster if it is closed by a repo owner/collaborator.
Thanks for looking into it! I'll upload an apk here, please do test it and let me know.
Just tested and it works fine, but I just found out it might not be my patch doing the magic:
onKeyLongPress
is executed in the UI thread rather than a separate thread as I previously thought, so there's no chance for a race to occur (or it's an Android's bug...)So could you please upload an apk with my commit reverted to verify this? And it will be nice to have an up-to-date version available at Play Store after this issue (and probably other issues that you want to fix now) is properly dealt with.
Yeah, I really need to update the Play Store version. Here's the original apk app_og.zip
The original one works fine either, so my patch is completely unnecessary 🤣
Fix #51.