Skip to content
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

TextInput not behaving with SwiftKey #198

Closed
dusty-phillips opened this issue Jan 20, 2014 · 7 comments · Fixed by #204
Closed

TextInput not behaving with SwiftKey #198

dusty-phillips opened this issue Jan 20, 2014 · 7 comments · Fixed by #204

Comments

@dusty-phillips
Copy link

Note: qua-non was unable to reproduce this bug, but we wanted to post it here for future testing.

TextInput isn't working for me when I deploy it to my Android phone running SwiftKey. Instead of allowing me to enter and predict words, as SwiftKey does in other apps, each letter I enter overwrites the previous character. If I press the space key, it inserts a space, and the next enter shows up correctly. However, another letter after that will overwrite the previous one. Thus if I type 'hello world', I see the following in the display (one line per keypress):

h
e
l
l
o
o<space>
o w
o o
o r
o l
o d

Using the HTC Sense or default Android keyboard, I get expected behavior, so this is an interaction effect with SwiftKey. I've tested this on an Android 4.2.2 (AOKP) and a Android 4.3 (HTC Sense) device, both using Swiftkey 4.4.2.254. I'm also getting it using the Swiftkey 4.5 beta app.

@snarky-snark
Copy link

I am able to reproduce this as well. I'm running Android 4.4.2 with SwiftKey 4.4.2.254, Kivy 1.7.2 and python-for-android (changeset:21037eb).

@akshayaurora
Copy link
Member

@buchuki @snarky-snark could you guys test with setting keyboard_suggestion set to False? http://kivy.org/docs/api-kivy.uix.textinput.html#kivy.uix.textinput.TextInput.keyboard_suggestions

Just want to know if this issue is even reproducible with keyboard suggestions disabled.

@snarky-snark
Copy link

Sure. For what it's worth, the predictions in SwiftKey populate the TextInput correctly. It's just single character input that appears to be having issues.

@snarky-snark
Copy link

I get the same behavior when keyboard_suggestions is set to False.

@snarky-snark
Copy link

I get the same behavior with Kivy 1.8.1.

@snarky-snark
Copy link

I have determined the cause of this error. When a single character is entered using SwiftKey, an insert command is sent to the 'on_key_down' handler of TextInput. When any additional characters are entered after the first, SwiftKey sends a command to delete the previous character followed by a command to insert the next character.

For example, assume that the string 'abc' is typed on the SwiftKey keyboard (one character at a time not swiped). After 'a' is typed, SwiftKey will dispatch the following characters sequentially via the Keyboard 'on_key_down' event to be handled by the 'insert_text' method of TextInput: ' INSERT:a '. After 'b' is typed, the commands ' DEL:1 INSERT:b ' are dispatched. After 'c' is typed, the commands ' DEL:1 INSERT:c ' are dispatched.

I'm not sure why SwiftKey is sending these delete commands. They are only sent when more than one character is entered individually, sequentially. A delete command is sometimes not sent if the character is a period. This doesn't happen, when words are swiped, only when individual characters are entered in sequence.

Another quirk is that long pressing backspace sends a ' DEL:1023 ' command regardless of the length of the previous word. This results in the deletion of the last 1023 characters of the text in the TextInput.

It appears that these are bugs in SwiftKey and not in Kivy. I don't see any way to fix these issues by modifying Kivy. There is no way to differentiate between a sequence of delete and insert commands entered by the user and that same sequence entered erroneously by SwiftKey. :/

@snarky-snark
Copy link

I looked into the implementation of the subclassed BaseInputConnection in python-for-android that is responsible for dispatching the 'DEL' and 'INSERT' commands. I think the 'setComposingText' and 'commitText' methods should be taking into account the newCursorPosition and the bounds of the previous composing text. If you look into the implementation of BaseInputConnection in Android, the 'replaceText' method (line 596) demonstrates the complexity of managing this. I don't think deleting the length of the previous composing text is sufficient to handle all cases of composing text as is evidenced by this bug with SwiftKey.

https://android.googlesource.com/platform/frameworks/base/+/c064a1b5d9a68bb5513e6ed64a067ab822e98764/core/java/android/view/inputmethod/BaseInputConnection.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants