Search code examples
androidandroid-softkeyboardandroid-input-methodcandidate

Android Sample Soft Keyboard: Partial text deletion/hiding by switiching between ABC and 123? keyboards


It seems that there is an issue with the Android Soft Keyboard ( sample ). It works weird when I try typing some letters from ABC keyboard then some special characters like apostrofe ('), quotation (") and some others. In practice it removes the ABC characters by pressing those special characters, and appends them to the end of the characters as soon as I press the next alphabetical characters.

Question:

  • a) If you have this keyboard operational on your device could you please give it a try and let me know if that also happens on yours?
  • b) If the issue is actual, what are the suggestions to resolve that?

An example sentence: You'll be fine Where it creates the problem between "You" and "ll"

  1. Type: You
  2. Use 123? button to switch to the other keyboard
  3. Then type: apostrofe mark (')
  4. Use ABC button to switch to the alphabetical keyboard
  5. Then type: ll

What I see in the text field in each step (Steps 3 and 5 depict the unusual behavior):

  1. You
  2. You
  3. '
  4. '
  5. 'Youll

I'm specious that the issue comes from the keyboard's suggestion making functionality since only the newly typed characters are misplaced if you keep typing other alphabetical characters and include new special characters in between.


Solution

  • Eventually I figured out what the problem was, so I'm sharing the solution for those who may encounter the situation: It seems that some characters were omitted to be included in the word separators in the String.xml

    Take a look at the file here. At line# 25 it specifies the word separators:

    <string name="word_separators">\u0020.,;:!?\n()[]*&amp;@{}/&lt;&gt;_+=|&quot;</string>
    

    I added Apostrophe, slash and back slash and the result looked like this:

    <string name="word_separators">\u0020.,;:!?\n()[]*&amp;@{}/&lt;&gt;_+=|&quot;'\\/</string>
    

    Apparently the example that I provided in the question works fine.