Updated javascript popups events

This commit is contained in:
Lorenzo Pichilli 2019-10-29 12:16:31 +01:00
parent ab0a5cc5b5
commit 153ab6023f
11 changed files with 671 additions and 435 deletions

View File

@ -16,26 +16,16 @@
<component name="ChangeListManager">
<list default="true" id="9b41f7a2-a71e-4923-91fb-249d7815b3e7" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/AndroidManifest.xml" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/AndroidManifest.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerHandler.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerHandler.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerTriggerResourceType.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerTriggerResourceType.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/FlutterWebView.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/FlutterWebView.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/android/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebChromeClient.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebChromeClient.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/res/values/styles.xml" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/res/values/styles.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/android/app/src/main/AndroidManifest.xml" beforeDir="false" afterPath="$PROJECT_DIR$/example/android/app/src/main/AndroidManifest.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/android/app/src/main/java/com/pichillilorenzo/flutterwebviewexample/MainActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/example/android/app/src/main/java/com/pichillilorenzo/flutterwebviewexample/MainActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/assets/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/example/assets/index.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/lib/inline_example.screen.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/inline_example.screen.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/lib/webview_example.screen.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/webview_example.screen.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ios/Classes/FlutterWebViewController.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/FlutterWebViewController.swift" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ios/Classes/InAppWebView.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/InAppWebView.swift" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ios/flutter_inappbrowser.podspec" beforeDir="false" afterPath="$PROJECT_DIR$/ios/flutter_inappbrowser.podspec" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/in_app_browser.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/in_app_browser.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/in_app_webview.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/in_app_webview.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/types.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/types.dart" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/.dart_tool/" />
<ignored path="$PROJECT_DIR$/.idea/" />
@ -58,8 +48,20 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="169">
<caret line="20" column="92" selection-start-line="20" selection-start-column="92" selection-end-line="20" selection-end-column="92" />
<state relative-caret-position="454">
<caret line="39" column="107" selection-start-line="39" selection-start-column="107" selection-end-line="39" selection-end-column="107" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/lib/webview_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="79">
<caret line="88" selection-start-line="88" selection-end-line="88" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -76,8 +78,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="205">
<caret line="164" column="80" selection-start-line="164" selection-start-column="80" selection-end-line="164" selection-end-column="80" />
<state relative-caret-position="-727">
<caret line="439" column="66" selection-start-line="439" selection-start-column="58" selection-end-line="439" selection-end-column="66" />
<folding>
<element signature="e#0#17#0" expanded="true" />
</folding>
@ -88,8 +90,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/in_app_browser.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="428">
<caret line="380" column="80" lean-forward="true" selection-start-line="376" selection-start-column="2" selection-end-line="380" selection-end-column="80" />
<state relative-caret-position="222">
<caret line="370" selection-start-line="370" selection-end-line="370" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
@ -100,7 +102,7 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/types.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="193">
<state relative-caret-position="477">
<caret line="212" column="22" selection-start-line="212" selection-start-column="7" selection-end-line="212" selection-end-column="22" />
<folding>
<element signature="e#0#32#0" expanded="true" />
@ -112,8 +114,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="260">
<caret line="58" column="44" selection-start-line="58" selection-start-column="44" selection-end-line="58" selection-end-column="44" />
<state relative-caret-position="514">
<caret line="73" column="12" selection-start-line="73" selection-start-column="12" selection-end-line="73" selection-end-column="12" />
</state>
</provider>
</entry>
@ -121,8 +123,8 @@
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/example/lib/inline_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="318">
<caret line="190" column="26" lean-forward="true" selection-start-line="190" selection-start-column="26" selection-end-line="190" selection-end-column="26" />
<state relative-caret-position="353">
<caret line="205" column="82" lean-forward="true" selection-start-line="205" selection-start-column="82" selection-end-line="205" selection-end-column="82" />
<folding>
<element signature="e#0#22#0" expanded="true" />
</folding>
@ -130,11 +132,20 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$USER_HOME$/flutter/packages/flutter/lib/src/material/dialog.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="307">
<caret line="690" column="10" selection-start-line="690" selection-start-column="10" selection-end-line="690" selection-end-column="10" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="17" column="2" selection-start-line="17" selection-start-column="2" selection-end-line="17" selection-end-column="2" />
<state relative-caret-position="405">
<caret line="37" column="18" selection-start-line="37" selection-start-column="18" selection-end-line="37" selection-end-column="18" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
@ -154,9 +165,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>List&lt;Con</find>
<find>appCacheEnabled</find>
<find>List&lt;Content</find>
<find>NOTE</find>
<find>onGeolocationPermissionsShowPrompt</find>
<find>&quot;onGeolocationPermissionsShowPrompt&quot;</find>
@ -184,6 +192,9 @@
<find>onJs</find>
<find>onJsAlert</find>
<find>defaultValue</find>
<find>onJsA</find>
<find>toMap()</find>
<find>.toMap()</find>
</findStrings>
<replaceStrings>
<replace>activity.getPreferences(0)</replace>
@ -242,7 +253,6 @@
<option value="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" />
<option value="$PROJECT_DIR$/example/lib/chrome_safari_example.screen.dart" />
<option value="$PROJECT_DIR$/lib/src/chrome_safari_browser.dart" />
<option value="$PROJECT_DIR$/example/lib/webview_example.screen.dart" />
<option value="$PROJECT_DIR$/example/pubspec.yaml" />
<option value="$PROJECT_DIR$/lib/src/webview_options.dart" />
<option value="$PROJECT_DIR$/example/ios/Runner/Info.plist" />
@ -250,16 +260,16 @@
<option value="$PROJECT_DIR$/example/lib/main.dart" />
<option value="$PROJECT_DIR$/lib/src/content_blocker.dart" />
<option value="$PROJECT_DIR$/lib/src/types.dart" />
<option value="$PROJECT_DIR$/example/assets/index.html" />
<option value="$PROJECT_DIR$/lib/src/in_app_browser.dart" />
<option value="$PROJECT_DIR$/lib/src/in_app_webview.dart" />
<option value="$PROJECT_DIR$/CHANGELOG.md" />
<option value="$PROJECT_DIR$/lib/src/in_app_browser.dart" />
<option value="$PROJECT_DIR$/example/lib/webview_example.screen.dart" />
<option value="$PROJECT_DIR$/lib/src/in_app_webview.dart" />
<option value="$PROJECT_DIR$/example/assets/index.html" />
<option value="$PROJECT_DIR$/example/lib/inline_example.screen.dart" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-1920" />
<option name="y" value="23" />
<option name="width" value="1920" />
<option name="height" value="1057" />
@ -270,6 +280,17 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope">
<subPane subId="Project Files">
<expand>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="flutter_inappbrowser" type="cbb8eebc:String" user="flutter_inappbrowser" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="AndroidView">
<subPane>
<expand>
@ -326,17 +347,6 @@
<select />
</subPane>
</pane>
<pane id="Scope">
<subPane subId="Project Files">
<expand>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="flutter_inappbrowser" type="cbb8eebc:String" user="flutter_inappbrowser" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
@ -487,11 +497,11 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="-1920" y="23" width="1920" height="1057" extended-state="6" />
<frame x="0" y="23" width="1920" height="1057" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.59969324" visible="true" weight="0.15867944" />
<window_info id="Structure" order="1" sideWeight="0.40030676" side_tool="true" visible="true" weight="0.15867944" />
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.59711075" visible="true" weight="0.15867944" />
<window_info id="Structure" order="1" sideWeight="0.40288925" side_tool="true" visible="true" weight="0.15867944" />
<window_info id="Designer" order="2" />
<window_info id="Build Variants" order="3" side_tool="true" />
<window_info id="Captures" order="4" side_tool="true" weight="0.32936507" />
@ -501,7 +511,7 @@
<window_info id="Resources Explorer" order="8" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32642487" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49307775" visible="true" weight="0.32435232" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49307775" visible="true" weight="0.35440415" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.34196892" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@ -509,7 +519,7 @@
<window_info anchor="bottom" id="Android Profiler" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" order="8" sideWeight="0.50692225" side_tool="true" weight="0.38445595" />
<window_info anchor="bottom" id="Version Control" order="9" weight="0.32953367" />
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.49533224" weight="0.2611399" />
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.49533224" weight="0.29430053" />
<window_info anchor="bottom" id="Logcat" order="11" weight="0.32953367" />
<window_info anchor="bottom" id="Messages" order="12" weight="0.226943" />
<window_info anchor="bottom" id="Dependency Viewer" order="13" weight="0.32800853" />
@ -748,23 +758,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/webview_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="184">
<caret line="81" column="47" selection-start-line="81" selection-start-column="47" selection-end-line="81" selection-end-column="47" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/flutter/packages/flutter/lib/src/material/dialog.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="189">
<caret line="690" column="10" selection-start-line="690" selection-start-column="10" selection-end-line="690" selection-end-column="10" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="345">
@ -793,23 +786,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="17" column="2" selection-start-line="17" selection-start-column="2" selection-end-line="17" selection-end-column="2" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="260">
<caret line="58" column="44" selection-start-line="58" selection-start-column="44" selection-end-line="58" selection-end-column="44" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/content_blocker.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375">
@ -817,16 +793,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="205">
<caret line="164" column="80" selection-start-line="164" selection-start-column="80" selection-end-line="164" selection-end-column="80" />
<folding>
<element signature="e#0#17#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/webview_options.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1456">
@ -837,6 +803,13 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="454">
<caret line="39" column="107" selection-start-line="39" selection-start-column="107" selection-end-line="39" selection-end-column="107" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
@ -844,17 +817,10 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<entry file="file://$PROJECT_DIR$/example/lib/webview_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="169">
<caret line="20" column="92" selection-start-line="20" selection-start-column="92" selection-end-line="20" selection-end-column="92" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_browser.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="428">
<caret line="380" column="80" lean-forward="true" selection-start-line="376" selection-start-column="2" selection-end-line="380" selection-end-column="80" />
<state relative-caret-position="79">
<caret line="88" selection-start-line="88" selection-end-line="88" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
@ -863,7 +829,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/types.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="193">
<state relative-caret-position="477">
<caret line="212" column="22" selection-start-line="212" selection-start-column="7" selection-end-line="212" selection-end-column="22" />
<folding>
<element signature="e#0#32#0" expanded="true" />
@ -871,10 +837,54 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-727">
<caret line="439" column="66" selection-start-line="439" selection-start-column="58" selection-end-line="439" selection-end-column="66" />
<folding>
<element signature="e#0#17#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_browser.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="222">
<caret line="370" selection-start-line="370" selection-end-line="370" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="405">
<caret line="37" column="18" selection-start-line="37" selection-start-column="18" selection-end-line="37" selection-end-column="18" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="514">
<caret line="73" column="12" selection-start-line="73" selection-start-column="12" selection-end-line="73" selection-end-column="12" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/flutter/packages/flutter/lib/src/material/dialog.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="307">
<caret line="690" column="10" selection-start-line="690" selection-start-column="10" selection-end-line="690" selection-end-column="10" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/inline_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="318">
<caret line="190" column="26" lean-forward="true" selection-start-line="190" selection-start-column="26" selection-end-line="190" selection-end-column="26" />
<state relative-caret-position="353">
<caret line="205" column="82" lean-forward="true" selection-start-line="205" selection-start-column="82" selection-end-line="205" selection-end-column="82" />
<folding>
<element signature="e#0#22#0" expanded="true" />
</folding>

