From 83855311feebdab5f7765b93f8bccf3438b90da1 Mon Sep 17 00:00:00 2001 From: Patrick Sullivan Date: Thu, 15 May 2014 15:59:44 -0700 Subject: [PATCH] Support relative paths on 3.3 Cordova in Android --- .../pwlin/cordova/plugins/fileopener2/FileOpener2.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/android/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java b/src/android/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java index a682209..32ac492 100644 --- a/src/android/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java +++ b/src/android/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java @@ -11,6 +11,7 @@ import android.net.Uri; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CallbackContext; import org.apache.cordova.PluginResult; +import org.apache.cordova.CordovaResourceApi; public class FileOpener2 extends CordovaPlugin { @@ -72,7 +73,12 @@ public class FileOpener2 extends CordovaPlugin { public void onDestroy() { } - private boolean _open(String fileName, String contentType, CallbackContext callbackContext) throws JSONException { + private boolean _open(String fileArg, String contentType, CallbackContext callbackContext) throws JSONException { + + CordovaResourceApi resourceApi = webView.getResourceApi(); + + Uri fileUri = resourceApi.remapUri(Uri.parse(fileArg)); + String fileName = org.apache.cordova.FileHelper.stripFileProtocol(fileUri.toString()); File file = new File(fileName);