From b2d92b2c9f3a74a31dee8296739986579b95e47f Mon Sep 17 00:00:00 2001 From: amirh Date: Wed, 25 Jul 2018 08:51:56 -0700 Subject: [PATCH] Make the virtual display's presentation window non focusable. (flutter/engine#5845) When the FlutterView's window loses focus Flutter cannot bring up the keyboard (so e.g tapping on text fields doesn't work). This workaround makes sure that Flutter text fields are working but unfortunately now the embedded Android view cannot bring up the keyboard as it's window is not focused. Submitting this until as a stop gap while we're trying to figure out if it's possible to allow both windows to bring up the keyboard. --- .../flutter/plugin/platform/SingleViewPresentation.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/SingleViewPresentation.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/SingleViewPresentation.java index b305c40faf..f743061de6 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/SingleViewPresentation.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/SingleViewPresentation.java @@ -11,6 +11,7 @@ import android.os.Build; import android.os.Bundle; import android.view.Display; import android.view.View; +import android.view.WindowManager; import android.widget.FrameLayout; @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @@ -32,6 +33,10 @@ class SingleViewPresentation extends Presentation { super(outerContext, display); mViewFactory = viewFactory; mViewId = viewId; + getWindow().setFlags( + WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, + WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE + ); } /** @@ -45,6 +50,10 @@ class SingleViewPresentation extends Presentation { super(outerContext, display); mViewFactory = null; mView = view; + getWindow().setFlags( + WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, + WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE + ); } @Override