Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[webview_flutter] Fix double tap on resize issue #1965

Merged
merged 1 commit into from
Aug 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/webview_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.3.11+2

* Add fix for input connection being dropped after a screen resize on certain
Android devices.

## 0.3.11+1

* Work around a bug in old Android WebView versions that was causing a crash
Expand Down
6 changes: 2 additions & 4 deletions packages/webview_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ Keyboard support within webviews is also experimental. The above tags also
surface known issues with keyboard input. Some currently known keyboard issues,
as of `webview_flutter` version `0.3.10+4`:

* [Input needs to be tapped twice to be registered on Samsung
devices](https://github.com/flutter/flutter/issues/35867)
* [Keyboard behavior is buggy after a
resize](https://github.com/flutter/flutter/issues/36978)
* [Keyboard persists after tapping outside text
field](https://github.com/flutter/flutter/issues/36478)
* [WebView's text selection dialog is not responding to touch
events](https://github.com/flutter/flutter/issues/24585)

## Setup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.annotation.TargetApi;
import android.os.Build;
import android.util.Log;
import android.view.KeyEvent;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
Expand Down Expand Up @@ -110,6 +111,13 @@ public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request
public void onPageFinished(WebView view, String url) {
FlutterWebViewClient.this.onPageFinished(view, url);
}

@Override
public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
// Deliberately empty. Occasionally the webview will mark events as having failed to be
// handled even though they were handled. We don't want to propagate those as they're not
// truly lost.
}
};
}

Expand All @@ -130,6 +138,13 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
public void onPageFinished(WebView view, String url) {
FlutterWebViewClient.this.onPageFinished(view, url);
}

@Override
public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
// Deliberately empty. Occasionally the webview will mark events as having failed to be
// handled even though they were handled. We don't want to propagate those as they're not
// truly lost.
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,11 @@ void lockInputConnection() {

/** Sets the proxy adapter view back to its default behavior. */
void unlockInputConnection() {
if (proxyAdapterView != null) {
proxyAdapterView.setLocked(false);
if (proxyAdapterView == null) {
return;
}

// Restart the input connection to avoid ViewRootImpl assuming an incorrect window state.
InputMethodManager imm =
(InputMethodManager) containerView.getContext().getSystemService(INPUT_METHOD_SERVICE);
imm.restartInput(containerView);
proxyAdapterView.setLocked(false);
}

/** Restore the original InputConnection, if needed. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/** WebViewFlutterPlugin */
public class WebViewFlutterPlugin {

/** Plugin registration. */
public static void registerWith(Registrar registrar) {
registrar
Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: webview_flutter
description: A Flutter plugin that provides a WebView widget on Android and iOS.
version: 0.3.11+1
version: 0.3.11+2
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/webview_flutter

Expand Down