View File

@ -1,16 +1,3 @@
def PLUGIN = "flutter_inappbrowser";
def ANDROIDX_WARNING = "flutterPluginsAndroidXWarning";
gradle.buildFinished { buildResult ->
if (buildResult.failure && !rootProject.ext.has(ANDROIDX_WARNING)) {
println ' *********************************************************'
println 'WARNING: This version of ' + PLUGIN + ' will break your Android build if it or its dependencies aren\'t compatible with AndroidX.'
println ' See https://goo.gl/CP92wY for more information on the problem and how to fix it.'
println ' This warning prints for all Android build failures. The real root cause of the error may be unrelated.'
println ' *********************************************************'
rootProject.ext.set(ANDROIDX_WARNING, true);
}
}
group 'com.pichillilorenzo.flutter_inappbrowser'
version '1.0-SNAPSHOT'

View File

@ -112,67 +112,78 @@ public class InAppWebChromeClient extends WebChromeClient {
getChannel().invokeMethod("onJsAlert", obj, new MethodChannel.Result() {
@Override
public void success(Object response) {
Map<String, Object> responseMap = (Map<String, Object>) response;
String responseMessage = (String) responseMap.get("message");
String confirmButtonTitle = (String) responseMap.get("confirmButtonTitle");
boolean handledByClient = (boolean) responseMap.get("handledByClient");
if (handledByClient) {
Integer action = (Integer) responseMap.get("action");
action = action != null ? action : 1;
switch (action) {
case 0:
result.confirm();
break;
case 1:
default:
result.cancel();
}
} else {
String alertMessage = (responseMessage != null && !responseMessage.isEmpty()) ? responseMessage : message;
Log.d(LOG_TAG, alertMessage);
DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm();
dialog.dismiss();
String responseMessage = null;
String confirmButtonTitle = null;
if (response != null) {
Map<String, Object> responseMap = (Map<String, Object>) response;
responseMessage = (String) responseMap.get("message");
confirmButtonTitle = (String) responseMap.get("confirmButtonTitle");
Boolean handledByClient = (Boolean) responseMap.get("handledByClient");
if (handledByClient != null && handledByClient) {
Integer action = (Integer) responseMap.get("action");
action = action != null ? action : 1;
switch (action) {
case 0:
result.confirm();
break;
case 1:
default:
result.cancel();
}
};
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(view.getContext(), R.style.Theme_AppCompat_Dialog_Alert);
alertDialogBuilder.setMessage(alertMessage);
if (confirmButtonTitle != null && !confirmButtonTitle.isEmpty()) {
alertDialogBuilder.setPositiveButton(confirmButtonTitle, clickListener);
} else {
alertDialogBuilder.setPositiveButton(android.R.string.ok, clickListener);
return;
}
alertDialogBuilder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
result.cancel();
dialog.dismiss();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
createAlertDialog(view, message, result, responseMessage, confirmButtonTitle);
}
@Override
public void error(String s, String s1, Object o) {
Log.e(LOG_TAG, s + ", " + s1);
result.cancel();
}
@Override
public void notImplemented() {
createAlertDialog(view, message, result, null, null);
}
});
return true;
}
public void createAlertDialog(WebView view, String message, final JsResult result, String responseMessage, String confirmButtonTitle) {
String alertMessage = (responseMessage != null && !responseMessage.isEmpty()) ? responseMessage : message;
DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm();
dialog.dismiss();
}
};
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(view.getContext(), R.style.Theme_AppCompat_Dialog_Alert);
alertDialogBuilder.setMessage(alertMessage);
if (confirmButtonTitle != null && !confirmButtonTitle.isEmpty()) {
alertDialogBuilder.setPositiveButton(confirmButtonTitle, clickListener);
} else {
alertDialogBuilder.setPositiveButton(android.R.string.ok, clickListener);
}
alertDialogBuilder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
result.cancel();
dialog.dismiss();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
@Override
public boolean onJsConfirm(final WebView view, String url, final String message,
final JsResult result) {
@ -184,79 +195,91 @@ public class InAppWebChromeClient extends WebChromeClient {
getChannel().invokeMethod("onJsConfirm", obj, new MethodChannel.Result() {
@Override
public void success(Object response) {
Map<String, Object> responseMap = (Map<String, Object>) response;
String responseMessage = (String) responseMap.get("message");
String confirmButtonTitle = (String) responseMap.get("confirmButtonTitle");
String cancelButtonTitle = (String) responseMap.get("cancelButtonTitle");
boolean handledByClient = (boolean) responseMap.get("handledByClient");
if (handledByClient) {
Integer action = (Integer) responseMap.get("action");
action = action != null ? action : 1;
switch (action) {
case 0:
result.confirm();
break;
case 1:
default:
result.cancel();
}
} else {
String alertMessage = (responseMessage != null && !responseMessage.isEmpty()) ? responseMessage : message;
DialogInterface.OnClickListener confirmClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm();
dialog.dismiss();
}
};
DialogInterface.OnClickListener cancelClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.cancel();
dialog.dismiss();
}
};
String responseMessage = null;
String confirmButtonTitle = null;
String cancelButtonTitle = null;
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(view.getContext(), R.style.Theme_AppCompat_Dialog_Alert);
alertDialogBuilder.setMessage(alertMessage);
if (confirmButtonTitle != null && !confirmButtonTitle.isEmpty()) {
alertDialogBuilder.setPositiveButton(confirmButtonTitle, confirmClickListener);
} else {
alertDialogBuilder.setPositiveButton(android.R.string.ok, confirmClickListener);
}
if (cancelButtonTitle != null && !cancelButtonTitle.isEmpty()) {
alertDialogBuilder.setNegativeButton(cancelButtonTitle, cancelClickListener);
} else {
alertDialogBuilder.setNegativeButton(android.R.string.cancel, cancelClickListener);
}
alertDialogBuilder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
result.cancel();
dialog.dismiss();
if (response != null) {
Map<String, Object> responseMap = (Map<String, Object>) response;
responseMessage = (String) responseMap.get("message");
confirmButtonTitle = (String) responseMap.get("confirmButtonTitle");
cancelButtonTitle = (String) responseMap.get("cancelButtonTitle");
Boolean handledByClient = (Boolean) responseMap.get("handledByClient");
if (handledByClient != null && handledByClient) {
Integer action = (Integer) responseMap.get("action");
action = action != null ? action : 1;
switch (action) {
case 0:
result.confirm();
break;
case 1:
default:
result.cancel();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
return;
}
}
createConfirmDialog(view, message, result, responseMessage, confirmButtonTitle, cancelButtonTitle);
}
@Override
public void error(String s, String s1, Object o) {
Log.e(LOG_TAG, s + ", " + s1);
result.cancel();
}
@Override
public void notImplemented() {
createConfirmDialog(view, message, result, null, null, null);
}
});
return true;
}
public void createConfirmDialog(WebView view, String message, final JsResult result, String responseMessage, String confirmButtonTitle, String cancelButtonTitle) {
String alertMessage = (responseMessage != null && !responseMessage.isEmpty()) ? responseMessage : message;
DialogInterface.OnClickListener confirmClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm();
dialog.dismiss();
}
};
DialogInterface.OnClickListener cancelClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.cancel();
dialog.dismiss();
}
};
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(view.getContext(), R.style.Theme_AppCompat_Dialog_Alert);
alertDialogBuilder.setMessage(alertMessage);
if (confirmButtonTitle != null && !confirmButtonTitle.isEmpty()) {
alertDialogBuilder.setPositiveButton(confirmButtonTitle, confirmClickListener);
} else {
alertDialogBuilder.setPositiveButton(android.R.string.ok, confirmClickListener);
}
if (cancelButtonTitle != null && !cancelButtonTitle.isEmpty()) {
alertDialogBuilder.setNegativeButton(cancelButtonTitle, cancelClickListener);
} else {
alertDialogBuilder.setNegativeButton(android.R.string.cancel, cancelClickListener);
}
alertDialogBuilder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
result.cancel();
dialog.dismiss();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
@Override
public boolean onJsPrompt(final WebView view, String url, final String message,
final String defaultValue, final JsPromptResult result) {
@ -269,99 +292,112 @@ public class InAppWebChromeClient extends WebChromeClient {
getChannel().invokeMethod("onJsPrompt", obj, new MethodChannel.Result() {
@Override
public void success(Object response) {
Map<String, Object> responseMap = (Map<String, Object>) response;
String responseMessage = (String) responseMap.get("message");
String responseDefaultValue = (String) responseMap.get("defaultValue");
String confirmButtonTitle = (String) responseMap.get("confirmButtonTitle");
String cancelButtonTitle = (String) responseMap.get("cancelButtonTitle");
final String value = (String) responseMap.get("value");
boolean handledByClient = (boolean) responseMap.get("handledByClient");
if (handledByClient) {
Integer action = (Integer) responseMap.get("action");
action = action != null ? action : 1;
switch (action) {
case 0:
if (value != null)
String responseMessage = null;
String responseDefaultValue = null;
String confirmButtonTitle = null;
String cancelButtonTitle = null;
String value = null;
if (response != null) {
Map<String, Object> responseMap = (Map<String, Object>) response;
responseMessage = (String) responseMap.get("message");
responseDefaultValue = (String) responseMap.get("defaultValue");
confirmButtonTitle = (String) responseMap.get("confirmButtonTitle");
cancelButtonTitle = (String) responseMap.get("cancelButtonTitle");
value = (String) responseMap.get("value");
Boolean handledByClient = (Boolean) responseMap.get("handledByClient");
if (handledByClient != null && handledByClient) {
Integer action = (Integer) responseMap.get("action");
action = action != null ? action : 1;
switch (action) {
case 0:
result.confirm(value);
else
result.confirm();
break;
case 1:
default:
result.cancel();
}
} else {
FrameLayout layout = new FrameLayout(view.getContext());
final EditText input = new EditText(view.getContext());
input.setMaxLines(1);
input.setText((responseDefaultValue != null && !responseDefaultValue.isEmpty()) ? responseDefaultValue : defaultValue);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
layout.setPaddingRelative(45,15,45,0);
layout.addView(input);
String alertMessage = (responseMessage != null && !responseMessage.isEmpty()) ? responseMessage : message;
DialogInterface.OnClickListener confirmClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = input.getText().toString();
result.confirm(value != null ? value : text);
dialog.dismiss();
break;
case 1:
default:
result.cancel();
}
};
DialogInterface.OnClickListener cancelClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.cancel();
dialog.dismiss();
}
};
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(view.getContext(), R.style.Theme_AppCompat_Dialog_Alert);
alertDialogBuilder.setMessage(alertMessage);
if (confirmButtonTitle != null && !confirmButtonTitle.isEmpty()) {
alertDialogBuilder.setPositiveButton(confirmButtonTitle, confirmClickListener);
} else {
alertDialogBuilder.setPositiveButton(android.R.string.ok, confirmClickListener);
return;
}
if (cancelButtonTitle != null && !cancelButtonTitle.isEmpty()) {
alertDialogBuilder.setNegativeButton(cancelButtonTitle, cancelClickListener);
} else {
alertDialogBuilder.setNegativeButton(android.R.string.cancel, cancelClickListener);
}
alertDialogBuilder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
result.cancel();
dialog.dismiss();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.setView(layout);
alertDialog.show();
}
createPromptDialog(view, message, defaultValue, result, responseMessage, responseDefaultValue, value, cancelButtonTitle, confirmButtonTitle);
}
@Override
public void error(String s, String s1, Object o) {
Log.e(LOG_TAG, s + ", " + s1);
result.cancel();
}
@Override
public void notImplemented() {
createPromptDialog(view, message, defaultValue, result, null, null, null, null, null);
}
});
return true;
}
public void createPromptDialog(WebView view, String message, String defaultValue, final JsPromptResult result, String responseMessage, String responseDefaultValue, String value, String cancelButtonTitle, String confirmButtonTitle) {
FrameLayout layout = new FrameLayout(view.getContext());
final EditText input = new EditText(view.getContext());
input.setMaxLines(1);
input.setText((responseDefaultValue != null && !responseDefaultValue.isEmpty()) ? responseDefaultValue : defaultValue);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
layout.setPaddingRelative(45,15,45,0);
layout.addView(input);
String alertMessage = (responseMessage != null && !responseMessage.isEmpty()) ? responseMessage : message;
final String finalValue = value;
DialogInterface.OnClickListener confirmClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = input.getText().toString();
result.confirm(finalValue != null ? finalValue : text);
dialog.dismiss();
}
};
DialogInterface.OnClickListener cancelClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.cancel();
dialog.dismiss();
}
};
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(view.getContext(), R.style.Theme_AppCompat_Dialog_Alert);
alertDialogBuilder.setMessage(alertMessage);
if (confirmButtonTitle != null && !confirmButtonTitle.isEmpty()) {
alertDialogBuilder.setPositiveButton(confirmButtonTitle, confirmClickListener);
} else {
alertDialogBuilder.setPositiveButton(android.R.string.ok, confirmClickListener);
}
if (cancelButtonTitle != null && !cancelButtonTitle.isEmpty()) {
alertDialogBuilder.setNegativeButton(cancelButtonTitle, cancelClickListener);
} else {
alertDialogBuilder.setNegativeButton(android.R.string.cancel, cancelClickListener);
}
alertDialogBuilder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
result.cancel();
dialog.dismiss();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.setView(layout);
alertDialog.show();
}
@Override
public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, android.os.Message resultMsg)
{

View File

@ -55,13 +55,14 @@
});
});
$(document).ready(function() {
/*
alert("Alert Popup");
console.log(confirm("Press a button!"));
console.log(prompt("Please enter your name", "Harry Potter"));
console.log(prompt("Please enter your name", "Lorenzo"));
*/
console.log("jQuery ready");
/*
/*
if ("geolocation" in navigator) {
console.log("Geolocation API enabled");
navigator.geolocation.getCurrentPosition(function(position) {
@ -69,7 +70,8 @@
});
} else {
console.log("No geolocation API");
}*/
}
*/
});
</script>
</body>

