Added , (available only for Android), Added , and events to manage javascript popup dialogs only for Android now, added support for javascript dialogs popups for iOS
This commit is contained in:
parent
bc6bed1891
commit
ab0a5cc5b5
|
@ -15,39 +15,27 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9b41f7a2-a71e-4923-91fb-249d7815b3e7" name="Default" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerHandler.java" afterDir="false" />
|
||||
<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/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/android/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlocker.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlocker.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerTrigger.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerTrigger.java" 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/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/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/RequestPermissionHandler.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/RequestPermissionHandler.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/Util.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/Util.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/ios/Runner.xcodeproj/project.pbxproj" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Runner.xcodeproj/project.pbxproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/ios/Runner/AppDelegate.swift" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Runner/AppDelegate.swift" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/ios/Runner/Info.plist" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Runner/Info.plist" 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/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/main.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$/example/pubspec.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/example/pubspec.yaml" 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/Classes/InAppWebViewOptions.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/InAppWebViewOptions.swift" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/src/content_blocker.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/content_blocker.dart" 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" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/src/webview_options.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/webview_options.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pubspec.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.yaml" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.dart_tool/" />
|
||||
<ignored path="$PROJECT_DIR$/.idea/" />
|
||||
|
@ -67,11 +55,11 @@
|
|||
<component name="ExecutionTargetManager" SELECTED_TARGET="Pixel_3_XL_API_24" />
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<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="405">
|
||||
<caret line="27" selection-start-line="27" selection-end-line="27" />
|
||||
<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>
|
||||
|
@ -85,23 +73,11 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/webview_options.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="61">
|
||||
<caret line="239" column="47" lean-forward="true" selection-start-line="239" selection-start-column="47" selection-end-line="239" selection-end-column="47" />
|
||||
<folding>
|
||||
<element signature="e#0#17#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<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="233">
|
||||
<caret line="396" column="56" selection-start-line="396" selection-start-column="56" selection-end-line="396" selection-end-column="56" />
|
||||
<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>
|
||||
|
@ -109,20 +85,11 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<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="302">
|
||||
<caret line="111" column="45" selection-start-line="111" selection-start-column="6" selection-end-line="111" selection-end-column="45" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<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="5265">
|
||||
<caret line="359" column="84" selection-start-line="359" selection-start-column="50" selection-end-line="359" selection-end-column="84" />
|
||||
<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" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -131,10 +98,13 @@
|
|||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/content_blocker.dart">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/types.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="90">
|
||||
<caret line="6" column="45" selection-start-line="6" selection-start-column="45" selection-end-line="6" selection-end-column="45" />
|
||||
<state relative-caret-position="193">
|
||||
<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" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -142,17 +112,17 @@
|
|||
<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="460">
|
||||
<caret line="63" column="19" lean-forward="true" selection-start-line="63" selection-start-column="19" selection-end-line="63" selection-end-column="19" />
|
||||
<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>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<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="439">
|
||||
<caret line="85" column="38" selection-start-line="85" selection-start-column="38" selection-end-line="85" selection-end-column="38" />
|
||||
<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" />
|
||||
<folding>
|
||||
<element signature="e#0#22#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -163,7 +133,7 @@
|
|||
<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="255">
|
||||
<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" />
|
||||
|
@ -184,21 +154,6 @@
|
|||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>options)</find>
|
||||
<find>WebViewOptions</find>
|
||||
<find>websiteDataStore</find>
|
||||
<find>CacheMode</find>
|
||||
<find>toStr</find>
|
||||
<find>cacheMode</find>
|
||||
<find>disabledActionModeMenuItems</find>
|
||||
<find>AndroidInAppWebViewModeMenuItem</find>
|
||||
<find>fantasyFontFamily</find>
|
||||
<find>AndroidInAppWebViewLayoutAlgorithm</find>
|
||||
<find>loadWithOverviewMode</find>
|
||||
<find>AndroidInAppWebViewCacheMode</find>
|
||||
<find>mixedContentMode</find>
|
||||
<find>disable</find>
|
||||
<find>appCachePath</find>
|
||||
<find>List<Con</find>
|
||||
<find>appCacheEnabled</find>
|
||||
<find>List<Content</find>
|
||||
|
@ -214,6 +169,21 @@
|
|||
<find>defaultWebpagePreferences</find>
|
||||
<find>contentBlockers</find>
|
||||
<find>preferredContentMode</find>
|
||||
<find>useOnLoadResource</find>
|
||||
<find>safe</find>
|
||||
<find>InAppWebViewController</find>
|
||||
<find>safeBrowsingEnabled</find>
|
||||
<find>only</find>
|
||||
<find>///**NOTE**: available only for Android.</find>
|
||||
<find>_inAppBrowser</find>
|
||||
<find>_channel</find>
|
||||
<find>uuid_</find>
|
||||
<find>javaScriptHandlersMap</find>
|
||||
<find>onJsAlertResponseCallback</find>
|
||||
<find>_jsResultCallbackMap</find>
|
||||
<find>onJs</find>
|
||||
<find>onJsAlert</find>
|
||||
<find>defaultValue</find>
|
||||
</findStrings>
|
||||
<replaceStrings>
|
||||
<replace>activity.getPreferences(0)</replace>
|
||||
|
@ -222,6 +192,7 @@
|
|||
<replace>flutter_inappbrowser</replace>
|
||||
<replace>throwIsNotOpened</replace>
|
||||
<replace>ChannelManager</replace>
|
||||
<replace>Function</replace>
|
||||
</replaceStrings>
|
||||
<dirStrings>
|
||||
<dir>$PROJECT_DIR$/example/android</dir>
|
||||
|
@ -271,23 +242,24 @@
|
|||
<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$/lib/src/content_blocker.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/in_app_browser.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/in_app_webview.dart" />
|
||||
<option value="$PROJECT_DIR$/example/lib/webview_example.screen.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/types.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" />
|
||||
<option value="$PROJECT_DIR$/example/lib/inline_example.screen.dart" />
|
||||
<option value="$PROJECT_DIR$/pubspec.yaml" />
|
||||
<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$/example/lib/inline_example.screen.dart" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<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" />
|
||||
|
@ -298,67 +270,6 @@
|
|||
<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="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="example" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="example" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="assets" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="example" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="ios" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="example" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="ios" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="Runner" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="AndroidView">
|
||||
<subPane>
|
||||
<expand>
|
||||
|
@ -389,6 +300,43 @@
|
|||
</subPane>
|
||||
</pane>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<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">
|
||||
|
@ -539,11 +487,11 @@
|
|||
</todo-panel>
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="0" y="23" width="1920" height="1057" extended-state="0" />
|
||||
<frame x="-1920" y="23" width="1920" height="1057" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.6049822" visible="true" weight="0.15867944" />
|
||||
<window_info id="Structure" order="1" sideWeight="0.3950178" side_tool="true" visible="true" weight="0.15867944" />
|
||||
<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 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" />
|
||||
|
@ -553,7 +501,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 anchor="bottom" id="Run" order="2" sideWeight="0.49307775" weight="0.38445595" />
|
||||
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49307775" visible="true" weight="0.32435232" />
|
||||
<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" />
|
||||
|
@ -561,7 +509,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 active="true" anchor="bottom" id="Terminal" order="10" sideWeight="0.49533224" visible="true" weight="0.41761658" />
|
||||
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.49533224" weight="0.2611399" />
|
||||
<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" />
|
||||
|
@ -626,7 +574,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/flutter/bin/cache/pkg/sky_engine/lib/core/map.dart" />
|
||||
<entry file="file://$PROJECT_DIR$/example/assets/page-3.html" />
|
||||
<entry file="file://$USER_HOME$/flutter/bin/cache/pkg/sky_engine/lib/convert/json.dart" />
|
||||
<entry file="file://$PROJECT_DIR$/example/assets/page-2.html">
|
||||
|
@ -825,16 +772,6 @@
|
|||
</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="5265">
|
||||
<caret line="359" column="84" selection-start-line="359" selection-start-column="50" selection-end-line="359" selection-end-column="84" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/ios/Podfile">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="990">
|
||||
|
@ -849,26 +786,16 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/content_blocker.dart">
|
||||
<entry file="file://$USER_HOME$/flutter/bin/cache/pkg/sky_engine/lib/core/map.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="90">
|
||||
<caret line="6" column="45" selection-start-line="6" selection-start-column="45" selection-end-line="6" selection-end-column="45" />
|
||||
</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="439">
|
||||
<caret line="85" column="38" selection-start-line="85" selection-start-column="38" selection-end-line="85" selection-end-column="38" />
|
||||
<folding>
|
||||
<element signature="e#0#22#0" expanded="true" />
|
||||
</folding>
|
||||
<state relative-caret-position="181">
|
||||
<caret line="303" column="4" selection-start-line="303" selection-start-column="4" selection-end-line="303" selection-end-column="4" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="255">
|
||||
<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" />
|
||||
|
@ -878,22 +805,32 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="460">
|
||||
<caret line="63" column="19" lean-forward="true" selection-start-line="63" selection-start-column="19" selection-end-line="63" selection-end-column="19" />
|
||||
<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/types.dart">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/content_blocker.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="302">
|
||||
<caret line="111" column="45" selection-start-line="111" selection-start-column="6" selection-end-line="111" selection-end-column="45" />
|
||||
<state relative-caret-position="375">
|
||||
<caret line="25" column="34" selection-start-line="25" selection-start-column="34" selection-end-line="25" selection-end-column="34" />
|
||||
</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="61">
|
||||
<caret line="239" column="47" lean-forward="true" selection-start-line="239" selection-start-column="47" selection-end-line="239" selection-end-column="47" />
|
||||
<state relative-caret-position="-1456">
|
||||
<caret line="79" column="2" selection-start-line="79" selection-start-column="2" selection-end-line="86" selection-end-column="91" />
|
||||
<folding>
|
||||
<element signature="e#0#17#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -907,20 +844,40 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="233">
|
||||
<caret line="396" column="56" selection-start-line="396" selection-start-column="56" selection-end-line="396" selection-end-column="56" />
|
||||
<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" />
|
||||
<folding>
|
||||
<element signature="e#0#17#0" expanded="true" />
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/types.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="405">
|
||||
<caret line="27" selection-start-line="27" selection-end-line="27" />
|
||||
<state relative-caret-position="193">
|
||||
<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" />
|
||||
</folding>
|
||||
</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" />
|
||||
<folding>
|
||||
<element signature="e#0#22#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
- Added new Android WebView options: `allowContentAccess`, `allowFileAccess`, `allowFileAccessFromFileURLs`, `allowUniversalAccessFromFileURLs`, `appCacheEnabled`, `appCachePath`, `blockNetworkImage`, `blockNetworkLoads`, `cacheMode`, `cursiveFontFamily`, `defaultFixedFontSize`, `defaultFontSize`, `defaultTextEncodingName`, `disabledActionModeMenuItems`, `fantasyFontFamily`, `fixedFontFamily`, `forceDark`, `geolocationEnabled`, `layoutAlgorithm`, `loadWithOverviewMode`, `loadsImagesAutomatically`, `minimumLogicalFontSize`, `needInitialFocus`, `offscreenPreRaster`, `sansSerifFontFamily`, `serifFontFamily`, `standardFontFamily`
|
||||
- Added new iOS WebView options: `applicationNameForUserAgent`, `isFraudulentWebsiteWarningEnabled`, `selectionGranularity`, `dataDetectorTypes`, `preferredContentMode`
|
||||
- Added `onGeolocationPermissionsShowPrompt` event and `GeolocationPermissionShowPromptResponse` class (available only for Android)
|
||||
- Added `startSafeBrowsing`, `setSafeBrowsingWhitelist` and `getSafeBrowsingPrivacyPolicyUrl` methods (available only for Android)
|
||||
- Added `onJsAlert`, `onJsConfirm` and `onJsPrompt` events to manage javascript popup dialogs
|
||||
|
||||
### BREAKING CHANGES
|
||||
- Deleted `WebResourceRequest` class
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
package="com.pichillilorenzo.flutter_inappbrowser">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<application>
|
||||
<activity android:theme="@style/AppTheme" android:name=".InAppBrowserActivity" android:configChanges="orientation|screenSize"></activity>
|
||||
|
|
|
@ -192,12 +192,11 @@ public class ContentBlockerHandler {
|
|||
return checkUrl(webView, url, responseResourceType);
|
||||
}
|
||||
|
||||
|
||||
public ContentBlockerTriggerResourceType getResourceTypeFromUrl(InAppWebView webView, String url) {
|
||||
ContentBlockerTriggerResourceType responseResourceType = ContentBlockerTriggerResourceType.RAW;
|
||||
|
||||
// make an HTTP "HEAD" request to the server for that URL. This will not return the full content of the URL.
|
||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||
// make an HTTP "HEAD" request to the server for that URL. This will not return the full content of the URL.
|
||||
Request mRequest = new Request.Builder().url(url).head().build();
|
||||
Response response = null;
|
||||
try {
|
||||
|
|
|
@ -8,6 +8,7 @@ public enum ContentBlockerTriggerResourceType {
|
|||
FONT ("font"),
|
||||
SVG_DOCUMENT ("svg-document"),
|
||||
MEDIA ("media"),
|
||||
POPUP ("popup"),
|
||||
RAW ("raw");
|
||||
|
||||
private final String value;
|
||||
|
|
|
@ -195,7 +195,7 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
|
|||
if (webView != null)
|
||||
webView.takeScreenshot(result);
|
||||
else
|
||||
result.error(LOG_TAG, "webView is null", null);
|
||||
result.success(null);
|
||||
break;
|
||||
case "setOptions":
|
||||
if (webView != null) {
|
||||
|
@ -212,6 +212,20 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
|
|||
case "getCopyBackForwardList":
|
||||
result.success((webView != null) ? webView.getCopyBackForwardList() : null);
|
||||
break;
|
||||
case "startSafeBrowsing":
|
||||
if (webView != null)
|
||||
webView.startSafeBrowsing(result);
|
||||
else
|
||||
result.success(false);
|
||||
break;
|
||||
case "setSafeBrowsingWhitelist":
|
||||
if (webView != null) {
|
||||
List<String> hosts = (List<String>) call.argument("hosts");
|
||||
webView.setSafeBrowsingWhitelist(hosts, result);
|
||||
}
|
||||
else
|
||||
result.success(false);
|
||||
break;
|
||||
case "dispose":
|
||||
dispose();
|
||||
result.success(true);
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.flutter.app.FlutterActivity;
|
||||
|
@ -460,4 +461,17 @@ public class InAppBrowserActivity extends AppCompatActivity {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void startSafeBrowsing(MethodChannel.Result result) {
|
||||
if (webView != null)
|
||||
webView.startSafeBrowsing(result);
|
||||
else
|
||||
result.success(false);
|
||||
}
|
||||
|
||||
public void setSafeBrowsingWhitelist(List<String> hosts, MethodChannel.Result result) {
|
||||
if (webView != null)
|
||||
webView.setSafeBrowsingWhitelist(hosts, result);
|
||||
else
|
||||
result.success(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -299,6 +299,12 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
|||
case "getCopyBackForwardList":
|
||||
result.success(getCopyBackForwardList(uuid));
|
||||
break;
|
||||
case "startSafeBrowsing":
|
||||
startSafeBrowsing(uuid, result);
|
||||
break;
|
||||
case "setSafeBrowsingWhitelist":
|
||||
setSafeBrowsingWhitelist(uuid, (List<String>) call.argument("hosts"), result);
|
||||
break;
|
||||
default:
|
||||
result.notImplemented();
|
||||
}
|
||||
|
@ -668,4 +674,17 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void startSafeBrowsing(String uuid, Result result) {
|
||||
InAppBrowserActivity inAppBrowserActivity = webViewActivities.get(uuid);
|
||||
if (inAppBrowserActivity != null)
|
||||
inAppBrowserActivity.startSafeBrowsing(result);
|
||||
result.success(false);
|
||||
}
|
||||
|
||||
public void setSafeBrowsingWhitelist(String uuid, List<String> hosts, Result result) {
|
||||
InAppBrowserActivity inAppBrowserActivity = webViewActivities.get(uuid);
|
||||
if (inAppBrowserActivity != null)
|
||||
inAppBrowserActivity.setSafeBrowsingWhitelist(hosts, result);
|
||||
result.success(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,25 +2,37 @@ package com.pichillilorenzo.flutter_inappbrowser.InAppWebView;
|
|||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.ConsoleMessage;
|
||||
import android.webkit.GeolocationPermissions;
|
||||
import android.webkit.JsPromptResult;
|
||||
import android.webkit.JsResult;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.pichillilorenzo.flutter_inappbrowser.FlutterWebView;
|
||||
import com.pichillilorenzo.flutter_inappbrowser.InAppBrowserActivity;
|
||||
import com.pichillilorenzo.flutter_inappbrowser.InAppBrowserFlutterPlugin;
|
||||
import com.pichillilorenzo.flutter_inappbrowser.R;
|
||||
import com.pichillilorenzo.flutter_inappbrowser.RequestPermissionHandler;
|
||||
import com.pichillilorenzo.flutter_inappbrowser.Util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -89,6 +101,267 @@ public class InAppWebChromeClient extends WebChromeClient {
|
|||
decorView.setSystemUiVisibility(3846 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onJsAlert(final WebView view, String url, final String message,
|
||||
final JsResult result) {
|
||||
Map<String, Object> obj = new HashMap<>();
|
||||
if (inAppBrowserActivity != null)
|
||||
obj.put("uuid", inAppBrowserActivity.uuid);
|
||||
obj.put("message", message);
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
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 void error(String s, String s1, Object o) {
|
||||
Log.e(LOG_TAG, s + ", " + s1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notImplemented() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onJsConfirm(final WebView view, String url, final String message,
|
||||
final JsResult result) {
|
||||
Map<String, Object> obj = new HashMap<>();
|
||||
if (inAppBrowserActivity != null)
|
||||
obj.put("uuid", inAppBrowserActivity.uuid);
|
||||
obj.put("message", message);
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
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 void error(String s, String s1, Object o) {
|
||||
Log.e(LOG_TAG, s + ", " + s1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notImplemented() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onJsPrompt(final WebView view, String url, final String message,
|
||||
final String defaultValue, final JsPromptResult result) {
|
||||
Map<String, Object> obj = new HashMap<>();
|
||||
if (inAppBrowserActivity != null)
|
||||
obj.put("uuid", inAppBrowserActivity.uuid);
|
||||
obj.put("message", message);
|
||||
obj.put("defaultValue", defaultValue);
|
||||
|
||||
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)
|
||||
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();
|
||||
}
|
||||
};
|
||||
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 void error(String s, String s1, Object o) {
|
||||
Log.e(LOG_TAG, s + ", " + s1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notImplemented() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, android.os.Message resultMsg)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.util.JsonToken;
|
|||
import android.util.Log;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.DownloadListener;
|
||||
import android.webkit.JsResult;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebBackForwardList;
|
||||
import android.webkit.WebHistoryItem;
|
||||
|
@ -53,6 +54,7 @@ public class InAppWebView extends WebView {
|
|||
public InAppWebViewOptions options;
|
||||
public boolean isLoading = false;
|
||||
public OkHttpClient httpClient;
|
||||
public float scale = getResources().getDisplayMetrics().density;
|
||||
int okHttpClientCacheSize = 10 * 1024 * 1024; // 10MB
|
||||
public ContentBlockerHandler contentBlockerHandler = new ContentBlockerHandler();
|
||||
|
||||
|
@ -123,7 +125,7 @@ public class InAppWebView extends WebView {
|
|||
|
||||
public void prepare() {
|
||||
|
||||
final Activity activity = (inAppBrowserActivity != null) ? inAppBrowserActivity : registrar.activity().getParent();
|
||||
final Activity activity = (inAppBrowserActivity != null) ? inAppBrowserActivity : registrar.activity();
|
||||
|
||||
boolean isFromInAppBrowserActivity = inAppBrowserActivity != null;
|
||||
|
||||
|
@ -322,7 +324,6 @@ public class InAppWebView extends WebView {
|
|||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
float scale = getResources().getDisplayMetrics().density; // getScale();
|
||||
int height = (int) (getContentHeight() * scale + 0.5);
|
||||
|
||||
Bitmap b = Bitmap.createBitmap( getWidth(),
|
||||
|
@ -644,7 +645,6 @@ public class InAppWebView extends WebView {
|
|||
int oldt) {
|
||||
super.onScrollChanged(l, t, oldl, oldt);
|
||||
|
||||
float scale = getResources().getDisplayMetrics().density;
|
||||
int x = (int) (l/scale);
|
||||
int y = (int) (t/scale);
|
||||
|
||||
|
@ -660,6 +660,33 @@ public class InAppWebView extends WebView {
|
|||
return (inAppBrowserActivity != null) ? InAppBrowserFlutterPlugin.instance.channel : flutterWebView.channel;
|
||||
}
|
||||
|
||||
public void startSafeBrowsing(final MethodChannel.Result result) {
|
||||
Activity activity = (inAppBrowserActivity != null) ? inAppBrowserActivity : registrar.activity();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
startSafeBrowsing(activity.getApplicationContext(), new ValueCallback<Boolean>() {
|
||||
@Override
|
||||
public void onReceiveValue(Boolean value) {
|
||||
result.success(value);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
result.success(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSafeBrowsingWhitelist(List<String> hosts, final MethodChannel.Result result) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
setSafeBrowsingWhitelist(hosts, new ValueCallback<Boolean>() {
|
||||
@Override
|
||||
public void onReceiveValue(Boolean value) {
|
||||
result.success(value);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
result.success(false);
|
||||
}
|
||||
}
|
||||
|
||||
class DownloadStartListener implements DownloadListener {
|
||||
@Override
|
||||
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
|
||||
|
|
|
@ -19,7 +19,6 @@ import android.webkit.WebViewClient;
|
|||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.pichillilorenzo.flutter_inappbrowser.ContentBlocker.ContentBlocker;
|
||||
import com.pichillilorenzo.flutter_inappbrowser.FlutterWebView;
|
||||
import com.pichillilorenzo.flutter_inappbrowser.InAppBrowserActivity;
|
||||
import com.pichillilorenzo.flutter_inappbrowser.InAppBrowserFlutterPlugin;
|
||||
|
@ -27,8 +26,6 @@ import com.pichillilorenzo.flutter_inappbrowser.JavaScriptBridgeInterface;
|
|||
import com.pichillilorenzo.flutter_inappbrowser.Util;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -303,6 +300,12 @@ public class InAppWebViewClient extends WebViewClient {
|
|||
super.onReceivedHttpAuthRequest(view, handler, host, realm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScaleChanged(WebView view, float oldScale, float newScale) {
|
||||
final InAppWebView webView = (InAppWebView) view;
|
||||
webView.scale = newScale;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="InAppWebViewTheme" parent="Theme.AppCompat">
|
||||
|
||||
</style>
|
||||
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light">
|
||||
|
||||
</style>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.pichillilorenzo.flutter_inappbrowserexample">
|
||||
package="com.pichillilorenzo.flutterwebviewexample">
|
||||
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
flutter needs it to communicate with the running application
|
||||
|
@ -21,14 +21,14 @@
|
|||
additional functionality it is fine to subclass or reimplement
|
||||
FlutterApplication and put your custom class here. -->
|
||||
<application
|
||||
android:name="com.pichillilorenzo.flutterwebviewexample.MyApplication"
|
||||
android:name=".MyApplication"
|
||||
android:label="flutter_inappbrowser_example"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:theme="@style/InAppWebViewTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.pichillilorenzo.flutter_inappbrowserexample;
|
||||
package com.pichillilorenzo.flutterwebviewexample;
|
||||
|
||||
import android.os.Bundle;
|
||||
import io.flutter.app.FlutterActivity;
|
||||
|
|
|
@ -55,8 +55,13 @@
|
|||
});
|
||||
});
|
||||
$(document).ready(function() {
|
||||
console.log("jQuery ready");
|
||||
alert("Alert Popup");
|
||||
console.log(confirm("Press a button!"));
|
||||
console.log(prompt("Please enter your name", "Harry Potter"));
|
||||
|
||||
|
||||
console.log("jQuery ready");
|
||||
/*
|
||||
if ("geolocation" in navigator) {
|
||||
console.log("Geolocation API enabled");
|
||||
navigator.geolocation.getCurrentPosition(function(position) {
|
||||
|
@ -64,7 +69,7 @@
|
|||
});
|
||||
} else {
|
||||
console.log("No geolocation API");
|
||||
}
|
||||
}*/
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -32,6 +32,8 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
|
|||
String url = "";
|
||||
double progress = 0;
|
||||
|
||||
TextEditingController _textFieldController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
@ -171,18 +173,18 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
|
|||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: new Text("Permission Geolocation API"),
|
||||
content: new Text("Can we use Geolocation API?"),
|
||||
title: Text("Permission Geolocation API"),
|
||||
content: Text("Can we use Geolocation API?"),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text("Close"),
|
||||
FlatButton(
|
||||
child: Text("Close"),
|
||||
onPressed: () {
|
||||
response = new GeolocationPermissionShowPromptResponse(origin, false, false);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text("Accept"),
|
||||
FlatButton(
|
||||
child: Text("Accept"),
|
||||
onPressed: () {
|
||||
response = new GeolocationPermissionShowPromptResponse(origin, true, true);
|
||||
Navigator.of(context).pop();
|
||||
|
@ -194,7 +196,94 @@ 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();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
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();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
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();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
return new JsPromptResponse(handledByClient: true, action: action, value: _textFieldController.text);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -44,6 +44,7 @@ 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
|
||||
|
|
|
@ -745,6 +745,63 @@ 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,
|
||||
preferredStyle: UIAlertController.Style.alert);
|
||||
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default) {
|
||||
_ in completionHandler()}
|
||||
);
|
||||
|
||||
let presentingViewController = ((IABController != nil) ? IABController! : window!.rootViewController!)
|
||||
presentingViewController.present(alertController, animated: true, completion: {})
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
|
||||
alertController.addTextField { (textField) in
|
||||
textField.text = defaultText
|
||||
}
|
||||
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in
|
||||
if let text = alertController.textFields?.first?.text {
|
||||
completionHandler(text)
|
||||
} else {
|
||||
completionHandler(defaultText)
|
||||
}
|
||||
}))
|
||||
|
||||
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) in
|
||||
completionHandler(nil)
|
||||
}))
|
||||
|
||||
let presentingViewController = ((IABController != nil) ? IABController! : window!.rootViewController!)
|
||||
presentingViewController.present(alertController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
if navigationDelegate != nil {
|
||||
let x = Int(scrollView.contentOffset.x / scrollView.contentScaleFactor)
|
||||
|
|
|
@ -327,39 +327,72 @@ class InAppBrowser {
|
|||
}
|
||||
|
||||
///Event fires when the [InAppBrowser] webview scrolls.
|
||||
///
|
||||
///[x] represents the current horizontal scroll origin in pixels.
|
||||
///
|
||||
///[y] represents the current vertical scroll origin in pixels.
|
||||
void onScrollChanged(int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
///Event fires when [InAppBrowser] recognizes and starts a downloadable file.
|
||||
///
|
||||
///[url] represents the url of the file.
|
||||
void onDownloadStart(String url) {
|
||||
|
||||
}
|
||||
|
||||
///Event fires when the [InAppBrowser] webview finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
|
||||
///
|
||||
///[scheme] represents the scheme of the url.
|
||||
///
|
||||
///[url] represents the url of the request.
|
||||
Future<CustomSchemeResponse> onLoadResourceCustomScheme(String scheme, String url) {
|
||||
|
||||
}
|
||||
|
||||
///Event fires when the [InAppBrowser] webview tries to open a link with `target="_blank"`.
|
||||
///
|
||||
///[url] represents the url of the link.
|
||||
void onTargetBlank(String url) {
|
||||
|
||||
}
|
||||
|
||||
///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.
|
||||
///
|
||||
///[message] represents the message to be displayed in the alert dialog.
|
||||
Future<JsAlertResponse> onJsAlert(String message) {
|
||||
|
||||
}
|
||||
|
||||
///Event fires when javascript calls the `confirm()` method to display a confirm dialog.
|
||||
///If [JsConfirmResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
|
||||
///
|
||||
///[message] represents the message to be displayed in the alert dialog.
|
||||
Future<JsConfirmResponse> onJsConfirm(String message) {
|
||||
|
||||
}
|
||||
|
||||
///Event fires when javascript calls the `prompt()` method to display a prompt dialog.
|
||||
///If [JsPromptResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
|
||||
///
|
||||
///[message] represents the message to be displayed in the alert dialog.
|
||||
///[defaultValue] represents the default value displayed in the prompt dialog.
|
||||
Future<JsPromptResponse> onJsPrompt(String message, String defaultValue) {
|
||||
|
||||
}
|
||||
|
||||
///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()) {
|
||||
|
@ -372,4 +405,5 @@ class InAppBrowser {
|
|||
throw Exception(['Error: ${ (message.isEmpty) ? '' : message + ' '}The browser is not opened.']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ import 'in_app_browser.dart';
|
|||
import 'channel_manager.dart';
|
||||
import 'webview_options.dart';
|
||||
|
||||
/*
|
||||
* TODO: injectFileFromAssets, injectJavaScriptBeforeLoad
|
||||
*/
|
||||
|
||||
///Initial [data] as a content for an [InAppWebView] instance, using [baseUrl] as the base URL for it.
|
||||
///The [mimeType] property specifies the format of the data.
|
||||
|
@ -107,34 +110,61 @@ class InAppWebView extends StatefulWidget {
|
|||
///
|
||||
///**NOTE**: In order to be able to listen this event, you need to set `useOnLoadResource` option to `true`.
|
||||
///
|
||||
///**NOTE only for iOS**: In some cases, the [response.data] of a [response] with `text/assets` encoding could be empty.
|
||||
///**NOTE only for Android**: to be able to listen this event, you need also the enable javascript.
|
||||
final onWebViewLoadResourceCallback onLoadResource;
|
||||
|
||||
///Event fires when the [InAppWebView] scrolls.
|
||||
///
|
||||
///[x] represents the current horizontal scroll origin in pixels.
|
||||
///
|
||||
///[y] represents the current vertical scroll origin in pixels.
|
||||
final onWebViewScrollChangedCallback onScrollChanged;
|
||||
|
||||
///Event fires when [InAppWebView] recognizes and starts a downloadable file.
|
||||
///
|
||||
///[url] represents the url of the file.
|
||||
final onDownloadStartCallback onDownloadStart;
|
||||
|
||||
///Event fires when the [InAppWebView] finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
|
||||
///
|
||||
///[scheme] represents the scheme of the url.
|
||||
///
|
||||
///[url] represents the url of the request.
|
||||
final onLoadResourceCustomSchemeCallback onLoadResourceCustomScheme;
|
||||
|
||||
///Event fires when the [InAppWebView] tries to open a link with `target="_blank"`.
|
||||
///
|
||||
///[url] represents the url of the link.
|
||||
final onTargetBlankCallback onTargetBlank;
|
||||
|
||||
///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.
|
||||
final onGeolocationPermissionsShowPromptCallback onGeolocationPermissionsShowPrompt;
|
||||
|
||||
///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.
|
||||
///
|
||||
///[message] represents the message to be displayed in the alert dialog.
|
||||
final onJsAlertCallback onJsAlert;
|
||||
|
||||
///Event fires when javascript calls the `confirm()` method to display a confirm dialog.
|
||||
///If [JsConfirmResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
|
||||
///
|
||||
///[message] represents the message to be displayed in the alert dialog.
|
||||
final onJsConfirmCallback onJsConfirm;
|
||||
|
||||
///Event fires when javascript calls the `prompt()` method to display a prompt dialog.
|
||||
///If [JsPromptResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
|
||||
///
|
||||
///[message] represents the message to be displayed in the alert dialog.
|
||||
///[defaultValue] represents the default value displayed in the prompt dialog.
|
||||
final onJsPromptCallback onJsPrompt;
|
||||
|
||||
///Initial url that will be loaded.
|
||||
final String initialUrl;
|
||||
///Initial asset file that will be loaded. See [InAppWebView.loadFile()] for explanation.
|
||||
|
@ -174,6 +204,9 @@ class InAppWebView extends StatefulWidget {
|
|||
this.onLoadResourceCustomScheme,
|
||||
this.onTargetBlank,
|
||||
this.onGeolocationPermissionsShowPrompt,
|
||||
this.onJsAlert,
|
||||
this.onJsConfirm,
|
||||
this.onJsPrompt,
|
||||
this.gestureRecognizers,
|
||||
}) : super(key: key);
|
||||
|
||||
|
@ -269,16 +302,16 @@ class InAppWebViewController {
|
|||
|
||||
|
||||
InAppWebViewController(int id, InAppWebView widget) {
|
||||
_id = id;
|
||||
_channel = MethodChannel('com.pichillilorenzo/flutter_inappwebview_$id');
|
||||
_channel.setMethodCallHandler(handleMethod);
|
||||
_widget = widget;
|
||||
this._id = id;
|
||||
this._channel = MethodChannel('com.pichillilorenzo/flutter_inappwebview_$id');
|
||||
this._channel.setMethodCallHandler(handleMethod);
|
||||
this._widget = widget;
|
||||
}
|
||||
|
||||
InAppWebViewController.fromInAppBrowser(String uuid, MethodChannel channel, InAppBrowser inAppBrowser) {
|
||||
_inAppBrowserUuid = uuid;
|
||||
_channel = channel;
|
||||
_inAppBrowser = inAppBrowser;
|
||||
this._inAppBrowserUuid = uuid;
|
||||
this._channel = channel;
|
||||
this._inAppBrowser = inAppBrowser;
|
||||
}
|
||||
|
||||
Future<dynamic> handleMethod(MethodCall call) async {
|
||||
|
@ -399,6 +432,28 @@ class InAppWebViewController {
|
|||
else if (_inAppBrowser != null)
|
||||
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();
|
||||
else if (_inAppBrowser != null)
|
||||
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();
|
||||
else if (_inAppBrowser != null)
|
||||
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();
|
||||
else if (_inAppBrowser != null)
|
||||
return (await _inAppBrowser.onJsPrompt(message, defaultValue)).toMap();
|
||||
break;
|
||||
case "onCallJsHandler":
|
||||
String handlerName = call.arguments["handlerName"];
|
||||
// decode args to json
|
||||
|
@ -818,9 +873,55 @@ class InAppWebViewController {
|
|||
}
|
||||
return WebHistory(historyList, currentIndex);
|
||||
}
|
||||
|
||||
///Starts Safe Browsing initialization.
|
||||
///
|
||||
///URL loads are not guaranteed to be protected by Safe Browsing until after the this method returns true.
|
||||
///Safe Browsing is not fully supported on all devices. For those devices this method will returns false.
|
||||
///
|
||||
///This should not be called if Safe Browsing has been disabled by manifest tag
|
||||
///or [AndroidInAppWebViewOptions.safeBrowsingEnabled]. This prepares resources used for Safe Browsing.
|
||||
///
|
||||
///**NOTE**: available only for Android.
|
||||
Future<bool> startSafeBrowsing() async {
|
||||
Map<String, dynamic> args = <String, dynamic>{};
|
||||
if (_inAppBrowserUuid != null && _inAppBrowser != null) {
|
||||
_inAppBrowser.throwIsNotOpened();
|
||||
args.putIfAbsent('uuid', () => _inAppBrowserUuid);
|
||||
}
|
||||
return await _channel.invokeMethod('startSafeBrowsing', args);
|
||||
}
|
||||
|
||||
///Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The list is global for all the WebViews.
|
||||
///
|
||||
/// Each rule should take one of these:
|
||||
///| Rule | Example | Matches Subdomain |
|
||||
///| -- | -- | -- |
|
||||
///| HOSTNAME | example.com | Yes |
|
||||
///| .HOSTNAME | .example.com | No |
|
||||
///| IPV4_LITERAL | 192.168.1.1 | No |
|
||||
///| IPV6_LITERAL_WITH_BRACKETS | [10:20:30:40:50:60:70:80] | No |
|
||||
///
|
||||
///All other rules, including wildcards, are invalid. The correct syntax for hosts is defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3.2.2).
|
||||
///
|
||||
///[hosts] represents the list of hosts. This value must never be null.
|
||||
///
|
||||
///**NOTE**: available only for Android.
|
||||
Future<bool> setSafeBrowsingWhitelist(List<String> hosts) async {
|
||||
assert(hosts != null);
|
||||
Map<String, dynamic> args = <String, dynamic>{};
|
||||
if (_inAppBrowserUuid != null && _inAppBrowser != null) {
|
||||
_inAppBrowser.throwIsNotOpened();
|
||||
args.putIfAbsent('uuid', () => _inAppBrowserUuid);
|
||||
}
|
||||
args.putIfAbsent('hosts', () => hosts);
|
||||
return await _channel.invokeMethod('setSafeBrowsingWhitelist', args);
|
||||
}
|
||||
|
||||
|
||||
///Dispose/Destroy the WebView.
|
||||
Future<void> _dispose() async {
|
||||
await _channel.invokeMethod('dispose');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:uuid/uuid.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'in_app_webview.dart' show InAppWebViewController;
|
||||
import 'in_app_webview.dart';
|
||||
|
||||
var uuidGenerator = new Uuid();
|
||||
|
||||
|
@ -128,6 +128,95 @@ class GeolocationPermissionShowPromptResponse {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class JsAlertResponseAction {
|
||||
final int _value;
|
||||
const JsAlertResponseAction._internal(this._value);
|
||||
toValue() => _value;
|
||||
|
||||
static const CONFIRM = const JsAlertResponseAction._internal(0);
|
||||
}
|
||||
|
||||
class JsAlertResponse {
|
||||
String message;
|
||||
String confirmButtonTitle;
|
||||
bool handledByClient;
|
||||
JsAlertResponseAction action;
|
||||
|
||||
JsAlertResponse({this.message = "", this.handledByClient = false, this.confirmButtonTitle = "", this.action = JsAlertResponseAction.CONFIRM});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
"message": message,
|
||||
"confirmButtonTitle": confirmButtonTitle,
|
||||
"handledByClient": handledByClient,
|
||||
"action": action?.toValue()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class JsConfirmResponseAction {
|
||||
final int _value;
|
||||
const JsConfirmResponseAction._internal(this._value);
|
||||
toValue() => _value;
|
||||
|
||||
static const CONFIRM = const JsConfirmResponseAction._internal(0);
|
||||
static const CANCEL = const JsConfirmResponseAction._internal(1);
|
||||
}
|
||||
|
||||
class JsConfirmResponse {
|
||||
String message;
|
||||
String confirmButtonTitle;
|
||||
String cancelButtonTitle;
|
||||
bool handledByClient;
|
||||
JsConfirmResponseAction action;
|
||||
|
||||
JsConfirmResponse({this.message = "", this.handledByClient = false, this.confirmButtonTitle = "", this.cancelButtonTitle = "", this.action = JsConfirmResponseAction.CANCEL});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
"message": message,
|
||||
"confirmButtonTitle": confirmButtonTitle,
|
||||
"cancelButtonTitle": cancelButtonTitle,
|
||||
"handledByClient": handledByClient,
|
||||
"action": action?.toValue()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class JsPromptResponseAction {
|
||||
final int _value;
|
||||
const JsPromptResponseAction._internal(this._value);
|
||||
toValue() => _value;
|
||||
|
||||
static const CONFIRM = const JsPromptResponseAction._internal(0);
|
||||
static const CANCEL = const JsPromptResponseAction._internal(1);
|
||||
}
|
||||
|
||||
class JsPromptResponse {
|
||||
String message;
|
||||
String defaultValue;
|
||||
String confirmButtonTitle;
|
||||
String cancelButtonTitle;
|
||||
bool handledByClient;
|
||||
String value;
|
||||
JsPromptResponseAction action;
|
||||
|
||||
JsPromptResponse({this.message = "", this.defaultValue = "", this.handledByClient = false, this.confirmButtonTitle = "", this.cancelButtonTitle = "", this.value, this.action = JsPromptResponseAction.CANCEL});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
"message": message,
|
||||
"defaultValue": defaultValue,
|
||||
"confirmButtonTitle": confirmButtonTitle,
|
||||
"cancelButtonTitle": cancelButtonTitle,
|
||||
"handledByClient": handledByClient,
|
||||
"value": value,
|
||||
"action": action?.toValue()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
typedef onWebViewCreatedCallback = void Function(InAppWebViewController controller);
|
||||
typedef onWebViewLoadStartCallback = void Function(InAppWebViewController controller, String url);
|
||||
typedef onWebViewLoadStopCallback = void Function(InAppWebViewController controller, String url);
|
||||
|
@ -140,4 +229,7 @@ typedef onWebViewScrollChangedCallback = void Function(InAppWebViewController co
|
|||
typedef onDownloadStartCallback = void Function(InAppWebViewController controller, String url);
|
||||
typedef onLoadResourceCustomSchemeCallback = Future<CustomSchemeResponse> Function(InAppWebViewController controller, String scheme, String url);
|
||||
typedef onTargetBlankCallback = void Function(InAppWebViewController controller, String url);
|
||||
typedef onGeolocationPermissionsShowPromptCallback = Future<GeolocationPermissionShowPromptResponse> Function(InAppWebViewController controller, String origin);
|
||||
typedef onGeolocationPermissionsShowPromptCallback = Future<GeolocationPermissionShowPromptResponse> Function(InAppWebViewController controller, String origin);
|
||||
typedef onJsAlertCallback = Future<JsAlertResponse> Function(InAppWebViewController controller, String message);
|
||||
typedef onJsConfirmCallback = Future<JsConfirmResponse> Function(InAppWebViewController controller, String message);
|
||||
typedef onJsPromptCallback = Future<JsPromptResponse> Function(InAppWebViewController controller, String message, String defaultValue);
|
Loading…
Reference in New Issue