expose contentdisposition and contentlength from android
This commit is contained in:
parent
f06bcdf695
commit
8f43faf832
|
@ -1184,6 +1184,10 @@ final public class InAppWebView extends InputAwareWebView {
|
||||||
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
|
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
|
||||||
Map<String, Object> obj = new HashMap<>();
|
Map<String, Object> obj = new HashMap<>();
|
||||||
obj.put("url", url);
|
obj.put("url", url);
|
||||||
|
obj.put("userAgent", userAgent);
|
||||||
|
obj.put("contentDisposition", contentDisposition);
|
||||||
|
obj.put("mimetype", mimetype);
|
||||||
|
obj.put("contentLength", contentLength);
|
||||||
channel.invokeMethod("onDownloadStart", obj);
|
channel.invokeMethod("onDownloadStart", obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2739,7 +2739,7 @@ void main() {
|
||||||
onWebViewCreated: (controller) {
|
onWebViewCreated: (controller) {
|
||||||
controllerCompleter.complete(controller);
|
controllerCompleter.complete(controller);
|
||||||
},
|
},
|
||||||
onDownloadStart: (controller, url) {
|
onDownloadStart:(controller, url, userAgent, contentDisposition, mimeType, contentLength) {
|
||||||
onDownloadStartCompleter.complete(url.toString());
|
onDownloadStartCompleter.complete(url.toString());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -377,7 +377,7 @@ class InAppBrowser {
|
||||||
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)
|
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)
|
||||||
///
|
///
|
||||||
///**Official iOS API**: https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview
|
///**Official iOS API**: https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview
|
||||||
void onDownloadStart(Uri url) {}
|
void onDownloadStart(Uri url, String userAgent, String contentDisposition, String mimeType, int contentLength) {}
|
||||||
|
|
||||||
///Event fired when the [InAppBrowser] webview finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
|
///Event fired when the [InAppBrowser] webview finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
|
||||||
///
|
///
|
||||||
|
|
|
@ -299,7 +299,13 @@ class HeadlessInAppWebView implements WebView {
|
||||||
void Function(InAppWebViewController controller)? onWindowBlur;
|
void Function(InAppWebViewController controller)? onWindowBlur;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void Function(InAppWebViewController controller, Uri url)? onDownloadStart;
|
void Function(
|
||||||
|
InAppWebViewController controller,
|
||||||
|
Uri url,
|
||||||
|
String userAgent,
|
||||||
|
String contentDisposition,
|
||||||
|
String mimeType,
|
||||||
|
int contentLength)? onDownloadStart;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void Function(InAppWebViewController controller, int activeMatchOrdinal,
|
void Function(InAppWebViewController controller, int activeMatchOrdinal,
|
||||||
|
|
|
@ -208,7 +208,7 @@ class InAppWebView extends StatefulWidget implements WebView {
|
||||||
androidOnReceivedTouchIconUrl;
|
androidOnReceivedTouchIconUrl;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final void Function(InAppWebViewController controller, Uri url)?
|
final void Function(InAppWebViewController controller, Uri url, String userAgent, String contentDisposition, String mimeType, int contentLength)?
|
||||||
onDownloadStart;
|
onDownloadStart;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -205,11 +205,16 @@ class InAppWebViewController {
|
||||||
if ((_webview != null && _webview!.onDownloadStart != null) ||
|
if ((_webview != null && _webview!.onDownloadStart != null) ||
|
||||||
_inAppBrowser != null) {
|
_inAppBrowser != null) {
|
||||||
String url = call.arguments["url"];
|
String url = call.arguments["url"];
|
||||||
|
String userAgent = call.arguments["userAgent"];
|
||||||
|
String contentDisposition = call.arguments["contentDisposition"];
|
||||||
|
String mimeType = call.arguments["mimetype"];
|
||||||
|
int contentLength = call.arguments["contentLength"] as int;
|
||||||
Uri uri = Uri.parse(url);
|
Uri uri = Uri.parse(url);
|
||||||
|
|
||||||
if (_webview != null && _webview!.onDownloadStart != null)
|
if (_webview != null && _webview!.onDownloadStart != null)
|
||||||
_webview!.onDownloadStart!(this, uri);
|
_webview!.onDownloadStart!(this, uri, userAgent, contentDisposition, mimeType, contentLength);
|
||||||
else
|
else
|
||||||
_inAppBrowser!.onDownloadStart(uri);
|
_inAppBrowser!.onDownloadStart(uri, userAgent, contentDisposition, mimeType, contentLength);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "onLoadResourceCustomScheme":
|
case "onLoadResourceCustomScheme":
|
||||||
|
|
|
@ -120,7 +120,7 @@ abstract class WebView {
|
||||||
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)
|
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)
|
||||||
///
|
///
|
||||||
///**Official iOS API**: https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview
|
///**Official iOS API**: https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview
|
||||||
final void Function(InAppWebViewController controller, Uri url)?
|
final void Function(InAppWebViewController controller, Uri url, String userAgent, String contentDisposition, String mimeType, int contentLength)?
|
||||||
onDownloadStart;
|
onDownloadStart;
|
||||||
|
|
||||||
///Event fired when the [WebView] finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
|
///Event fired when the [WebView] finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
|
||||||
|
|
Loading…
Reference in New Issue