View File

@ -198,90 +198,16 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
return response;
},
onJsAlert: (InAppWebViewController controller, String message) async {
JsAlertResponseAction action;
await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
content: Text(message),
actions: <Widget>[
FlatButton(
child: Text("Ok"),
onPressed: () {
action = JsAlertResponseAction.CONFIRM;
Navigator.of(context).pop();
},
),
],
);
},
);
JsAlertResponseAction action = await createAlertDialog(context, message);
return new JsAlertResponse(handledByClient: true, action: action);
},
onJsConfirm: (InAppWebViewController controller, String message) async {
JsConfirmResponseAction action;
await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
content: Text(message),
actions: <Widget>[
FlatButton(
child: Text("Cancel"),
onPressed: () {
action = JsConfirmResponseAction.CANCEL;
Navigator.of(context).pop();
},
),
FlatButton(
child: Text("Ok"),
onPressed: () {
action = JsConfirmResponseAction.CONFIRM;
Navigator.of(context).pop();
},
),
],
);
},
);
JsConfirmResponseAction action = await createConfirmDialog(context, message);
return new JsConfirmResponse(handledByClient: true, action: action);
},
onJsPrompt: (InAppWebViewController controller, String message, String defaultValue) async {
JsPromptResponseAction action;
_textFieldController.text = defaultValue;
await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(message),
content: TextField(
controller: _textFieldController,
),
actions: <Widget>[
FlatButton(
child: Text("Cancel"),
onPressed: () {
action = JsPromptResponseAction.CANCEL;
Navigator.of(context).pop();
},
),
FlatButton(
child: Text("Ok"),
onPressed: () {
action = JsPromptResponseAction.CONFIRM;
Navigator.of(context).pop();
},
),
],
);
},
);
JsPromptResponseAction action = await createPromptDialog(context, message);
return new JsPromptResponse(handledByClient: true, action: action, value: _textFieldController.text);
},
),
@ -319,6 +245,95 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
]));
}
Future<JsAlertResponseAction> createAlertDialog(BuildContext context, String message) async {
JsAlertResponseAction action;
await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
content: Text(message),
actions: <Widget>[
FlatButton(
child: Text("Ok"),
onPressed: () {
action = JsAlertResponseAction.CONFIRM;
Navigator.of(context).pop();
},
),
],
);
},
);
return action;
}
Future<JsConfirmResponseAction> createConfirmDialog(BuildContext context, String message) async {
JsConfirmResponseAction action;
await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
content: Text(message),
actions: <Widget>[
FlatButton(
child: Text("Cancel"),
onPressed: () {
action = JsConfirmResponseAction.CANCEL;
Navigator.of(context).pop();
},
),
FlatButton(
child: Text("Ok"),
onPressed: () {
action = JsConfirmResponseAction.CONFIRM;
Navigator.of(context).pop();
},
),
],
);
},
);
return action;
}
Future<JsPromptResponseAction> createPromptDialog(BuildContext context, String message) async {
JsPromptResponseAction action;
await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(message),
content: TextField(
controller: _textFieldController,
),
actions: <Widget>[
FlatButton(
child: Text("Cancel"),
onPressed: () {
action = JsPromptResponseAction.CANCEL;
Navigator.of(context).pop();
},
),
FlatButton(
child: Text("Ok"),
onPressed: () {
action = JsPromptResponseAction.CONFIRM;
Navigator.of(context).pop();
},
),
],
);
},
);
return action;
}
Future<String> _findLocalPath() async {
final directory = Platform.isAndroid
? await getExternalStorageDirectory()

View File

@ -81,10 +81,27 @@ class MyInappBrowser extends InAppBrowser {
Future<GeolocationPermissionShowPromptResponse> onGeolocationPermissionsShowPrompt(String origin) async {
print("request Geolocation permission API");
}
@override
Future<JsAlertResponse> onJsAlert(String message) async {
return new JsAlertResponse(handledByClient: false, message: "coma iam");
}
@override
Future<JsConfirmResponse> onJsConfirm(String message) {
}
@override
Future<JsPromptResponse> onJsPrompt(String message, String defaultValue) {
}
}
class WebviewExampleScreen extends StatefulWidget {
final MyInappBrowser browser = new MyInappBrowser();
static BuildContext context = null;
@override
_WebviewExampleScreenState createState() => new _WebviewExampleScreenState();
}
@ -97,17 +114,19 @@ class _WebviewExampleScreenState extends State<WebviewExampleScreen> {
@override
Widget build(BuildContext context) {
WebviewExampleScreen.context = context;
return new Center(
child: new RaisedButton(
onPressed: () {
widget.browser.open(
url: "https://www.google.com/",
options: [
InAppWebViewOptions(
useShouldOverrideUrlLoading: true,
useOnLoadResource: true,
)
]
widget.browser.openFile(
"assets/index.html",
//url: "https://www.google.com/",
options: [
InAppWebViewOptions(
useShouldOverrideUrlLoading: true,
useOnLoadResource: true,
)
]
);
},
child: Text("Open Webview Browser")),

View File

@ -44,7 +44,6 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {
do {
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
let blockRules = String(data: jsonData, encoding: String.Encoding.utf8)
print(blockRules)
WKContentRuleListStore.default().compileContentRuleList(
forIdentifier: "ContentBlockingRules",
encodedContentRuleList: blockRules) { (contentRuleList, error) in

View File

@ -745,63 +745,200 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
}
}
public func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String,
initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
let alertController = UIAlertController(title: message, message: nil,
fileprivate func createAlertDialog(message: String?, responseMessage: String?, confirmButtonTitle: String?, completionHandler: @escaping () -> Void) {
let title = responseMessage != nil && !responseMessage!.isEmpty ? responseMessage : message
let okButton = confirmButtonTitle != nil && !confirmButtonTitle!.isEmpty ? confirmButtonTitle : NSLocalizedString("Ok", comment: "")
let alertController = UIAlertController(title: title, message: nil,
preferredStyle: UIAlertController.Style.alert);
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default) {
alertController.addAction(UIAlertAction(title: okButton, style: UIAlertAction.Style.default) {
_ in completionHandler()}
);
let presentingViewController = ((IABController != nil) ? IABController! : window!.rootViewController!)
let presentingViewController = ((self.IABController != nil) ? self.IABController! : self.window!.rootViewController!)
presentingViewController.present(alertController, animated: true, completion: {})
}
public func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String,
initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
onJsAlert(message: message, result: {(result) -> Void in
if result is FlutterError {
print((result as! FlutterError).message)
completionHandler()
}
else if (result as? NSObject) == FlutterMethodNotImplemented {
self.createAlertDialog(message: message, responseMessage: nil, confirmButtonTitle: nil, completionHandler: completionHandler)
}
else {
let response: [String: Any]
var responseMessage: String?;
var confirmButtonTitle: String?;
if let r = result {
response = r as! [String: Any]
responseMessage = response["message"] as? String
confirmButtonTitle = response["confirmButtonTitle"] as? String
let handledByClient = response["handledByClient"] as? Bool
if handledByClient != nil, handledByClient! {
var action = response["action"] as? Int
action = action != nil ? action : 1;
switch action {
case 0:
completionHandler()
break
default:
completionHandler()
}
return;
}
}
self.createAlertDialog(message: message, responseMessage: responseMessage, confirmButtonTitle: confirmButtonTitle, completionHandler: completionHandler)
}
})
}
fileprivate func createConfirmDialog(message: String?, responseMessage: String?, confirmButtonTitle: String?, cancelButtonTitle: String?, completionHandler: @escaping (Bool) -> Void) {
let dialogMessage = responseMessage != nil && !responseMessage!.isEmpty ? responseMessage : message
let okButton = confirmButtonTitle != nil && !confirmButtonTitle!.isEmpty ? confirmButtonTitle : NSLocalizedString("Ok", comment: "")
let cancelButton = cancelButtonTitle != nil && !cancelButtonTitle!.isEmpty ? cancelButtonTitle : NSLocalizedString("Cancel", comment: "")
let alertController = UIAlertController(title: nil, message: dialogMessage, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: okButton, style: .default, handler: { (action) in
completionHandler(true)
}))
alertController.addAction(UIAlertAction(title: cancelButton, style: .cancel, handler: { (action) in
completionHandler(false)
}))
let presentingViewController = ((self.IABController != nil) ? self.IABController! : self.window!.rootViewController!)
presentingViewController.present(alertController, animated: true, completion: nil)
}
public func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo,
completionHandler: @escaping (Bool) -> Void) {
let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in
completionHandler(true)
}))
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) in
completionHandler(false)
}))
let presentingViewController = ((IABController != nil) ? IABController! : window!.rootViewController!)
presentingViewController.present(alertController, animated: true, completion: nil)
onJsConfirm(message: message, result: {(result) -> Void in
if result is FlutterError {
print((result as! FlutterError).message)
completionHandler(false)
}
else if (result as? NSObject) == FlutterMethodNotImplemented {
self.createConfirmDialog(message: message, responseMessage: nil, confirmButtonTitle: nil, cancelButtonTitle: nil, completionHandler: completionHandler)
}
else {
let response: [String: Any]
var responseMessage: String?;
var confirmButtonTitle: String?;
var cancelButtonTitle: String?;
if let r = result {
response = r as! [String: Any]
responseMessage = response["message"] as? String
confirmButtonTitle = response["confirmButtonTitle"] as? String
cancelButtonTitle = response["cancelButtonTitle"] as? String
let handledByClient = response["handledByClient"] as? Bool
if handledByClient != nil, handledByClient! {
var action = response["action"] as? Int
action = action != nil ? action : 1;
switch action {
case 0:
completionHandler(true)
break
case 1:
completionHandler(false)
break
default:
completionHandler(false)
}
return;
}
}
self.createConfirmDialog(message: message, responseMessage: responseMessage, confirmButtonTitle: confirmButtonTitle, cancelButtonTitle: cancelButtonTitle, completionHandler: completionHandler)
}
})
}
public func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo,
completionHandler: @escaping (String?) -> Void) {
let alertController = UIAlertController(title: nil, message: prompt, preferredStyle: .alert)
fileprivate func createPromptDialog(message: String, defaultValue: String?, responseMessage: String?, confirmButtonTitle: String?, cancelButtonTitle: String?, value: String?, completionHandler: @escaping (String?) -> Void) {
let dialogMessage = responseMessage != nil && !responseMessage!.isEmpty ? responseMessage : message
let okButton = confirmButtonTitle != nil && !confirmButtonTitle!.isEmpty ? confirmButtonTitle : NSLocalizedString("Ok", comment: "")
let cancelButton = cancelButtonTitle != nil && !cancelButtonTitle!.isEmpty ? cancelButtonTitle : NSLocalizedString("Cancel", comment: "")
let alertController = UIAlertController(title: nil, message: dialogMessage, preferredStyle: .alert)
alertController.addTextField { (textField) in
textField.text = defaultText
textField.text = defaultValue
}
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in
if let text = alertController.textFields?.first?.text {
alertController.addAction(UIAlertAction(title: okButton, style: .default, handler: { (action) in
if let v = value {
completionHandler(v)
}
else if let text = alertController.textFields?.first?.text {
completionHandler(text)
} else {
completionHandler(defaultText)
completionHandler("")
}
}))
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) in
alertController.addAction(UIAlertAction(title: cancelButton, style: .cancel, handler: { (action) in
completionHandler(nil)
}))
let presentingViewController = ((IABController != nil) ? IABController! : window!.rootViewController!)
let presentingViewController = ((self.IABController != nil) ? self.IABController! : self.window!.rootViewController!)
presentingViewController.present(alertController, animated: true, completion: nil)
}
public func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt message: String, defaultText defaultValue: String?, initiatedByFrame frame: WKFrameInfo,
completionHandler: @escaping (String?) -> Void) {
onJsPrompt(message: message, defaultValue: defaultValue, result: {(result) -> Void in
if result is FlutterError {
print((result as! FlutterError).message)
completionHandler(nil)
}
else if (result as? NSObject) == FlutterMethodNotImplemented {
self.createPromptDialog(message: message, defaultValue: defaultValue, responseMessage: nil, confirmButtonTitle: nil, cancelButtonTitle: nil, value: nil, completionHandler: completionHandler)
}
else {
let response: [String: Any]
var responseMessage: String?;
var confirmButtonTitle: String?;
var cancelButtonTitle: String?;
var value: String?;
if let r = result {
response = r as! [String: Any]
responseMessage = response["message"] as? String
confirmButtonTitle = response["confirmButtonTitle"] as? String
cancelButtonTitle = response["cancelButtonTitle"] as? String
let handledByClient = response["handledByClient"] as? Bool
value = response["value"] as? String;
if handledByClient != nil, handledByClient! {
var action = response["action"] as? Int
action = action != nil ? action : 1;
switch action {
case 0:
completionHandler(value)
break
case 1:
completionHandler(nil)
break
default:
completionHandler(nil)
}
return;
}
}
self.createPromptDialog(message: message, defaultValue: defaultValue, responseMessage: responseMessage, confirmButtonTitle: confirmButtonTitle, cancelButtonTitle: cancelButtonTitle, value: value, completionHandler: completionHandler)
}
})
}
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
if navigationDelegate != nil {
let x = Int(scrollView.contentOffset.x / scrollView.contentScaleFactor)
@ -916,6 +1053,36 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
}
}
public func onJsAlert(message: String, result: FlutterResult?) {
var arguments: [String: Any] = ["message": message]
if IABController != nil {
arguments["uuid"] = IABController!.uuid
}
if let channel = getChannel() {
channel.invokeMethod("onJsAlert", arguments: arguments, result: result)
}
}
public func onJsConfirm(message: String, result: FlutterResult?) {
var arguments: [String: Any] = ["message": message]
if IABController != nil {
arguments["uuid"] = IABController!.uuid
}
if let channel = getChannel() {
channel.invokeMethod("onJsConfirm", arguments: arguments, result: result)
}
}
public func onJsPrompt(message: String, defaultValue: String?, result: FlutterResult?) {
var arguments: [String: Any] = ["message": message, "defaultValue": defaultValue as Any]
if IABController != nil {
arguments["uuid"] = IABController!.uuid
}
if let channel = getChannel() {
channel.invokeMethod("onJsPrompt", arguments: arguments, result: result)
}
}
public func onConsoleMessage(sourceURL: String, lineNumber: Int, message: String, messageLevel: String) {
var arguments: [String: Any] = ["sourceURL": sourceURL, "lineNumber": lineNumber, "message": message, "messageLevel": messageLevel]
if IABController != nil {

View File

@ -18,6 +18,7 @@ A new Flutter plugin.
s.dependency 'Flutter'
s.ios.deployment_target = '8.0'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
s.swift_version = '5.0'
end

View File

@ -358,6 +358,17 @@ class InAppBrowser {
}
///Event that notifies the host application that web content from the specified origin is attempting to use the Geolocation API, but no permission state is currently set for that origin.
///Note that for applications targeting Android N and later SDKs (API level > `Build.VERSION_CODES.M`) this method is only called for requests originating from secure origins such as https.
///On non-secure origins geolocation requests are automatically denied.
///
///[origin] represents the origin of the web content attempting to use the Geolocation API.
///
///**NOTE**: available only for Android.
Future<GeolocationPermissionShowPromptResponse> onGeolocationPermissionsShowPrompt (String origin) {
}
///Event fires when javascript calls the `alert()` method to display an alert dialog.
///If [JsAlertResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
@ -383,17 +394,6 @@ class InAppBrowser {
}
///Event that notifies the host application that web content from the specified origin is attempting to use the Geolocation API, but no permission state is currently set for that origin.
///Note that for applications targeting Android N and later SDKs (API level > `Build.VERSION_CODES.M`) this method is only called for requests originating from secure origins such as https.
///On non-secure origins geolocation requests are automatically denied.
///
///[origin] represents the origin of the web content attempting to use the Geolocation API.
///
///**NOTE**: available only for Android.
Future<GeolocationPermissionShowPromptResponse> onGeolocationPermissionsShowPrompt (String origin) {
}
void throwIsAlreadyOpened({String message = ''}) {
if (this.isOpened()) {
throw Exception(['Error: ${ (message.isEmpty) ? '' : message + ' '}The browser is already opened.']);

View File

@ -428,31 +428,31 @@ class InAppWebViewController {
case "onGeolocationPermissionsShowPrompt":
String origin = call.arguments["origin"];
if (_widget != null && _widget.onGeolocationPermissionsShowPrompt != null)
return (await _widget.onGeolocationPermissionsShowPrompt(this, origin)).toMap();
return (await _widget.onGeolocationPermissionsShowPrompt(this, origin))?.toMap();
else if (_inAppBrowser != null)
return (await _inAppBrowser.onGeolocationPermissionsShowPrompt(origin)).toMap();
return (await _inAppBrowser.onGeolocationPermissionsShowPrompt(origin))?.toMap();
break;
case "onJsAlert":
String message = call.arguments["message"];
if (_widget != null && _widget.onJsAlert != null)
return (await _widget.onJsAlert(this, message)).toMap();
return (await _widget.onJsAlert(this, message))?.toMap();
else if (_inAppBrowser != null)
return (await _inAppBrowser.onJsAlert(message)).toMap();
return (await _inAppBrowser.onJsAlert(message))?.toMap();
break;
case "onJsConfirm":
String message = call.arguments["message"];
if (_widget != null && _widget.onJsConfirm != null)
return (await _widget.onJsConfirm(this, message)).toMap();
return (await _widget.onJsConfirm(this, message))?.toMap();
else if (_inAppBrowser != null)
return (await _inAppBrowser.onJsConfirm(message)).toMap();
return (await _inAppBrowser.onJsConfirm(message))?.toMap();
break;
case "onJsPrompt":
String message = call.arguments["message"];
String defaultValue = call.arguments["defaultValue"];
if (_widget != null && _widget.onJsPrompt != null)
return (await _widget.onJsPrompt(this, message, defaultValue)).toMap();
return (await _widget.onJsPrompt(this, message, defaultValue))?.toMap();
else if (_inAppBrowser != null)
return (await _inAppBrowser.onJsPrompt(message, defaultValue)).toMap();
return (await _inAppBrowser.onJsPrompt(message, defaultValue))?.toMap();
break;
case "onCallJsHandler":
String handlerName = call.arguments["handlerName"];