diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 48b812ad..59a276f9 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -15,8 +15,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -36,50 +49,51 @@
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
@@ -89,8 +103,8 @@
-
-
+
+
@@ -98,8 +112,8 @@
-
-
+
+
@@ -107,7 +121,7 @@
-
+
@@ -116,25 +130,33 @@
-
-
+
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
@@ -142,15 +164,6 @@
-
-
-
-
-
-
-
-
-
@@ -162,11 +175,6 @@
- distributionUrl
- args.putIfAbsent('isData', () => false);
- VERSIONING_SYSTEM
- config.build_settings['SWIFT_VERSION']
- BUILD TARGETInAppWebView {lookupMimeTypeAndroidView
@@ -190,8 +198,13 @@
CallBacdart```
- addJavaScriptHandlerJavaScriptHandlerCallback
+ addJavaScriptHandler
+ indexTest
+ removeJavaScriptHandler
+ __safeBrowsingEnabled__
+ __safe
+ __textZoomactivity.getPreferences(0)
@@ -239,21 +252,22 @@
-
-
-
-
-
+
+
+
+
+
-
+
+
@@ -264,41 +278,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -328,6 +308,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -465,11 +484,11 @@
-
+
-
-
+
+
@@ -478,7 +497,7 @@
-
+
@@ -486,9 +505,9 @@
-
+
-
+
@@ -511,9 +530,7 @@
-
-
-
+
@@ -680,13 +697,7 @@
-
-
-
-
-
-
-
+
@@ -701,13 +712,6 @@
-
-
-
-
-
-
-
@@ -743,53 +747,18 @@
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
@@ -798,14 +767,55 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ae69dce4..72efb261 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+## 1.1.2
+
+- Fix InAppBrowser crashes the app when i change the page "Lost connection" [#74](https://github.com/pichillilorenzo/flutter_inappbrowser/issues/74)
+- Fix javascript `...args` parameter of `window.flutter_inappbrowser.callHandler()`
+- Merge Enable setTextZoom function of Android WebViewSetting [#81](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/81)
+- Merge bug fix for android build: Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath [#83](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/83)
+
## 1.1.1
- Fixed README.md and `addJavaScriptHandler` method documentation
diff --git a/README.md b/README.md
index 06676098..3898a649 100644
--- a/README.md
+++ b/README.md
@@ -250,7 +250,7 @@ All platforms support:
- __domStorageEnabled__: Set to `true` if you want the DOM storage API is enabled. The default value is `false`.
- __useWideViewPort__: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
- __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
- - __textZoom__: Set text scaling of android-webview. The default value is `100`.
+ - __textZoom__: Set text scaling of the WebView. The default value is `100`.
**iOS** supports these additional options:
@@ -824,6 +824,7 @@ Opens an `url` in a new `InAppBrowser` instance.
- __useWideViewPort__: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
- __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
- __progressBar__: Set to `false` to hide the progress bar at the bottom of the toolbar at the top. The default value is `true`.
+ - __textZoom__: Set text scaling of the WebView. The default value is `100`.
**iOS** supports these additional options:
diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
index a9117f30..235a43d0 100644
--- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
+++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
@@ -182,7 +182,6 @@ public class InAppWebView extends WebView {
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(options.useWideViewPort);
settings.setSupportZoom(options.supportZoom);
-
settings.setTextZoom(options.textZoom);
}
diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java
index 08b2f03d..5410e7ec 100644
--- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java
+++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java
@@ -13,6 +13,7 @@ public class InAppWebViewOptions extends Options {
public boolean javaScriptEnabled = true;
public boolean javaScriptCanOpenWindowsAutomatically = false;
public boolean mediaPlaybackRequiresUserGesture = true;
+ public int textZoom = 100;
public boolean clearSessionCache = false;
public boolean builtInZoomControls = false;
@@ -22,5 +23,4 @@ public class InAppWebViewOptions extends Options {
public boolean useWideViewPort = true;
public boolean safeBrowsingEnabled = true;
- public int textZoom = 100;
}
diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/JavaScriptBridgeInterface.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/JavaScriptBridgeInterface.java
index 2f0bd3df..2ed9320a 100644
--- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/JavaScriptBridgeInterface.java
+++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/JavaScriptBridgeInterface.java
@@ -17,9 +17,9 @@ public class JavaScriptBridgeInterface {
private FlutterWebView flutterWebView;
private InAppBrowserActivity inAppBrowserActivity;
- public static final String flutterInAppBroserJSClass = "window." + name + ".callHandler = function(handlerName, ...args) {" +
+ public static final String flutterInAppBroserJSClass = "window." + name + ".callHandler = function() {" +
"var _callHandlerID = setTimeout(function(){});" +
- "window." + name + "._callHandler(handlerName, _callHandlerID, JSON.stringify(args));" +
+ "window." + name + "._callHandler(arguments[0], _callHandlerID, JSON.stringify(Array.prototype.slice.call(arguments, 1)));" +
"return new Promise(function(resolve, reject) {" +
" window." + name + "[_callHandlerID] = resolve;" +
"});" +
diff --git a/example/lib/webview_example.screen.dart b/example/lib/webview_example.screen.dart
index 3d210bc5..9648be8a 100644
--- a/example/lib/webview_example.screen.dart
+++ b/example/lib/webview_example.screen.dart
@@ -86,7 +86,7 @@ class _WebviewExampleScreenState extends State {
return new Center(
child: new RaisedButton(
onPressed: () {
- widget.browser.open(url: "https://flutter.dev/", options: {
+ widget.browser.open(url: "https://google.com", options: {
"useShouldOverrideUrlLoading": true,
"useOnLoadResource": true
});
diff --git a/ios/Classes/InAppWebView.swift b/ios/Classes/InAppWebView.swift
index fe662b90..31b1a5bf 100644
--- a/ios/Classes/InAppWebView.swift
+++ b/ios/Classes/InAppWebView.swift
@@ -71,9 +71,9 @@ let JAVASCRIPT_BRIDGE_NAME = "flutter_inappbrowser"
let javaScriptBridgeJS = """
window.\(JAVASCRIPT_BRIDGE_NAME) = {};
-window.\(JAVASCRIPT_BRIDGE_NAME).callHandler = function(handlerName, ...args) {
+window.\(JAVASCRIPT_BRIDGE_NAME).callHandler = function() {
var _callHandlerID = setTimeout(function(){});
- window.webkit.messageHandlers['callHandler'].postMessage( {'handlerName': handlerName, '_callHandlerID': _callHandlerID, 'args': JSON.stringify(args)} );
+ window.webkit.messageHandlers['callHandler'].postMessage( {'handlerName': arguments[0], '_callHandlerID': _callHandlerID, 'args': JSON.stringify(Array.prototype.slice.call(arguments, 1))} );
return new Promise(function(resolve, reject) {
window.\(JAVASCRIPT_BRIDGE_NAME)[_callHandlerID] = resolve;
});
@@ -629,7 +629,9 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
if IABController != nil {
arguments["uuid"] = IABController!.uuid
}
- getChannel().invokeMethod("onLoadStart", arguments: arguments)
+ if let channel = getChannel() {
+ channel.invokeMethod("onLoadStart", arguments: arguments)
+ }
}
public func onLoadStop(url: String) {
@@ -637,7 +639,9 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
if IABController != nil {
arguments["uuid"] = IABController!.uuid
}
- getChannel().invokeMethod("onLoadStop", arguments: arguments)
+ if let channel = getChannel() {
+ channel.invokeMethod("onLoadStop", arguments: arguments)
+ }
}
public func onLoadError(url: String, error: Error) {
@@ -645,7 +649,9 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
if IABController != nil {
arguments["uuid"] = IABController!.uuid
}
- getChannel().invokeMethod("onLoadError", arguments: arguments)
+ if let channel = getChannel() {
+ channel.invokeMethod("onLoadError", arguments: arguments)
+ }
}
public func onProgressChanged(progress: Int) {
@@ -653,7 +659,9 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
if IABController != nil {
arguments["uuid"] = IABController!.uuid
}
- getChannel().invokeMethod("onProgressChanged", arguments: arguments)
+ if let channel = getChannel() {
+ channel.invokeMethod("onProgressChanged", arguments: arguments)
+ }
}
public func onLoadResource(response: URLResponse, fromRequest request: URLRequest?, withData data: Data, startTime: Int64, duration: Int64) {
@@ -681,7 +689,9 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
if IABController != nil {
arguments["uuid"] = IABController!.uuid
}
- getChannel().invokeMethod("onLoadResource", arguments: arguments)
+ if let channel = getChannel() {
+ channel.invokeMethod("onLoadResource", arguments: arguments)
+ }
}
public func onScrollChanged(x: Int, y: Int) {
@@ -689,7 +699,9 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
if IABController != nil {
arguments["uuid"] = IABController!.uuid
}
- getChannel().invokeMethod("onScrollChanged", arguments: arguments)
+ if let channel = getChannel() {
+ channel.invokeMethod("onScrollChanged", arguments: arguments)
+ }
}
public func shouldOverrideUrlLoading(url: URL) {
@@ -697,7 +709,9 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
if IABController != nil {
arguments["uuid"] = IABController!.uuid
}
- getChannel().invokeMethod("shouldOverrideUrlLoading", arguments: arguments)
+ if let channel = getChannel() {
+ channel.invokeMethod("shouldOverrideUrlLoading", arguments: arguments)
+ }
}
public func onConsoleMessage(sourceURL: String, lineNumber: Int, message: String, messageLevel: String) {
@@ -705,7 +719,9 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
if IABController != nil {
arguments["uuid"] = IABController!.uuid
}
- getChannel().invokeMethod("onConsoleMessage", arguments: arguments)
+ if let channel = getChannel() {
+ channel.invokeMethod("onConsoleMessage", arguments: arguments)
+ }
}
public func onCallJsHandler(handlerName: String, _callHandlerID: Int64, args: String) {
@@ -714,19 +730,21 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
arguments["uuid"] = IABController!.uuid
}
- getChannel().invokeMethod("onCallJsHandler", arguments: arguments, result: {(result) -> Void in
- if result is FlutterError {
- print((result as! FlutterError).message)
- }
- else if (result as? NSObject) == FlutterMethodNotImplemented {}
- else {
- var json = "null"
- if let r = result {
- json = r as! String
+ if let channel = getChannel() {
+ channel.invokeMethod("onCallJsHandler", arguments: arguments, result: {(result) -> Void in
+ if result is FlutterError {
+ print((result as! FlutterError).message)
}
- self.evaluateJavaScript("window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)](\(json)); delete window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)];", completionHandler: nil)
- }
- })
+ else if (result as? NSObject) == FlutterMethodNotImplemented {}
+ else {
+ var json = "null"
+ if let r = result {
+ json = r as! String
+ }
+ self.evaluateJavaScript("window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)](\(json)); delete window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)];", completionHandler: nil)
+ }
+ })
+ }
}
public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
@@ -794,7 +812,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
}
}
- private func getChannel() -> FlutterMethodChannel {
- return (IABController != nil) ? SwiftFlutterPlugin.channel! : IAWController!.channel!;
+ private func getChannel() -> FlutterMethodChannel? {
+ return (IABController != nil) ? SwiftFlutterPlugin.channel! : ((IAWController != nil) ? IAWController!.channel! : nil);
}
}
diff --git a/lib/flutter_inappbrowser.dart b/lib/flutter_inappbrowser.dart
index 378b0126..ca25e612 100644
--- a/lib/flutter_inappbrowser.dart
+++ b/lib/flutter_inappbrowser.dart
@@ -184,6 +184,7 @@ class InAppBrowser {
/// - __useWideViewPort__: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
/// - __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
/// - __progressBar__: Set to `false` to hide the progress bar at the bottom of the toolbar at the top. The default value is `true`.
+ /// - __textZoom__: Set text scaling of the WebView. The default value is `100`.
///
/// - **iOS** supports these additional options:
///
@@ -589,6 +590,7 @@ class InAppWebViewInitialData {
/// - __domStorageEnabled__: Set to `true` if you want the DOM storage API is enabled. The default value is `false`.
/// - __useWideViewPort__: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
/// - __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
+/// - __textZoom__: Set text scaling of the WebView. The default value is `100`.
///
/// **iOS** supports these additional options:
///
@@ -1214,7 +1216,7 @@ class InAppWebViewController {
}
///Takes a screenshot (in PNG format) of the WebView's visible viewport and returns a `Uint8List`. Returns `null` if it wasn't be able to take it.
- ///
+ ///__safeBrowsingEnabled__
///**NOTE for iOS**: available from iOS 11.0+.
Future takeScreenshot() async {
Map args = {};
diff --git a/pubspec.yaml b/pubspec.yaml
index df5b33fa..0fea2dd8 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: flutter_inappbrowser
description: A Flutter plugin that allows you to add an inline webview or open an in-app browser window (inspired by the popular cordova-plugin-inappbrowser).
-version: 1.1.1
+version: 1.1.2
author: Lorenzo Pichilli
homepage: https://github.com/pichillilorenzo/flutter_inappbrowser