Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.lang.IllegalArgumentException;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -196,36 +197,40 @@ protected WebView createViewInstance(ThemedReactContext reactContext) {
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
RNCWebViewModule module = getModule(reactContext);

DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));

String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
String downloadMessage = "Downloading " + fileName;

//Attempt to add cookie, if it exists
URL urlObj = null;
try {
urlObj = new URL(url);
String baseUrl = urlObj.getProtocol() + "://" + urlObj.getHost();
String cookie = CookieManager.getInstance().getCookie(baseUrl);
request.addRequestHeader("Cookie", cookie);
System.out.println("Got cookie for DownloadManager: " + cookie);
} catch (MalformedURLException e) {
System.out.println("Error getting cookie for DownloadManager: " + e.toString());
e.printStackTrace();
}
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));

String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
String downloadMessage = "Downloading " + fileName;

//Attempt to add cookie, if it exists
URL urlObj = null;
try {
urlObj = new URL(url);
String baseUrl = urlObj.getProtocol() + "://" + urlObj.getHost();
String cookie = CookieManager.getInstance().getCookie(baseUrl);
request.addRequestHeader("Cookie", cookie);
System.out.println("Got cookie for DownloadManager: " + cookie);
} catch (MalformedURLException e) {
System.out.println("Error getting cookie for DownloadManager: " + e.toString());
e.printStackTrace();
}

//Finish setting up request
request.addRequestHeader("User-Agent", userAgent);
request.setTitle(fileName);
request.setDescription(downloadMessage);
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
//Finish setting up request
request.addRequestHeader("User-Agent", userAgent);
request.setTitle(fileName);
request.setDescription(downloadMessage);
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);

module.setDownloadRequest(request);
module.setDownloadRequest(request);

if (module.grantFileDownloaderPermissions()) {
module.downloadFile();
if (module.grantFileDownloaderPermissions()) {
module.downloadFile();
}
} catch (IllegalArgumentException e) {
System.out.println("IllegalArgumentException: " + e.toString());
}
}
});
Expand Down Expand Up @@ -396,7 +401,7 @@ public void setInjectedJavaScript(WebView view, @Nullable String injectedJavaScr
public void setMessagingEnabled(WebView view, boolean enabled) {
((RNCWebView) view).setMessagingEnabled(enabled);
}

@ReactProp(name = "incognito")
public void setIncognito(WebView view, boolean enabled) {
// Remove all previous cookies
Expand Down Expand Up @@ -646,7 +651,7 @@ protected void setupWebChromeClient(ReactContext reactContext, WebView webView)
public Bitmap getDefaultVideoPoster() {
return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
}

@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
if (mVideoView != null) {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "react-native-webview",
"name": "@pandadoc/react-native-webview",
"description": "React Native WebView component for iOS, Android, and macOS",
"main": "index.js",
"typings": "index.d.ts",
Expand All @@ -8,8 +8,8 @@
"Thibault Malbranche <malbranche.thibault@gmail.com>"
],
"license": "MIT",
"version": "8.1.0",
"homepage": "https://github.com/react-native-community/react-native-webview#readme",
"version": "8.1.5",
"homepage": "https://github.com/pandadoc/react-native-webview#readme",
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"start:android": "react-native run-android --root example/",
Expand Down Expand Up @@ -37,8 +37,8 @@
"devDependencies": {
"@babel/core": "7.4.5",
"@babel/runtime": "7.4.5",
"@react-native-community/cli-platform-ios": "^3.0.0",
"@react-native-community/cli-platform-android": "^3.0.0",
"@react-native-community/cli-platform-ios": "^3.0.0",
"@semantic-release/git": "7.0.16",
"@types/invariant": "^2.2.30",
"@types/jest": "24.0.18",
Expand Down Expand Up @@ -66,7 +66,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/react-native-community/react-native-webview.git"
"url": "https://github.com/pandadoc/react-native-webview.git"
},
"files": [
"android",
Expand Down
4 changes: 2 additions & 2 deletions react-native-webview.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = package['name']
s.name = "react-native-webview"
s.version = package['version']
s.summary = package['description']
s.license = package['license']
Expand All @@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s.homepage = package['homepage']
s.platform = :ios, "9.0"

s.source = { :git => "https://github.com/react-native-community/react-native-webview.git", :tag => "v#{s.version}" }
s.source = { :git => "https://github.com/pandadoc/react-native-webview.git", :tag => "v#{s.version}" }
s.source_files = "ios/**/*.{h,m}"

s.dependency 'React'
Expand Down