Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Flutter Inappwebview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
Flutter Inappwebview
Commits
4d3a1789
Commit
4d3a1789
authored
6 years ago
by
pichillilorenzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed webview closing on android
parent
aa583ad6
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
402 additions
and
284 deletions
+402
-284
.idea/workspace.xml
.idea/workspace.xml
+107
-63
CHANGELOG.md
CHANGELOG.md
+7
-0
README.md
README.md
+167
-93
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java
...renzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java
+2
-2
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserOptions.java
...illilorenzo/flutter_inappbrowser/InAppBrowserOptions.java
+9
-8
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/WebViewActivity.java
...pichillilorenzo/flutter_inappbrowser/WebViewActivity.java
+10
-11
android/src/main/res/layout/activity_web_view.xml
android/src/main/res/layout/activity_web_view.xml
+14
-13
example/lib/main.dart
example/lib/main.dart
+12
-10
ios/Classes/InAppBrowserOptions.swift
ios/Classes/InAppBrowserOptions.swift
+10
-10
ios/Classes/InAppBrowserWebViewController.swift
ios/Classes/InAppBrowserWebViewController.swift
+11
-20
lib/flutter_inappbrowser.dart
lib/flutter_inappbrowser.dart
+51
-52
pubspec.yaml
pubspec.yaml
+2
-2
No files found.
.idea/workspace.xml
View file @
4d3a1789
This diff is collapsed.
Click to expand it.
CHANGELOG.md
View file @
4d3a1789
## 0.1.0
-
updated/added new methods
-
updated UI of android/iOS in-app browser
-
code cleanup
-
added new options when opening the in-app browser
## 0.0.1
Initial release.
This diff is collapsed.
Click to expand it.
README.md
View file @
4d3a1789
This diff is collapsed.
Click to expand it.
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java
View file @
4d3a1789
...
...
@@ -436,8 +436,8 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
}
public
void
close
()
{
this
.
activity
.
runOnUiThread
(
new
Runnable
()
{
public
static
void
close
()
{
registrar
.
activity
()
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
This diff is collapsed.
Click to expand it.
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserOptions.java
View file @
4d3a1789
...
...
@@ -9,27 +9,28 @@ import java.util.HashMap;
public
class
InAppBrowserOptions
{
boolean
useShouldOverrideUrlLoading
=
false
;
boolean
clearCache
=
false
;
boolean
clearSessionCache
=
false
;
String
userAgent
=
""
;
boolean
progressBar
=
true
;
boolean
javaScriptEnabled
=
true
;
boolean
javaScriptCanOpenWindowsAutomatically
=
false
;
boolean
hidden
=
false
;
boolean
toolbarTop
=
true
;
String
toolbarTopBackgroundColor
=
""
;
String
toolbarTopFixedTitle
=
""
;
boolean
hideUrlBar
=
false
;
boolean
mediaPlaybackRequiresUserGesture
=
true
;
boolean
hideTitleBar
=
false
;
boolean
closeOnCannotGoBack
=
true
;
boolean
mediaPlaybackRequiresUserGesture
=
true
;
boolean
javaScriptCanOpenWindowsAutomatically
=
false
;
boolean
javaScriptEnabled
=
true
;
boolean
clearSessionCache
=
false
;
boolean
builtInZoomControls
=
false
;
boolean
supportZoom
=
true
;
boolean
databaseEnabled
=
tru
e
;
boolean
domStorageEnabled
=
tru
e
;
boolean
databaseEnabled
=
fals
e
;
boolean
domStorageEnabled
=
fals
e
;
boolean
useWideViewPort
=
true
;
boolean
safeBrowsingEnabled
=
true
;
boolean
useShouldOverrideUrlLoading
=
fals
e
;
boolean
progressBar
=
tru
e
;
public
void
parse
(
HashMap
<
String
,
Object
>
options
)
{
Iterator
it
=
options
.
entrySet
().
iterator
();
...
...
This diff is collapsed.
Click to expand it.
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/WebViewActivity.java
View file @
4d3a1789
...
...
@@ -143,10 +143,8 @@ public class WebViewActivity extends AppCompatActivity {
else
settings
.
setTextZoom
(
100
);
if
(
options
.
progressBar
)
{
if
(
options
.
progressBar
)
progressBar
=
findViewById
(
R
.
id
.
progressBar
);
progressBar
.
setMax
(
100
);
}
actionBar
.
setDisplayShowTitleEnabled
(!
options
.
hideTitleBar
);
...
...
@@ -242,13 +240,14 @@ public class WebViewActivity extends AppCompatActivity {
if
(
canGoBack
())
goBack
();
else
if
(
options
.
closeOnCannotGoBack
)
close
();
InAppBrowserFlutterPlugin
.
close
();
return
true
;
}
return
super
.
onKeyDown
(
keyCode
,
event
);
}
public
void
close
()
{
hide
();
finish
();
}
...
...
@@ -277,15 +276,15 @@ public class WebViewActivity extends AppCompatActivity {
public
void
hide
()
{
isHidden
=
true
;
Intent
open
MainActivity
=
new
Intent
(
this
,
InAppBrowserFlutterPlugin
.
registrar
.
activity
().
getClass
());
open
Main
Activity
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
);
startActivityIfNeeded
(
open
Main
Activity
,
0
);
Intent
open
Activity
=
new
Intent
(
this
,
InAppBrowserFlutterPlugin
.
registrar
.
activity
().
getClass
());
openActivity
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
);
startActivityIfNeeded
(
openActivity
,
0
);
}
public
void
show
()
{
isHidden
=
false
;
Intent
open
MainActivity
=
new
Intent
(
InAppBrowserFlutterPlugin
.
registrar
.
activity
(),
WebViewActivity
.
class
);
open
Main
Activity
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
);
startActivityIfNeeded
(
open
Main
Activity
,
0
);
Intent
open
Activity
=
new
Intent
(
InAppBrowserFlutterPlugin
.
registrar
.
activity
(),
WebViewActivity
.
class
);
openActivity
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
);
startActivityIfNeeded
(
openActivity
,
0
);
}
public
void
stopLoading
(){
...
...
@@ -338,7 +337,7 @@ public class WebViewActivity extends AppCompatActivity {
}
public
void
closeButtonClicked
(
MenuItem
item
)
{
close
();
InAppBrowserFlutterPlugin
.
close
();
}
}
This diff is collapsed.
Click to expand it.
android/src/main/res/layout/activity_web_view.xml
View file @
4d3a1789
<?xml version="1.0" encoding="utf-8"?>
<
Linear
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
Relative
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:clickable=
"true"
android:focusableInTouchMode=
"true"
android:orientation=
"vertical"
tools:context=
".WebViewActivity"
>
tools:context=
".WebViewActivity"
android:focusable=
"true"
>
<WebView
android:id=
"@+id/webView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
</WebView>
<ProgressBar
android:id=
"@+id/progressBar"
style=
"@android:style/Widget.Holo.ProgressBar.Horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"3dp"
android:layout_gravity=
"top"
android:progress=
"0"
android:visibility=
"gone"
/>
<WebView
android:id=
"@+id/webView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"5dp"
android:max=
"100"
android:progress=
"0"
/>
</
Linear
Layout>
</
Relative
Layout>
This diff is collapsed.
Click to expand it.
example/lib/main.dart
View file @
4d3a1789
...
...
@@ -29,17 +29,19 @@ class MyInAppBrowser extends InAppBrowser {
// x;
// """));
//print("\n\n ${await this.isHidden()} \n\n");
/*this.injectScriptFile("https://code.jquery.com/jquery-3.3.1.min.js");
this.injectScriptCode("""
\$( "body" ).html( "Next Step..." )
""");
this.injectStyleCode("""
body {
background-color: #3c3c3c !important;
}
""");
this.injectStyleFile("https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css");*/
// await this.injectScriptFile("https://code.jquery.com/jquery-3.3.1.min.js");
// this.injectScriptCode("""
// \$( "body" ).html( "Next Step..." )
// """);
//
// // add custom css
// this.injectStyleCode("""
// body {
// background-color: #3c3c3c !important;
// }
// """);
// this.injectStyleFile("https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css");
}
@override
...
...
This diff is collapsed.
Click to expand it.
ios/Classes/InAppBrowserOptions.swift
View file @
4d3a1789
...
...
@@ -10,35 +10,35 @@ import Foundation
@objcMembers
public
class
InAppBrowserOptions
:
NSObject
{
var
closeButtonCaption
=
""
var
closeButtonColor
=
""
var
useShouldOverrideUrlLoading
=
false
var
clearCache
=
false
var
userAgent
=
""
var
spinner
=
true
var
javaScriptEnabled
=
true
var
javaScriptCanOpenWindowsAutomatically
=
false
var
hidden
=
false
var
disallowOverScroll
=
false
var
toolbarTop
=
true
var
toolbarTopBackgroundColor
=
""
var
toolbarTopTranslucent
=
true
var
hideUrlBar
=
false
var
mediaPlaybackRequiresUserGesture
=
true
var
disallowOverScroll
=
false
var
toolbarBottom
=
true
var
toolbarBottomBackgroundColor
=
""
var
toolbarBottomTranslucent
=
true
var
hideUrlBar
=
false
var
closeButtonCaption
=
""
var
closeButtonColor
=
""
var
presentationStyle
=
0
//fullscreen
var
transitionStyle
=
0
//crossDissolve
var
enableViewportScale
=
false
var
keyboardDisplayRequiresUserAction
=
true
var
suppressesIncrementalRendering
=
false
var
allowsAirPlayForMediaPlayback
=
true
var
mediaTypesRequiringUserActionForPlayback
=
"none"
var
allowsBackForwardNavigationGestures
=
true
var
allowsLinkPreview
=
true
var
ignoresViewportScaleLimits
=
false
var
allowsInlineMediaPlayback
=
false
var
allowsPictureInPictureMediaPlayback
=
true
var
javaScriptCanOpenWindowsAutomatically
=
false
var
javaScriptEnabled
=
true
var
useShouldOverrideUrlLoading
=
false
var
spinner
=
true
override
init
(){
super
.
init
()
...
...
This diff is collapsed.
Click to expand it.
ios/Classes/InAppBrowserWebViewController.swift
View file @
4d3a1789
...
...
@@ -206,29 +206,20 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
let
jscriptWebkitTouchCallout
=
WKUserScript
(
source
:
"document.body.style.webkitTouchCallout='none';"
,
injectionTime
:
.
atDocumentEnd
,
forMainFrameOnly
:
true
)
self
.
webView
.
configuration
.
userContentController
.
addUserScript
(
jscriptWebkitTouchCallout
)
if
(
browserOptions
?
.
mediaTypesRequiringUserActionForPlayback
)
!
!=
""
{
if
#available(iOS 10.0, *)
{
switch
(
browserOptions
?
.
mediaTypesRequiringUserActionForPlayback
)
!
{
case
"all"
:
self
.
webView
.
configuration
.
mediaTypesRequiringUserActionForPlayback
=
.
all
break
case
"audio"
:
self
.
webView
.
configuration
.
mediaTypesRequiringUserActionForPlayback
=
.
audio
break
case
"video"
:
self
.
webView
.
configuration
.
mediaTypesRequiringUserActionForPlayback
=
.
video
break
default
:
self
.
webView
.
configuration
.
mediaTypesRequiringUserActionForPlayback
=
[]
break
}
}
else
{
// Fallback on earlier versions
self
.
webView
.
configuration
.
mediaPlaybackRequiresUserAction
=
true
if
#available(iOS 10.0, *)
{
if
(
browserOptions
?
.
mediaPlaybackRequiresUserGesture
)
!
{
self
.
webView
.
configuration
.
mediaTypesRequiringUserActionForPlayback
=
.
all
}
else
{
self
.
webView
.
configuration
.
mediaTypesRequiringUserActionForPlayback
=
[]
}
}
else
{
// Fallback on earlier versions
self
.
webView
.
configuration
.
mediaPlaybackRequiresUserAction
=
(
browserOptions
?
.
mediaPlaybackRequiresUserGesture
)
!
}
self
.
webView
.
configuration
.
allowsInlineMediaPlayback
=
(
browserOptions
?
.
allowsInlineMediaPlayback
)
!
self
.
webView
.
keyboardDisplayRequiresUserAction
=
browserOptions
?
.
keyboardDisplayRequiresUserAction
self
.
webView
.
configuration
.
suppressesIncrementalRendering
=
(
browserOptions
?
.
suppressesIncrementalRendering
)
!
...
...
This diff is collapsed.
Click to expand it.
lib/flutter_inappbrowser.dart
View file @
4d3a1789
This diff is collapsed.
Click to expand it.
pubspec.yaml
View file @
4d3a1789
name
:
flutter_inappbrowser
description
:
A Flutter plugin that allows you to open an in-app browser window. (
porting of
the popular cordova-plugin-inappbrowser).
version
:
0.
0.1
description
:
A Flutter plugin that allows you to open an in-app browser window. (
inspired by
the popular cordova-plugin-inappbrowser).
version
:
0.
1.0
author
:
Lorenzo Pichilli <pichillilorenzo@gmail.com>
homepage
:
https://github.com/pichillilorenzo/flutter_inappbrowser
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment