added the ability to create multiple instances of browsers
This commit is contained in:
parent
5db9575a6f
commit
bc47fd2471
|
@ -10,20 +10,18 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="9b41f7a2-a71e-4923-91fb-249d7815b3e7" name="Default" comment="">
|
<list default="true" id="9b41f7a2-a71e-4923-91fb-249d7815b3e7" name="Default" comment="">
|
||||||
<change beforePath="" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/Options.java" />
|
|
||||||
<change beforePath="" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/chrome_custom_tabs/ChromeCustomTabsOptions.java" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||||
<change beforePath="$PROJECT_DIR$/README.md" afterPath="$PROJECT_DIR$/README.md" />
|
<change beforePath="$PROJECT_DIR$/CHANGELOG.md" afterPath="$PROJECT_DIR$/CHANGELOG.md" />
|
||||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" />
|
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" />
|
||||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserOptions.java" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserOptions.java" />
|
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebViewClient.java" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebViewClient.java" />
|
||||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/WebViewActivity.java" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/WebViewActivity.java" />
|
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/WebViewActivity.java" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/WebViewActivity.java" />
|
||||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/chrome_custom_tabs/ChromeCustomTabsActivity.java" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/chrome_custom_tabs/ChromeCustomTabsActivity.java" />
|
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/chrome_custom_tabs/ChromeCustomTabsActivity.java" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/chrome_custom_tabs/ChromeCustomTabsActivity.java" />
|
||||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/chrome_custom_tabs/CustomTabActivityHelper.java" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/chrome_custom_tabs/CustomTabActivityHelper.java" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/example/lib/main.dart" afterPath="$PROJECT_DIR$/example/lib/main.dart" />
|
<change beforePath="$PROJECT_DIR$/example/lib/main.dart" afterPath="$PROJECT_DIR$/example/lib/main.dart" />
|
||||||
<change beforePath="$PROJECT_DIR$/ios/Classes/InAppBrowserOptions.swift" afterPath="$PROJECT_DIR$/ios/Classes/InAppBrowserOptions.swift" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ios/Classes/InAppBrowserWebViewController.swift" afterPath="$PROJECT_DIR$/ios/Classes/InAppBrowserWebViewController.swift" />
|
<change beforePath="$PROJECT_DIR$/ios/Classes/InAppBrowserWebViewController.swift" afterPath="$PROJECT_DIR$/ios/Classes/InAppBrowserWebViewController.swift" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/ios/Classes/SafariViewController.swift" afterPath="$PROJECT_DIR$/ios/Classes/SafariViewController.swift" />
|
||||||
<change beforePath="$PROJECT_DIR$/ios/Classes/SwiftFlutterPlugin.swift" afterPath="$PROJECT_DIR$/ios/Classes/SwiftFlutterPlugin.swift" />
|
<change beforePath="$PROJECT_DIR$/ios/Classes/SwiftFlutterPlugin.swift" afterPath="$PROJECT_DIR$/ios/Classes/SwiftFlutterPlugin.swift" />
|
||||||
<change beforePath="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" afterPath="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" />
|
<change beforePath="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" afterPath="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pubspec.yaml" afterPath="$PROJECT_DIR$/pubspec.yaml" />
|
||||||
</list>
|
</list>
|
||||||
<ignored path="$PROJECT_DIR$/.dart_tool/" />
|
<ignored path="$PROJECT_DIR$/.dart_tool/" />
|
||||||
<ignored path="$PROJECT_DIR$/.idea/" />
|
<ignored path="$PROJECT_DIR$/.idea/" />
|
||||||
|
@ -40,11 +38,11 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="FileEditorManager">
|
<component name="FileEditorManager">
|
||||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||||
<file leaf-file-name="flutter_inappbrowser.dart" pinned="false" current-in-tab="true">
|
<file leaf-file-name="flutter_inappbrowser.dart" pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart">
|
<entry file="file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="465">
|
<state relative-caret-position="119">
|
||||||
<caret line="50" column="54" lean-forward="false" selection-start-line="50" selection-start-column="54" selection-end-line="50" selection-end-column="54" />
|
<caret line="307" column="30" lean-forward="true" selection-start-line="307" selection-start-column="30" selection-end-line="307" selection-end-column="30" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#814#834#0" expanded="true" />
|
<element signature="e#814#834#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
|
@ -52,11 +50,24 @@
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
|
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="true">
|
||||||
|
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||||
|
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||||
|
<state split_layout="SPLIT">
|
||||||
|
<first_editor relative-caret-position="240">
|
||||||
|
<caret line="16" column="0" lean-forward="true" selection-start-line="16" selection-start-column="0" selection-end-line="16" selection-end-column="0" />
|
||||||
|
<folding />
|
||||||
|
</first_editor>
|
||||||
|
<second_editor />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
<file leaf-file-name="main.dart" pinned="false" current-in-tab="false">
|
<file leaf-file-name="main.dart" pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="87">
|
<state relative-caret-position="440">
|
||||||
<caret line="111" column="20" lean-forward="true" selection-start-line="111" selection-start-column="20" selection-end-line="111" selection-end-column="20" />
|
<caret line="124" column="36" lean-forward="false" selection-start-line="124" selection-start-column="36" selection-end-line="124" selection-end-column="36" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#39#0" expanded="true" />
|
<element signature="e#0#39#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
|
@ -143,16 +154,16 @@
|
||||||
<option value="$PROJECT_DIR$/example/ios/Podfile" />
|
<option value="$PROJECT_DIR$/example/ios/Podfile" />
|
||||||
<option value="$PROJECT_DIR$/ios/flutter_inappbrowser.podspec" />
|
<option value="$PROJECT_DIR$/ios/flutter_inappbrowser.podspec" />
|
||||||
<option value="$PROJECT_DIR$/android/build.gradle" />
|
<option value="$PROJECT_DIR$/android/build.gradle" />
|
||||||
<option value="$PROJECT_DIR$/CHANGELOG.md" />
|
|
||||||
<option value="$PROJECT_DIR$/pubspec.yaml" />
|
|
||||||
<option value="$PROJECT_DIR$/README.md" />
|
<option value="$PROJECT_DIR$/README.md" />
|
||||||
|
<option value="$PROJECT_DIR$/pubspec.yaml" />
|
||||||
<option value="$PROJECT_DIR$/example/lib/main.dart" />
|
<option value="$PROJECT_DIR$/example/lib/main.dart" />
|
||||||
<option value="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" />
|
<option value="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" />
|
||||||
|
<option value="$PROJECT_DIR$/CHANGELOG.md" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectFrameBounds">
|
<component name="ProjectFrameBounds">
|
||||||
<option name="x" value="85" />
|
<option name="x" value="288" />
|
||||||
<option name="y" value="23" />
|
<option name="y" value="23" />
|
||||||
<option name="width" value="1632" />
|
<option name="width" value="1632" />
|
||||||
<option name="height" value="1057" />
|
<option name="height" value="1057" />
|
||||||
|
@ -174,8 +185,9 @@
|
||||||
</navigator>
|
</navigator>
|
||||||
<panes>
|
<panes>
|
||||||
<pane id="PackagesPane" />
|
<pane id="PackagesPane" />
|
||||||
<pane id="Scope" />
|
|
||||||
<pane id="AndroidView" />
|
<pane id="AndroidView" />
|
||||||
|
<pane id="Scope" />
|
||||||
|
<pane id="Scratches" />
|
||||||
<pane id="ProjectPane">
|
<pane id="ProjectPane">
|
||||||
<subPane>
|
<subPane>
|
||||||
<expand>
|
<expand>
|
||||||
|
@ -188,6 +200,12 @@
|
||||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||||
<item name="example" type="462c0819:PsiDirectoryNode" />
|
<item name="example" type="462c0819:PsiDirectoryNode" />
|
||||||
</path>
|
</path>
|
||||||
|
<path>
|
||||||
|
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||||
|
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||||
|
<item name="example" type="462c0819:PsiDirectoryNode" />
|
||||||
|
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
||||||
|
</path>
|
||||||
<path>
|
<path>
|
||||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||||
|
@ -198,7 +216,6 @@
|
||||||
</subPane>
|
</subPane>
|
||||||
<option name="show-excluded-files" value="false" />
|
<option name="show-excluded-files" value="false" />
|
||||||
</pane>
|
</pane>
|
||||||
<pane id="Scratches" />
|
|
||||||
</panes>
|
</panes>
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">
|
<component name="PropertiesComponent">
|
||||||
|
@ -388,20 +405,21 @@
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="ToolWindowManager">
|
<component name="ToolWindowManager">
|
||||||
<frame x="85" y="23" width="1632" height="1057" extended-state="0" />
|
<frame x="288" y="23" width="1632" height="1057" extended-state="0" />
|
||||||
<editor active="true" />
|
<editor active="true" />
|
||||||
<layout>
|
<layout>
|
||||||
<window_info id="Android Profiler" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
<window_info id="Android Profiler" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.23855165" sideWeight="0.5" order="12" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Palette	" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
<window_info id="Palette	" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Build Variants" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
<window_info id="Build Variants" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
||||||
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.31735888" sideWeight="0.5026455" order="8" side_tool="true" content_ui="tabs" />
|
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.31735888" sideWeight="0.5026455" order="8" side_tool="true" content_ui="tabs" />
|
||||||
<window_info id="Dart Analysis" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3290735" sideWeight="0.5" order="14" side_tool="false" content_ui="tabs" />
|
<window_info id="Dart Analysis" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3290735" sideWeight="0.5" order="14" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32161874" sideWeight="0.4973545" order="2" side_tool="false" content_ui="tabs" />
|
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32161874" sideWeight="0.4973545" order="2" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
|
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3258786" sideWeight="0.4973545" order="10" side_tool="false" content_ui="tabs" />
|
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.3258786" sideWeight="0.4973545" order="10" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Flutter Outline" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32936507" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
<window_info id="Flutter Outline" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32936507" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Logcat" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
|
<window_info id="Logcat" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Captures" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32936507" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
<window_info id="Captures" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32936507" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||||
|
@ -420,7 +438,6 @@
|
||||||
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32800853" sideWeight="0.5" order="13" side_tool="false" content_ui="tabs" />
|
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32800853" sideWeight="0.5" order="13" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
||||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.18956336" sideWeight="0.5" order="12" side_tool="false" content_ui="tabs" />
|
|
||||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3290735" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3290735" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -733,24 +750,7 @@
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
|
||||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
|
||||||
<state split_layout="SPLIT">
|
|
||||||
<first_editor relative-caret-position="75">
|
|
||||||
<caret line="5" column="36" lean-forward="false" selection-start-line="5" selection-start-column="36" selection-end-line="5" selection-end-column="36" />
|
|
||||||
</first_editor>
|
|
||||||
<second_editor />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/example/flutter_plugin/lib/flutter_plugin.dart" />
|
<entry file="file://$PROJECT_DIR$/example/flutter_plugin/lib/flutter_plugin.dart" />
|
||||||
<entry file="file://$PROJECT_DIR$/pubspec.lock">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="0">
|
|
||||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/flutter_inappbrowser.iml">
|
<entry file="file://$PROJECT_DIR$/flutter_inappbrowser.iml">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="330">
|
<state relative-caret-position="330">
|
||||||
|
@ -758,54 +758,38 @@
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="30">
|
|
||||||
<caret line="2" column="9" lean-forward="true" selection-start-line="2" selection-start-column="9" selection-end-line="2" selection-end-column="14" />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/README.md">
|
<entry file="file://$PROJECT_DIR$/README.md">
|
||||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||||
<state split_layout="SPLIT">
|
<state split_layout="SPLIT">
|
||||||
<first_editor relative-caret-position="302">
|
<first_editor relative-caret-position="302">
|
||||||
<caret line="225" column="29" lean-forward="false" selection-start-line="225" selection-start-column="29" selection-end-line="225" selection-end-column="29" />
|
<caret line="225" column="29" lean-forward="false" selection-start-line="225" selection-start-column="29" selection-end-line="225" selection-end-column="29" />
|
||||||
<folding>
|
|
||||||
<marker date="1537920487557" expanded="false" signature="863:961" ph="..." />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="1005:2050" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="1051:1091" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="1143:1717" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="1429:1482" ph=""""..."""" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="1537:1609" ph=""""..."""" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="1788:1849" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="1879:1922" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="1982:2047" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="2177:2242" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="2283:2872" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="2317:2345" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="2396:2870" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="2424:2865" ph="(...)" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="2450:2858" ph="(...)" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="2478:2561" ph="(...)" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="2507:2550" ph="(...)" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="2587:2849" ph="(...)" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="2622:2838" ph="(...)" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="2701:2768" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="10453:10461" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="10580:10588" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="10748:10756" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="10852:10860" ph="{...}" />
|
|
||||||
<marker date="1537920487557" expanded="true" signature="11144:11150" ph="{...}" />
|
|
||||||
</folding>
|
|
||||||
</first_editor>
|
</first_editor>
|
||||||
<second_editor />
|
<second_editor />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/pubspec.lock">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="0">
|
||||||
|
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||||
|
<folding />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="180">
|
||||||
|
<caret line="12" column="9" lean-forward="false" selection-start-line="12" selection-start-column="9" selection-end-line="12" selection-end-column="9" />
|
||||||
|
<folding>
|
||||||
|
<marker date="1538314178690" expanded="true" signature="171:173" ph="0.1.1" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="87">
|
<state relative-caret-position="440">
|
||||||
<caret line="111" column="20" lean-forward="true" selection-start-line="111" selection-start-column="20" selection-end-line="111" selection-end-column="20" />
|
<caret line="124" column="36" lean-forward="false" selection-start-line="124" selection-start-column="36" selection-end-line="124" selection-end-column="36" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#39#0" expanded="true" />
|
<element signature="e#0#39#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
|
@ -814,14 +798,25 @@
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart">
|
<entry file="file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="465">
|
<state relative-caret-position="119">
|
||||||
<caret line="50" column="54" lean-forward="false" selection-start-line="50" selection-start-column="54" selection-end-line="50" selection-end-column="54" />
|
<caret line="307" column="30" lean-forward="true" selection-start-line="307" selection-start-column="30" selection-end-line="307" selection-end-column="30" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#814#834#0" expanded="true" />
|
<element signature="e#814#834#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||||
|
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||||
|
<state split_layout="SPLIT">
|
||||||
|
<first_editor relative-caret-position="240">
|
||||||
|
<caret line="16" column="0" lean-forward="true" selection-start-line="16" selection-start-column="0" selection-end-line="16" selection-end-column="0" />
|
||||||
|
<folding />
|
||||||
|
</first_editor>
|
||||||
|
<second_editor />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
</component>
|
</component>
|
||||||
<component name="masterDetails">
|
<component name="masterDetails">
|
||||||
<states>
|
<states>
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
## 0.1.0
|
## 0.2.0
|
||||||
|
|
||||||
|
- added support of Chrome CustomTabs for android
|
||||||
|
- added support of SFSafariViewController for iOS
|
||||||
|
- added the ability to create multiple instances of browsers
|
||||||
|
|
||||||
|
## 0.1.1
|
||||||
|
|
||||||
- updated/added new methods
|
- updated/added new methods
|
||||||
- updated UI of android/iOS in-app browser
|
- updated UI of android/iOS in-app browser
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
||||||
public static Registrar registrar;
|
public static Registrar registrar;
|
||||||
public Activity activity;
|
public Activity activity;
|
||||||
public static MethodChannel channel;
|
public static MethodChannel channel;
|
||||||
public static WebViewActivity webViewActivity;
|
public static Map<String, WebViewActivity> webViewActivities = new HashMap<>();
|
||||||
public static ChromeCustomTabsActivity chromeCustomTabsActivity;
|
public static Map<String, ChromeCustomTabsActivity> chromeCustomTabsActivities = new HashMap<>();
|
||||||
|
|
||||||
private static final String NULL = "null";
|
private static final String NULL = "null";
|
||||||
protected static final String LOG_TAG = "InAppBrowserFlutterP";
|
protected static final String LOG_TAG = "InAppBrowserFlutterP";
|
||||||
|
@ -85,6 +85,7 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
||||||
String source;
|
String source;
|
||||||
String jsWrapper;
|
String jsWrapper;
|
||||||
String urlFile;
|
String urlFile;
|
||||||
|
final String uuid = (String) call.argument("uuid");
|
||||||
|
|
||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
case "open":
|
case "open":
|
||||||
|
@ -110,13 +111,15 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
||||||
|
|
||||||
if (useChromeSafariBrowser) {
|
if (useChromeSafariBrowser) {
|
||||||
|
|
||||||
|
final String uuidFallback = (String) call.argument("uuidFallback");
|
||||||
|
|
||||||
final ChromeCustomTabsOptions options = new ChromeCustomTabsOptions();
|
final ChromeCustomTabsOptions options = new ChromeCustomTabsOptions();
|
||||||
options.parse((HashMap<String, Object>) call.argument("options"));
|
options.parse((HashMap<String, Object>) call.argument("options"));
|
||||||
|
|
||||||
final InAppBrowserOptions optionsFallback = new InAppBrowserOptions();
|
final InAppBrowserOptions optionsFallback = new InAppBrowserOptions();
|
||||||
optionsFallback.parse((HashMap<String, Object>) call.argument("optionsFallback"));
|
optionsFallback.parse((HashMap<String, Object>) call.argument("optionsFallback"));
|
||||||
|
|
||||||
open(url, options, headers,true, optionsFallback);
|
open(uuid, uuidFallback, url, options, headers,true, optionsFallback);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -141,89 +144,90 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
||||||
// load in InAppBrowserFlutterPlugin
|
// load in InAppBrowserFlutterPlugin
|
||||||
else {
|
else {
|
||||||
Log.d(LOG_TAG, "loading in InAppBrowserFlutterPlugin");
|
Log.d(LOG_TAG, "loading in InAppBrowserFlutterPlugin");
|
||||||
open(url, options, headers, false, null);
|
open(uuid, null, url, options, headers, false, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SYSTEM
|
// SYSTEM
|
||||||
else if ("_system".equals(target)) {
|
else if ("_system".equals(target)) {
|
||||||
Log.d(LOG_TAG, "in system");
|
Log.d(LOG_TAG, "in system");
|
||||||
openExternal(url, result);
|
openExternal(url);
|
||||||
}
|
}
|
||||||
// BLANK - or anything else
|
// BLANK - or anything else
|
||||||
else {
|
else {
|
||||||
Log.d(LOG_TAG, "in blank");
|
Log.d(LOG_TAG, "in blank");
|
||||||
open(url, options, headers, false, null);
|
open(uuid, null, url, options, headers, false, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.success(true);
|
result.success(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "loadUrl":
|
case "loadUrl":
|
||||||
loadUrl(call.argument("url").toString(), (Map<String, String>) call.argument("headers"), result);
|
loadUrl(uuid, call.argument("url").toString(), (Map<String, String>) call.argument("headers"), result);
|
||||||
break;
|
break;
|
||||||
case "close":
|
case "close":
|
||||||
close();
|
close(uuid);
|
||||||
result.success(true);
|
result.success(true);
|
||||||
break;
|
break;
|
||||||
case "injectScriptCode":
|
case "injectScriptCode":
|
||||||
source = call.argument("source").toString();
|
source = call.argument("source").toString();
|
||||||
jsWrapper = "(function(){return JSON.stringify(eval(%s));})();";
|
jsWrapper = "(function(){return JSON.stringify(eval(%s));})();";
|
||||||
injectDeferredObject(source, jsWrapper, result);
|
injectDeferredObject(uuid, source, jsWrapper, result);
|
||||||
break;
|
break;
|
||||||
case "injectScriptFile":
|
case "injectScriptFile":
|
||||||
urlFile = call.argument("urlFile").toString();
|
urlFile = call.argument("urlFile").toString();
|
||||||
jsWrapper = "(function(d) { var c = d.createElement('script'); c.src = %s; d.body.appendChild(c); })(document);";
|
jsWrapper = "(function(d) { var c = d.createElement('script'); c.src = %s; d.body.appendChild(c); })(document);";
|
||||||
injectDeferredObject(urlFile, jsWrapper, null);
|
injectDeferredObject(uuid, urlFile, jsWrapper, null);
|
||||||
result.success(true);
|
result.success(true);
|
||||||
break;
|
break;
|
||||||
case "injectStyleCode":
|
case "injectStyleCode":
|
||||||
source = call.argument("source").toString();
|
source = call.argument("source").toString();
|
||||||
jsWrapper = "(function(d) { var c = d.createElement('style'); c.innerHTML = %s; d.body.appendChild(c); })(document);";
|
jsWrapper = "(function(d) { var c = d.createElement('style'); c.innerHTML = %s; d.body.appendChild(c); })(document);";
|
||||||
injectDeferredObject(source, jsWrapper, null);
|
injectDeferredObject(uuid, source, jsWrapper, null);
|
||||||
result.success(true);
|
result.success(true);
|
||||||
break;
|
break;
|
||||||
case "injectStyleFile":
|
case "injectStyleFile":
|
||||||
urlFile = call.argument("urlFile").toString();
|
urlFile = call.argument("urlFile").toString();
|
||||||
jsWrapper = "(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %s; d.head.appendChild(c); })(document);";
|
jsWrapper = "(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %s; d.head.appendChild(c); })(document);";
|
||||||
injectDeferredObject(urlFile, jsWrapper, null);
|
injectDeferredObject(uuid, urlFile, jsWrapper, null);
|
||||||
result.success(true);
|
result.success(true);
|
||||||
break;
|
break;
|
||||||
case "show":
|
case "show":
|
||||||
show();
|
show(uuid);
|
||||||
result.success(true);
|
result.success(true);
|
||||||
break;
|
break;
|
||||||
case "hide":
|
case "hide":
|
||||||
hide();
|
hide(uuid);
|
||||||
result.success(true);
|
result.success(true);
|
||||||
break;
|
break;
|
||||||
case "reload":
|
case "reload":
|
||||||
reload();
|
reload(uuid);
|
||||||
result.success(true);
|
result.success(true);
|
||||||
break;
|
break;
|
||||||
case "goBack":
|
case "goBack":
|
||||||
goBack();
|
goBack(uuid);
|
||||||
result.success(true);
|
result.success(true);
|
||||||
break;
|
break;
|
||||||
case "canGoBack":
|
case "canGoBack":
|
||||||
result.success(canGoBack());
|
result.success(canGoBack(uuid));
|
||||||
break;
|
break;
|
||||||
case "goForward":
|
case "goForward":
|
||||||
goForward();
|
goForward(uuid);
|
||||||
result.success(true);
|
result.success(true);
|
||||||
break;
|
break;
|
||||||
case "canGoForward":
|
case "canGoForward":
|
||||||
result.success(canGoForward());
|
result.success(canGoForward(uuid));
|
||||||
break;
|
break;
|
||||||
case "stopLoading":
|
case "stopLoading":
|
||||||
stopLoading();
|
stopLoading(uuid);
|
||||||
result.success(true);
|
result.success(true);
|
||||||
break;
|
break;
|
||||||
case "isLoading":
|
case "isLoading":
|
||||||
result.success(isLoading());
|
result.success(isLoading(uuid));
|
||||||
break;
|
break;
|
||||||
case "isHidden":
|
case "isHidden":
|
||||||
result.success(isHidden());
|
result.success(isHidden(uuid));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result.notImplemented();
|
result.notImplemented();
|
||||||
|
@ -240,13 +244,15 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
||||||
* If a wrapper string is supplied, then the source string will be JSON-encoded (adding
|
* If a wrapper string is supplied, then the source string will be JSON-encoded (adding
|
||||||
* quotes) and wrapped using string formatting. (The wrapper string should have a single
|
* quotes) and wrapped using string formatting. (The wrapper string should have a single
|
||||||
* '%s' marker)
|
* '%s' marker)
|
||||||
* @param source The source object (filename or script/style text) to inject into
|
* @param uuid
|
||||||
|
* @param source The source object (filename or script/style text) to inject into
|
||||||
* the document.
|
* the document.
|
||||||
* @param jsWrapper A JavaScript string to wrap the source string in, so that the object
|
* @param jsWrapper A JavaScript string to wrap the source string in, so that the object
|
||||||
* is properly injected, or null if the source string is JavaScript text
|
* is properly injected, or null if the source string is JavaScript text
|
||||||
* @param result
|
* @param result
|
||||||
*/
|
*/
|
||||||
private void injectDeferredObject(String source, String jsWrapper, final Result result) {
|
private void injectDeferredObject(String uuid, String source, String jsWrapper, final Result result) {
|
||||||
|
final WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null) {
|
if (webViewActivity != null) {
|
||||||
String scriptToInject;
|
String scriptToInject;
|
||||||
if (jsWrapper != null) {
|
if (jsWrapper != null) {
|
||||||
|
@ -323,7 +329,7 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
||||||
* @param url the url to load.
|
* @param url the url to load.
|
||||||
* @return "" if ok, or error message.
|
* @return "" if ok, or error message.
|
||||||
*/
|
*/
|
||||||
public void openExternal(String url, Result result) {
|
public void openExternal(String url) {
|
||||||
try {
|
try {
|
||||||
Intent intent;
|
Intent intent;
|
||||||
intent = new Intent(Intent.ACTION_VIEW);
|
intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
@ -381,24 +387,29 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void open(final String url, Options options, Map<String, String> headers, boolean useChromeSafariBrowser, InAppBrowserOptions optionsFallback) {
|
public static void open(String uuid, String uuidFallback, final String url, Options options, Map<String, String> headers, boolean useChromeSafariBrowser, InAppBrowserOptions optionsFallback) {
|
||||||
Intent intent = new Intent(registrar.activity(), (useChromeSafariBrowser) ? ChromeCustomTabsActivity.class : WebViewActivity.class);
|
Intent intent = new Intent(registrar.activity(), (useChromeSafariBrowser) ? ChromeCustomTabsActivity.class : WebViewActivity.class);
|
||||||
|
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
|
extras.putString("uuid", uuid);
|
||||||
extras.putString("url", url);
|
extras.putString("url", url);
|
||||||
extras.putSerializable("options", options.getHashMap());
|
extras.putSerializable("options", options.getHashMap());
|
||||||
extras.putSerializable("headers", (Serializable) headers);
|
extras.putSerializable("headers", (Serializable) headers);
|
||||||
if (useChromeSafariBrowser && optionsFallback != null)
|
if (useChromeSafariBrowser) {
|
||||||
extras.putSerializable("optionsFallback", optionsFallback.getHashMap());
|
extras.putString("uuidFallback", uuidFallback);
|
||||||
else
|
if (optionsFallback != null)
|
||||||
extras.putSerializable("optionsFallback", (new InAppBrowserOptions()).getHashMap());
|
extras.putSerializable("optionsFallback", optionsFallback.getHashMap());
|
||||||
|
else
|
||||||
|
extras.putSerializable("optionsFallback", (new InAppBrowserOptions()).getHashMap());
|
||||||
|
}
|
||||||
|
|
||||||
intent.putExtras(extras);
|
intent.putExtras(extras);
|
||||||
|
|
||||||
registrar.activity().startActivity(intent);
|
registrar.activity().startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadUrl(String url, Map<String, String> headers, Result result) {
|
public void loadUrl(String uuid, String url, Map<String, String> headers, Result result) {
|
||||||
|
WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null) {
|
if (webViewActivity != null) {
|
||||||
if (headers != null)
|
if (headers != null)
|
||||||
webViewActivity.loadUrl(url, headers, result);
|
webViewActivity.loadUrl(url, headers, result);
|
||||||
|
@ -407,67 +418,79 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show(String uuid) {
|
||||||
|
WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null)
|
if (webViewActivity != null)
|
||||||
webViewActivity.show();
|
webViewActivity.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide() {
|
public void hide(String uuid) {
|
||||||
|
WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null)
|
if (webViewActivity != null)
|
||||||
webViewActivity.hide();
|
webViewActivity.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload() {
|
public void reload(String uuid) {
|
||||||
|
WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null)
|
if (webViewActivity != null)
|
||||||
webViewActivity.reload();
|
webViewActivity.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoading() {
|
public boolean isLoading(String uuid) {
|
||||||
|
WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null)
|
if (webViewActivity != null)
|
||||||
return webViewActivity.isLoading();
|
return webViewActivity.isLoading();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHidden() {
|
public boolean isHidden(String uuid) {
|
||||||
|
WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null)
|
if (webViewActivity != null)
|
||||||
return webViewActivity.isHidden;
|
return webViewActivity.isHidden;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopLoading() {
|
public void stopLoading(String uuid) {
|
||||||
|
WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null)
|
if (webViewActivity != null)
|
||||||
webViewActivity.stopLoading();
|
webViewActivity.stopLoading();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void goBack() {
|
public void goBack(String uuid) {
|
||||||
|
WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null)
|
if (webViewActivity != null)
|
||||||
webViewActivity.goBack();
|
webViewActivity.goBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canGoBack() {
|
public boolean canGoBack(String uuid) {
|
||||||
|
WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null)
|
if (webViewActivity != null)
|
||||||
return webViewActivity.canGoBack();
|
return webViewActivity.canGoBack();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void goForward() {
|
public void goForward(String uuid) {
|
||||||
|
WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null)
|
if (webViewActivity != null)
|
||||||
webViewActivity.goForward();
|
webViewActivity.goForward();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canGoForward() {
|
public boolean canGoForward(String uuid) {
|
||||||
|
WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
if (webViewActivity != null)
|
if (webViewActivity != null)
|
||||||
return webViewActivity.canGoForward();
|
return webViewActivity.canGoForward();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void close() {
|
public static void close(final String uuid) {
|
||||||
|
final WebViewActivity webViewActivity = webViewActivities.get(uuid);
|
||||||
registrar.activity().runOnUiThread(new Runnable() {
|
registrar.activity().runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
Map<String, Object> obj = new HashMap<>();
|
Map<String, Object> obj = new HashMap<>();
|
||||||
|
obj.put("uuid", uuid);
|
||||||
channel.invokeMethod("onExit", obj);
|
channel.invokeMethod("onExit", obj);
|
||||||
|
|
||||||
// The JS protects against multiple calls, so this should happen only when
|
// The JS protects against multiple calls, so this should happen only when
|
||||||
|
|
|
@ -30,6 +30,7 @@ public class InAppBrowserWebViewClient extends WebViewClient {
|
||||||
|
|
||||||
if (activity.options.useShouldOverrideUrlLoading) {
|
if (activity.options.useShouldOverrideUrlLoading) {
|
||||||
Map<String, Object> obj = new HashMap<>();
|
Map<String, Object> obj = new HashMap<>();
|
||||||
|
obj.put("uuid", activity.uuid);
|
||||||
obj.put("url", url);
|
obj.put("url", url);
|
||||||
InAppBrowserFlutterPlugin.channel.invokeMethod("shouldOverrideUrlLoading", obj);
|
InAppBrowserFlutterPlugin.channel.invokeMethod("shouldOverrideUrlLoading", obj);
|
||||||
return true;
|
return true;
|
||||||
|
@ -110,6 +111,7 @@ public class InAppBrowserWebViewClient extends WebViewClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> obj = new HashMap<>();
|
Map<String, Object> obj = new HashMap<>();
|
||||||
|
obj.put("uuid", activity.uuid);
|
||||||
obj.put("url", url);
|
obj.put("url", url);
|
||||||
InAppBrowserFlutterPlugin.channel.invokeMethod("onLoadStart", obj);
|
InAppBrowserFlutterPlugin.channel.invokeMethod("onLoadStart", obj);
|
||||||
}
|
}
|
||||||
|
@ -133,6 +135,7 @@ public class InAppBrowserWebViewClient extends WebViewClient {
|
||||||
view.requestFocus();
|
view.requestFocus();
|
||||||
|
|
||||||
Map<String, Object> obj = new HashMap<>();
|
Map<String, Object> obj = new HashMap<>();
|
||||||
|
obj.put("uuid", activity.uuid);
|
||||||
obj.put("url", url);
|
obj.put("url", url);
|
||||||
InAppBrowserFlutterPlugin.channel.invokeMethod("onLoadStop", obj);
|
InAppBrowserFlutterPlugin.channel.invokeMethod("onLoadStop", obj);
|
||||||
}
|
}
|
||||||
|
@ -143,6 +146,7 @@ public class InAppBrowserWebViewClient extends WebViewClient {
|
||||||
activity.isLoading = false;
|
activity.isLoading = false;
|
||||||
|
|
||||||
Map<String, Object> obj = new HashMap<>();
|
Map<String, Object> obj = new HashMap<>();
|
||||||
|
obj.put("uuid", activity.uuid);
|
||||||
obj.put("url", failingUrl);
|
obj.put("url", failingUrl);
|
||||||
obj.put("code", errorCode);
|
obj.put("code", errorCode);
|
||||||
obj.put("message", description);
|
obj.put("message", description);
|
||||||
|
@ -153,6 +157,7 @@ public class InAppBrowserWebViewClient extends WebViewClient {
|
||||||
super.onReceivedSslError(view, handler, error);
|
super.onReceivedSslError(view, handler, error);
|
||||||
|
|
||||||
Map<String, Object> obj = new HashMap<>();
|
Map<String, Object> obj = new HashMap<>();
|
||||||
|
obj.put("uuid", activity.uuid);
|
||||||
obj.put("url", error.getUrl());
|
obj.put("url", error.getUrl());
|
||||||
obj.put("code", error.getPrimaryError());
|
obj.put("code", error.getPrimaryError());
|
||||||
String message;
|
String message;
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.os.Build;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
|
@ -27,6 +26,7 @@ import io.flutter.plugin.common.MethodChannel;
|
||||||
|
|
||||||
public class WebViewActivity extends AppCompatActivity {
|
public class WebViewActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
String uuid;
|
||||||
WebView webView;
|
WebView webView;
|
||||||
ActionBar actionBar;
|
ActionBar actionBar;
|
||||||
InAppBrowserWebViewClient inAppBrowserWebViewClient;
|
InAppBrowserWebViewClient inAppBrowserWebViewClient;
|
||||||
|
@ -47,6 +47,7 @@ public class WebViewActivity extends AppCompatActivity {
|
||||||
webView = findViewById(R.id.webView);
|
webView = findViewById(R.id.webView);
|
||||||
|
|
||||||
Bundle b = getIntent().getExtras();
|
Bundle b = getIntent().getExtras();
|
||||||
|
uuid = b.getString("uuid");
|
||||||
String url = b.getString("url");
|
String url = b.getString("url");
|
||||||
|
|
||||||
options = new InAppBrowserOptions();
|
options = new InAppBrowserOptions();
|
||||||
|
@ -54,7 +55,7 @@ public class WebViewActivity extends AppCompatActivity {
|
||||||
|
|
||||||
headers = (HashMap<String, String>) b.getSerializable("headers");
|
headers = (HashMap<String, String>) b.getSerializable("headers");
|
||||||
|
|
||||||
InAppBrowserFlutterPlugin.webViewActivity = this;
|
InAppBrowserFlutterPlugin.webViewActivities.put(uuid, this);
|
||||||
|
|
||||||
actionBar = getSupportActionBar();
|
actionBar = getSupportActionBar();
|
||||||
|
|
||||||
|
@ -243,7 +244,7 @@ public class WebViewActivity extends AppCompatActivity {
|
||||||
if (canGoBack())
|
if (canGoBack())
|
||||||
goBack();
|
goBack();
|
||||||
else if (options.closeOnCannotGoBack)
|
else if (options.closeOnCannotGoBack)
|
||||||
InAppBrowserFlutterPlugin.close();
|
InAppBrowserFlutterPlugin.close(uuid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
|
@ -340,7 +341,7 @@ public class WebViewActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeButtonClicked(MenuItem item) {
|
public void closeButtonClicked(MenuItem item) {
|
||||||
InAppBrowserFlutterPlugin.close();
|
InAppBrowserFlutterPlugin.close(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.customtabs.CustomTabsIntent;
|
import android.support.customtabs.CustomTabsIntent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.pichillilorenzo.flutter_inappbrowser.InAppBrowserFlutterPlugin;
|
import com.pichillilorenzo.flutter_inappbrowser.InAppBrowserFlutterPlugin;
|
||||||
import com.pichillilorenzo.flutter_inappbrowser.InAppBrowserOptions;
|
import com.pichillilorenzo.flutter_inappbrowser.InAppBrowserOptions;
|
||||||
|
@ -16,6 +17,9 @@ import java.util.Map;
|
||||||
|
|
||||||
public class ChromeCustomTabsActivity extends Activity {
|
public class ChromeCustomTabsActivity extends Activity {
|
||||||
|
|
||||||
|
protected static final String LOG_TAG = "CustomTabsActivity";
|
||||||
|
String uuid;
|
||||||
|
String uuidFallback;
|
||||||
CustomTabsIntent.Builder builder;
|
CustomTabsIntent.Builder builder;
|
||||||
ChromeCustomTabsOptions options;
|
ChromeCustomTabsOptions options;
|
||||||
Map<String, String> headersFallback;
|
Map<String, String> headersFallback;
|
||||||
|
@ -30,6 +34,8 @@ public class ChromeCustomTabsActivity extends Activity {
|
||||||
setContentView(R.layout.chrome_custom_tabs_layout);
|
setContentView(R.layout.chrome_custom_tabs_layout);
|
||||||
|
|
||||||
Bundle b = getIntent().getExtras();
|
Bundle b = getIntent().getExtras();
|
||||||
|
uuid = b.getString("uuid");
|
||||||
|
uuidFallback = b.getString("uuidFallback");
|
||||||
String url = b.getString("url");
|
String url = b.getString("url");
|
||||||
|
|
||||||
options = new ChromeCustomTabsOptions();
|
options = new ChromeCustomTabsOptions();
|
||||||
|
@ -40,8 +46,9 @@ public class ChromeCustomTabsActivity extends Activity {
|
||||||
optionsFallback = new InAppBrowserOptions();
|
optionsFallback = new InAppBrowserOptions();
|
||||||
optionsFallback.parse((HashMap<String, Object>) b.getSerializable("optionsFallback"));
|
optionsFallback.parse((HashMap<String, Object>) b.getSerializable("optionsFallback"));
|
||||||
|
|
||||||
customTabActivityHelper = new CustomTabActivityHelper();
|
InAppBrowserFlutterPlugin.chromeCustomTabsActivities.put(uuid, this);
|
||||||
|
|
||||||
|
customTabActivityHelper = new CustomTabActivityHelper();
|
||||||
builder = new CustomTabsIntent.Builder();
|
builder = new CustomTabsIntent.Builder();
|
||||||
|
|
||||||
prepareCustomTabs();
|
prepareCustomTabs();
|
||||||
|
@ -52,13 +59,20 @@ public class ChromeCustomTabsActivity extends Activity {
|
||||||
new CustomTabActivityHelper.CustomTabFallback() {
|
new CustomTabActivityHelper.CustomTabFallback() {
|
||||||
@Override
|
@Override
|
||||||
public void openUri(Activity activity, Uri uri) {
|
public void openUri(Activity activity, Uri uri) {
|
||||||
InAppBrowserFlutterPlugin.open(uri.toString(), optionsFallback, headersFallback, false, null);
|
if (!uuidFallback.isEmpty())
|
||||||
|
InAppBrowserFlutterPlugin.open(uuidFallback, null, uri.toString(), optionsFallback, headersFallback, false, null);
|
||||||
|
else {
|
||||||
|
Log.d(LOG_TAG, "No WebView fallback declared.");
|
||||||
|
activity.finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (chromeCustomTabsOpened) {
|
if (chromeCustomTabsOpened) {
|
||||||
InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserOpened", null);
|
Map<String, Object> obj = new HashMap<>();
|
||||||
InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserLoaded", null);
|
obj.put("uuid", uuid);
|
||||||
|
InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserOpened", obj);
|
||||||
|
InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserLoaded", obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +107,9 @@ public class ChromeCustomTabsActivity extends Activity {
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (requestCode == CHROME_CUSTOM_TAB_REQUEST_CODE) {
|
if (requestCode == CHROME_CUSTOM_TAB_REQUEST_CODE) {
|
||||||
finish();
|
finish();
|
||||||
InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserClosed", null);
|
Map<String, Object> obj = new HashMap<>();
|
||||||
|
obj.put("uuid", uuid);
|
||||||
|
InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserClosed", obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,17 @@ class MyInAppBrowser extends InAppBrowser {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future onLoadStart(String url) async {
|
Future onLoadStart(String url) async {
|
||||||
print("\n\nStarted $url\n\n");
|
print("\n\nStarted aaa $url\n\n");
|
||||||
|
inAppBrowserFallback2.open("https://www.google.com", options: {
|
||||||
|
"hidden": true
|
||||||
|
});
|
||||||
//print("\n\n ${await this.isHidden()} \n\n");
|
//print("\n\n ${await this.isHidden()} \n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future onLoadStop(String url) async {
|
Future onLoadStop(String url) async {
|
||||||
print("\n\nStopped $url\n\n");
|
print("\n\nStopped aaa $url\n\n");
|
||||||
|
inAppBrowserFallback2.show();
|
||||||
// print(await this.injectScriptCode("document.body.innerHTML"));
|
// print(await this.injectScriptCode("document.body.innerHTML"));
|
||||||
// print(await this.injectScriptCode("3"));
|
// print(await this.injectScriptCode("3"));
|
||||||
// print(await this.injectScriptCode("""
|
// print(await this.injectScriptCode("""
|
||||||
|
@ -61,7 +65,38 @@ class MyInAppBrowser extends InAppBrowser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MyInAppBrowser2 extends InAppBrowser {
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future onLoadStart(String url) async {
|
||||||
|
print("\n\nStarted $url\n\n");
|
||||||
|
//print("\n\n ${await this.isHidden()} \n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future onLoadStop(String url) async {
|
||||||
|
print("\n\nStopped $url\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onLoadError(String url, int code, String message) {
|
||||||
|
print("\n\nCan't load $url.. Error: $message\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onExit() {
|
||||||
|
print("\n\nBrowser closed!\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void shouldOverrideUrlLoading(String url) {
|
||||||
|
print("\n\n override $url\n\n");
|
||||||
|
this.loadUrl(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MyInAppBrowser inAppBrowserFallback = new MyInAppBrowser();
|
MyInAppBrowser inAppBrowserFallback = new MyInAppBrowser();
|
||||||
|
MyInAppBrowser2 inAppBrowserFallback2 = new MyInAppBrowser2();
|
||||||
|
|
||||||
class MyChromeSafariBrowser extends ChromeSafariBrowser {
|
class MyChromeSafariBrowser extends ChromeSafariBrowser {
|
||||||
MyChromeSafariBrowser(browserFallback) : super(browserFallback);
|
MyChromeSafariBrowser(browserFallback) : super(browserFallback);
|
||||||
|
@ -79,6 +114,7 @@ class MyChromeSafariBrowser extends ChromeSafariBrowser {
|
||||||
@override
|
@override
|
||||||
void onClosed() {
|
void onClosed() {
|
||||||
print("ChromeSafari browser closed");
|
print("ChromeSafari browser closed");
|
||||||
|
inAppBrowserFallback.open("https://flutter.io/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
||||||
var browserOptions: InAppBrowserOptions?
|
var browserOptions: InAppBrowserOptions?
|
||||||
var initHeaders: [String: String]?
|
var initHeaders: [String: String]?
|
||||||
var isHidden = false
|
var isHidden = false
|
||||||
|
var uuid: String = ""
|
||||||
|
|
||||||
required init(coder aDecoder: NSCoder) {
|
required init(coder aDecoder: NSCoder) {
|
||||||
super.init(coder: aDecoder)!
|
super.init(coder: aDecoder)!
|
||||||
|
@ -323,7 +324,7 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
||||||
currentURL = nil
|
currentURL = nil
|
||||||
|
|
||||||
if (navigationDelegate != nil) {
|
if (navigationDelegate != nil) {
|
||||||
navigationDelegate?.browserExit()
|
navigationDelegate?.browserExit(uuid: self.uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
weak var weakSelf = self
|
weak var weakSelf = self
|
||||||
|
@ -419,7 +420,7 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
||||||
let url = navigationAction.request.url
|
let url = navigationAction.request.url
|
||||||
|
|
||||||
if (url != nil && navigationAction.navigationType == .linkActivated && (browserOptions?.useShouldOverrideUrlLoading)!) {
|
if (url != nil && navigationAction.navigationType == .linkActivated && (browserOptions?.useShouldOverrideUrlLoading)!) {
|
||||||
navigationDelegate?.shouldOverrideUrlLoading(webView, url: url!)
|
navigationDelegate?.shouldOverrideUrlLoading(uuid: self.uuid, webView: webView, url: url!)
|
||||||
decisionHandler(.cancel)
|
decisionHandler(.cancel)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -475,7 +476,7 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
||||||
spinner.startAnimating()
|
spinner.startAnimating()
|
||||||
}
|
}
|
||||||
|
|
||||||
return (navigationDelegate?.onLoadStart(webView))!
|
return (navigationDelegate?.onLoadStart(uuid: self.uuid, webView: webView))!
|
||||||
}
|
}
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||||
|
@ -485,7 +486,7 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
||||||
backButton.isEnabled = webView.canGoBack
|
backButton.isEnabled = webView.canGoBack
|
||||||
forwardButton.isEnabled = webView.canGoForward
|
forwardButton.isEnabled = webView.canGoForward
|
||||||
spinner.stopAnimating()
|
spinner.stopAnimating()
|
||||||
navigationDelegate?.onLoadStop(webView)
|
navigationDelegate?.onLoadStop(uuid: self.uuid, webView: webView)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func webView(_ webView: WKWebView,
|
// func webView(_ webView: WKWebView,
|
||||||
|
@ -495,7 +496,7 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
||||||
// backButton.isEnabled = webView.canGoBack
|
// backButton.isEnabled = webView.canGoBack
|
||||||
// forwardButton.isEnabled = webView.canGoForward
|
// forwardButton.isEnabled = webView.canGoForward
|
||||||
// spinner.stopAnimating()
|
// spinner.stopAnimating()
|
||||||
// navigationDelegate?.webView(webView, didFailLoadWithError: error)
|
// navigationDelegate?.webView(uuid: self.uuid, webView: webView, didFailLoadWithError: error)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
|
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
|
||||||
|
@ -503,6 +504,6 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
||||||
backButton.isEnabled = webView.canGoBack
|
backButton.isEnabled = webView.canGoBack
|
||||||
forwardButton.isEnabled = webView.canGoForward
|
forwardButton.isEnabled = webView.canGoForward
|
||||||
spinner.stopAnimating()
|
spinner.stopAnimating()
|
||||||
navigationDelegate?.onLoadError(webView, error: error)
|
navigationDelegate?.onLoadError(uuid: self.uuid, webView: webView, error: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ class SafariViewController: SFSafariViewController, SFSafariViewControllerDelega
|
||||||
weak var statusDelegate: SwiftFlutterPlugin?
|
weak var statusDelegate: SwiftFlutterPlugin?
|
||||||
var tmpWindow: UIWindow?
|
var tmpWindow: UIWindow?
|
||||||
var safariOptions: SafariBrowserOptions?
|
var safariOptions: SafariBrowserOptions?
|
||||||
|
var uuid: String = ""
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
prepareSafariBrowser()
|
prepareSafariBrowser()
|
||||||
|
@ -37,7 +38,7 @@ class SafariViewController: SFSafariViewController, SFSafariViewControllerDelega
|
||||||
|
|
||||||
func close() {
|
func close() {
|
||||||
if (statusDelegate != nil) {
|
if (statusDelegate != nil) {
|
||||||
statusDelegate?.safariExit()
|
statusDelegate?.safariExit(uuid: self.uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
dismiss(animated: true)
|
dismiss(animated: true)
|
||||||
|
@ -55,7 +56,7 @@ class SafariViewController: SFSafariViewController, SFSafariViewControllerDelega
|
||||||
func safariViewController(_ controller: SFSafariViewController,
|
func safariViewController(_ controller: SFSafariViewController,
|
||||||
didCompleteInitialLoad didLoadSuccessfully: Bool) {
|
didCompleteInitialLoad didLoadSuccessfully: Bool) {
|
||||||
if didLoadSuccessfully {
|
if didLoadSuccessfully {
|
||||||
statusDelegate?.onChromeSafariBrowserLoaded()
|
statusDelegate?.onChromeSafariBrowserLoaded(uuid: self.uuid)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print("Cant load successfully the 'SafariViewController'.")
|
print("Cant load successfully the 'SafariViewController'.")
|
||||||
|
|
|
@ -26,8 +26,8 @@ let WEBVIEW_STORYBOARD = "WebView"
|
||||||
let WEBVIEW_STORYBOARD_CONTROLLER_ID = "viewController"
|
let WEBVIEW_STORYBOARD_CONTROLLER_ID = "viewController"
|
||||||
|
|
||||||
public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
||||||
var webViewController: InAppBrowserWebViewController?
|
var webViewControllers: [String: InAppBrowserWebViewController?] = [:]
|
||||||
var safariViewController: Any?
|
var safariViewControllers: [String: Any?] = [:]
|
||||||
|
|
||||||
var tmpWindow: UIWindow?
|
var tmpWindow: UIWindow?
|
||||||
var channel: FlutterMethodChannel
|
var channel: FlutterMethodChannel
|
||||||
|
@ -45,66 +45,96 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
||||||
|
|
||||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
let arguments = call.arguments as? NSDictionary
|
let arguments = call.arguments as? NSDictionary
|
||||||
|
let uuid: String = (arguments!["uuid"] as? String)!
|
||||||
|
|
||||||
switch call.method {
|
switch call.method {
|
||||||
case "open":
|
case "open":
|
||||||
self.open(arguments: arguments!, result: result)
|
self.open(uuid: uuid, arguments: arguments!, result: result)
|
||||||
break
|
break
|
||||||
case "loadUrl":
|
case "loadUrl":
|
||||||
self.loadUrl(arguments: arguments!, result: result)
|
self.loadUrl(uuid: uuid, arguments: arguments!, result: result)
|
||||||
break
|
break
|
||||||
case "close":
|
case "close":
|
||||||
self.close()
|
self.close(uuid: uuid)
|
||||||
result(true)
|
result(true)
|
||||||
break
|
break
|
||||||
case "show":
|
case "show":
|
||||||
self.show()
|
self.show(uuid: uuid)
|
||||||
result(true)
|
result(true)
|
||||||
break
|
break
|
||||||
case "hide":
|
case "hide":
|
||||||
self.hide()
|
self.hide(uuid: uuid)
|
||||||
result(true)
|
result(true)
|
||||||
break
|
break
|
||||||
case "reload":
|
case "reload":
|
||||||
self.webViewController?.reload()
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
webViewController?.reload()
|
||||||
|
}
|
||||||
result(true)
|
result(true)
|
||||||
break
|
break
|
||||||
case "goBack":
|
case "goBack":
|
||||||
self.webViewController?.goBack()
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
webViewController?.goBack()
|
||||||
|
}
|
||||||
result(true)
|
result(true)
|
||||||
break
|
break
|
||||||
case "canGoBack":
|
case "canGoBack":
|
||||||
result(self.webViewController?.canGoBack() ?? false)
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
result(webViewController?.canGoBack() ?? false)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result(false)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case "goForward":
|
case "goForward":
|
||||||
self.webViewController?.goForward()
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
webViewController?.goForward()
|
||||||
|
}
|
||||||
result(true)
|
result(true)
|
||||||
break
|
break
|
||||||
case "canGoForward":
|
case "canGoForward":
|
||||||
result(self.webViewController?.canGoForward() ?? false)
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
result(webViewController?.canGoForward() ?? false)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result(false)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case "isLoading":
|
case "isLoading":
|
||||||
result((self.webViewController?.webView.isLoading ?? false) == true)
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
result((webViewController?.webView.isLoading ?? false) == true)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result(false)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case "stopLoading":
|
case "stopLoading":
|
||||||
self.webViewController?.webView.stopLoading()
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
webViewController?.webView.stopLoading()
|
||||||
|
}
|
||||||
result(true)
|
result(true)
|
||||||
break
|
break
|
||||||
case "isHidden":
|
case "isHidden":
|
||||||
result((self.webViewController?.isHidden ?? false) == true)
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
result((webViewController?.isHidden ?? false) == true)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result(false)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case "injectScriptCode":
|
case "injectScriptCode":
|
||||||
self.injectScriptCode(arguments: arguments!, result: result)
|
self.injectScriptCode(uuid: uuid, arguments: arguments!, result: result)
|
||||||
break
|
break
|
||||||
case "injectScriptFile":
|
case "injectScriptFile":
|
||||||
self.injectScriptFile(arguments: arguments!, result: nil)
|
self.injectScriptFile(uuid: uuid, arguments: arguments!, result: nil)
|
||||||
result(true)
|
result(true)
|
||||||
break
|
break
|
||||||
case "injectStyleCode":
|
case "injectStyleCode":
|
||||||
self.injectStyleCode(arguments: arguments!, result: nil)
|
self.injectStyleCode(uuid: uuid, arguments: arguments!, result: nil)
|
||||||
result(true)
|
result(true)
|
||||||
break
|
break
|
||||||
case "injectStyleFile":
|
case "injectStyleFile":
|
||||||
self.injectStyleFile(arguments: arguments!, result: nil)
|
self.injectStyleFile(uuid: uuid, arguments: arguments!, result: nil)
|
||||||
result(true)
|
result(true)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
@ -113,13 +143,15 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func close() {
|
func close(uuid: String) {
|
||||||
if webViewController == nil {
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
// Things are cleaned up in browserExit.
|
||||||
|
webViewController?.close()
|
||||||
|
}
|
||||||
|
else {
|
||||||
print("IAB.close() called but it was already closed.")
|
print("IAB.close() called but it was already closed.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Things are cleaned up in browserExit.
|
|
||||||
webViewController?.close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func isSystemUrl(_ url: URL) -> Bool {
|
func isSystemUrl(_ url: URL) -> Bool {
|
||||||
|
@ -129,7 +161,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
public func open(arguments: NSDictionary, result: @escaping FlutterResult) {
|
public func open(uuid: String, arguments: NSDictionary, result: @escaping FlutterResult) {
|
||||||
let url: String = (arguments["url"] as? String)!
|
let url: String = (arguments["url"] as? String)!
|
||||||
|
|
||||||
let headers = (arguments["headers"] as? [String: String])!
|
let headers = (arguments["headers"] as? [String: String])!
|
||||||
|
@ -140,56 +172,47 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
||||||
let useChromeSafariBrowser = (arguments["useChromeSafariBrowser"] as? Bool)
|
let useChromeSafariBrowser = (arguments["useChromeSafariBrowser"] as? Bool)
|
||||||
|
|
||||||
if useChromeSafariBrowser! {
|
if useChromeSafariBrowser! {
|
||||||
|
let uuidFallback = (arguments["uuidFallback"] as? String)!
|
||||||
let options = (arguments["options"] as? [String: Any])!
|
let options = (arguments["options"] as? [String: Any])!
|
||||||
let optionsFallback = (arguments["optionsFallback"] as? [String: Any])!
|
let optionsFallback = (arguments["optionsFallback"] as? [String: Any])!
|
||||||
|
|
||||||
open(inAppBrowser: absoluteUrl!, headers: headers, withOptions: options, useChromeSafariBrowser: true, withOptionsFallback: optionsFallback);
|
open(uuid: uuid, uuidFallback: uuidFallback, inAppBrowser: absoluteUrl!, headers: headers, withOptions: options, useChromeSafariBrowser: true, withOptionsFallback: optionsFallback);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let options = (arguments["options"] as? [String: Any])!
|
let options = (arguments["options"] as? [String: Any])!
|
||||||
|
|
||||||
if isSystemUrl(absoluteUrl!) {
|
if isSystemUrl(absoluteUrl!) {
|
||||||
target = "_system"
|
target = "_system"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == "_self" || target == "_target") {
|
if (target == "_self" || target == "_target") {
|
||||||
open(inAppBrowser: absoluteUrl!, headers: headers, withOptions: options, useChromeSafariBrowser: false, withOptionsFallback: nil)
|
open(uuid: uuid, uuidFallback: nil, inAppBrowser: absoluteUrl!, headers: headers, withOptions: options, useChromeSafariBrowser: false, withOptionsFallback: nil)
|
||||||
}
|
}
|
||||||
else if (target == "_system") {
|
else if (target == "_system") {
|
||||||
open(inSystem: absoluteUrl!)
|
open(inSystem: absoluteUrl!)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// anything else
|
// anything else
|
||||||
open(inAppBrowser: absoluteUrl!, headers: headers,withOptions: options, useChromeSafariBrowser: false, withOptionsFallback: nil)
|
open(uuid: uuid, uuidFallback: nil, inAppBrowser: absoluteUrl!, headers: headers,withOptions: options, useChromeSafariBrowser: false, withOptionsFallback: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result(true)
|
result(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func loadUrl(arguments: NSDictionary, result: @escaping FlutterResult) {
|
func open(uuid: String, uuidFallback: String?, inAppBrowser url: URL, headers: [String: String], withOptions options: [String: Any], useChromeSafariBrowser: Bool, withOptionsFallback optionsFallback: [String: Any]?) {
|
||||||
let url: String? = (arguments["url"] as? String)!
|
|
||||||
let headers = (arguments["headers"] as? [String: String])!
|
|
||||||
|
|
||||||
if url != nil {
|
var uuid = uuid
|
||||||
let absoluteUrl = URL(string: url!)!.absoluteURL
|
|
||||||
webViewController?.loadUrl(url: absoluteUrl, headers: headers)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
print("url is empty")
|
|
||||||
result(FlutterError(code: "InAppBrowserFlutterPlugin", message: "url is empty", details: nil))
|
|
||||||
}
|
|
||||||
result(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func open(inAppBrowser url: URL, headers: [String: String], withOptions options: [String: Any], useChromeSafariBrowser: Bool, withOptionsFallback optionsFallback: [String: Any]?) {
|
if self.webViewControllers[uuid] != nil {
|
||||||
|
close(uuid: uuid)
|
||||||
if webViewController != nil {
|
|
||||||
close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let safariViewController = self.safariViewControllers[uuid]
|
||||||
|
|
||||||
if safariViewController != nil {
|
if safariViewController != nil {
|
||||||
if #available(iOS 9.0, *) {
|
if #available(iOS 9.0, *) {
|
||||||
(safariViewController! as! SafariViewController).close()
|
(safariViewController! as! SafariViewController).close()
|
||||||
safariViewController = nil
|
self.safariViewControllers[uuid] = nil
|
||||||
} else {
|
} else {
|
||||||
// Fallback on earlier versions
|
// Fallback on earlier versions
|
||||||
}
|
}
|
||||||
|
@ -230,19 +253,25 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
||||||
safari = SafariViewController(url: url)
|
safari = SafariViewController(url: url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
safari.uuid = uuid
|
||||||
safari.delegate = safari
|
safari.delegate = safari
|
||||||
safari.statusDelegate = self
|
safari.statusDelegate = self
|
||||||
safari.tmpWindow = tmpWindow
|
safari.tmpWindow = tmpWindow
|
||||||
safari.safariOptions = safariOptions
|
safari.safariOptions = safariOptions
|
||||||
|
|
||||||
safariViewController = safari
|
self.safariViewControllers[uuid] = safari
|
||||||
|
|
||||||
tmpController.present(safariViewController! as! SFSafariViewController, animated: true)
|
tmpController.present(self.safariViewControllers[uuid]! as! SFSafariViewController, animated: true)
|
||||||
onChromeSafariBrowserOpened()
|
onChromeSafariBrowserOpened(uuid: uuid)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if uuidFallback == nil {
|
||||||
|
print("No WebView fallback declared.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
uuid = uuidFallback!
|
||||||
browserOptions = InAppBrowserOptions()
|
browserOptions = InAppBrowserOptions()
|
||||||
browserOptions.parse(options: optionsFallback!)
|
browserOptions.parse(options: optionsFallback!)
|
||||||
}
|
}
|
||||||
|
@ -254,17 +283,19 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
||||||
|
|
||||||
let storyboard = UIStoryboard(name: WEBVIEW_STORYBOARD, bundle: nil)
|
let storyboard = UIStoryboard(name: WEBVIEW_STORYBOARD, bundle: nil)
|
||||||
let vc = storyboard.instantiateViewController(withIdentifier: WEBVIEW_STORYBOARD_CONTROLLER_ID)
|
let vc = storyboard.instantiateViewController(withIdentifier: WEBVIEW_STORYBOARD_CONTROLLER_ID)
|
||||||
webViewController = vc as? InAppBrowserWebViewController
|
self.webViewControllers[uuid] = vc as? InAppBrowserWebViewController
|
||||||
webViewController?.browserOptions = browserOptions
|
let webViewController: InAppBrowserWebViewController = self.webViewControllers[uuid] as! InAppBrowserWebViewController
|
||||||
webViewController?.isHidden = browserOptions.hidden
|
webViewController.uuid = uuid
|
||||||
webViewController?.tmpWindow = tmpWindow
|
webViewController.browserOptions = browserOptions
|
||||||
webViewController?.currentURL = url
|
webViewController.isHidden = browserOptions.hidden
|
||||||
webViewController?.initHeaders = headers
|
webViewController.tmpWindow = tmpWindow
|
||||||
webViewController?.navigationDelegate = self
|
webViewController.currentURL = url
|
||||||
|
webViewController.initHeaders = headers
|
||||||
|
webViewController.navigationDelegate = self
|
||||||
|
|
||||||
if browserOptions.hidden {
|
if browserOptions.hidden {
|
||||||
webViewController!.view.isHidden = true
|
webViewController.view.isHidden = true
|
||||||
tmpController.present(self.webViewController!, animated: false, completion: {() -> Void in
|
tmpController.present(webViewController, animated: false, completion: {() -> Void in
|
||||||
// if self.previousStatusBarStyle != -1 {
|
// if self.previousStatusBarStyle != -1 {
|
||||||
// UIApplication.shared.statusBarStyle = UIStatusBarStyle(rawValue: self.previousStatusBarStyle)!
|
// UIApplication.shared.statusBarStyle = UIStatusBarStyle(rawValue: self.previousStatusBarStyle)!
|
||||||
// }
|
// }
|
||||||
|
@ -272,65 +303,89 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
||||||
// if self.previousStatusBarStyle != -1 {
|
// if self.previousStatusBarStyle != -1 {
|
||||||
// UIApplication.shared.statusBarStyle = UIStatusBarStyle(rawValue: self.previousStatusBarStyle)!
|
// UIApplication.shared.statusBarStyle = UIStatusBarStyle(rawValue: self.previousStatusBarStyle)!
|
||||||
// }
|
// }
|
||||||
webViewController?.presentingViewController?.dismiss(animated: false, completion: {() -> Void in
|
webViewController.presentingViewController?.dismiss(animated: false, completion: {() -> Void in
|
||||||
self.tmpWindow?.windowLevel = 0.0
|
self.tmpWindow?.windowLevel = 0.0
|
||||||
UIApplication.shared.delegate?.window??.makeKeyAndVisible()
|
UIApplication.shared.delegate?.window??.makeKeyAndVisible()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tmpController.present(webViewController!, animated: true, completion: nil)
|
tmpController.present(webViewController, animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func show() {
|
public func loadUrl(uuid: String, arguments: NSDictionary, result: @escaping FlutterResult) {
|
||||||
|
let webViewController: InAppBrowserWebViewController = self.webViewControllers[uuid] as! InAppBrowserWebViewController
|
||||||
|
let url: String? = (arguments["url"] as? String)!
|
||||||
|
let headers = (arguments["headers"] as? [String: String])!
|
||||||
|
|
||||||
if webViewController == nil {
|
if url != nil {
|
||||||
print("Tried to hide IAB after it was closed.")
|
let absoluteUrl = URL(string: url!)!.absoluteURL
|
||||||
return
|
webViewController.loadUrl(url: absoluteUrl, headers: headers)
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
self.webViewController?.isHidden = false
|
print("url is empty")
|
||||||
self.webViewController!.view.isHidden = false
|
result(FlutterError(code: "InAppBrowserFlutterPlugin", message: "url is empty", details: nil))
|
||||||
|
}
|
||||||
// Run later to avoid the "took a long time" log message.
|
result(true)
|
||||||
DispatchQueue.main.async(execute: {() -> Void in
|
|
||||||
if self.webViewController != nil {
|
|
||||||
let baseWindowLevel = UIApplication.shared.keyWindow?.windowLevel
|
|
||||||
self.tmpWindow?.windowLevel = UIWindowLevel(baseWindowLevel! + 1)
|
|
||||||
self.tmpWindow?.makeKeyAndVisible()
|
|
||||||
UIApplication.shared.delegate?.window??.makeKeyAndVisible()
|
|
||||||
self.tmpWindow?.rootViewController?.present(self.webViewController!, animated: true, completion: nil)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func hide() {
|
public func show(uuid: String) {
|
||||||
if webViewController == nil {
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
print("Tried to hide IAB after it was closed.")
|
if webViewController != nil {
|
||||||
return
|
webViewController?.isHidden = false
|
||||||
}
|
webViewController?.view.isHidden = false
|
||||||
|
|
||||||
if self.webViewController != nil {
|
// Run later to avoid the "took a long time" log message.
|
||||||
self.webViewController?.isHidden = true
|
DispatchQueue.main.async(execute: {() -> Void in
|
||||||
}
|
if webViewController != nil {
|
||||||
|
let baseWindowLevel = UIApplication.shared.keyWindow?.windowLevel
|
||||||
// Run later to avoid the "took a long time" log message.
|
self.tmpWindow?.windowLevel = UIWindowLevel(baseWindowLevel! + 1)
|
||||||
DispatchQueue.main.async(execute: {() -> Void in
|
self.tmpWindow?.makeKeyAndVisible()
|
||||||
if self.webViewController != nil {
|
UIApplication.shared.delegate?.window??.makeKeyAndVisible()
|
||||||
self.webViewController?.presentingViewController?.dismiss(animated: true, completion: {() -> Void in
|
self.tmpWindow?.rootViewController?.present(webViewController!, animated: true, completion: nil)
|
||||||
self.tmpWindow?.windowLevel = 0.0
|
|
||||||
UIApplication.shared.delegate?.window??.makeKeyAndVisible()
|
|
||||||
if self.previousStatusBarStyle != -1 {
|
|
||||||
UIApplication.shared.statusBarStyle = UIStatusBarStyle(rawValue: self.previousStatusBarStyle)!
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
else {
|
||||||
|
print("Tried to hide IAB after it was closed.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func hide(uuid: String) {
|
||||||
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
if webViewController != nil {
|
||||||
|
webViewController?.isHidden = true
|
||||||
|
|
||||||
|
// Run later to avoid the "took a long time" log message.
|
||||||
|
DispatchQueue.main.async(execute: {() -> Void in
|
||||||
|
if webViewController != nil {
|
||||||
|
webViewController?.presentingViewController?.dismiss(animated: true, completion: {() -> Void in
|
||||||
|
self.tmpWindow?.windowLevel = 0.0
|
||||||
|
UIApplication.shared.delegate?.window??.makeKeyAndVisible()
|
||||||
|
if self.previousStatusBarStyle != -1 {
|
||||||
|
UIApplication.shared.statusBarStyle = UIStatusBarStyle(rawValue: self.previousStatusBarStyle)!
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print("Tried to hide IAB after it was closed.")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func open(inSystem url: URL) {
|
func open(inSystem url: URL) {
|
||||||
if UIApplication.shared.openURL(url) == false {
|
if !UIApplication.shared.canOpenURL(url) {
|
||||||
NotificationCenter.default.post(Notification(name: Notification.Name(rawValue: "CDVPluginHandleOpenURLNotification"), object: url))
|
NotificationCenter.default.post(Notification(name: Notification.Name(rawValue: "PluginHandleOpenURLNotification"), object: url))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if #available(iOS 10.0, *) {
|
||||||
|
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||||
|
} else {
|
||||||
|
UIApplication.shared.openURL(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,113 +397,131 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
||||||
// '%@' marker).
|
// '%@' marker).
|
||||||
//
|
//
|
||||||
// If no wrapper is supplied, then the source string is executed directly.
|
// If no wrapper is supplied, then the source string is executed directly.
|
||||||
func injectDeferredObject(_ source: String, withWrapper jsWrapper: String, result: FlutterResult?) {
|
func injectDeferredObject(uuid: String, source: String, withWrapper jsWrapper: String, result: FlutterResult?) {
|
||||||
let jsonData: Data? = try? JSONSerialization.data(withJSONObject: [source], options: [])
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
let sourceArrayString = String(data: jsonData!, encoding: String.Encoding.utf8)
|
let jsonData: Data? = try? JSONSerialization.data(withJSONObject: [source], options: [])
|
||||||
if sourceArrayString != nil {
|
let sourceArrayString = String(data: jsonData!, encoding: String.Encoding.utf8)
|
||||||
let sourceString: String? = (sourceArrayString! as NSString).substring(with: NSRange(location: 1, length: (sourceArrayString?.characters.count ?? 0) - 2))
|
if sourceArrayString != nil {
|
||||||
let jsToInject = String(format: jsWrapper, sourceString!)
|
let sourceString: String? = (sourceArrayString! as NSString).substring(with: NSRange(location: 1, length: (sourceArrayString?.characters.count ?? 0) - 2))
|
||||||
|
let jsToInject = String(format: jsWrapper, sourceString!)
|
||||||
|
|
||||||
webViewController?.webView?.evaluateJavaScript(jsToInject, completionHandler: {(value, error) in
|
webViewController?.webView?.evaluateJavaScript(jsToInject, completionHandler: {(value, error) in
|
||||||
if result == nil {
|
if result == nil {
|
||||||
return
|
return
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
let data: Data = ("[" + String(describing: value!) + "]").data(using: String.Encoding.utf8, allowLossyConversion: false)!
|
|
||||||
let json: Array<Any> = try JSONSerialization.jsonObject(with: data, options: []) as! Array<Any>
|
|
||||||
if json[0] is String {
|
|
||||||
result!(json[0])
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
result!(value)
|
|
||||||
}
|
|
||||||
} catch let error as NSError {
|
|
||||||
print("Failed to load: \(error.localizedDescription)")
|
|
||||||
result!(FlutterError(code: "InAppBrowserFlutterPlugin", message: "Failed to load: \(error.localizedDescription)", details: error))
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
do {
|
||||||
|
let data: Data = ("[" + String(describing: value!) + "]").data(using: String.Encoding.utf8, allowLossyConversion: false)!
|
||||||
|
let json: Array<Any> = try JSONSerialization.jsonObject(with: data, options: []) as! Array<Any>
|
||||||
|
if json[0] is String {
|
||||||
|
result!(json[0])
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result!(value)
|
||||||
|
}
|
||||||
|
} catch let error as NSError {
|
||||||
|
print("Failed to load: \(error.localizedDescription)")
|
||||||
|
result!(FlutterError(code: "InAppBrowserFlutterPlugin", message: "Failed to load: \(error.localizedDescription)", details: error))
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func injectScriptCode(arguments: NSDictionary, result: FlutterResult?) {
|
public func injectScriptCode(uuid: String, arguments: NSDictionary, result: FlutterResult?) {
|
||||||
let jsWrapper = "(function(){return JSON.stringify(eval(%@));})();"
|
let jsWrapper = "(function(){return JSON.stringify(eval(%@));})();"
|
||||||
injectDeferredObject(arguments["source"] as! String, withWrapper: jsWrapper, result: result)
|
injectDeferredObject(uuid: uuid, source: arguments["source"] as! String, withWrapper: jsWrapper, result: result)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func injectScriptFile(arguments: NSDictionary, result: FlutterResult?) {
|
public func injectScriptFile(uuid: String, arguments: NSDictionary, result: FlutterResult?) {
|
||||||
let jsWrapper = "(function(d) { var c = d.createElement('script'); c.src = %@; d.body.appendChild(c); })(document);"
|
let jsWrapper = "(function(d) { var c = d.createElement('script'); c.src = %@; d.body.appendChild(c); })(document);"
|
||||||
injectDeferredObject(arguments["urlFile"] as! String, withWrapper: jsWrapper, result: result)
|
injectDeferredObject(uuid: uuid, source: arguments["urlFile"] as! String, withWrapper: jsWrapper, result: result)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func injectStyleCode(arguments: NSDictionary, result: FlutterResult?) {
|
public func injectStyleCode(uuid: String, arguments: NSDictionary, result: FlutterResult?) {
|
||||||
let jsWrapper = "(function(d) { var c = d.createElement('style'); c.innerHTML = %@; d.body.appendChild(c); })(document);"
|
let jsWrapper = "(function(d) { var c = d.createElement('style'); c.innerHTML = %@; d.body.appendChild(c); })(document);"
|
||||||
injectDeferredObject(arguments["source"] as! String, withWrapper: jsWrapper, result: result)
|
injectDeferredObject(uuid: uuid, source: arguments["source"] as! String, withWrapper: jsWrapper, result: result)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func injectStyleFile(arguments: NSDictionary, result: FlutterResult?) {
|
public func injectStyleFile(uuid: String, arguments: NSDictionary, result: FlutterResult?) {
|
||||||
let jsWrapper = "(function(d) { var c = d.createElement('link'); c.rel='stylesheet', c.type='text/css'; c.href = %@; d.body.appendChild(c); })(document);"
|
let jsWrapper = "(function(d) { var c = d.createElement('link'); c.rel='stylesheet', c.type='text/css'; c.href = %@; d.body.appendChild(c); })(document);"
|
||||||
injectDeferredObject(arguments["urlFile"] as! String, withWrapper: jsWrapper, result: result)
|
injectDeferredObject(uuid: uuid, source: arguments["urlFile"] as! String, withWrapper: jsWrapper, result: result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func onLoadStart(_ webView: WKWebView) {
|
func onLoadStart(uuid: String, webView: WKWebView) {
|
||||||
let url: String = webViewController!.currentURL!.absoluteString
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
channel.invokeMethod("onLoadStart", arguments: ["url": url])
|
let url: String = webViewController!.currentURL!.absoluteString
|
||||||
}
|
channel.invokeMethod("onLoadStart", arguments: ["uuid": uuid, "url": url])
|
||||||
|
|
||||||
func onLoadStop(_ webView: WKWebView) {
|
|
||||||
let url: String = webViewController!.currentURL!.absoluteString
|
|
||||||
channel.invokeMethod("onLoadStop", arguments: ["url": url])
|
|
||||||
}
|
|
||||||
|
|
||||||
func onLoadError(_ webView: WKWebView, error: Error) {
|
|
||||||
let url: String = webViewController!.currentURL!.absoluteString
|
|
||||||
let arguments = ["url": url, "code": error._code, "message": error.localizedDescription] as [String : Any]
|
|
||||||
channel.invokeMethod("onLoadError", arguments: arguments)
|
|
||||||
}
|
|
||||||
|
|
||||||
func onExit() {
|
|
||||||
channel.invokeMethod("onExit", arguments: [])
|
|
||||||
}
|
|
||||||
|
|
||||||
func shouldOverrideUrlLoading(_ webView: WKWebView, url: URL) {
|
|
||||||
channel.invokeMethod("shouldOverrideUrlLoading", arguments: ["url": url.absoluteString])
|
|
||||||
}
|
|
||||||
|
|
||||||
func onChromeSafariBrowserOpened() {
|
|
||||||
channel.invokeMethod("onChromeSafariBrowserOpened", arguments: [])
|
|
||||||
}
|
|
||||||
|
|
||||||
func onChromeSafariBrowserLoaded() {
|
|
||||||
channel.invokeMethod("onChromeSafariBrowserLoaded", arguments: [])
|
|
||||||
}
|
|
||||||
|
|
||||||
func onChromeSafariBrowserClosed() {
|
|
||||||
channel.invokeMethod("onChromeSafariBrowserClosed", arguments: [])
|
|
||||||
}
|
|
||||||
|
|
||||||
func safariExit() {
|
|
||||||
if #available(iOS 9.0, *) {
|
|
||||||
(safariViewController as! SafariViewController).statusDelegate = nil
|
|
||||||
(safariViewController as! SafariViewController).delegate = nil
|
|
||||||
}
|
}
|
||||||
safariViewController = nil
|
|
||||||
onChromeSafariBrowserClosed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func browserExit() {
|
func onLoadStop(uuid: String, webView: WKWebView) {
|
||||||
// Set navigationDelegate to nil to ensure no callbacks are received from it.
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
webViewController?.navigationDelegate = nil
|
let url: String = webViewController!.currentURL!.absoluteString
|
||||||
// Don't recycle the ViewController since it may be consuming a lot of memory.
|
channel.invokeMethod("onLoadStop", arguments: ["uuid": uuid, "url": url])
|
||||||
// Also - this is required for the PDF/User-Agent bug work-around.
|
|
||||||
webViewController = nil
|
|
||||||
|
|
||||||
if previousStatusBarStyle != -1 {
|
|
||||||
UIApplication.shared.statusBarStyle = UIStatusBarStyle(rawValue: previousStatusBarStyle)!
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onExit()
|
func onLoadError(uuid: String, webView: WKWebView, error: Error) {
|
||||||
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
let url: String = webViewController!.currentURL!.absoluteString
|
||||||
|
let arguments = ["uuid": uuid, "url": url, "code": error._code, "message": error.localizedDescription] as [String : Any]
|
||||||
|
channel.invokeMethod("onLoadError", arguments: arguments)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func onExit(uuid: String) {
|
||||||
|
channel.invokeMethod("onExit", arguments: ["uuid": uuid])
|
||||||
|
}
|
||||||
|
|
||||||
|
func shouldOverrideUrlLoading(uuid: String, webView: WKWebView, url: URL) {
|
||||||
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
channel.invokeMethod("shouldOverrideUrlLoading", arguments: ["uuid": uuid, "url": url.absoluteString])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func onChromeSafariBrowserOpened(uuid: String) {
|
||||||
|
if let safariViewController = self.safariViewControllers[uuid] {
|
||||||
|
channel.invokeMethod("onChromeSafariBrowserOpened", arguments: ["uuid": uuid])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func onChromeSafariBrowserLoaded(uuid: String) {
|
||||||
|
if let safariViewController = self.safariViewControllers[uuid] {
|
||||||
|
channel.invokeMethod("onChromeSafariBrowserLoaded", arguments: ["uuid": uuid])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func onChromeSafariBrowserClosed(uuid: String) {
|
||||||
|
channel.invokeMethod("onChromeSafariBrowserClosed", arguments: ["uuid": uuid])
|
||||||
|
}
|
||||||
|
|
||||||
|
func safariExit(uuid: String) {
|
||||||
|
if let safariViewController = self.safariViewControllers[uuid] {
|
||||||
|
if #available(iOS 9.0, *) {
|
||||||
|
(safariViewController as! SafariViewController).statusDelegate = nil
|
||||||
|
(safariViewController as! SafariViewController).delegate = nil
|
||||||
|
}
|
||||||
|
self.safariViewControllers[uuid] = nil
|
||||||
|
onChromeSafariBrowserClosed(uuid: uuid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func browserExit(uuid: String) {
|
||||||
|
if let webViewController = self.webViewControllers[uuid] {
|
||||||
|
// Set navigationDelegate to nil to ensure no callbacks are received from it.
|
||||||
|
webViewController?.navigationDelegate = nil
|
||||||
|
// Don't recycle the ViewController since it may be consuming a lot of memory.
|
||||||
|
// Also - this is required for the PDF/User-Agent bug work-around.
|
||||||
|
self.webViewControllers[uuid] = nil
|
||||||
|
|
||||||
|
if previousStatusBarStyle != -1 {
|
||||||
|
UIApplication.shared.statusBarStyle = UIStatusBarStyle(rawValue: previousStatusBarStyle)!
|
||||||
|
}
|
||||||
|
|
||||||
|
onExit(uuid: uuid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,25 +20,30 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:collection';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
|
typedef Future<dynamic> ListenerCallback(MethodCall call);
|
||||||
|
|
||||||
|
var uuidGenerator = new Uuid();
|
||||||
|
|
||||||
class _ChannelManager {
|
class _ChannelManager {
|
||||||
static const MethodChannel channel = const MethodChannel('com.pichillilorenzo/flutter_inappbrowser');
|
static const MethodChannel channel = const MethodChannel('com.pichillilorenzo/flutter_inappbrowser');
|
||||||
static final initialized = false;
|
static final initialized = false;
|
||||||
static final listeners = <Function>[];
|
static final listeners = HashMap<String, ListenerCallback>();
|
||||||
|
|
||||||
static Future<dynamic> _handleMethod(MethodCall call) async {
|
static Future<dynamic> _handleMethod(MethodCall call) async {
|
||||||
for (var listener in listeners) {
|
String uuid = call.arguments["uuid"];
|
||||||
listener(call);
|
listeners[uuid](call);
|
||||||
}
|
|
||||||
return new Future.value("");
|
return new Future.value("");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addListener (Function callback) {
|
static void addListener (String key, ListenerCallback callback) {
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init();
|
init();
|
||||||
listeners.add(callback);
|
listeners.putIfAbsent(key, () => callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init () {
|
static void init () {
|
||||||
|
@ -51,9 +56,12 @@ class _ChannelManager {
|
||||||
/// This class uses the native WebView of the platform.
|
/// This class uses the native WebView of the platform.
|
||||||
class InAppBrowser {
|
class InAppBrowser {
|
||||||
|
|
||||||
|
String uuid;
|
||||||
|
|
||||||
///
|
///
|
||||||
InAppBrowser () {
|
InAppBrowser () {
|
||||||
_ChannelManager.addListener(_handleMethod);
|
uuid = uuidGenerator.v4();
|
||||||
|
_ChannelManager.addListener(uuid, _handleMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> _handleMethod(MethodCall call) async {
|
Future<dynamic> _handleMethod(MethodCall call) async {
|
||||||
|
@ -144,6 +152,7 @@ class InAppBrowser {
|
||||||
/// - __spinner__: Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`.
|
/// - __spinner__: Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`.
|
||||||
Future<void> open(String url, {Map<String, String> headers = const {}, String target = "_self", Map<String, dynamic> options = const {}}) async {
|
Future<void> open(String url, {Map<String, String> headers = const {}, String target = "_self", Map<String, dynamic> options = const {}}) async {
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
args.putIfAbsent('url', () => url);
|
args.putIfAbsent('url', () => url);
|
||||||
args.putIfAbsent('headers', () => headers);
|
args.putIfAbsent('headers', () => headers);
|
||||||
args.putIfAbsent('target', () => target);
|
args.putIfAbsent('target', () => target);
|
||||||
|
@ -155,6 +164,7 @@ class InAppBrowser {
|
||||||
///Loads the given [url] with optional [headers] specified as a map from name to value.
|
///Loads the given [url] with optional [headers] specified as a map from name to value.
|
||||||
Future<void> loadUrl(String url, {Map<String, String> headers = const {}}) async {
|
Future<void> loadUrl(String url, {Map<String, String> headers = const {}}) async {
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
args.putIfAbsent('url', () => url);
|
args.putIfAbsent('url', () => url);
|
||||||
args.putIfAbsent('headers', () => headers);
|
args.putIfAbsent('headers', () => headers);
|
||||||
return await _ChannelManager.channel.invokeMethod('loadUrl', args);
|
return await _ChannelManager.channel.invokeMethod('loadUrl', args);
|
||||||
|
@ -162,52 +172,71 @@ class InAppBrowser {
|
||||||
|
|
||||||
///Displays an [InAppBrowser] window that was opened hidden. Calling this has no effect if the [InAppBrowser] was already visible.
|
///Displays an [InAppBrowser] window that was opened hidden. Calling this has no effect if the [InAppBrowser] was already visible.
|
||||||
Future<void> show() async {
|
Future<void> show() async {
|
||||||
return await _ChannelManager.channel.invokeMethod('show');
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
|
return await _ChannelManager.channel.invokeMethod('show', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Hides the [InAppBrowser] window. Calling this has no effect if the [InAppBrowser] was already hidden.
|
///Hides the [InAppBrowser] window. Calling this has no effect if the [InAppBrowser] was already hidden.
|
||||||
Future<void> hide() async {
|
Future<void> hide() async {
|
||||||
return await _ChannelManager.channel.invokeMethod('hide');
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
|
return await _ChannelManager.channel.invokeMethod('hide', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Closes the [InAppBrowser] window.
|
///Closes the [InAppBrowser] window.
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
return await _ChannelManager.channel.invokeMethod('close');
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
|
return await _ChannelManager.channel.invokeMethod('close', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Reloads the [InAppBrowser] window.
|
///Reloads the [InAppBrowser] window.
|
||||||
Future<void> reload() async {
|
Future<void> reload() async {
|
||||||
return await _ChannelManager.channel.invokeMethod('reload');
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
|
return await _ChannelManager.channel.invokeMethod('reload', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Goes back in the history of the [InAppBrowser] window.
|
///Goes back in the history of the [InAppBrowser] window.
|
||||||
Future<void> goBack() async {
|
Future<void> goBack() async {
|
||||||
return await _ChannelManager.channel.invokeMethod('goBack');
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
|
return await _ChannelManager.channel.invokeMethod('goBack', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Goes forward in the history of the [InAppBrowser] window.
|
///Goes forward in the history of the [InAppBrowser] window.
|
||||||
Future<void> goForward() async {
|
Future<void> goForward() async {
|
||||||
return await _ChannelManager.channel.invokeMethod('goForward');
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
|
return await _ChannelManager.channel.invokeMethod('goForward', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Check if the Web View of the [InAppBrowser] instance is in a loading state.
|
///Check if the Web View of the [InAppBrowser] instance is in a loading state.
|
||||||
Future<bool> isLoading() async {
|
Future<bool> isLoading() async {
|
||||||
return await _ChannelManager.channel.invokeMethod('isLoading');
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
|
return await _ChannelManager.channel.invokeMethod('isLoading', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Stops the Web View of the [InAppBrowser] instance from loading.
|
///Stops the Web View of the [InAppBrowser] instance from loading.
|
||||||
Future<void> stopLoading() async {
|
Future<void> stopLoading() async {
|
||||||
return await _ChannelManager.channel.invokeMethod('stopLoading');
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
|
return await _ChannelManager.channel.invokeMethod('stopLoading', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Check if the Web View of the [InAppBrowser] instance is hidden.
|
///Check if the Web View of the [InAppBrowser] instance is hidden.
|
||||||
Future<bool> isHidden() async {
|
Future<bool> isHidden() async {
|
||||||
return await _ChannelManager.channel.invokeMethod('isHidden');
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
|
return await _ChannelManager.channel.invokeMethod('isHidden', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Injects JavaScript code into the [InAppBrowser] window and returns the result of the evaluation. (Only available when the target is set to `_blank` or to `_self`)
|
///Injects JavaScript code into the [InAppBrowser] window and returns the result of the evaluation. (Only available when the target is set to `_blank` or to `_self`)
|
||||||
Future<String> injectScriptCode(String source) async {
|
Future<String> injectScriptCode(String source) async {
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
args.putIfAbsent('source', () => source);
|
args.putIfAbsent('source', () => source);
|
||||||
return await _ChannelManager.channel.invokeMethod('injectScriptCode', args);
|
return await _ChannelManager.channel.invokeMethod('injectScriptCode', args);
|
||||||
}
|
}
|
||||||
|
@ -215,6 +244,7 @@ class InAppBrowser {
|
||||||
///Injects a JavaScript file into the [InAppBrowser] window. (Only available when the target is set to `_blank` or to `_self`)
|
///Injects a JavaScript file into the [InAppBrowser] window. (Only available when the target is set to `_blank` or to `_self`)
|
||||||
Future<void> injectScriptFile(String urlFile) async {
|
Future<void> injectScriptFile(String urlFile) async {
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
args.putIfAbsent('urlFile', () => urlFile);
|
args.putIfAbsent('urlFile', () => urlFile);
|
||||||
return await _ChannelManager.channel.invokeMethod('injectScriptFile', args);
|
return await _ChannelManager.channel.invokeMethod('injectScriptFile', args);
|
||||||
}
|
}
|
||||||
|
@ -222,6 +252,7 @@ class InAppBrowser {
|
||||||
///Injects CSS into the [InAppBrowser] window. (Only available when the target is set to `_blank` or to `_self`)
|
///Injects CSS into the [InAppBrowser] window. (Only available when the target is set to `_blank` or to `_self`)
|
||||||
Future<void> injectStyleCode(String source) async {
|
Future<void> injectStyleCode(String source) async {
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
args.putIfAbsent('source', () => source);
|
args.putIfAbsent('source', () => source);
|
||||||
return await _ChannelManager.channel.invokeMethod('injectStyleCode', args);
|
return await _ChannelManager.channel.invokeMethod('injectStyleCode', args);
|
||||||
}
|
}
|
||||||
|
@ -229,6 +260,7 @@ class InAppBrowser {
|
||||||
///Injects a CSS file into the [InAppBrowser] window. (Only available when the target is set to `_blank` or to `_self`)
|
///Injects a CSS file into the [InAppBrowser] window. (Only available when the target is set to `_blank` or to `_self`)
|
||||||
Future<void> injectStyleFile(String urlFile) async {
|
Future<void> injectStyleFile(String urlFile) async {
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
args.putIfAbsent('urlFile', () => urlFile);
|
args.putIfAbsent('urlFile', () => urlFile);
|
||||||
return await _ChannelManager.channel.invokeMethod('injectStyleFile', args);
|
return await _ChannelManager.channel.invokeMethod('injectStyleFile', args);
|
||||||
}
|
}
|
||||||
|
@ -268,12 +300,14 @@ class InAppBrowser {
|
||||||
///
|
///
|
||||||
///[browserFallback] represents the [InAppBrowser] instance fallback in case [Chrome Custom Tabs]/[SFSafariViewController] is not available.
|
///[browserFallback] represents the [InAppBrowser] instance fallback in case [Chrome Custom Tabs]/[SFSafariViewController] is not available.
|
||||||
class ChromeSafariBrowser {
|
class ChromeSafariBrowser {
|
||||||
|
String uuid;
|
||||||
InAppBrowser browserFallback;
|
InAppBrowser browserFallback;
|
||||||
|
|
||||||
///
|
///
|
||||||
ChromeSafariBrowser (browserFallback) {
|
ChromeSafariBrowser (bf) {
|
||||||
this.browserFallback = browserFallback;
|
uuid = uuidGenerator.v4();
|
||||||
_ChannelManager.addListener(_handleMethod);
|
browserFallback = bf;
|
||||||
|
_ChannelManager.addListener(uuid, _handleMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> _handleMethod(MethodCall call) async {
|
Future<dynamic> _handleMethod(MethodCall call) async {
|
||||||
|
@ -294,6 +328,9 @@ class ChromeSafariBrowser {
|
||||||
///
|
///
|
||||||
Future<void> open(String url, {Map<String, dynamic> options = const {}, Map<String, String> headersFallback = const {}, Map<String, dynamic> optionsFallback = const {}}) async {
|
Future<void> open(String url, {Map<String, dynamic> options = const {}, Map<String, String> headersFallback = const {}, Map<String, dynamic> optionsFallback = const {}}) async {
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('uuid', () => uuid);
|
||||||
|
print(browserFallback.uuid);
|
||||||
|
args.putIfAbsent('uuidFallback', () => (browserFallback != null) ? browserFallback.uuid : '');
|
||||||
args.putIfAbsent('url', () => url);
|
args.putIfAbsent('url', () => url);
|
||||||
args.putIfAbsent('headers', () => headersFallback);
|
args.putIfAbsent('headers', () => headersFallback);
|
||||||
args.putIfAbsent('target', () => "");
|
args.putIfAbsent('target', () => "");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_inappbrowser
|
name: flutter_inappbrowser
|
||||||
description: A Flutter plugin that allows you to open an in-app browser window. (inspired by the popular cordova-plugin-inappbrowser).
|
description: A Flutter plugin that allows you to open an in-app browser window. (inspired by the popular cordova-plugin-inappbrowser).
|
||||||
version: 0.1.1
|
version: 0.2.0
|
||||||
author: Lorenzo Pichilli <pichillilorenzo@gmail.com>
|
author: Lorenzo Pichilli <pichillilorenzo@gmail.com>
|
||||||
homepage: https://github.com/pichillilorenzo/flutter_inappbrowser
|
homepage: https://github.com/pichillilorenzo/flutter_inappbrowser
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ environment:
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
uuid: ^1.0.3
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
# For information on the generic Dart part of this file, see the
|
||||||
# following page: https://www.dartlang.org/tools/pub/pubspec
|
# following page: https://www.dartlang.org/tools/pub/pubspec
|
||||||
|
|
Loading…
Reference in New Issue