1

Problem: Can't delete image in contenteditable div on Android

Only known solution at the moment: Android: Backspace in WebView/BaseInputConnection

Problem with solution: Setting: creating a BaseInputConnection using the regular constructor seems to disable speech to text from functioning correctly. as opposed to using WebView.onCreateInputConnection(EditorInfo) to generate an InputConnection.

any ideas how to remedy this?

Community
  • 1
  • 1
user3251651
  • 93
  • 1
  • 9
  • You asked for help on this. I am sorry, but I do not do much complex with `WebView` and have never touched `InputConnection` in my life. – CommonsWare Jul 13 '14 at 01:13

1 Answers1

1

I had the same issue also with text completion using SwiftKey. In order to fix it you must remember some things:

  • you must extend BaseInputConnection and wrap the original webview's InputConnection
  • don't use InputConnectionWrapper as it will cause other problems
  • you need to subclass a second method: commitText

    public boolean commitText(CharSequence text, int newCursorPosition) {
    
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
            return orig.commitText(text, newCursorPosition);
    
        } else {
            // pre-kitkat workaround 
            boolean res = true;
            for (int i = 0; i < text.length(); i++) {
                res = orig.commitText(text.subSequence(i, i+1), newCursorPosition);
            }
            return res;
        }
    }
    
Simone Avogadro
  • 789
  • 8
  • 23