Commit b8ec14d6 authored by Lorenzo Pichilli's avatar Lorenzo Pichilli

Reverted calling handler.post on Android when a WebView is created, Fixed iOS...

Reverted calling handler.post on Android when a WebView is created, Fixed iOS extra bottom padding when opening the keyboard, fix #429
parent 3bb05cf0
## 4.0.0+3
- Reverted calling `handler.post` on Android when a WebView is created
- Fixed iOS extra bottom padding when opening the keyboard
- Fixed "Build for web not working – The integer literal 9223372036854775807 can't be represented exactly in JavaScript" [#429](https://github.com/pichillilorenzo/flutter_inappwebview/issues/429)
## 4.0.0 ## 4.0.0
- Updated `onCreateWindow`, `onJsAlert`, `onJsConfirm`, `onJsPrompt` webview events - Updated `onCreateWindow`, `onJsAlert`, `onJsConfirm`, `onJsPrompt` webview events
......
...@@ -14,7 +14,11 @@ ...@@ -14,7 +14,11 @@
A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window.
### Requirements ## Articles/Resources
- [InAppWebView: The Real Power of WebViews in Flutter](https://medium.com/flutter-community/inappwebview-the-real-power-of-webviews-in-flutter-c6d52374209d?source=friends_link&sk=cb74487219bcd85e610a670ee0b447d0)
## Requirements
- Dart sdk: ">=2.7.0 <3.0.0" - Dart sdk: ">=2.7.0 <3.0.0"
- Flutter: ">=1.12.13+hotfix.5" - Flutter: ">=1.12.13+hotfix.5"
......
...@@ -108,11 +108,6 @@ public class FlutterWebView implements PlatformView, MethodCallHandler { ...@@ -108,11 +108,6 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
} }
} }
final String finalInitialUrl = initialUrl;
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
if (initialData != null) { if (initialData != null) {
String data = initialData.get("data"); String data = initialData.get("data");
String mimeType = initialData.get("mimeType"); String mimeType = initialData.get("mimeType");
...@@ -121,10 +116,9 @@ public class FlutterWebView implements PlatformView, MethodCallHandler { ...@@ -121,10 +116,9 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
String historyUrl = initialData.get("historyUrl"); String historyUrl = initialData.get("historyUrl");
webView.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl); webView.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl);
} }
else else {
webView.loadUrl(finalInitialUrl, initialHeaders); webView.loadUrl(initialUrl, initialHeaders);
} }
});
} }
if (containerView == null && id instanceof String) { if (containerView == null && id instanceof String) {
......
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]}],"android":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[]},"dependencyGraph":[{"name":"e2e","dependencies":[]},{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"permission_handler","dependencies":[]}],"date_created":"2020-06-30 14:26:38.633976","version":"1.17.4"} {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.11/","dependencies":[]},{"name":"webview_flutter","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/","dependencies":[]}],"android":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.11/","dependencies":[]},{"name":"webview_flutter","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[{"name":"url_launcher_web","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2/","dependencies":[]}]},"dependencyGraph":[{"name":"e2e","dependencies":[]},{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"webview_flutter","dependencies":[]}],"date_created":"2020-07-02 09:44:29.597292","version":"1.17.4"}
\ No newline at end of file \ No newline at end of file
...@@ -259,6 +259,8 @@ ...@@ -259,6 +259,8 @@
"${BUILT_PRODUCTS_DIR}/flutter_downloader/flutter_downloader.framework", "${BUILT_PRODUCTS_DIR}/flutter_downloader/flutter_downloader.framework",
"${BUILT_PRODUCTS_DIR}/flutter_inappwebview/flutter_inappwebview.framework", "${BUILT_PRODUCTS_DIR}/flutter_inappwebview/flutter_inappwebview.framework",
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework", "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
"${BUILT_PRODUCTS_DIR}/webview_flutter/webview_flutter.framework",
); );
name = "[CP] Embed Pods Frameworks"; name = "[CP] Embed Pods Frameworks";
outputPaths = ( outputPaths = (
...@@ -267,6 +269,8 @@ ...@@ -267,6 +269,8 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_downloader.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_downloader.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_inappwebview.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_inappwebview.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/webview_flutter.framework",
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
......
...@@ -3,6 +3,7 @@ import 'dart:io'; ...@@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:url_launcher/url_launcher.dart';
import 'main.dart'; import 'main.dart';
...@@ -86,7 +87,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> { ...@@ -86,7 +87,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
initialOptions: InAppWebViewGroupOptions( initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions( crossPlatform: InAppWebViewOptions(
debuggingEnabled: true, debuggingEnabled: true,
useShouldOverrideUrlLoading: true useShouldOverrideUrlLoading: true,
), ),
), ),
onWebViewCreated: (InAppWebViewController controller) { onWebViewCreated: (InAppWebViewController controller) {
...@@ -100,7 +101,22 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> { ...@@ -100,7 +101,22 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
}); });
}, },
shouldOverrideUrlLoading: (controller, shouldOverrideUrlLoadingRequest) async { shouldOverrideUrlLoading: (controller, shouldOverrideUrlLoadingRequest) async {
print("shouldOverrideUrlLoading"); var url = shouldOverrideUrlLoadingRequest.url;
var uri = Uri.parse(url);
if (!["http", "https", "file",
"chrome", "data", "javascript",
"about"].contains(uri.scheme)) {
if (await canLaunch(url)) {
// Launch the App
await launch(
url,
);
// and cancel the request
return ShouldOverrideUrlLoadingAction.CANCEL;
}
}
return ShouldOverrideUrlLoadingAction.ALLOW; return ShouldOverrideUrlLoadingAction.ALLOW;
}, },
onLoadStop: (InAppWebViewController controller, String url) async { onLoadStop: (InAppWebViewController controller, String url) async {
......
...@@ -23,7 +23,7 @@ dependencies: ...@@ -23,7 +23,7 @@ dependencies:
flutter_downloader: ^1.4.4 flutter_downloader: ^1.4.4
path_provider: ^1.6.9 path_provider: ^1.6.9
permission_handler: ^5.0.0+hotfix.6 permission_handler: ^5.0.0+hotfix.6
# webview_flutter: ^0.3.22+1 url_launcher: ^5.4.11
# connectivity: ^0.4.5+6 # connectivity: ^0.4.5+6
flutter_inappwebview: flutter_inappwebview:
path: ../ path: ../
......
...@@ -869,6 +869,26 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi ...@@ -869,6 +869,26 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
self.longPressRecognizer!.addTarget(self, action: #selector(longPressGestureDetected)) self.longPressRecognizer!.addTarget(self, action: #selector(longPressGestureDetected))
} }
override public var frame: CGRect {
get {
return super.frame
}
set {
super.frame = newValue
self.scrollView.contentInset = UIEdgeInsets.zero;
if #available(iOS 11, *) {
// Above iOS 11, adjust contentInset to compensate the adjustedContentInset so the sum will
// always be 0.
if (scrollView.adjustedContentInset != UIEdgeInsets.zero) {
let insetToAdjust = self.scrollView.adjustedContentInset;
scrollView.contentInset = UIEdgeInsets(top: -insetToAdjust.top, left: -insetToAdjust.left,
bottom: -insetToAdjust.bottom, right: -insetToAdjust.right);
}
}
}
}
required public init(coder aDecoder: NSCoder) { required public init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)! super.init(coder: aDecoder)!
} }
......
...@@ -160,7 +160,7 @@ class ASN1DERDecoder { ...@@ -160,7 +160,7 @@ class ASN1DERDecoder {
static List<int> loadSubContent({@required Iterator<int> iterator}) { static List<int> loadSubContent({@required Iterator<int> iterator}) {
var len = getContentLength(iterator: iterator); var len = getContentLength(iterator: iterator);
int int64MaxValue = 9223372036854775807; int int64MaxValue = double.maxFinite.toInt();
if (len >= BigInt.from(int64MaxValue)) { if (len >= BigInt.from(int64MaxValue)) {
return <int>[]; return <int>[];
......
...@@ -198,7 +198,7 @@ class HeadlessInAppWebView implements WebView { ...@@ -198,7 +198,7 @@ class HeadlessInAppWebView implements WebView {
@override @override
final Future<bool> Function(InAppWebViewController controller, final Future<bool> Function(InAppWebViewController controller,
CreateWindowRequest onCreateWindowRequest) onCreateWindow; CreateWindowRequest createWindowRequest) onCreateWindow;
@override @override
final void Function(InAppWebViewController controller) onCloseWindow; final void Function(InAppWebViewController controller) onCloseWindow;
......
...@@ -347,6 +347,8 @@ class InAppBrowser { ...@@ -347,6 +347,8 @@ class InAppBrowser {
/// ///
///[createWindowRequest] represents the request. ///[createWindowRequest] represents the request.
/// ///
///**NOTE**: to allow JavaScript to open windows, you need to set [InAppWebViewOptions.javaScriptCanOpenWindowsAutomatically] option to `true`.
///
///**NOTE**: on Android you need to set [AndroidInAppWebViewOptions.supportMultipleWindows] option to `true`. ///**NOTE**: on Android you need to set [AndroidInAppWebViewOptions.supportMultipleWindows] option to `true`.
/// ///
///**NOTE**: on iOS, setting these initial options: [InAppWebViewOptions.supportZoom], [InAppWebViewOptions.useOnLoadResource], [InAppWebViewOptions.useShouldInterceptAjaxRequest], ///**NOTE**: on iOS, setting these initial options: [InAppWebViewOptions.supportZoom], [InAppWebViewOptions.useOnLoadResource], [InAppWebViewOptions.useShouldInterceptAjaxRequest],
......
...@@ -162,7 +162,7 @@ class InAppWebView extends StatefulWidget implements WebView { ...@@ -162,7 +162,7 @@ class InAppWebView extends StatefulWidget implements WebView {
@override @override
final Future<bool> Function(InAppWebViewController controller, final Future<bool> Function(InAppWebViewController controller,
CreateWindowRequest onCreateWindowRequest) onCreateWindow; CreateWindowRequest createWindowRequest) onCreateWindow;
@override @override
final void Function(InAppWebViewController controller) onCloseWindow; final void Function(InAppWebViewController controller) onCloseWindow;
......
...@@ -138,6 +138,8 @@ abstract class WebView { ...@@ -138,6 +138,8 @@ abstract class WebView {
/// ///
///[createWindowRequest] represents the request. ///[createWindowRequest] represents the request.
/// ///
///**NOTE**: to allow JavaScript to open windows, you need to set [InAppWebViewOptions.javaScriptCanOpenWindowsAutomatically] option to `true`.
///
///**NOTE**: on Android you need to set [AndroidInAppWebViewOptions.supportMultipleWindows] option to `true`. ///**NOTE**: on Android you need to set [AndroidInAppWebViewOptions.supportMultipleWindows] option to `true`.
/// ///
///**NOTE**: on iOS, setting these initial options: [InAppWebViewOptions.supportZoom], [InAppWebViewOptions.useOnLoadResource], [InAppWebViewOptions.useShouldInterceptAjaxRequest], ///**NOTE**: on iOS, setting these initial options: [InAppWebViewOptions.supportZoom], [InAppWebViewOptions.useOnLoadResource], [InAppWebViewOptions.useShouldInterceptAjaxRequest],
......
name: flutter_inappwebview name: flutter_inappwebview
description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window.
version: 4.0.0 version: 4.0.0+3
homepage: https://github.com/pichillilorenzo/flutter_inappwebview homepage: https://github.com/pichillilorenzo/flutter_inappwebview
environment: environment:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment