From 60b26e495e26bfe086cd764af8ade5eb71a0d24a Mon Sep 17 00:00:00 2001 From: jan4dev Date: Thu, 19 Feb 2015 15:51:01 +0100 Subject: [PATCH 1/2] IntelliJ agnostic --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 214350b..108e640 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.swp .DS_Store +.idea/ From d9c4062801d6b544e728a1510c58e12311d2daf2 Mon Sep 17 00:00:00 2001 From: jan4dev Date: Thu, 19 Feb 2015 15:53:23 +0100 Subject: [PATCH 2/2] Added file:// support on Android. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DocumentHandler handle file:// url on iOS but not on Android trying every time to download the resource at the given url. Added a shorcut for Android when the url is already a local file which doesn’t need to be downloaded. --- src/android/DocumentHandler.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/android/DocumentHandler.java b/src/android/DocumentHandler.java index f5d2aad..952ddf5 100644 --- a/src/android/DocumentHandler.java +++ b/src/android/DocumentHandler.java @@ -1,6 +1,10 @@ package ch.ti8m.phonegap.plugins; -import java.io.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; @@ -136,7 +140,13 @@ public FileDownloaderAsyncTask(CallbackContext callbackContext, @Override protected File doInBackground(Void... arg0) { - return downloadFile(url, callbackContext); + if(!url.startsWith("file://")){ + return downloadFile(url, callbackContext); + } + else{ + File file = new File(url.replaceFirst("file://", "")); + return file; + } } @Override