diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7cd3fcf5..f17d566a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -15,15 +15,16 @@
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
@@ -46,8 +47,8 @@
-
-
+
+
@@ -55,23 +56,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -79,11 +68,26 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -91,17 +95,41 @@
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -118,7 +146,6 @@
- ClientCertResponse
weBVIEWCONTROL
getFa
supportZoom
@@ -148,6 +175,7 @@
flutterInAppBrowserPlatformReady
evaluateJ
AjaxRequest
+ _onPlatformViewCreated
activity.getPreferences(0)
@@ -173,20 +201,6 @@
-
+
@@ -238,6 +266,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -267,6 +306,7 @@
+
@@ -288,19 +328,19 @@
+
-
-
+
+
-
@@ -310,18 +350,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
@@ -333,27 +361,27 @@
-
-
+
+
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
@@ -384,12 +412,6 @@
-
-
-
-
-
-
@@ -486,7 +508,7 @@
-
+
@@ -494,8 +516,8 @@
-
-
+
+
@@ -524,54 +546,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -586,16 +560,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -623,13 +587,6 @@
-
-
-
-
-
-
-
@@ -660,13 +617,6 @@
-
-
-
-
-
-
-
@@ -753,24 +703,85 @@
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -779,28 +790,93 @@
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java
index 67228eef..55fa9670 100644
--- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java
+++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java
@@ -567,10 +567,17 @@ public class InAppWebViewClient extends WebViewClient {
URI uri;
try {
uri = new URI(url);
- } catch (URISyntaxException e) {
- e.printStackTrace();
- Log.e(LOG_TAG, e.getMessage());
- return null;
+ } catch (URISyntaxException uriExpection) {
+ String[] urlSplitted = url.split(":");
+ String scheme = urlSplitted[0];
+ try {
+ URL tempUrl = new URL(url.replace(scheme, "https"));
+ uri = new URI(scheme, tempUrl.getUserInfo(), tempUrl.getHost(), tempUrl.getPort(), tempUrl.getPath(), tempUrl.getQuery(), tempUrl.getRef());
+ } catch (Exception e) {
+ e.printStackTrace();
+ Log.d(LOG_TAG, e.getMessage());
+ return null;
+ }
}
String scheme = uri.getScheme();
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 84824217..fd1ef227 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -25,9 +25,6 @@ class MyApp extends StatefulWidget {
}
class _MyAppState extends State {
- InAppWebViewController webView;
- String url = "";
- double progress = 0;
@override
void initState() {
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index ab86227d..c20d43ca 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -26,6 +26,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
+ ansicolor: 1.0.2
flutter_inappbrowser:
path: ../
diff --git a/example/test/custom_widget_test.dart b/example/test/custom_widget_test.dart
new file mode 100644
index 00000000..36d0c89d
--- /dev/null
+++ b/example/test/custom_widget_test.dart
@@ -0,0 +1,18 @@
+import 'package:ansicolor/ansicolor.dart';
+import 'package:flutter/widgets.dart';
+
+class WidgetTest extends StatefulWidget {
+ final String name;
+
+ WidgetTest({this.name, Key key}): super(key: key) {
+ AnsiPen pen = new AnsiPen()..white()..rgb(r: 1.0, g: 0.8, b: 0.2);
+ print("\n");
+ print(pen("'" + this.name + "' test loading..."));
+ print("\n");
+ }
+
+ @override
+ State createState() {
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/example/test/in_app_webview_initial_file_test.dart b/example/test/in_app_webview_initial_file_test.dart
new file mode 100644
index 00000000..45be8a27
--- /dev/null
+++ b/example/test/in_app_webview_initial_file_test.dart
@@ -0,0 +1,50 @@
+import 'package:flutter/material.dart';
+
+import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
+
+import 'util_test.dart';
+import 'custom_widget_test.dart';
+
+class InAppWebViewInitialFileTest extends WidgetTest {
+ InAppWebViewInitialFileTest(): super(name: "InAppWebViewInitialFileTest");
+
+ @override
+ _InAppWebViewInitialFileTestState createState() => new _InAppWebViewInitialFileTestState();
+}
+
+class _InAppWebViewInitialFileTestState extends State {
+ InAppWebViewController webView;
+ String initialUrl = "https://flutter.dev/";
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: Text('InAppWebViewInitialFileTest'),
+ ),
+ body: Container(
+ child: Column(children: [
+ Expanded(
+ child: Container(
+ child: InAppWebView(
+ initialFile: "assets/index.html",
+ initialHeaders: {},
+ initialOptions: InAppWebViewWidgetOptions(),
+ onWebViewCreated: (InAppWebViewController controller) {
+ webView = controller;
+ },
+ onLoadStart: (InAppWebViewController controller, String url) {
+
+ },
+ onLoadStop: (InAppWebViewController controller, String url) {
+ customAssert(widget: widget, name: "initialFile", value: true);
+ nextTest(context: context);
+ },
+ ),
+ ),
+ ),
+ ])
+ )
+ );
+ }
+}
diff --git a/example/test/in_app_webview_initial_url_test.dart b/example/test/in_app_webview_initial_url_test.dart
new file mode 100644
index 00000000..e13f87d0
--- /dev/null
+++ b/example/test/in_app_webview_initial_url_test.dart
@@ -0,0 +1,50 @@
+import 'package:flutter/material.dart';
+
+import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
+
+import 'util_test.dart';
+import 'custom_widget_test.dart';
+
+class InAppWebViewInitialUrlTest extends WidgetTest {
+ InAppWebViewInitialUrlTest(): super(name: "InAppWebViewInitialUrlTest");
+
+ @override
+ _InAppWebViewInitialUrlTestState createState() => new _InAppWebViewInitialUrlTestState();
+}
+
+class _InAppWebViewInitialUrlTestState extends State {
+ InAppWebViewController webView;
+ String initialUrl = "https://flutter.dev/";
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: Text('InAppWebViewInitialUrlTest'),
+ ),
+ body: Container(
+ child: Column(children: [
+ Expanded(
+ child: Container(
+ child: InAppWebView(
+ initialUrl: initialUrl,
+ initialHeaders: {},
+ initialOptions: InAppWebViewWidgetOptions(),
+ onWebViewCreated: (InAppWebViewController controller) {
+ webView = controller;
+ },
+ onLoadStart: (InAppWebViewController controller, String url) {
+
+ },
+ onLoadStop: (InAppWebViewController controller, String url) {
+ customAssert(widget: widget, name: "initialUrl", value: url == initialUrl);
+ nextTest(context: context);
+ },
+ ),
+ ),
+ ),
+ ])
+ )
+ );
+ }
+}
diff --git a/example/test/in_app_webview_on_load_resource_test.dart b/example/test/in_app_webview_on_load_resource_test.dart
new file mode 100644
index 00000000..5f9d052f
--- /dev/null
+++ b/example/test/in_app_webview_on_load_resource_test.dart
@@ -0,0 +1,66 @@
+import 'package:flutter/material.dart';
+
+import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
+
+import 'util_test.dart';
+import 'custom_widget_test.dart';
+
+class InAppWebViewOnLoadResourceTest extends WidgetTest {
+ InAppWebViewOnLoadResourceTest(): super(name: "InAppWebViewOnLoadResourceTest");
+
+ @override
+ _InAppWebViewOnLoadResourceTestState createState() => new _InAppWebViewOnLoadResourceTestState();
+}
+
+class _InAppWebViewOnLoadResourceTestState extends State {
+ InAppWebViewController webView;
+ List resourceList = [
+ "http://getbootstrap.com/docs/4.3/dist/css/bootstrap.min.css",
+ "https://code.jquery.com/jquery-3.3.1.min.js",
+ "https://via.placeholder.com/100x50"
+ ];
+ int countResources = 0;
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: Text('InAppWebViewOnLoadResourceTest'),
+ ),
+ body: Container(
+ child: Column(children: [
+ Expanded(
+ child: Container(
+ child: InAppWebView(
+ initialFile: "assets/index.html",
+ initialHeaders: {},
+ initialOptions: InAppWebViewWidgetOptions(
+ inAppWebViewOptions: InAppWebViewOptions(
+ clearCache: true,
+ useOnLoadResource: true
+ )
+ ),
+ onWebViewCreated: (InAppWebViewController controller) {
+ webView = controller;
+ },
+ onLoadStart: (InAppWebViewController controller, String url) {
+
+ },
+ onLoadStop: (InAppWebViewController controller, String url) {
+
+ },
+ onLoadResource: (InAppWebViewController controller, LoadedResource response) {
+ customAssert(widget: widget, name: "onLoadResource", value: resourceList.contains(response.url));
+ countResources++;
+ if (countResources == resourceList.length) {
+ nextTest(context: context);
+ }
+ }
+ ),
+ ),
+ ),
+ ])
+ )
+ );
+ }
+}
diff --git a/example/test/main_test.dart b/example/test/main_test.dart
new file mode 100644
index 00000000..b5c8e30a
--- /dev/null
+++ b/example/test/main_test.dart
@@ -0,0 +1,43 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+
+import 'in_app_webview_initial_file_test.dart';
+import 'in_app_webview_initial_url_test.dart';
+import 'in_app_webview_on_load_resource_test.dart';
+
+
+Future main() async {
+ runApp(new MyApp());
+}
+
+class MyApp extends StatefulWidget {
+ @override
+ _MyAppState createState() => new _MyAppState();
+}
+
+class _MyAppState extends State {
+
+ @override
+ void initState() {
+ super.initState();
+ }
+
+ @override
+ void dispose() {
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return MaterialApp(
+ title: 'flutter_inappbrowser tests',
+ initialRoute: '/',
+ routes: {
+ '/': (context) => InAppWebViewInitialUrlTest(),
+ '/InAppWebViewInitialFileTest': (context) => InAppWebViewInitialFileTest(),
+ '/InAppWebViewOnLoadResourceTest': (context) => InAppWebViewOnLoadResourceTest()
+ }
+ );
+ }
+}
\ No newline at end of file
diff --git a/example/test/util_test.dart b/example/test/util_test.dart
new file mode 100644
index 00000000..bcd16e4d
--- /dev/null
+++ b/example/test/util_test.dart
@@ -0,0 +1,60 @@
+import 'package:ansicolor/ansicolor.dart';
+import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
+
+import 'custom_widget_test.dart';
+
+int countTestPassed = 0;
+int countTestFailed = 0;
+int currentTest = 0;
+List testRoutes = [
+ '/',
+ '/InAppWebViewInitialFileTest',
+ '/InAppWebViewOnLoadResourceTest'
+];
+
+void nextTest({@required BuildContext context}) {
+ if (currentTest + 1 < testRoutes.length) {
+ currentTest++;
+ String nextRoute = testRoutes[currentTest];
+ Navigator.pushReplacementNamed(context, nextRoute);
+ } else {
+ AnsiPen penError = new AnsiPen()..white()..rgb(r: 1.0, g: 0.0, b: 0.0);
+ AnsiPen penSuccess = new AnsiPen()..white()..rgb(r: 0.0, g: 1.0, b: 0.0);
+
+ if (countTestFailed > 0)
+ print("\n" + penError("Total tests failed $countTestFailed.") + "\n");
+ if (countTestPassed > 0)
+ print("\n" + penSuccess("Total tests passed $countTestPassed.") + "\n");
+ }
+}
+
+bool customAssert({WidgetTest widget, String name, @required bool value}) {
+ try {
+ assert(value);
+ } catch (e, stackTrace) {
+ String message = "${widget != null ? "'" + widget.name + "' - " : ""} ERROR - Failed assertion: ";
+ List stakTraceSplitted = stackTrace.toString().split("\n");
+ String lineCallingAssert = stakTraceSplitted[3].trim().substring(2).trim();
+
+ AnsiPen penError = new AnsiPen()..white()..rgb(r: 1.0, g: 0.0, b: 0.0);
+ print("\n" + penError(message + lineCallingAssert) + "\n");
+ countTestFailed++;
+ return false;
+ }
+ countTestPassed++;
+ try {
+ throw Exception();
+ } on Exception catch(e, stackTrace) {
+ String message = "${widget != null ? "'" + widget.name + "' - " : ""} Test ";
+ message += (name != null) ? "'$name' " : "";
+ message += "passed!";
+ List stakTraceSplitted = stackTrace.toString().split("\n");
+ String lineCallingAssert = stakTraceSplitted[1].trim().substring(2).trim();
+ message += " $lineCallingAssert";
+
+ AnsiPen pen = new AnsiPen()..white()..rgb(r: 1.0, g: 0.8, b: 0.2);
+ print("\n" + pen(message) + "\n");
+ }
+ return true;
+}
\ No newline at end of file
diff --git a/lib/src/in_app_localhost_server.dart b/lib/src/in_app_localhost_server.dart
index cfb534bf..6770ee12 100644
--- a/lib/src/in_app_localhost_server.dart
+++ b/lib/src/in_app_localhost_server.dart
@@ -45,7 +45,7 @@ class InAppLocalhostServer {
var body = List();
var path = request.requestedUri.path;
path = (path.startsWith('/')) ? path.substring(1) : path;
- path += (path.endsWith('/')) ? 't-rex.html' : '';
+ path += (path.endsWith('/')) ? 'index.html' : '';
try {
body = (await rootBundle.load(path))
@@ -85,4 +85,4 @@ class InAppLocalhostServer {
}
}
-}
\ No newline at end of file
+}