After bumping the targetSdk of Flutter apps to 28, the keyboard doesn't open anymore when inputting text on an Android Pie devices. The problem is caused by a change on the way the focus in handled: when the call `mImm.showSoftInput(view, 0);` is made, the currently focused view is the `DecorView` from the `Activity` hosting Flutter but the passed view reference (`view` argument) is the `FlutterView`. As the `InputMethodManager` checks if both views are the same before showing the keyboard, it never appears because the `FlutterView` never has focus.
As Flutter doesn't have any input views as far as the Android side is concerned, the focus should always stay on the `FlutterView` itself and thus, this PR changes the `TextInputPlugin` to focus on the `FlutterView` as soon as it's created, fixing the keyboard issue.
Co-authored-by: Igor Borges <igorborges12@gmail.com>
If restartInput is called twice in quick succession, then the IME may output
warnings related to usage of the obsolete connection resulting from the first
call.
Fixes https://github.com/flutter/flutter/issues/10730
In particular, this avoids some unnecessary calls to InputMethodManager.restartInput
that caused noticeable lag when moving the cursor.
Fixes https://github.com/flutter/flutter/issues/9928
Some keyboards (e.g., on some Samsung devices, SwiftKey) ignore
InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS and require
InputType.TYPE_TEXT_VARIATION_PASSWORD.