fixed WebView.storyboard to iOS deployment target 8.0, added onLoadResource method
This commit is contained in:
parent
f032b7f635
commit
d696ed1e68
|
@ -0,0 +1,82 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MarkdownProjectSettings" wasCopied="false">
|
||||
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true" openRemoteLinks="true" replaceUnicodeEmoji="false" lastLayoutSetsDefault="false">
|
||||
<PanelProvider>
|
||||
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
|
||||
</PanelProvider>
|
||||
</PreviewSettings>
|
||||
<ParserSettings gitHubSyntaxChange="false" emojiShortcuts="1" emojiImages="0">
|
||||
<PegdownExtensions>
|
||||
<option name="ABBREVIATIONS" value="false" />
|
||||
<option name="ANCHORLINKS" value="true" />
|
||||
<option name="ASIDE" value="false" />
|
||||
<option name="ATXHEADERSPACE" value="true" />
|
||||
<option name="AUTOLINKS" value="true" />
|
||||
<option name="DEFINITIONS" value="false" />
|
||||
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
|
||||
<option name="FENCED_CODE_BLOCKS" value="true" />
|
||||
<option name="FOOTNOTES" value="false" />
|
||||
<option name="HARDWRAPS" value="false" />
|
||||
<option name="HTML_DEEP_PARSER" value="false" />
|
||||
<option name="INSERTED" value="false" />
|
||||
<option name="QUOTES" value="false" />
|
||||
<option name="RELAXEDHRULES" value="true" />
|
||||
<option name="SMARTS" value="false" />
|
||||
<option name="STRIKETHROUGH" value="true" />
|
||||
<option name="SUBSCRIPT" value="false" />
|
||||
<option name="SUPERSCRIPT" value="false" />
|
||||
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
|
||||
<option name="SUPPRESS_INLINE_HTML" value="false" />
|
||||
<option name="TABLES" value="true" />
|
||||
<option name="TASKLISTITEMS" value="true" />
|
||||
<option name="TOC" value="false" />
|
||||
<option name="WIKILINKS" value="true" />
|
||||
</PegdownExtensions>
|
||||
<ParserOptions>
|
||||
<option name="ADMONITION_EXT" value="false" />
|
||||
<option name="ATTRIBUTES_EXT" value="false" />
|
||||
<option name="COMMONMARK_LISTS" value="true" />
|
||||
<option name="DUMMY" value="false" />
|
||||
<option name="EMOJI_SHORTCUTS" value="true" />
|
||||
<option name="ENUMERATED_REFERENCES_EXT" value="false" />
|
||||
<option name="FLEXMARK_FRONT_MATTER" value="false" />
|
||||
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
|
||||
<option name="GFM_TABLE_RENDERING" value="true" />
|
||||
<option name="GITBOOK_URL_ENCODING" value="false" />
|
||||
<option name="GITHUB_LISTS" value="false" />
|
||||
<option name="GITHUB_WIKI_LINKS" value="true" />
|
||||
<option name="GITLAB_EXT" value="false" />
|
||||
<option name="GITLAB_MATH_EXT" value="false" />
|
||||
<option name="GITLAB_MERMAID_EXT" value="false" />
|
||||
<option name="HEADER_ID_NO_DUPED_DASHES" value="false" />
|
||||
<option name="JEKYLL_FRONT_MATTER" value="false" />
|
||||
<option name="MACROS_EXT" value="false" />
|
||||
<option name="NO_TEXT_ATTRIBUTES" value="false" />
|
||||
<option name="PARSE_HTML_ANCHOR_ID" value="false" />
|
||||
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
|
||||
</ParserOptions>
|
||||
</ParserSettings>
|
||||
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true" embedImages="false" embedHttpImages="false" imageUriSerials="false" addDocTypeHtml="true">
|
||||
<GeneratorProvider>
|
||||
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
|
||||
</GeneratorProvider>
|
||||
<headerTop />
|
||||
<headerBottom />
|
||||
<bodyTop />
|
||||
<bodyBottom />
|
||||
</HtmlSettings>
|
||||
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="true" isCssTextEnabled="false" isDynamicPageWidth="true">
|
||||
<StylesheetProvider>
|
||||
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
|
||||
</StylesheetProvider>
|
||||
<ScriptProviders />
|
||||
<cssText />
|
||||
<cssUriHistory />
|
||||
</CssSettings>
|
||||
<HtmlExportSettings updateOnSave="false" parentDir="" targetDir="" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
|
||||
<LinkMapSettings>
|
||||
<textMaps />
|
||||
</LinkMapSettings>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,3 @@
|
|||
<component name="MarkdownNavigator.ProfileManager">
|
||||
<settings default="" pdf-export="" />
|
||||
</component>
|
|
@ -15,21 +15,19 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9b41f7a2-a71e-4923-91fb-249d7815b3e7" name="Default" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebChromeClient.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebChromeClient.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/android/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebViewClient.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserWebViewClient.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/WebViewActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/WebViewActivity.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/android/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/example/android/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/android/gradle/wrapper/gradle-wrapper.properties" beforeDir="false" afterPath="$PROJECT_DIR$/example/android/gradle/wrapper/gradle-wrapper.properties" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/ios/Runner.xcodeproj/project.pbxproj" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Runner.xcodeproj/project.pbxproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/ios/Runner/WebView.storyboard" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Runner/WebView.storyboard" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/main.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ios/Classes/InAppBrowserOptions.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/InAppBrowserOptions.swift" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ios/Classes/InAppBrowserWebViewController.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/InAppBrowserWebViewController.swift" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ios/Classes/SwiftFlutterPlugin.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/SwiftFlutterPlugin.swift" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pubspec.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.yaml" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.dart_tool/" />
|
||||
<ignored path="$PROJECT_DIR$/.idea/" />
|
||||
|
@ -45,39 +43,65 @@
|
|||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file leaf-file-name="flutter_inappbrowser.dart" pinned="false" current-in-tab="false">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file leaf-file-name="flutter_inappbrowser.dart" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-624">
|
||||
<caret line="268" column="33" selection-start-line="268" selection-start-column="17" selection-end-line="268" selection-end-column="33" />
|
||||
<state relative-caret-position="358">
|
||||
<caret line="262" column="75" selection-start-line="262" selection-start-column="75" selection-end-line="262" selection-end-column="75" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="build.gradle" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/android/build.gradle">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="262">
|
||||
<caret line="34" column="5" selection-start-line="34" selection-start-column="5" selection-end-line="34" selection-end-column="5" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="README.md" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="2820">
|
||||
<caret line="188" column="158" selection-start-line="188" selection-start-column="158" selection-end-line="188" selection-end-column="158" />
|
||||
</first_editor>
|
||||
<second_editor>
|
||||
<markdownNavigatorState />
|
||||
</second_editor>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="pubspec.yaml" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="247">
|
||||
<caret line="19" column="15" selection-start-line="19" selection-start-column="3" selection-end-line="19" selection-end-column="15" />
|
||||
<state relative-caret-position="30">
|
||||
<caret line="2" column="14" selection-start-line="2" selection-start-column="14" selection-end-line="2" selection-end-column="14" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<caret column="8" selection-start-column="8" selection-end-column="8" />
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor />
|
||||
<second_editor>
|
||||
<markdownNavigatorState />
|
||||
</second_editor>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="main.dart" pinned="false" current-in-tab="true">
|
||||
<file leaf-file-name="main.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="102">
|
||||
<caret line="15" column="25" lean-forward="true" selection-start-line="15" selection-start-column="25" selection-end-line="15" selection-end-column="25" />
|
||||
<state relative-caret-position="200">
|
||||
<caret line="74" column="60" selection-start-line="74" selection-start-column="54" selection-end-line="74" selection-end-column="60" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -157,21 +181,21 @@
|
|||
<option value="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserClient.java" />
|
||||
<option value="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowser.java" />
|
||||
<option value="$PROJECT_DIR$/ios/flutter_inappbrowser.podspec" />
|
||||
<option value="$PROJECT_DIR$/android/build.gradle" />
|
||||
<option value="$PROJECT_DIR$/example/ios/Podfile" />
|
||||
<option value="$PROJECT_DIR$/pubspec.yaml" />
|
||||
<option value="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" />
|
||||
<option value="$PROJECT_DIR$/README.md" />
|
||||
<option value="$PROJECT_DIR$/CHANGELOG.md" />
|
||||
<option value="$PROJECT_DIR$/README.md" />
|
||||
<option value="$PROJECT_DIR$/android/build.gradle" />
|
||||
<option value="$PROJECT_DIR$/example/lib/main.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="x" value="-1808" />
|
||||
<option name="y" value="-21" />
|
||||
<option name="x" value="235" />
|
||||
<option name="y" value="23" />
|
||||
<option name="width" value="1589" />
|
||||
<option name="height" value="1057" />
|
||||
<option name="height" value="1027" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectView">
|
||||
|
@ -179,6 +203,8 @@
|
|||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="AndroidView" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
|
@ -191,6 +217,11 @@
|
|||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="android" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="ios" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
|
@ -201,8 +232,6 @@
|
|||
</subPane>
|
||||
<option name="show-excluded-files" value="false" />
|
||||
</pane>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="AndroidView" />
|
||||
<pane id="Scope">
|
||||
<subPane subId="Project Files">
|
||||
<expand>
|
||||
|
@ -369,33 +398,33 @@
|
|||
<servers />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-1808" y="-21" width="1589" height="1057" extended-state="0" />
|
||||
<frame x="235" y="23" width="1589" height="1027" extended-state="0" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info anchor="bottom" id="Android Profiler" order="7" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="bottom" id="Messages" order="12" weight="0.2375" />
|
||||
<window_info anchor="right" id="Palette	" order="3" />
|
||||
<window_info id="Image Layers" order="2" />
|
||||
<window_info id="Build Variants" order="2" side_tool="true" />
|
||||
<window_info anchor="right" id="Capture Analysis" order="3" />
|
||||
<window_info anchor="bottom" id="Event Log" order="8" sideWeight="0.50316054" side_tool="true" weight="0.32083333" />
|
||||
<window_info anchor="bottom" id="Dart Analysis" order="14" weight="0.3290735" />
|
||||
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49683943" weight="0.32123798" />
|
||||
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49683943" visible="true" weight="0.39801544" />
|
||||
<window_info anchor="bottom" id="Version Control" order="9" />
|
||||
<window_info active="true" anchor="bottom" id="Terminal" order="10" sideWeight="0.4973545" visible="true" weight="0.25933832" />
|
||||
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.4973545" weight="0.25689086" />
|
||||
<window_info anchor="right" id="Flutter Outline" order="3" weight="0.32922077" />
|
||||
<window_info anchor="bottom" id="Logcat" order="11" />
|
||||
<window_info id="Captures" order="2" weight="0.32936507" />
|
||||
<window_info id="Capture Tool" order="2" />
|
||||
<window_info id="Designer" order="2" />
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.18293472" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.24969475" />
|
||||
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.49855492" visible="true" weight="0.18293472" />
|
||||
<window_info id="Structure" order="1" sideWeight="0.5014451" side_tool="true" weight="0.18293472" />
|
||||
<window_info anchor="right" id="Device File Explorer" order="3" side_tool="true" />
|
||||
<window_info anchor="right" id="Theme Preview" order="3" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info id="Favorites" order="2" side_tool="true" />
|
||||
<window_info anchor="right" id="Flutter Inspector" order="3" weight="0.32987013" />
|
||||
<window_info anchor="bottom" id="Messages" order="12" visible="true" weight="0.2370452" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="right" id="Commander" order="0" weight="0.4" />
|
||||
<window_info anchor="right" id="Assistant" order="4" visible="true" weight="0.32987013" />
|
||||
|
@ -410,6 +439,7 @@
|
|||
<window_info id="Designer" order="4" />
|
||||
<window_info anchor="bottom" id="Dart Analysis" order="14" weight="0.3290735" />
|
||||
<window_info id="Build Variants" order="2" side_tool="true" />
|
||||
<window_info id="Image Layers" order="5" />
|
||||
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.4973545" weight="0.32161874" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
|
@ -421,22 +451,21 @@
|
|||
<window_info anchor="bottom" id="Android Profiler" order="7" show_stripe_button="false" />
|
||||
<window_info anchor="right" id="Commander" order="0" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Event Log" order="8" sideWeight="0.5026455" side_tool="true" weight="0.31735888" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.18376623" />
|
||||
<window_info anchor="right" id="Device File Explorer" order="4" side_tool="true" />
|
||||
<window_info anchor="right" id="Flutter Outline" order="3" weight="0.32936507" />
|
||||
<window_info anchor="bottom" id="Logcat" order="11" />
|
||||
<window_info anchor="bottom" id="Dependency Viewer" order="13" weight="0.32800853" />
|
||||
<window_info anchor="bottom" id="Version Control" order="9" />
|
||||
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.4973545" visible="true" weight="0.27888888" />
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.18376623" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Messages" order="12" weight="0.23777778" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info id="Image Layers" order="5" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="right" id="Palette	" order="5" />
|
||||
<window_info anchor="right" id="Theme Preview" order="7" />
|
||||
<window_info id="Structure" order="1" weight="0.24969475" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Find" order="1" weight="0.3290735" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
</layout-to-restore>
|
||||
|
@ -450,13 +479,6 @@
|
|||
</breakpoint-manager>
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="105">
|
||||
<caret line="74" column="13" selection-start-line="74" selection-start-column="13" selection-end-line="74" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="270">
|
||||
|
@ -512,11 +534,6 @@
|
|||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/android/gradle.properties">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/android/gradle.properties">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state />
|
||||
|
@ -591,26 +608,12 @@
|
|||
<state relative-caret-position="-27" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/android/build.gradle">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="585">
|
||||
<caret line="39" column="60" selection-start-line="39" selection-start-column="60" selection-end-line="39" selection-end-column="60" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<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 />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/ios/flutter_inappbrowser.podspec">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="240">
|
||||
<caret line="16" column="24" selection-start-line="16" selection-start-column="24" selection-end-line="16" selection-end-column="24" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/ios/Podfile">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="539">
|
||||
|
@ -634,18 +637,6 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/android/gradlew" />
|
||||
<entry file="file://$PROJECT_DIR$/android/gradlew.bat" />
|
||||
<entry file="file://$PROJECT_DIR$/android/local.properties">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/android/settings.gradle">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<caret column="20" selection-start-column="20" selection-end-column="20" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/flutter_webview_example.iml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state />
|
||||
|
@ -679,35 +670,91 @@
|
|||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="30">
|
||||
<caret line="2" column="14" lean-forward="true" selection-start-line="2" selection-start-column="14" selection-end-line="2" selection-end-column="14" />
|
||||
<caret line="2" column="14" selection-start-line="2" selection-start-column="14" selection-end-line="2" selection-end-column="14" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<entry file="file://$PROJECT_DIR$/ios/flutter_inappbrowser.podspec">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<caret column="8" selection-start-column="8" selection-end-column="8" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-624">
|
||||
<caret line="268" column="33" selection-start-line="268" selection-start-column="17" selection-end-line="268" selection-end-column="33" />
|
||||
<state relative-caret-position="240">
|
||||
<caret line="16" column="24" selection-start-line="16" selection-start-column="24" selection-end-line="16" selection-end-column="24" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="2820">
|
||||
<caret line="188" column="158" selection-start-line="188" selection-start-column="158" selection-end-line="188" selection-end-column="158" />
|
||||
</first_editor>
|
||||
<second_editor>
|
||||
<markdownNavigatorState />
|
||||
</second_editor>
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="text-editor">
|
||||
<state relative-caret-position="247">
|
||||
<caret line="19" column="15" selection-start-line="19" selection-start-column="3" selection-end-line="19" selection-end-column="15" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor />
|
||||
<second_editor>
|
||||
<markdownNavigatorState />
|
||||
</second_editor>
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="text-editor">
|
||||
<state relative-caret-position="30">
|
||||
<caret line="2" column="69" lean-forward="true" selection-start-line="2" selection-start-column="2" selection-end-line="2" selection-end-column="73" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/android/settings.gradle">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<caret column="20" selection-start-column="20" selection-end-column="20" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/android/local.properties">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/android/gradle.properties">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/android/build.gradle">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="262">
|
||||
<caret line="34" column="5" selection-start-line="34" selection-start-column="5" selection-end-line="34" selection-end-column="5" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/flutter/bin/cache/pkg/sky_engine/lib/core/string.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="173">
|
||||
<caret line="99" column="15" selection-start-line="99" selection-start-column="15" selection-end-line="99" selection-end-column="15" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="102">
|
||||
<caret line="15" column="25" lean-forward="true" selection-start-line="15" selection-start-column="25" selection-end-line="15" selection-end-column="25" />
|
||||
<state relative-caret-position="200">
|
||||
<caret line="74" column="60" selection-start-line="74" selection-start-column="54" selection-end-line="74" selection-end-column="60" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="358">
|
||||
<caret line="262" column="75" selection-start-line="262" selection-start-column="75" selection-end-line="262" selection-end-column="75" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
|
|
@ -187,7 +187,6 @@ Opens an `url` in a new `InAppBrowser` instance or the system browser.
|
|||
- __presentationStyle__: Set the custom modal presentation style when presenting the WebView. The default value is `0 //fullscreen`. See [UIModalPresentationStyle](https://developer.apple.com/documentation/uikit/uimodalpresentationstyle) for all the available styles.
|
||||
- __transitionStyle__: Set to the custom transition style when presenting the WebView. The default value is `0 //crossDissolve`. See [UIModalTransitionStyle](https://developer.apple.com/documentation/uikit/uimodaltransitionStyle) for all the available styles.
|
||||
- __enableViewportScale__: Set to `true` to allow a viewport meta tag to either disable or restrict the range of user scaling. The default value is `false`.
|
||||
- __keyboardDisplayRequiresUserAction__: Set to `true` if you want the user must explicitly tap the elements in the WebView to display the keyboard (or other relevant input view) for that element. When set to `false`, a focus event on an element causes the input view to be displayed and associated with that element automatically. The default value is `true`.
|
||||
- __suppressesIncrementalRendering__: Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory.. The default value is `false`.
|
||||
- __allowsAirPlayForMediaPlayback__: Set to `true` to allow AirPlay. The default value is `true`.
|
||||
- __allowsBackForwardNavigationGestures__: Set to `true` to allow the horizontal swipe gestures trigger back-forward list navigations. The default value is `true`.
|
||||
|
|
|
@ -38,4 +38,5 @@ android {
|
|||
dependencies {
|
||||
implementation 'com.android.support:customtabs:27.1.1'
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.squareup.okhttp3:mockwebserver:3.11.0'
|
||||
}
|
||||
|
|
|
@ -1,29 +1,97 @@
|
|||
package com.pichillilorenzo.flutter_inappbrowser;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.net.http.SslError;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.CookieSyncManager;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.webkit.SslErrorHandler;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class InAppBrowserWebViewClient extends WebViewClient {
|
||||
|
||||
protected static final String LOG_TAG = "IABWebViewClient";
|
||||
private WebViewActivity activity;
|
||||
Map<Integer, String> statusCodeMapping = new HashMap<Integer, String>();
|
||||
|
||||
public InAppBrowserWebViewClient(WebViewActivity activity) {
|
||||
super();
|
||||
this.activity = activity;
|
||||
statusCodeMapping.put(100, "Continue");
|
||||
statusCodeMapping.put(101, "Switching Protocols");
|
||||
statusCodeMapping.put(200, "OK");
|
||||
statusCodeMapping.put(201, "Created");
|
||||
statusCodeMapping.put(202, "Accepted");
|
||||
statusCodeMapping.put(203, "Non-Authoritative Information");
|
||||
statusCodeMapping.put(204, "No Content");
|
||||
statusCodeMapping.put(205, "Reset Content");
|
||||
statusCodeMapping.put(206, "Partial Content");
|
||||
statusCodeMapping.put(300, "Multiple Choices");
|
||||
statusCodeMapping.put(301, "Moved Permanently");
|
||||
statusCodeMapping.put(302, "Found");
|
||||
statusCodeMapping.put(303, "See Other");
|
||||
statusCodeMapping.put(304, "Not Modified");
|
||||
statusCodeMapping.put(307, "Temporary Redirect");
|
||||
statusCodeMapping.put(308, "Permanent Redirect");
|
||||
statusCodeMapping.put(400, "Bad Request");
|
||||
statusCodeMapping.put(401, "Unauthorized");
|
||||
statusCodeMapping.put(403, "Forbidden");
|
||||
statusCodeMapping.put(404, "Not Found");
|
||||
statusCodeMapping.put(405, "Method Not Allowed");
|
||||
statusCodeMapping.put(406, "Not Acceptable");
|
||||
statusCodeMapping.put(407, "Proxy Authentication Required");
|
||||
statusCodeMapping.put(408, "Request Timeout");
|
||||
statusCodeMapping.put(409, "Conflict");
|
||||
statusCodeMapping.put(410, "Gone");
|
||||
statusCodeMapping.put(411, "Length Required");
|
||||
statusCodeMapping.put(412, "Precondition Failed");
|
||||
statusCodeMapping.put(413, "Payload Too Large");
|
||||
statusCodeMapping.put(414, "URI Too Long");
|
||||
statusCodeMapping.put(415, "Unsupported Media Type");
|
||||
statusCodeMapping.put(416, "Range Not Satisfiable");
|
||||
statusCodeMapping.put(417, "Expectation Failed");
|
||||
statusCodeMapping.put(418, "I'm a teapot");
|
||||
statusCodeMapping.put(422, "Unprocessable Entity");
|
||||
statusCodeMapping.put(425, "Too Early");
|
||||
statusCodeMapping.put(426, "Upgrade Required");
|
||||
statusCodeMapping.put(428, "Precondition Required");
|
||||
statusCodeMapping.put(429, "Too Many Requests");
|
||||
statusCodeMapping.put(431, "Request Header Fields Too Large");
|
||||
statusCodeMapping.put(451, "Unavailable For Legal Reasons");
|
||||
statusCodeMapping.put(500, "Internal Server Error");
|
||||
statusCodeMapping.put(501, "Not Implemented");
|
||||
statusCodeMapping.put(502, "Bad Gateway");
|
||||
statusCodeMapping.put(503, "Service Unavailable");
|
||||
statusCodeMapping.put(504, "Gateway Timeout");
|
||||
statusCodeMapping.put(505, "HTTP Version Not Supported");
|
||||
statusCodeMapping.put(511, "Network Authentication Required");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -202,4 +270,53 @@ public class InAppBrowserWebViewClient extends WebViewClient {
|
|||
super.onReceivedHttpAuthRequest(view, handler, host, realm);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest (WebView view, WebResourceRequest request){
|
||||
final String url = request.getUrl().toString();
|
||||
|
||||
Request mRequest = new Request.Builder().url(url).build();
|
||||
|
||||
try {
|
||||
Response response = activity.httpClient.newCall(mRequest).execute();
|
||||
String reasonPhrase = response.message();
|
||||
if (reasonPhrase.equals("")) {
|
||||
reasonPhrase = statusCodeMapping.get(response.code());
|
||||
Log.d(LOG_TAG, reasonPhrase);
|
||||
}
|
||||
reasonPhrase = (reasonPhrase.equals("") || reasonPhrase == null) ? "OK" : reasonPhrase;
|
||||
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
for (Map.Entry<String, List<String>> entry : response.headers().toMultimap().entrySet()) {
|
||||
String value = "";
|
||||
for (String val: entry.getValue()) {
|
||||
value += (value == "") ? val : "; " + val;
|
||||
}
|
||||
headers.put(entry.getKey().toLowerCase(), value);
|
||||
}
|
||||
|
||||
Map<String, Object> obj = new HashMap<>();
|
||||
obj.put("uuid", activity.uuid);
|
||||
obj.put("url", url);
|
||||
obj.put("statusCode", response.code());
|
||||
obj.put("headers", headers);
|
||||
|
||||
InAppBrowserFlutterPlugin.channel.invokeMethod("onLoadResource", obj);
|
||||
|
||||
return new WebResourceResponse(
|
||||
response.header("content-type", "text/plain").split(";")[0].trim(),
|
||||
response.header("content-encoding"),
|
||||
response.code(),
|
||||
reasonPhrase,
|
||||
headers,
|
||||
response.body().byteStream()
|
||||
);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.d(LOG_TAG, e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class WebViewActivity extends AppCompatActivity {
|
||||
|
||||
|
@ -37,6 +38,7 @@ public class WebViewActivity extends AppCompatActivity {
|
|||
ProgressBar progressBar;
|
||||
public boolean isLoading = false;
|
||||
public boolean isHidden = false;
|
||||
OkHttpClient httpClient;
|
||||
|
||||
static final String jsConsoleLogScript = "(function() {\n"+
|
||||
" var oldLogs = {\n"+
|
||||
|
@ -87,6 +89,8 @@ public class WebViewActivity extends AppCompatActivity {
|
|||
|
||||
prepareWebView();
|
||||
|
||||
httpClient = new OkHttpClient();
|
||||
|
||||
webView.loadUrl(url, headers);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
|
||||
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||
|
@ -176,7 +175,7 @@
|
|||
97C146E61CF9000F007C117D /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0910;
|
||||
LastUpgradeCheck = 1000;
|
||||
ORGANIZATIONNAME = "The Chromium Authors";
|
||||
TargetAttributes = {
|
||||
97C146ED1CF9000F007C117D = {
|
||||
|
@ -211,7 +210,6 @@
|
|||
files = (
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
|
||||
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
|
||||
ED5EF13121506A3E0065FD45 /* WebView.storyboard in Resources */,
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
|
||||
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
|
||||
|
@ -336,12 +334,14 @@
|
|||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
|
@ -390,12 +390,14 @@
|
|||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0910"
|
||||
LastUpgradeVersion = "1000"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina5_5" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment version="4352" identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
|
@ -15,6 +13,10 @@
|
|||
<scene sceneID="PeV-E5-ivI">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="viewController" id="zfm-Ja-gep" customClass="InAppBrowserWebViewController" customModule="flutter_inappbrowser" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="eCU-xC-qdo"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="dUM-I7-PRF"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="ISu-6l-aO1">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
|
@ -22,14 +24,10 @@
|
|||
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="5cB-8U-Az3">
|
||||
<rect key="frame" x="206.66666666666666" y="367.66666666666669" width="1" height="1"/>
|
||||
</imageView>
|
||||
<wkWebView contentMode="scaleToFill" allowsBackForwardNavigationGestures="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gA9-n8-qaQ">
|
||||
<rect key="frame" x="0.0" y="67" width="414" height="625"/>
|
||||
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<wkWebViewConfiguration key="configuration" applicationNameForUserAgent="">
|
||||
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
|
||||
<wkPreferences key="preferences"/>
|
||||
</wkWebViewConfiguration>
|
||||
</wkWebView>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gA9-n8-qaQ" customClass="WKWebView_IBWrapper" customModule="flutter_inappbrowser">
|
||||
<rect key="frame" x="0.0" y="66" width="414" height="626"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</view>
|
||||
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="8Pf-5R-cFf" userLabel="Toolbar Bottom">
|
||||
<rect key="frame" x="0.0" y="692" width="414" height="44"/>
|
||||
<items>
|
||||
|
@ -43,7 +41,7 @@
|
|||
</items>
|
||||
</toolbar>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vlz-kT-71x" userLabel="Toolbar Top">
|
||||
<rect key="frame" x="0.0" y="20" width="414" height="47"/>
|
||||
<rect key="frame" x="0.0" y="20" width="414" height="46"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" contentMode="scaleToFill" horizontalCompressionResistancePriority="250" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="sy2-Vx-Cxd">
|
||||
<rect key="frame" x="8" y="8" width="351" height="30"/>
|
||||
|
@ -68,29 +66,28 @@
|
|||
</constraints>
|
||||
</view>
|
||||
<activityIndicatorView hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="HWt-17-FMf">
|
||||
<rect key="frame" x="197" y="369.66666666666669" width="20" height="20"/>
|
||||
<rect key="frame" x="197" y="369" width="20" height="20"/>
|
||||
</activityIndicatorView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="8Pf-5R-cFf" firstAttribute="top" secondItem="gA9-n8-qaQ" secondAttribute="bottom" id="5fJ-ST-ege"/>
|
||||
<constraint firstItem="5cB-8U-Az3" firstAttribute="centerY" secondItem="ISu-6l-aO1" secondAttribute="centerY" id="7gS-HV-ExU"/>
|
||||
<constraint firstItem="gA9-n8-qaQ" firstAttribute="leading" secondItem="F31-HP-PHQ" secondAttribute="leading" id="8YB-0N-UzE"/>
|
||||
<constraint firstItem="gA9-n8-qaQ" firstAttribute="trailing" secondItem="F31-HP-PHQ" secondAttribute="trailing" id="Dhn-ga-7dD"/>
|
||||
<constraint firstItem="gA9-n8-qaQ" firstAttribute="leading" secondItem="ISu-6l-aO1" secondAttribute="leading" id="8YB-0N-UzE"/>
|
||||
<constraint firstItem="gA9-n8-qaQ" firstAttribute="trailing" secondItem="ISu-6l-aO1" secondAttribute="trailing" id="Dhn-ga-7dD"/>
|
||||
<constraint firstItem="gA9-n8-qaQ" firstAttribute="bottom" secondItem="8Pf-5R-cFf" secondAttribute="top" id="KeI-jL-Qoi"/>
|
||||
<constraint firstItem="gA9-n8-qaQ" firstAttribute="trailing" secondItem="8Pf-5R-cFf" secondAttribute="trailing" id="OPR-aA-bxG"/>
|
||||
<constraint firstItem="vlz-kT-71x" firstAttribute="leading" secondItem="gA9-n8-qaQ" secondAttribute="leading" id="OZ2-Kx-4su"/>
|
||||
<constraint firstItem="8Pf-5R-cFf" firstAttribute="bottom" secondItem="F31-HP-PHQ" secondAttribute="bottom" id="Otv-w8-VOO"/>
|
||||
<constraint firstItem="gA9-n8-qaQ" firstAttribute="leading" secondItem="8Pf-5R-cFf" secondAttribute="leading" id="RGD-3l-ddR"/>
|
||||
<constraint firstItem="gA9-n8-qaQ" firstAttribute="top" secondItem="vlz-kT-71x" secondAttribute="bottom" id="Sjd-dV-din"/>
|
||||
<constraint firstItem="5cB-8U-Az3" firstAttribute="centerX" secondItem="ISu-6l-aO1" secondAttribute="centerX" id="Wh0-qC-IDM"/>
|
||||
<constraint firstItem="vlz-kT-71x" firstAttribute="trailing" secondItem="gA9-n8-qaQ" secondAttribute="trailing" id="XRo-VA-krE"/>
|
||||
<constraint firstItem="vlz-kT-71x" firstAttribute="top" secondItem="F31-HP-PHQ" secondAttribute="top" id="bWR-2T-bWy"/>
|
||||
<constraint firstItem="vlz-kT-71x" firstAttribute="top" secondItem="eCU-xC-qdo" secondAttribute="bottom" id="bWR-2T-bWy"/>
|
||||
<constraint firstItem="HWt-17-FMf" firstAttribute="centerX" secondItem="gA9-n8-qaQ" secondAttribute="centerX" id="dV8-Dm-9mc"/>
|
||||
<constraint firstItem="HWt-17-FMf" firstAttribute="centerY" secondItem="gA9-n8-qaQ" secondAttribute="centerY" id="pCx-Ia-kSL"/>
|
||||
<constraint firstItem="8Pf-5R-cFf" firstAttribute="bottom" secondItem="dUM-I7-PRF" secondAttribute="top" id="uVo-FW-XOM"/>
|
||||
<constraint firstAttribute="trailing" secondItem="vlz-kT-71x" secondAttribute="trailing" id="ugv-NZ-e6F"/>
|
||||
<constraint firstItem="vlz-kT-71x" firstAttribute="leading" secondItem="ISu-6l-aO1" secondAttribute="leading" id="yp6-RS-pBY"/>
|
||||
</constraints>
|
||||
<viewLayoutGuide key="safeArea" id="F31-HP-PHQ"/>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="backButton" destination="595-GQ-9lo" id="dvV-nO-BJ6"/>
|
||||
|
@ -102,7 +99,7 @@
|
|||
<outlet property="toolbarBottom" destination="8Pf-5R-cFf" id="Og7-Xw-2sq"/>
|
||||
<outlet property="toolbarTop" destination="vlz-kT-71x" id="WgC-80-Z28"/>
|
||||
<outlet property="urlField" destination="sy2-Vx-Cxd" id="MCW-lJ-Ehl"/>
|
||||
<outlet property="webView" destination="gA9-n8-qaQ" id="R0x-Ts-S58"/>
|
||||
<outlet property="webView" destination="gA9-n8-qaQ" id="7JE-lp-bwe"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="cYA-mw-BIR" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
|
|
@ -71,6 +71,13 @@ class MyInAppBrowser extends InAppBrowser {
|
|||
this.loadUrl(url);
|
||||
}
|
||||
|
||||
@override
|
||||
void onLoadResource(String url, int statusCode, Map<String, String> headers) {
|
||||
print("\n\n resource: $url\n\n");
|
||||
print(statusCode);
|
||||
print(headers);
|
||||
}
|
||||
|
||||
@override
|
||||
void onConsoleMessage(ConsoleMessage consoleMessage) {
|
||||
print("""
|
||||
|
|
|
@ -30,7 +30,7 @@ public class InAppBrowserOptions: Options {
|
|||
var presentationStyle = 0 //fullscreen
|
||||
var transitionStyle = 0 //crossDissolve
|
||||
var enableViewportScale = false
|
||||
var keyboardDisplayRequiresUserAction = true
|
||||
//var keyboardDisplayRequiresUserAction = true
|
||||
var suppressesIncrementalRendering = false
|
||||
var allowsAirPlayForMediaPlayback = true
|
||||
var allowsBackForwardNavigationGestures = true
|
||||
|
|
|
@ -92,8 +92,16 @@ extension WKWebView{
|
|||
|
||||
}
|
||||
|
||||
class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigationDelegate, UITextFieldDelegate, WKScriptMessageHandler {
|
||||
@IBOutlet var webView: WKWebView!
|
||||
class WKWebView_IBWrapper: WKWebView {
|
||||
required convenience init?(coder: NSCoder) {
|
||||
let config = WKWebViewConfiguration()
|
||||
self.init(frame: .zero, configuration: config)
|
||||
self.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
}
|
||||
|
||||
class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigationDelegate, UITextFieldDelegate, WKScriptMessageHandler, MyURLProtocolDelegate {
|
||||
@IBOutlet var webView: WKWebView_IBWrapper!
|
||||
@IBOutlet var closeButton: UIButton!
|
||||
@IBOutlet var reloadButton: UIBarButtonItem!
|
||||
@IBOutlet var backButton: UIBarButtonItem!
|
||||
|
@ -122,6 +130,15 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
|||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
URLProtocol.wk_registerScheme("http")
|
||||
URLProtocol.wk_registerScheme("https")
|
||||
|
||||
MyURLProtocol.URLProtocolDelegate = self
|
||||
|
||||
URLProtocol.registerClass(MyURLProtocol.self)
|
||||
|
||||
webView.uiDelegate = self
|
||||
webView.navigationDelegate = self
|
||||
|
||||
|
@ -237,7 +254,7 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
|||
let jscriptWebkitTouchCallout = WKUserScript(source: "document.body.style.webkitTouchCallout='none';", injectionTime: .atDocumentEnd, forMainFrameOnly: true)
|
||||
self.webView.configuration.userContentController.addUserScript(jscriptWebkitTouchCallout)
|
||||
|
||||
let jsConsoleLogScript = WKUserScript(source: jsConsoleLog, injectionTime: .atDocumentEnd, forMainFrameOnly: true)
|
||||
let jsConsoleLogScript = WKUserScript(source: jsConsoleLog, injectionTime: .atDocumentStart, forMainFrameOnly: false)
|
||||
self.webView.configuration.userContentController.addUserScript(jsConsoleLogScript)
|
||||
self.webView.configuration.userContentController.add(self, name: "consoleLog")
|
||||
self.webView.configuration.userContentController.add(self, name: "consoleDebug")
|
||||
|
@ -259,7 +276,9 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
|||
|
||||
|
||||
self.webView.configuration.allowsInlineMediaPlayback = (browserOptions?.allowsInlineMediaPlayback)!
|
||||
self.webView.keyboardDisplayRequiresUserAction = browserOptions?.keyboardDisplayRequiresUserAction
|
||||
|
||||
//self.webView.keyboardDisplayRequiresUserAction = browserOptions?.keyboardDisplayRequiresUserAction
|
||||
|
||||
self.webView.configuration.suppressesIncrementalRendering = (browserOptions?.suppressesIncrementalRendering)!
|
||||
self.webView.allowsBackForwardNavigationGestures = (browserOptions?.allowsBackForwardNavigationGestures)!
|
||||
if #available(iOS 9.0, *) {
|
||||
|
@ -469,6 +488,16 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
|||
decisionHandler(.allow)
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView,
|
||||
decidePolicyFor navigationResponse: WKNavigationResponse,
|
||||
decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
||||
|
||||
//dump((navigationResponse.response as! HTTPURLResponse))
|
||||
//print(navigationResponse.response.mimeType)
|
||||
//print(navigationResponse.response.url)
|
||||
decisionHandler(.allow)
|
||||
}
|
||||
|
||||
// func webView(_ webView: WKWebView,
|
||||
// decidePolicyFor navigationResponse: WKNavigationResponse,
|
||||
// decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
||||
|
@ -518,9 +547,6 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
|||
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||
// update url, stop spinner, update back/forward
|
||||
|
||||
// evaluate the console log script
|
||||
webView.evaluateJavaScript(jsConsoleLog)
|
||||
|
||||
currentURL = webView.url
|
||||
updateUrlTextField(url: (currentURL?.absoluteString)!)
|
||||
backButton.isEnabled = webView.canGoBack
|
||||
|
@ -529,15 +555,11 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
|||
navigationDelegate?.onLoadStop(uuid: self.uuid, webView: webView)
|
||||
}
|
||||
|
||||
// func webView(_ webView: WKWebView,
|
||||
// didFailProvisionalNavigation navigation: WKNavigation!,
|
||||
// withError error: Error) {
|
||||
// print("webView:didFailProvisionalNavigationWithError - \(Int(error._code)): \(error.localizedDescription)")
|
||||
// backButton.isEnabled = webView.canGoBack
|
||||
// forwardButton.isEnabled = webView.canGoForward
|
||||
// spinner.stopAnimating()
|
||||
// navigationDelegate?.webView(uuid: self.uuid, webView: webView, didFailLoadWithError: error)
|
||||
// }
|
||||
func webView(_ view: WKWebView,
|
||||
didFailProvisionalNavigation navigation: WKNavigation!,
|
||||
withError error: Error) {
|
||||
webView(view, didFail: navigation, withError: error)
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
|
||||
print("webView:didFailNavigationWithError - \(Int(error._code)): \(error.localizedDescription)")
|
||||
|
@ -547,8 +569,11 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
|||
navigationDelegate?.onLoadError(uuid: self.uuid, webView: webView, error: error)
|
||||
}
|
||||
|
||||
func didReceiveResponse(_ response: URLResponse, from request: URLRequest?) {
|
||||
navigationDelegate?.onLoadResource(uuid: self.uuid, webView: webView, response: response)
|
||||
}
|
||||
|
||||
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
|
||||
print(message.name)
|
||||
if message.name.starts(with: "console") {
|
||||
var messageLevel = "LOG"
|
||||
switch (message.name) {
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
//
|
||||
// MyURLProtocol.swift
|
||||
// Pods
|
||||
//
|
||||
// Created by Lorenzo on 12/10/18.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class MyURLProtocol: URLProtocol {
|
||||
|
||||
struct Constants {
|
||||
static let RequestHandledKey = "URLProtocolRequestHandled"
|
||||
}
|
||||
|
||||
var session: URLSession?
|
||||
var sessionTask: URLSessionDataTask?
|
||||
static var URLProtocolDelegate: MyURLProtocolDelegate?
|
||||
|
||||
override init(request: URLRequest, cachedResponse: CachedURLResponse?, client: URLProtocolClient?) {
|
||||
super.init(request: request, cachedResponse: cachedResponse, client: client)
|
||||
|
||||
if session == nil {
|
||||
session = URLSession(configuration: .default, delegate: self, delegateQueue: nil)
|
||||
}
|
||||
}
|
||||
|
||||
override class func canInit(with request: URLRequest) -> Bool {
|
||||
if MyURLProtocol.property(forKey: Constants.RequestHandledKey, in: request) != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override class func canonicalRequest(for request: URLRequest) -> URLRequest {
|
||||
return request
|
||||
}
|
||||
|
||||
override func startLoading() {
|
||||
let newRequest = ((request as NSURLRequest).mutableCopy() as? NSMutableURLRequest)!
|
||||
MyURLProtocol.setProperty(true, forKey: Constants.RequestHandledKey, in: newRequest)
|
||||
sessionTask = session?.dataTask(with: newRequest as URLRequest)
|
||||
sessionTask?.resume()
|
||||
}
|
||||
|
||||
override func stopLoading() {
|
||||
sessionTask?.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
extension MyURLProtocol: URLSessionDataDelegate {
|
||||
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
|
||||
client?.urlProtocol(self, didLoad: data)
|
||||
}
|
||||
|
||||
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) {
|
||||
let policy = URLCache.StoragePolicy(rawValue: request.cachePolicy.rawValue) ?? .notAllowed
|
||||
client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: policy)
|
||||
MyURLProtocol.URLProtocolDelegate?.didReceiveResponse(response, from: dataTask.currentRequest)
|
||||
completionHandler(.allow)
|
||||
}
|
||||
|
||||
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
|
||||
if let error = error {
|
||||
client?.urlProtocol(self, didFailWithError: error)
|
||||
} else {
|
||||
client?.urlProtocolDidFinishLoading(self)
|
||||
}
|
||||
}
|
||||
|
||||
func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) {
|
||||
client?.urlProtocol(self, wasRedirectedTo: request, redirectResponse: response)
|
||||
completionHandler(request)
|
||||
}
|
||||
|
||||
func urlSession(_ session: URLSession, didBecomeInvalidWithError error: Error?) {
|
||||
guard let error = error else { return }
|
||||
client?.urlProtocol(self, didFailWithError: error)
|
||||
}
|
||||
|
||||
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||
let protectionSpace = challenge.protectionSpace
|
||||
let sender = challenge.sender
|
||||
|
||||
if protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
|
||||
if let serverTrust = protectionSpace.serverTrust {
|
||||
let credential = URLCredential(trust: serverTrust)
|
||||
sender?.use(credential, for: challenge)
|
||||
completionHandler(.useCredential, credential)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func urlSessionDidFinishEvents(forBackgroundURLSession session: URLSession) {
|
||||
client?.urlProtocolDidFinishLoading(self)
|
||||
}
|
||||
}
|
||||
|
||||
protocol MyURLProtocolDelegate {
|
||||
func didReceiveResponse(_ response: URLResponse, from request: URLRequest?)
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// NSURLProtocol+WKWebVIew.h
|
||||
// Pods
|
||||
//
|
||||
// Created by Lorenzo on 11/10/18.
|
||||
//
|
||||
|
||||
#ifndef NSURLProtocol_WKWebVIew_h
|
||||
#define NSURLProtocol_WKWebVIew_h
|
||||
|
||||
|
||||
#endif /* NSURLProtocol_WKWebVIew_h */
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSURLProtocol (WKWebVIew)
|
||||
|
||||
+ (void)wk_registerScheme:(NSString*)scheme;
|
||||
|
||||
+ (void)wk_unregisterScheme:(NSString*)scheme;
|
||||
|
||||
|
||||
@end
|
|
@ -0,0 +1,54 @@
|
|||
//
|
||||
// NSURLProtocol+WKWebVIew.m
|
||||
// Pods
|
||||
//
|
||||
// Created by Lorenzo on 11/10/18.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "NSURLProtocol+WKWebVIew.h"
|
||||
#import <WebKit/WebKit.h>
|
||||
//FOUNDATION_STATIC_INLINE 属于属于runtime范畴,你的.m文件需要频繁调用一个函数,可以用static inline来声明。从SDWebImage从get到的。
|
||||
FOUNDATION_STATIC_INLINE Class ContextControllerClass() {
|
||||
static Class cls;
|
||||
if (!cls) {
|
||||
cls = [[[WKWebView new] valueForKey:@"browsingContextController"] class];
|
||||
}
|
||||
return cls;
|
||||
}
|
||||
|
||||
FOUNDATION_STATIC_INLINE SEL RegisterSchemeSelector() {
|
||||
return NSSelectorFromString(@"registerSchemeForCustomProtocol:");
|
||||
}
|
||||
|
||||
FOUNDATION_STATIC_INLINE SEL UnregisterSchemeSelector() {
|
||||
return NSSelectorFromString(@"unregisterSchemeForCustomProtocol:");
|
||||
}
|
||||
|
||||
@implementation NSURLProtocol (WebKitSupport)
|
||||
|
||||
+ (void)wk_registerScheme:(NSString *)scheme {
|
||||
Class cls = ContextControllerClass();
|
||||
SEL sel = RegisterSchemeSelector();
|
||||
if ([(id)cls respondsToSelector:sel]) {
|
||||
// 放弃编辑器警告
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
[(id)cls performSelector:sel withObject:scheme];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)wk_unregisterScheme:(NSString *)scheme {
|
||||
Class cls = ContextControllerClass();
|
||||
SEL sel = UnregisterSchemeSelector();
|
||||
if ([(id)cls respondsToSelector:sel]) {
|
||||
// 放弃编辑器警告
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
[(id)cls performSelector:sel withObject:scheme];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -25,6 +25,14 @@ import SafariServices
|
|||
let WEBVIEW_STORYBOARD = "WebView"
|
||||
let WEBVIEW_STORYBOARD_CONTROLLER_ID = "viewController"
|
||||
|
||||
extension Dictionary where Key: ExpressibleByStringLiteral {
|
||||
public mutating func lowercaseKeys() {
|
||||
for key in self.keys {
|
||||
self[String(describing: key).lowercased() as! Key] = self.removeValue(forKey: key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
||||
var webViewControllers: [String: InAppBrowserWebViewController?] = [:]
|
||||
var safariViewControllers: [String: Any?] = [:]
|
||||
|
@ -481,6 +489,21 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
func onLoadResource(uuid: String, webView: WKWebView, response: URLResponse) {
|
||||
if self.webViewControllers[uuid] != nil {
|
||||
var headers = (response as! HTTPURLResponse).allHeaderFields as! [String: String]
|
||||
headers.lowercaseKeys()
|
||||
|
||||
let arguments: [String : Any] = [
|
||||
"uuid": uuid,
|
||||
"url": response.url?.absoluteString ?? "",
|
||||
"statusCode": (response as! HTTPURLResponse).statusCode,
|
||||
"headers": headers
|
||||
]
|
||||
channel.invokeMethod("onLoadResource", arguments: arguments)
|
||||
}
|
||||
}
|
||||
|
||||
func onExit(uuid: String) {
|
||||
channel.invokeMethod("onExit", arguments: ["uuid": uuid])
|
||||
}
|
||||
|
|
|
@ -106,6 +106,12 @@ class InAppBrowser {
|
|||
String url = call.arguments["url"];
|
||||
shouldOverrideUrlLoading(url);
|
||||
break;
|
||||
case "onLoadResource":
|
||||
String url = call.arguments["url"];
|
||||
int statusCode = call.arguments["statusCode"];
|
||||
Map<dynamic, dynamic> headers = call.arguments["headers"];
|
||||
onLoadResource(url, statusCode, headers.cast<String, String>());
|
||||
break;
|
||||
case "onConsoleMessage":
|
||||
String sourceURL = call.arguments["sourceURL"];
|
||||
int lineNumber = call.arguments["lineNumber"];
|
||||
|
@ -173,7 +179,6 @@ class InAppBrowser {
|
|||
/// - __presentationStyle__: Set the custom modal presentation style when presenting the WebView. The default value is `0 //fullscreen`. See [UIModalPresentationStyle](https://developer.apple.com/documentation/uikit/uimodalpresentationstyle) for all the available styles.
|
||||
/// - __transitionStyle__: Set to the custom transition style when presenting the WebView. The default value is `0 //crossDissolve`. See [UIModalTransitionStyle](https://developer.apple.com/documentation/uikit/uimodaltransitionStyle) for all the available styles.
|
||||
/// - __enableViewportScale__: Set to `true` to allow a viewport meta tag to either disable or restrict the range of user scaling. The default value is `false`.
|
||||
/// - __keyboardDisplayRequiresUserAction__: Set to `true` if you want the user must explicitly tap the elements in the WebView to display the keyboard (or other relevant input view) for that element. When set to `false`, a focus event on an element causes the input view to be displayed and associated with that element automatically. The default value is `true`.
|
||||
/// - __suppressesIncrementalRendering__: Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory.. The default value is `false`.
|
||||
/// - __allowsAirPlayForMediaPlayback__: Set to `true` to allow AirPlay. The default value is `true`.
|
||||
/// - __allowsBackForwardNavigationGestures__: Set to `true` to allow the horizontal swipe gestures trigger back-forward list navigations. The default value is `true`.
|
||||
|
@ -323,6 +328,11 @@ class InAppBrowser {
|
|||
|
||||
}
|
||||
|
||||
///Event fires when the [InAppBrowser] webview will load the resource specified by the given [url].
|
||||
void onLoadResource(String url, int statusCode, Map<String, String> headers) {
|
||||
|
||||
}
|
||||
|
||||
///Event fires when the [InAppBrowser] webview receives a [ConsoleMessage].
|
||||
void onConsoleMessage(ConsoleMessage consoleMessage) {
|
||||
|
||||
|
@ -392,7 +402,6 @@ class ChromeSafariBrowser {
|
|||
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>{};
|
||||
args.putIfAbsent('uuid', () => uuid);
|
||||
print(browserFallback.uuid);
|
||||
args.putIfAbsent('uuidFallback', () => (browserFallback != null) ? browserFallback.uuid : '');
|
||||
args.putIfAbsent('url', () => url);
|
||||
args.putIfAbsent('headers', () => headersFallback);
|
||||
|
|
Loading…
Reference in New Issue