Fix keyboard not showing for targetSdk 28 (flutter/engine#6985)

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>
This commit is contained in:
Rafael Ring
2018-12-11 03:01:12 -02:00
committed by Michael Goderbauer
parent fc0ea72552
commit 5755e8b956

View File

@@ -167,6 +167,7 @@ public class TextInputPlugin implements MethodCallHandler {
}
private void showTextInput(FlutterView view) {
view.requestFocus();
mImm.showSoftInput(view, 0);
}