From 3352c9cef098b064d75b40d0647df412bd0cca50 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 22 Mar 2021 16:39:58 +0100 Subject: [PATCH] v5.2.0 --- .idea/libraries/Dart_Packages.xml | 420 ------------------ .idea/libraries/Flutter_Plugins.xml | 4 +- CHANGELOG.md | 1 + example/.flutter-plugins-dependencies | 2 +- .../webview_flutter_test.dart | 4 - flutter_inappwebview.iml | 1 - lib/src/android/webview_feature.dart | 1 - .../headless_in_app_webview.dart | 3 +- lib/src/in_app_webview/in_app_webview.dart | 3 +- .../in_app_webview_controller.dart | 18 +- lib/src/in_app_webview/webview.dart | 3 +- lib/src/types.dart | 5 +- lib/src/web_message/main.dart | 2 +- lib/src/web_message/web_message_channel.dart | 11 +- lib/src/web_message/web_message_listener.dart | 15 +- 15 files changed, 44 insertions(+), 449 deletions(-) delete mode 100644 .idea/libraries/Dart_Packages.xml diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml deleted file mode 100644 index 3b0b4626..00000000 --- a/.idea/libraries/Dart_Packages.xml +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml index 31799730..65bb3679 100755 --- a/.idea/libraries/Flutter_Plugins.xml +++ b/.idea/libraries/Flutter_Plugins.xml @@ -1,6 +1,8 @@ - + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 05091cd7..5c4b5d13 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Fixed iOS sometimes `scrollView.contentSize` doesn't fit all the `frame.size` available - Fixed ajax and fetch interceptor when the data/body sent is not a string - Fixed "InAppLocalhostServer - Error: type 'List' is not a subtype of type 'List' in type cast" [#724](https://github.com/pichillilorenzo/flutter_inappwebview/issues/724) +- Merge "fix proguard" [#737](https://github.com/pichillilorenzo/flutter_inappwebview/pull/737) (thanks to [myroid](https://github.com/myroid)) ### BREAKING CHANGES diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 8bd34688..09bebc6b 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_downloader","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"integration_test","path":"/Users/lorenzopichilli/fvm/versions/2.1.0-10.0.pre/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"android":[{"name":"flutter_downloader","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"integration_test","path":"/Users/lorenzopichilli/fvm/versions/2.1.0-10.0.pre/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.5-nullsafety/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.1.0-nullsafety.2/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.2.0-nullsafety/","dependencies":[]},{"name":"url_launcher_linux","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.1.0-nullsafety.3/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-0.1.0-nullsafety.3/","dependencies":[]},{"name":"url_launcher_windows","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-0.1.0-nullsafety.2/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"integration_test","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_windows"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2021-03-22 15:18:36.048089","version":"2.1.0-10.0.pre"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_downloader","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"integration_test","path":"/Users/lorenzopichilli/fvm/versions/2.1.0-10.0.pre/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"android":[{"name":"flutter_downloader","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"integration_test","path":"/Users/lorenzopichilli/fvm/versions/2.1.0-10.0.pre/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.5-nullsafety/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.1.0-nullsafety.2/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.2.0-nullsafety/","dependencies":[]},{"name":"url_launcher_linux","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.1.0-nullsafety.3/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-0.1.0-nullsafety.3/","dependencies":[]},{"name":"url_launcher_windows","path":"/Users/lorenzopichilli/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-0.1.0-nullsafety.2/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"integration_test","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_windows"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2021-03-22 16:27:21.616305","version":"2.1.0-10.0.pre"} \ No newline at end of file diff --git a/example/integration_test/webview_flutter_test.dart b/example/integration_test/webview_flutter_test.dart index 3922429c..a1abcaee 100644 --- a/example/integration_test/webview_flutter_test.dart +++ b/example/integration_test/webview_flutter_test.dart @@ -2068,7 +2068,6 @@ void main() { group('intercept fetch request', () { testWidgets('send string data', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); - final Completer fetchGetCompleter = Completer(); final Completer> fetchPostCompleter = Completer>(); final Completer shouldInterceptFetchPostRequestCompleter = @@ -2148,7 +2147,6 @@ void main() { testWidgets('send json data', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); - final Completer fetchGetCompleter = Completer(); final Completer> fetchPostCompleter = Completer>(); final Completer shouldInterceptFetchPostRequestCompleter = @@ -2233,7 +2231,6 @@ void main() { testWidgets('send URLSearchParams data', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); - final Completer fetchGetCompleter = Completer(); final Completer> fetchPostCompleter = Completer>(); final Completer shouldInterceptFetchPostRequestCompleter = @@ -2315,7 +2312,6 @@ void main() { testWidgets('send FormData', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); - final Completer fetchGetCompleter = Completer(); final Completer> fetchPostCompleter = Completer>(); final Completer shouldInterceptFetchPostRequestCompleter = diff --git a/flutter_inappwebview.iml b/flutter_inappwebview.iml index 4cb39159..0adae5aa 100755 --- a/flutter_inappwebview.iml +++ b/flutter_inappwebview.iml @@ -80,6 +80,5 @@ - \ No newline at end of file diff --git a/lib/src/android/webview_feature.dart b/lib/src/android/webview_feature.dart index 6867c1b8..99c9b2b9 100644 --- a/lib/src/android/webview_feature.dart +++ b/lib/src/android/webview_feature.dart @@ -31,7 +31,6 @@ class AndroidWebViewFeature { AndroidWebViewFeature.SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY, AndroidWebViewFeature.SAFE_BROWSING_RESPONSE_PROCEED, AndroidWebViewFeature.SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL, - AndroidWebViewFeature.SAFE_BROWSING_WHITELIST, AndroidWebViewFeature.SERVICE_WORKER_BASIC_USAGE, AndroidWebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS, AndroidWebViewFeature.SERVICE_WORKER_CACHE_MODE, diff --git a/lib/src/in_app_webview/headless_in_app_webview.dart b/lib/src/in_app_webview/headless_in_app_webview.dart index 4e63059f..1799b07d 100644 --- a/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/lib/src/in_app_webview/headless_in_app_webview.dart @@ -348,7 +348,8 @@ class HeadlessInAppWebView implements WebView { final void Function(InAppWebViewController controller)? onExitFullscreen; @override - final void Function(InAppWebViewController controller, int x, int y, bool clampedX, bool clampedY)? onOverScrolled; + final void Function(InAppWebViewController controller, int x, int y, + bool clampedX, bool clampedY)? onOverScrolled; @override final Future Function( diff --git a/lib/src/in_app_webview/in_app_webview.dart b/lib/src/in_app_webview/in_app_webview.dart index d45b5e8c..7c960b34 100755 --- a/lib/src/in_app_webview/in_app_webview.dart +++ b/lib/src/in_app_webview/in_app_webview.dart @@ -310,7 +310,8 @@ class InAppWebView extends StatefulWidget implements WebView { final void Function(InAppWebViewController controller)? onExitFullscreen; @override - final void Function(InAppWebViewController controller, int x, int y, bool clampedX, bool clampedY)? onOverScrolled; + final void Function(InAppWebViewController controller, int x, int y, + bool clampedX, bool clampedY)? onOverScrolled; @override final Future Function( diff --git a/lib/src/in_app_webview/in_app_webview_controller.dart b/lib/src/in_app_webview/in_app_webview_controller.dart index 82b0ca6e..386ecc0a 100644 --- a/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1473,7 +1473,8 @@ class InAppWebViewController { void addJavaScriptHandler( {required String handlerName, required JavaScriptHandlerCallback callback}) { - assert(!_JAVASCRIPT_HANDLER_FORBIDDEN_NAMES.contains(handlerName), '"$handlerName" is a forbidden name!'); + assert(!_JAVASCRIPT_HANDLER_FORBIDDEN_NAMES.contains(handlerName), + '"$handlerName" is a forbidden name!'); this.javaScriptHandlersMap[handlerName] = (callback); } @@ -2119,8 +2120,9 @@ class InAppWebViewController { ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewCompat#createWebMessageChannel(android.webkit.WebView) Future createWebMessageChannel() async { Map args = {}; - Map? result = (await _channel.invokeMethod('createWebMessageChannel', args)) - ?.cast(); + Map? result = + (await _channel.invokeMethod('createWebMessageChannel', args)) + ?.cast(); return WebMessageChannel.fromMap(result); } @@ -2134,7 +2136,8 @@ class InAppWebViewController { ///**NOTE for iOS**: This is implemented using Javascript. /// ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewCompat#postWebMessage(android.webkit.WebView,%20androidx.webkit.WebMessageCompat,%20android.net.Uri) - Future postWebMessage({required WebMessage message, Uri? targetOrigin}) async { + Future postWebMessage( + {required WebMessage message, Uri? targetOrigin}) async { if (targetOrigin == null) { targetOrigin = Uri.parse(""); } @@ -2303,8 +2306,11 @@ class InAppWebViewController { ///**NOTE for iOS**: This is implemented using Javascript. /// ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,%20java.lang.String,%20java.util.Set%3Cjava.lang.String%3E,%20androidx.webkit.WebViewCompat.WebMessageListener) - Future addWebMessageListener(WebMessageListener webMessageListener) async { - assert(!_webMessageListenerObjNames.contains(webMessageListener.jsObjectName), "jsObjectName ${webMessageListener.jsObjectName} was already added."); + Future addWebMessageListener( + WebMessageListener webMessageListener) async { + assert( + !_webMessageListenerObjNames.contains(webMessageListener.jsObjectName), + "jsObjectName ${webMessageListener.jsObjectName} was already added."); _webMessageListenerObjNames.add(webMessageListener.jsObjectName); Map args = {}; diff --git a/lib/src/in_app_webview/webview.dart b/lib/src/in_app_webview/webview.dart index d3647028..d63bab68 100644 --- a/lib/src/in_app_webview/webview.dart +++ b/lib/src/in_app_webview/webview.dart @@ -398,7 +398,8 @@ abstract class WebView { ///[clampedY] is `true` if [y] was clamped to an over-scroll boundary. /// ///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#onOverScrolled(int,%20int,%20boolean,%20boolean) - final void Function(InAppWebViewController controller, int x, int y, bool clampedX, bool clampedY)? onOverScrolled; + final void Function(InAppWebViewController controller, int x, int y, + bool clampedX, bool clampedY)? onOverScrolled; ///Event fired when the webview notifies that a loading URL has been flagged by Safe Browsing. ///The default behavior is to show an interstitial to the user, with the reporting checkbox visible. diff --git a/lib/src/types.dart b/lib/src/types.dart index 01c02b52..14a05274 100755 --- a/lib/src/types.dart +++ b/lib/src/types.dart @@ -33,7 +33,8 @@ import 'web_message/web_message_channel.dart'; typedef dynamic JavaScriptHandlerCallback(List arguments); ///The listener for handling [WebMessageListener] events sent by a `postMessage()` on the injected JavaScript object. -typedef void OnPostMessageCallback(String? message, Uri? sourceOrigin, bool isMainFrame, JavaScriptReplyProxy replyProxy); +typedef void OnPostMessageCallback(String? message, Uri? sourceOrigin, + bool isMainFrame, JavaScriptReplyProxy replyProxy); ///The listener for handling [WebMessagePort] events. ///The message callback methods are called on the main thread. @@ -6831,4 +6832,4 @@ class AndroidPullToRefreshSize { @override int get hashCode => _value.hashCode; -} \ No newline at end of file +} diff --git a/lib/src/web_message/main.dart b/lib/src/web_message/main.dart index 036f08b1..6173cba8 100644 --- a/lib/src/web_message/main.dart +++ b/lib/src/web_message/main.dart @@ -1,2 +1,2 @@ export 'web_message_channel.dart'; -export 'web_message_listener.dart'; \ No newline at end of file +export 'web_message_listener.dart'; diff --git a/lib/src/web_message/web_message_channel.dart b/lib/src/web_message/web_message_channel.dart index d2dffaf8..840959a6 100644 --- a/lib/src/web_message/web_message_channel.dart +++ b/lib/src/web_message/web_message_channel.dart @@ -15,7 +15,8 @@ class WebMessageChannel { late MethodChannel _channel; - WebMessageChannel({required this.id, required this.port1, required this.port2}) { + WebMessageChannel( + {required this.id, required this.port1, required this.port2}) { this._channel = MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_web_message_channel_$id'); this._channel.setMethodCallHandler(handleMethod); @@ -28,8 +29,7 @@ class WebMessageChannel { var webMessageChannel = WebMessageChannel( id: map["id"], port1: WebMessagePort(index: 0), - port2: WebMessagePort(index: 1) - ); + port2: WebMessagePort(index: 1)); webMessageChannel.port1._webMessageChannel = webMessageChannel; webMessageChannel.port2._webMessageChannel = webMessageChannel; return webMessageChannel; @@ -84,7 +84,8 @@ class WebMessagePort { Future setWebMessageCallback(WebMessageCallback? onMessage) async { Map args = {}; args.putIfAbsent('index', () => this._index); - await _webMessageChannel._channel.invokeMethod('setWebMessageCallback', args); + await _webMessageChannel._channel + .invokeMethod('setWebMessageCallback', args); this._onMessage = onMessage; } @@ -146,4 +147,4 @@ class WebMessage { String toString() { return toMap().toString(); } -} \ No newline at end of file +} diff --git a/lib/src/web_message/web_message_listener.dart b/lib/src/web_message/web_message_listener.dart index d8fe8b17..0f43a809 100644 --- a/lib/src/web_message/web_message_listener.dart +++ b/lib/src/web_message/web_message_listener.dart @@ -26,9 +26,14 @@ class WebMessageListener { late MethodChannel _channel; - WebMessageListener({required this.jsObjectName, Set? allowedOriginRules, this.onPostMessage}) { - this.allowedOriginRules = allowedOriginRules != null ? allowedOriginRules : Set.from(["*"]); - assert(!this.allowedOriginRules.contains(""), "allowedOriginRules cannot contain empty strings"); + WebMessageListener( + {required this.jsObjectName, + Set? allowedOriginRules, + this.onPostMessage}) { + this.allowedOriginRules = + allowedOriginRules != null ? allowedOriginRules : Set.from(["*"]); + assert(!this.allowedOriginRules.contains(""), + "allowedOriginRules cannot contain empty strings"); this._channel = MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_web_message_listener_$jsObjectName'); this._channel.setMethodCallHandler(handleMethod); @@ -42,7 +47,9 @@ class WebMessageListener { } if (onPostMessage != null) { String? message = call.arguments["message"]; - Uri? sourceOrigin = call.arguments["sourceOrigin"] != null ? Uri.parse(call.arguments["sourceOrigin"]) : null; + Uri? sourceOrigin = call.arguments["sourceOrigin"] != null + ? Uri.parse(call.arguments["sourceOrigin"]) + : null; bool isMainFrame = call.arguments["isMainFrame"]; onPostMessage!(message, sourceOrigin, isMainFrame, _replyProxy!); }