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
7a57f80f
Commit
7a57f80f
authored
Nov 25, 2019
by
Lorenzo Pichilli
Committed by
GitHub
Nov 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update InAppWebChromeClient.java
parent
7c5b1a1c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
505 additions
and
480 deletions
+505
-480
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebChromeClient.java
...utter_inappbrowser/InAppWebView/InAppWebChromeClient.java
+505
-480
No files found.
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebChromeClient.java
View file @
7a57f80f
...
...
@@ -9,6 +9,7 @@ import android.graphics.BitmapFactory;
import
android.graphics.Color
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Message
;
import
android.util.Log
;
import
android.view.View
;
import
android.webkit.ConsoleMessage
;
...
...
@@ -18,6 +19,7 @@ import android.webkit.JsResult;
import
android.webkit.ValueCallback
;
import
android.webkit.WebChromeClient
;
import
android.webkit.WebView
;
import
android.webkit.WebViewClient
;
import
android.widget.EditText
;
import
android.widget.FrameLayout
;
import
android.widget.LinearLayout
;
...
...
@@ -38,7 +40,7 @@ import io.flutter.plugin.common.PluginRegistry;
import
static
android
.
app
.
Activity
.
RESULT_CANCELED
;
import
static
android
.
app
.
Activity
.
RESULT_OK
;
public
class
InAppWebChromeClient
extends
WebChromeClient
implements
PluginRegistry
.
ActivityResultListener
{
public
class
InAppWeb
View
ChromeClient
extends
WebChromeClient
implements
PluginRegistry
.
ActivityResultListener
{
protected
static
final
String
LOG_TAG
=
"IABWebChromeClient"
;
private
PluginRegistry
.
Registrar
registrar
;
...
...
@@ -49,11 +51,10 @@ public class InAppWebChromeClient extends WebChromeClient implements PluginRegis
private
View
mCustomView
;
private
WebChromeClient
.
CustomViewCallback
mCustomViewCallback
;
protected
FrameLayout
mFullscreenContainer
;
private
int
mOriginalOrientation
;
private
int
mOriginalSystemUiVisibility
;
public
InAppWeb
ChromeClient
(
Object
obj
,
PluginRegistry
.
Registrar
registrar
)
{
public
InAppWebView
ChromeClient
(
Object
obj
,
PluginRegistry
.
Registrar
registrar
)
{
super
();
this
.
registrar
=
registrar
;
if
(
obj
instanceof
InAppBrowserActivity
)
...
...
@@ -394,12 +395,40 @@ public class InAppWebChromeClient extends WebChromeClient implements PluginRegis
}
@Override
public
boolean
onCreateWindow
(
WebView
view
,
boolean
dialog
,
boolean
userGesture
,
android
.
os
.
Message
resultMsg
)
{
WebView
.
HitTestResult
result
=
view
.
getHitTestResult
();
String
data
=
result
.
getExtra
();
Map
<
String
,
Object
>
obj
=
new
HashMap
<>();
public
boolean
onCreateWindow
(
WebView
view
,
boolean
isDialog
,
boolean
userGesture
,
final
Message
resultMsg
)
{
final
Map
<
String
,
Object
>
obj
=
new
HashMap
<>();
if
(
inAppBrowserActivity
!=
null
)
obj
.
put
(
"uuid"
,
inAppBrowserActivity
.
uuid
);
WebView
.
HitTestResult
result
=
view
.
getHitTestResult
();
String
data
=
result
.
getExtra
();
if
(
data
==
null
)
{
// to get the URL, create a temp weview
final
WebView
newWebView
=
new
WebView
(
view
.
getContext
());
// disable javascript
newWebView
.
getSettings
().
setJavaScriptEnabled
(
false
);
newWebView
.
setWebViewClient
(
new
WebViewClient
(){
@Override
public
void
onPageStarted
(
WebView
v
,
String
url
,
Bitmap
favicon
)
{
super
.
onPageStarted
(
v
,
url
,
favicon
);
obj
.
put
(
"url"
,
url
);
getChannel
().
invokeMethod
(
"onTargetBlank"
,
obj
);
// stop webview loading
v
.
stopLoading
();
// this will throw the error "Application attempted to call on a destroyed AwAutofillManager" that will kill the webview.
// that's ok.
v
.
destroy
();
}
});
((
WebView
.
WebViewTransport
)
resultMsg
.
obj
).
setWebView
(
newWebView
);
resultMsg
.
sendToTarget
();
return
true
;
}
obj
.
put
(
"url"
,
data
);
getChannel
().
invokeMethod
(
"onTargetBlank"
,
obj
);
return
false
;
...
...
@@ -438,8 +467,6 @@ public class InAppWebChromeClient extends WebChromeClient implements PluginRegis
Map
<
String
,
Object
>
obj
=
new
HashMap
<>();
if
(
inAppBrowserActivity
!=
null
)
obj
.
put
(
"uuid"
,
inAppBrowserActivity
.
uuid
);
obj
.
put
(
"sourceURL"
,
consoleMessage
.
sourceId
());
obj
.
put
(
"lineNumber"
,
consoleMessage
.
lineNumber
());
obj
.
put
(
"message"
,
consoleMessage
.
message
());
obj
.
put
(
"messageLevel"
,
consoleMessage
.
messageLevel
().
ordinal
());
getChannel
().
invokeMethod
(
"onConsoleMessage"
,
obj
);
...
...
@@ -516,9 +543,7 @@ public class InAppWebChromeClient extends WebChromeClient implements PluginRegis
}
//For Android 5.0+
public
boolean
onShowFileChooser
(
WebView
webView
,
ValueCallback
<
Uri
[]>
filePathCallback
,
FileChooserParams
fileChooserParams
)
{
public
boolean
onShowFileChooser
(
WebView
webView
,
ValueCallback
<
Uri
[]>
filePathCallback
,
FileChooserParams
fileChooserParams
)
{
InAppBrowserFlutterPlugin
.
uploadMessageArray
=
filePathCallback
;
try
{
Intent
contentSelectionIntent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
...
...
@@ -542,7 +567,7 @@ public class InAppWebChromeClient extends WebChromeClient implements PluginRegis
@TargetApi
(
Build
.
VERSION_CODES
.
LOLLIPOP
)
@Override
public
boolean
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
requestCode
==
FILECHOOSER_RESULTCODE
&&
(
resultCode
==
RESULT_OK
||
resultCode
==
RESULT_CANCELED
)
&&
InAppBrowserFlutterPlugin
.
uploadMessageArray
!=
null
)
{
if
(
requestCode
==
FILECHOOSER_RESULTCODE
&&
(
resultCode
==
RESULT_OK
||
resultCode
==
RESULT_CANCELED
)
)
{
InAppBrowserFlutterPlugin
.
uploadMessageArray
.
onReceiveValue
(
WebChromeClient
.
FileChooserParams
.
parseResult
(
resultCode
,
data
));
}
return
true
;
...
...
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