ソースを参照

fix(android): Fix Download on android P (#273)

Fixes #266. 
Now downloading works on Motorola Moto One with Android 9.
Marcin Ochyra 5 年 前
コミット
15d904f769
共有1 個のファイルを変更した1 個の追加11 個の削除を含む
  1. 1
    11
      android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java

+ 1
- 11
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java ファイルの表示

@@ -7,7 +7,6 @@ import com.facebook.react.uimanager.UIManagerModule;
7 7
 
8 8
 import java.net.MalformedURLException;
9 9
 import java.net.URL;
10
-import java.net.URLDecoder;
11 10
 import java.util.LinkedList;
12 11
 import java.util.List;
13 12
 import java.util.regex.Pattern;
@@ -480,16 +479,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
480 479
 
481 480
         DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
482 481
 
483
-        //Try to extract filename from contentDisposition, otherwise guess using URLUtil
484
-        String fileName = "";
485
-        try {
486
-          fileName = contentDisposition.replaceFirst("(?i)^.*filename=\"?([^\"]+)\"?.*$", "$1");
487
-          fileName = URLDecoder.decode(fileName, "UTF-8");
488
-        } catch (Exception e) {
489
-          System.out.println("Error extracting filename from contentDisposition: " + e);
490
-          System.out.println("Falling back to URLUtil.guessFileName");
491
-          fileName = URLUtil.guessFileName(url,contentDisposition,mimetype);
492
-        }
482
+        String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
493 483
         String downloadMessage = "Downloading " + fileName;
494 484
 
495 485
         //Attempt to add cookie, if it exists