From 8b5dd5eb0139fdff35595f7e26f214659bde1fa6 Mon Sep 17 00:00:00 2001 From: VincentRoth Date: Wed, 29 Jun 2016 18:01:42 +0200 Subject: [PATCH 01/47] Generalize callback context to options object and prepare for bounds parameter --- www/plugins.FileOpener2.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/www/plugins.FileOpener2.js b/www/plugins.FileOpener2.js index 06519dd..25047b5 100644 --- a/www/plugins.FileOpener2.js +++ b/www/plugins.FileOpener2.js @@ -26,19 +26,19 @@ var exec = require('cordova/exec'); function FileOpener2() {} -FileOpener2.prototype.open = function (fileName, contentType, callbackContext) { - callbackContext = callbackContext || {}; - exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType]); +FileOpener2.prototype.open = function (fileName, contentType, options) { + options = options || {}; + exec(options.success || null, options.error || null, 'FileOpener2', 'open', [fileName, contentType, options.bounds]); }; -FileOpener2.prototype.uninstall = function (packageId, callbackContext) { - callbackContext = callbackContext || {}; - exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'uninstall', [packageId]); +FileOpener2.prototype.uninstall = function (packageId, options) { + options = options || {}; + exec(options.success || null, options.error || null, 'FileOpener2', 'uninstall', [packageId]); }; -FileOpener2.prototype.appIsInstalled = function (packageId, callbackContext) { - callbackContext = callbackContext || {}; - exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'appIsInstalled', [packageId]); +FileOpener2.prototype.appIsInstalled = function (packageId, options) { + options = options || {}; + exec(options.success || null, options.error || null, 'FileOpener2', 'appIsInstalled', [packageId]); }; -module.exports = new FileOpener2(); \ No newline at end of file +module.exports = new FileOpener2(); From dc22bc583a48d720a0d2f603b118c684062ebf31 Mon Sep 17 00:00:00 2001 From: VincentRoth Date: Wed, 29 Jun 2016 18:05:45 +0200 Subject: [PATCH 02/47] iOS - Use bounds parameter to set dialog position --- src/ios/FileOpener2.m | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ios/FileOpener2.m b/src/ios/FileOpener2.m index b9f67fa..74cfacb 100644 --- a/src/ios/FileOpener2.m +++ b/src/ios/FileOpener2.m @@ -38,6 +38,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. uti = (__bridge NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)fileExt, NULL); } + + CGRect bounds; + if (3 >= [command.arguments count]) { + NSArray *boundsValues = [command.arguments objectAtIndex: 2]; + bounds = CGRectMake([[boundsValues objectAtIndex:0] floatValue], + [[boundsValues objectAtIndex:1] floatValue], + [[boundsValues objectAtIndex:2] floatValue], + [[boundsValues objectAtIndex:3] floatValue]); + } else { + bounds = CGRectMake(0, 0, 1000.0f, 150.0f); + } CDVViewController* cont = (CDVViewController*)[ super viewController ]; @@ -62,9 +73,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. self.controller.delegate = self; self.controller.UTI = uti; - CGRect rect = CGRectMake(0, 0, 1000.0f, 150.0f); CDVPluginResult* pluginResult = nil; - BOOL wasOpened = [self.controller presentOptionsMenuFromRect:rect inView:cont.view animated:NO]; + BOOL wasOpened = [self.controller presentOptionsMenuFromRect:bounds inView:cont.view animated:NO]; if(wasOpened) { pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @""]; From dbc778663e1c4b1d1ff606c3f80f42e465f8a63f Mon Sep 17 00:00:00 2001 From: VincentRoth Date: Thu, 30 Jun 2016 10:00:49 +0200 Subject: [PATCH 03/47] Describe position parameter in readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 4393066..a4ec0b7 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,11 @@ Usage { error : function(){ }, success : function(){ } + position : [x, y] } ); + +`position` array of coordinates from top-left device screen, use for iOS dialog positioning Examples -------- From 90ceca44aed7a1d1042effe5bf1ac16217360b90 Mon Sep 17 00:00:00 2001 From: VincentRoth Date: Thu, 30 Jun 2016 10:01:29 +0200 Subject: [PATCH 04/47] Rename bounds to position --- www/plugins.FileOpener2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/plugins.FileOpener2.js b/www/plugins.FileOpener2.js index 25047b5..2ff0d77 100644 --- a/www/plugins.FileOpener2.js +++ b/www/plugins.FileOpener2.js @@ -28,7 +28,7 @@ function FileOpener2() {} FileOpener2.prototype.open = function (fileName, contentType, options) { options = options || {}; - exec(options.success || null, options.error || null, 'FileOpener2', 'open', [fileName, contentType, options.bounds]); + exec(options.success || null, options.error || null, 'FileOpener2', 'open', [fileName, contentType, options.position]); }; FileOpener2.prototype.uninstall = function (packageId, options) { From 3f01a95c73ef5281661992c8514e9fdca6eb55f1 Mon Sep 17 00:00:00 2001 From: VincentRoth Date: Thu, 30 Jun 2016 10:03:57 +0200 Subject: [PATCH 05/47] Update bounds to only use position coordinates --- src/ios/FileOpener2.m | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ios/FileOpener2.m b/src/ios/FileOpener2.m index 74cfacb..025769e 100644 --- a/src/ios/FileOpener2.m +++ b/src/ios/FileOpener2.m @@ -39,15 +39,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. uti = (__bridge NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)fileExt, NULL); } - CGRect bounds; + CGRect rect; if (3 >= [command.arguments count]) { - NSArray *boundsValues = [command.arguments objectAtIndex: 2]; - bounds = CGRectMake([[boundsValues objectAtIndex:0] floatValue], - [[boundsValues objectAtIndex:1] floatValue], - [[boundsValues objectAtIndex:2] floatValue], - [[boundsValues objectAtIndex:3] floatValue]); + NSArray *positionValues = command.arguments[2]; + rect = CGRectMake([0,0, + [[positionValues objectAtIndex:0] floatValue], + [[positionValues objectAtIndex:1] floatValue]); } else { - bounds = CGRectMake(0, 0, 1000.0f, 150.0f); + rect = CGRectMake(0, 0, 1000.0f, 150.0f); } CDVViewController* cont = (CDVViewController*)[ super viewController ]; @@ -74,7 +73,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. self.controller.UTI = uti; CDVPluginResult* pluginResult = nil; - BOOL wasOpened = [self.controller presentOptionsMenuFromRect:bounds inView:cont.view animated:NO]; + BOOL wasOpened = [self.controller presentOptionsMenuFromRect:rect inView:cont.view animated:NO]; if(wasOpened) { pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @""]; From ad3166a3e6c5b623c26c3296c464a87971cf4d43 Mon Sep 17 00:00:00 2001 From: VincentRoth Date: Thu, 30 Jun 2016 10:09:11 +0200 Subject: [PATCH 06/47] Fix CGRectMake parameter --- src/ios/FileOpener2.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ios/FileOpener2.m b/src/ios/FileOpener2.m index 025769e..28484c2 100644 --- a/src/ios/FileOpener2.m +++ b/src/ios/FileOpener2.m @@ -42,9 +42,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CGRect rect; if (3 >= [command.arguments count]) { NSArray *positionValues = command.arguments[2]; - rect = CGRectMake([0,0, - [[positionValues objectAtIndex:0] floatValue], - [[positionValues objectAtIndex:1] floatValue]); + rect = CGRectMake(0,0,[[positionValues objectAtIndex:0] floatValue],[[positionValues objectAtIndex:1] floatValue]); } else { rect = CGRectMake(0, 0, 1000.0f, 150.0f); } From 3511dac4b11f968bb10e767f7ab780c4a69a8a7d Mon Sep 17 00:00:00 2001 From: Aaron Faber Date: Wed, 15 Nov 2017 15:31:54 +0000 Subject: [PATCH 07/47] Added fix to stop support version pulling in alphas --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 2ec207e..daf495b 100644 --- a/plugin.xml +++ b/plugin.xml @@ -31,7 +31,7 @@ - + From 90b620b9218390c59711c15c66f9bf60cd2c729e Mon Sep 17 00:00:00 2001 From: Aaron Faber Date: Mon, 12 Nov 2018 15:14:33 +0000 Subject: [PATCH 08/47] updated android support library version --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index daf495b..0c78ef2 100644 --- a/plugin.xml +++ b/plugin.xml @@ -31,7 +31,7 @@ - + From 054d7fa21b8fcca1f1f5fcdd7374741e0818918e Mon Sep 17 00:00:00 2001 From: Aaron Faber Date: Tue, 13 Nov 2018 10:55:11 +0000 Subject: [PATCH 09/47] allowed support library version to be configurable --- plugin.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 0c78ef2..38885f7 100644 --- a/plugin.xml +++ b/plugin.xml @@ -31,7 +31,8 @@ - + + From 636bce54bcd924fe31bac7213b2ff6c2310b72fc Mon Sep 17 00:00:00 2001 From: Aaron Faber Date: Mon, 10 Dec 2018 16:19:54 +0000 Subject: [PATCH 10/47] chore(): updated readme file with new android_support_version variable --- README.md | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 0f64971..b2431da 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,18 @@ Requirements Installation ------------- - cordova plugin add cordova-plugin-file-opener2 - + $ cordova plugin add cordova-plugin-file-opener2 + $ cordova plugin add cordova-plugin-file-opener2 --variable ANDROID_SUPPORT_VERSION={required version} + Usage ------ cordova.plugins.fileOpener2.open( - filePath, - fileMIMEType, + filePath, + fileMIMEType, { - error : function(){ }, - success : function(){ } - } + error : function(){ }, + success : function(){ } + } ); Examples @@ -35,21 +36,21 @@ Examples Open an APK install dialog: cordova.plugins.fileOpener2.open( - '/sdcard/Download/gmail.apk', + '/sdcard/Download/gmail.apk', 'application/vnd.android.package-archive' ); - + Open a PDF document with the default PDF reader and optional callback object: cordova.plugins.fileOpener2.open( '/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf - 'application/pdf', - { - error : function(e) { + 'application/pdf', + { + error : function(e) { console.log('Error status: ' + e.status + ' - Error message: ' + e.message); }, success : function () { - console.log('file opened successfully'); + console.log('file opened successfully'); } } ); @@ -58,13 +59,13 @@ Open a system modal to open PDF document with one of the already installed app a cordova.plugins.fileOpener2.showOpenWithDialog( '/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf - 'application/pdf', - { - error : function(e) { + 'application/pdf', + { + error : function(e) { console.log('Error status: ' + e.status + ' - Error message: ' + e.message); }, success : function () { - console.log('file opened successfully'); + console.log('file opened successfully'); } } ); @@ -102,7 +103,7 @@ Uninstall a package with its id. cordova.plugins.fileOpener2.uninstall('com.zynga.FarmVille2CountryEscape', { error : function(e) { - console.log('Error status: ' + e.status + ' - Error message: ' + e.message); + console.log('Error status: ' + e.status + ' - Error message: ' + e.message); }, success : function() { console.log('Uninstall intent activity started.'); From c3e972cab4260a72f3be2fa76d27e9f999da0e88 Mon Sep 17 00:00:00 2001 From: shnist Date: Mon, 10 Dec 2018 16:37:06 +0000 Subject: [PATCH 11/47] chore(): updated collaborators on readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2431da..db7b472 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Contributors ------------ -[@Gillardo](https://github.com/Gillardo/), [@TankOs](https://github.com/TankOs), [@Rovi23](https://github.com/Rovi23), [@josemanuelbd](https://github.com/josemanuelbd), [@ielcoro](https://github.com/ielcoro), [@keturn](https://github.com/keturn), [@conform](https://github.com/conform), [@guyc](https://github.com/guyc), [@J3r0M3D3V](https://github.com/J3r0M3D3V), [@WuglyakBolgoink](https://github.com/WuglyakBolgoink), [@lincolnthree](https://github.com/lincolnthree), [@rocco](https://github.com/rocco/), [@FrankFenton](https://github.com/FrankFenton), [@MHolmes91](https://github.com/MHolmes91), [@souly1](https://github.com/souly1), [@diogodias86](https://github.com/diogodias86), [@Arxi](https://github.com/Arxi), [@vzharkov](https://github.com/vzharkov), [@lp1bp](https://github.com/lp1bp), [@stalniy](https://github.com/stalniy), [@liugogal](https://github.com/liugogal), [@lcaprini](https://github.com/lcaprini), [@jcdickman](https://github.com/jcdickman) +[@Gillardo](https://github.com/Gillardo/), [@TankOs](https://github.com/TankOs), [@Rovi23](https://github.com/Rovi23), [@josemanuelbd](https://github.com/josemanuelbd), [@ielcoro](https://github.com/ielcoro), [@keturn](https://github.com/keturn), [@conform](https://github.com/conform), [@guyc](https://github.com/guyc), [@J3r0M3D3V](https://github.com/J3r0M3D3V), [@WuglyakBolgoink](https://github.com/WuglyakBolgoink), [@lincolnthree](https://github.com/lincolnthree), [@rocco](https://github.com/rocco/), [@FrankFenton](https://github.com/FrankFenton), [@MHolmes91](https://github.com/MHolmes91), [@souly1](https://github.com/souly1), [@diogodias86](https://github.com/diogodias86), [@Arxi](https://github.com/Arxi), [@vzharkov](https://github.com/vzharkov), [@lp1bp](https://github.com/lp1bp), [@stalniy](https://github.com/stalniy), [@liugogal](https://github.com/liugogal), [@lcaprini](https://github.com/lcaprini), [@jcdickman](https://github.com/jcdickman) [@shnist](https://github.com/shnist) A File Opener Plugin for Cordova (The Original Version) From 6bb67a9fa1ae86c74308663c46f33af7174b5039 Mon Sep 17 00:00:00 2001 From: shnist Date: Mon, 10 Dec 2018 16:45:11 +0000 Subject: [PATCH 12/47] 2.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 436e935..c543242 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-file-opener2", - "version": "2.0.19", + "version": "2.1.0", "description": "A File Opener Plugin for Cordova. (The Original Version)", "cordova": { "id": "cordova-plugin-file-opener2", From ee9058a3c51a46d5c9343a1833e3d401b396e2b9 Mon Sep 17 00:00:00 2001 From: shnist Date: Mon, 10 Dec 2018 16:46:35 +0000 Subject: [PATCH 13/47] Bumped the version to 2.1.0 --- CHANGELOG.md | 12 ++++++++++++ README.md | 2 +- plugin.xml | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7116dad --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +Changelog +========================== + +2.1.0 +---------------- + +*Features* +* #234 Add optional android version support variable at installation + +*Bug fixes* +* #176 Various Android fixes. To verify it doesn't break anything, I tested opening a PDF and installing an APK on Android 4.1, 4.4, 5.0, 6.0, and 7.0. +* #155 iOS: use contentType if provided, otherwise fall back to file extension \ No newline at end of file diff --git a/README.md b/README.md index db7b472..5bcdac3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A File Opener Plugin for Cordova (The Original Version) ========================== This plugin will open a file on your device file system with its default application. -Current Version: 2.0.19 +Current Version: 2.1.0 ---------------- Requirements diff --git a/plugin.xml b/plugin.xml index 38885f7..a368e8c 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + File Opener2 A File Opener Plugin for Cordova. (The Original Version) From fb9fcc7c9a5bb74a4b68b325b2daa12b384ff9f2 Mon Sep 17 00:00:00 2001 From: shnist Date: Tue, 11 Dec 2018 14:44:20 +0000 Subject: [PATCH 14/47] docs(): added npm version badge to readme --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 5bcdac3..71a2a40 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ A File Opener Plugin for Cordova (The Original Version) ========================== This plugin will open a file on your device file system with its default application. -Current Version: 2.1.0 ----------------- +[![npm version](https://badge.fury.io/js/cordova-plugin-file-opener2.svg)](https://badge.fury.io/js/cordova-plugin-file-opener2) Requirements ------------- From 4f9d9b22643a031b52ef345ad086091b3eaf2d39 Mon Sep 17 00:00:00 2001 From: shnist Date: Tue, 11 Dec 2018 14:44:42 +0000 Subject: [PATCH 15/47] docs(): removed changelog as will construct this in the releases --- CHANGELOG.md | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 7116dad..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -Changelog -========================== - -2.1.0 ----------------- - -*Features* -* #234 Add optional android version support variable at installation - -*Bug fixes* -* #176 Various Android fixes. To verify it doesn't break anything, I tested opening a PDF and installing an APK on Android 4.1, 4.4, 5.0, 6.0, and 7.0. -* #155 iOS: use contentType if provided, otherwise fall back to file extension \ No newline at end of file From d84b20e6209a7134dda39276dc1fa09a4229e604 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Tue, 11 Dec 2018 08:59:29 -0700 Subject: [PATCH 16/47] Update fileOpener2Proxy.js --- src/windows/fileOpener2Proxy.js | 150 ++++++++++++++++---------------- 1 file changed, 76 insertions(+), 74 deletions(-) diff --git a/src/windows/fileOpener2Proxy.js b/src/windows/fileOpener2Proxy.js index ce2dee6..b9c82d9 100644 --- a/src/windows/fileOpener2Proxy.js +++ b/src/windows/fileOpener2Proxy.js @@ -1,93 +1,95 @@ - var cordova = require('cordova'), - fileOpener2 = require('./FileOpener2'); +var cordova = require('cordova'), + fileOpener2 = require('./FileOpener2'); - var schemes = [ - { protocol: 'ms-app', getFile: getFileFromApplicationUri }, - { protocol: 'cdvfile', getFile: getFileFromFileUri } //protocol cdvfile - ] +var schemes = [ + { protocol: 'ms-app', getFile: getFileFromApplicationUri }, + { protocol: 'cdvfile', getFile: getFileFromFileUri } //protocol cdvfile +] - function nthIndex(str, pat, n) { - var L = str.length, i = -1; - while (n-- && i++ < L) { - i = str.indexOf(pat, i); - if (i < 0) break; - } - return i; - } +function nthIndex(str, pat, n) { + var L = str.length, i = -1; + while (n-- && i++ < L) { + i = str.indexOf(pat, i); + if (i < 0) break; + } + return i; +} - function getFileFromApplicationUri(uri) { - /* bad path from a file entry due to the last '//' - example: ms-appdata:///local//path/to/file - */ - var index = nthIndex(uri, "//", 3); - var newUri = uri.substr(0, index) + uri.substr(index + 1); +function getFileFromApplicationUri(uri) { + /* bad path from a file entry due to the last '//' + example: ms-appdata:///local//path/to/file + */ + var index = nthIndex(uri, "//", 3); + var newUri = uri.substr(0, index) + uri.substr(index + 1); - var applicationUri = new Windows.Foundation.Uri(newUri); + var applicationUri = new Windows.Foundation.Uri(newUri); - return Windows.Storage.StorageFile.getFileFromApplicationUriAsync(applicationUri); - } + return Windows.Storage.StorageFile.getFileFromApplicationUriAsync(applicationUri); +} - function getFileFromFileUri(uri) { - /* uri example: - cdvfile://localhost/persistent|temporary|another-fs-root/path/to/file - */ - var indexFrom = nthIndex(uri, "/", 3) + 1; - var indexTo = nthIndex(uri, "/", 4); - var whichFolder = uri.substring(indexFrom, indexTo); - var filePath = uri.substr(indexTo + 1); - var path = "\\" + filePath; +function getFileFromFileUri(uri) { + /* uri example: + cdvfile://localhost/persistent|temporary|another-fs-root/path/to/file + */ + var indexFrom = nthIndex(uri, "/", 3) + 1; + var indexTo = nthIndex(uri, "/", 4); + var whichFolder = uri.substring(indexFrom, indexTo); + var filePath = uri.substr(indexTo + 1); + var path = "\\" + filePath; - if (whichFolder == "persistent") { - path = Windows.Storage.ApplicationData.current.localFolder.path + path; - } - else { //temporary, note: no roaming management - path = Windows.Storage.ApplicationData.current.temporaryFolder.path + path; - } + if (whichFolder == "persistent") { + path = Windows.Storage.ApplicationData.current.localFolder.path + path; + } + else { //temporary, note: no roaming management + path = Windows.Storage.ApplicationData.current.temporaryFolder.path + path; + } - return getFileFromNativePath(path); - } + return getFileFromNativePath(path); +} - function getFileFromNativePath(path) { - var nativePath = path.split("/").join("\\"); +function getFileFromNativePath(path) { + var nativePath = path.split("/").join("\\"); - return Windows.Storage.StorageFile.getFileFromPathAsync(nativePath); - } + return Windows.Storage.StorageFile.getFileFromPathAsync(nativePath); +} - function getFileLoaderForScheme(path) { - var fileLoader = getFileFromNativePath; +function getFileLoaderForScheme(path) { + var fileLoader = getFileFromNativePath; - schemes.some(function (scheme) { - return path.indexOf(scheme.protocol) === 0 ? ((fileLoader = scheme.getFile), true) : false; - }); + schemes.some(function (scheme) { + return path.indexOf(scheme.protocol) === 0 ? ((fileLoader = scheme.getFile), true) : false; + }); - return fileLoader; - } + return fileLoader; +} - module.exports = { +module.exports = { - open: function (successCallback, errorCallback, args) { - - var path = args[0]; - - var getFile = getFileLoaderForScheme(path); - - getFile(path).then(function (file) { - var options = new Windows.System.LauncherOptions(); - - Windows.System.Launcher.launchFileAsync(file, options).then(function (success) { - successCallback(); - }, function (error) { - errorCallback(error); - }); + open: function (successCallback, errorCallback, args) { + + var path = args[0]; + + var getFile = getFileLoaderForScheme(path); + try{ + getFile(path).then(function (file) { + var options = new Windows.System.LauncherOptions(); + + Windows.System.Launcher.launchFileAsync(file, options).then(function (success) { + successCallback(); + }, function (error) { + errorCallback(error); + }); + }, function (error) { + console.log("Error while opening the file: "+error); + errorCallback(error); + }); + }catch(error){ + errorCallback(error); + } + } - }, function (error) { - console.log("Error while opening the file: "+error); - errorCallback(error); - }); - } - - }; +}; - require("cordova/exec/proxy").add("FileOpener2", module.exports); +require("cordova/exec/proxy").add("FileOpener2", module.exports); From 0c6cbedb172f8351570a3d57b4070db9e3268ecb Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Tue, 11 Dec 2018 09:02:14 -0700 Subject: [PATCH 17/47] Update fileOpener2Proxy.js --- src/windows/fileOpener2Proxy.js | 150 ++++++++++++++++---------------- 1 file changed, 76 insertions(+), 74 deletions(-) diff --git a/src/windows/fileOpener2Proxy.js b/src/windows/fileOpener2Proxy.js index b9c82d9..d5d2e2d 100644 --- a/src/windows/fileOpener2Proxy.js +++ b/src/windows/fileOpener2Proxy.js @@ -1,95 +1,97 @@ -var cordova = require('cordova'), - fileOpener2 = require('./FileOpener2'); + var cordova = require('cordova'), + fileOpener2 = require('./FileOpener2'); -var schemes = [ - { protocol: 'ms-app', getFile: getFileFromApplicationUri }, - { protocol: 'cdvfile', getFile: getFileFromFileUri } //protocol cdvfile -] + var schemes = [ + { protocol: 'ms-app', getFile: getFileFromApplicationUri }, + { protocol: 'cdvfile', getFile: getFileFromFileUri } //protocol cdvfile + ] -function nthIndex(str, pat, n) { - var L = str.length, i = -1; - while (n-- && i++ < L) { - i = str.indexOf(pat, i); - if (i < 0) break; - } - return i; -} - -function getFileFromApplicationUri(uri) { - /* bad path from a file entry due to the last '//' - example: ms-appdata:///local//path/to/file - */ - var index = nthIndex(uri, "//", 3); - var newUri = uri.substr(0, index) + uri.substr(index + 1); - - var applicationUri = new Windows.Foundation.Uri(newUri); - - return Windows.Storage.StorageFile.getFileFromApplicationUriAsync(applicationUri); -} - -function getFileFromFileUri(uri) { - /* uri example: - cdvfile://localhost/persistent|temporary|another-fs-root/path/to/file - */ - var indexFrom = nthIndex(uri, "/", 3) + 1; - var indexTo = nthIndex(uri, "/", 4); - var whichFolder = uri.substring(indexFrom, indexTo); - var filePath = uri.substr(indexTo + 1); - var path = "\\" + filePath; - - if (whichFolder == "persistent") { - path = Windows.Storage.ApplicationData.current.localFolder.path + path; - } - else { //temporary, note: no roaming management - path = Windows.Storage.ApplicationData.current.temporaryFolder.path + path; + function nthIndex(str, pat, n) { + var L = str.length, i = -1; + while (n-- && i++ < L) { + i = str.indexOf(pat, i); + if (i < 0) break; + } + return i; } - return getFileFromNativePath(path); -} + function getFileFromApplicationUri(uri) { + /* bad path from a file entry due to the last '//' + example: ms-appdata:///local//path/to/file + */ + var index = nthIndex(uri, "//", 3); + var newUri = uri.substr(0, index) + uri.substr(index + 1); -function getFileFromNativePath(path) { - var nativePath = path.split("/").join("\\"); + var applicationUri = new Windows.Foundation.Uri(newUri); - return Windows.Storage.StorageFile.getFileFromPathAsync(nativePath); -} + return Windows.Storage.StorageFile.getFileFromApplicationUriAsync(applicationUri); + } -function getFileLoaderForScheme(path) { - var fileLoader = getFileFromNativePath; + function getFileFromFileUri(uri) { + /* uri example: + cdvfile://localhost/persistent|temporary|another-fs-root/path/to/file + */ + var indexFrom = nthIndex(uri, "/", 3) + 1; + var indexTo = nthIndex(uri, "/", 4); + var whichFolder = uri.substring(indexFrom, indexTo); + var filePath = uri.substr(indexTo + 1); + var path = "\\" + filePath; - schemes.some(function (scheme) { - return path.indexOf(scheme.protocol) === 0 ? ((fileLoader = scheme.getFile), true) : false; - }); + if (whichFolder == "persistent") { + path = Windows.Storage.ApplicationData.current.localFolder.path + path; + } + else { //temporary, note: no roaming management + path = Windows.Storage.ApplicationData.current.temporaryFolder.path + path; + } - return fileLoader; -} + return getFileFromNativePath(path); + } -module.exports = { + function getFileFromNativePath(path) { + var nativePath = path.split("/").join("\\"); - open: function (successCallback, errorCallback, args) { - - var path = args[0]; - - var getFile = getFileLoaderForScheme(path); - try{ - getFile(path).then(function (file) { - var options = new Windows.System.LauncherOptions(); + return Windows.Storage.StorageFile.getFileFromPathAsync(nativePath); + } + + function getFileLoaderForScheme(path) { + var fileLoader = getFileFromNativePath; + + schemes.some(function (scheme) { + return path.indexOf(scheme.protocol) === 0 ? ((fileLoader = scheme.getFile), true) : false; + }); + + return fileLoader; + } + + module.exports = { + + open: function (successCallback, errorCallback, args) { - Windows.System.Launcher.launchFileAsync(file, options).then(function (success) { - successCallback(); - }, function (error) { + var path = args[0]; + + var getFile = getFileLoaderForScheme(path); + + getFile(path).then(function (file) { + var options = new Windows.System.LauncherOptions(); + + try{ + Windows.System.Launcher.launchFileAsync(file, options).then(function (success) { + successCallback(); + }, function (error) { + errorCallback(error); + }); + }catch(error){ errorCallback(error); - }); + } + }, function (error) { console.log("Error while opening the file: "+error); errorCallback(error); }); - }catch(error){ - errorCallback(error); } - } + + }; -}; - -require("cordova/exec/proxy").add("FileOpener2", module.exports); + require("cordova/exec/proxy").add("FileOpener2", module.exports); From 85fa81fba36f3c0e7a0df332346780b5ec0096b5 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Tue, 11 Dec 2018 09:03:22 -0700 Subject: [PATCH 18/47] Update fileOpener2Proxy.js --- src/windows/fileOpener2Proxy.js | 136 ++++++++++++++++---------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/windows/fileOpener2Proxy.js b/src/windows/fileOpener2Proxy.js index d5d2e2d..8155002 100644 --- a/src/windows/fileOpener2Proxy.js +++ b/src/windows/fileOpener2Proxy.js @@ -1,97 +1,97 @@ - var cordova = require('cordova'), - fileOpener2 = require('./FileOpener2'); + var cordova = require('cordova'), + fileOpener2 = require('./FileOpener2'); - var schemes = [ + var schemes = [ { protocol: 'ms-app', getFile: getFileFromApplicationUri }, { protocol: 'cdvfile', getFile: getFileFromFileUri } //protocol cdvfile - ] + ] - function nthIndex(str, pat, n) { - var L = str.length, i = -1; - while (n-- && i++ < L) { - i = str.indexOf(pat, i); - if (i < 0) break; - } - return i; - } + function nthIndex(str, pat, n) { + var L = str.length, i = -1; + while (n-- && i++ < L) { + i = str.indexOf(pat, i); + if (i < 0) break; + } + return i; + } - function getFileFromApplicationUri(uri) { - /* bad path from a file entry due to the last '//' + function getFileFromApplicationUri(uri) { + /* bad path from a file entry due to the last '//' example: ms-appdata:///local//path/to/file */ - var index = nthIndex(uri, "//", 3); - var newUri = uri.substr(0, index) + uri.substr(index + 1); + var index = nthIndex(uri, "//", 3); + var newUri = uri.substr(0, index) + uri.substr(index + 1); - var applicationUri = new Windows.Foundation.Uri(newUri); + var applicationUri = new Windows.Foundation.Uri(newUri); - return Windows.Storage.StorageFile.getFileFromApplicationUriAsync(applicationUri); - } + return Windows.Storage.StorageFile.getFileFromApplicationUriAsync(applicationUri); + } - function getFileFromFileUri(uri) { - /* uri example: + function getFileFromFileUri(uri) { + /* uri example: cdvfile://localhost/persistent|temporary|another-fs-root/path/to/file */ - var indexFrom = nthIndex(uri, "/", 3) + 1; - var indexTo = nthIndex(uri, "/", 4); - var whichFolder = uri.substring(indexFrom, indexTo); - var filePath = uri.substr(indexTo + 1); - var path = "\\" + filePath; + var indexFrom = nthIndex(uri, "/", 3) + 1; + var indexTo = nthIndex(uri, "/", 4); + var whichFolder = uri.substring(indexFrom, indexTo); + var filePath = uri.substr(indexTo + 1); + var path = "\\" + filePath; - if (whichFolder == "persistent") { - path = Windows.Storage.ApplicationData.current.localFolder.path + path; - } - else { //temporary, note: no roaming management - path = Windows.Storage.ApplicationData.current.temporaryFolder.path + path; - } + if (whichFolder == "persistent") { + path = Windows.Storage.ApplicationData.current.localFolder.path + path; + } + else { //temporary, note: no roaming management + path = Windows.Storage.ApplicationData.current.temporaryFolder.path + path; + } - return getFileFromNativePath(path); - } + return getFileFromNativePath(path); + } - function getFileFromNativePath(path) { - var nativePath = path.split("/").join("\\"); + function getFileFromNativePath(path) { + var nativePath = path.split("/").join("\\"); - return Windows.Storage.StorageFile.getFileFromPathAsync(nativePath); - } + return Windows.Storage.StorageFile.getFileFromPathAsync(nativePath); + } - function getFileLoaderForScheme(path) { - var fileLoader = getFileFromNativePath; + function getFileLoaderForScheme(path) { + var fileLoader = getFileFromNativePath; - schemes.some(function (scheme) { - return path.indexOf(scheme.protocol) === 0 ? ((fileLoader = scheme.getFile), true) : false; - }); + schemes.some(function (scheme) { + return path.indexOf(scheme.protocol) === 0 ? ((fileLoader = scheme.getFile), true) : false; + }); - return fileLoader; - } + return fileLoader; + } - module.exports = { + module.exports = { - open: function (successCallback, errorCallback, args) { - - var path = args[0]; - - var getFile = getFileLoaderForScheme(path); - - getFile(path).then(function (file) { - var options = new Windows.System.LauncherOptions(); - + open: function (successCallback, errorCallback, args) { + + var path = args[0]; + + var getFile = getFileLoaderForScheme(path); + + getFile(path).then(function (file) { + var options = new Windows.System.LauncherOptions(); + try{ - Windows.System.Launcher.launchFileAsync(file, options).then(function (success) { - successCallback(); - }, function (error) { - errorCallback(error); - }); + Windows.System.Launcher.launchFileAsync(file, options).then(function (success) { + successCallback(); + }, function (error) { + errorCallback(error); + }); }catch(error){ errorCallback(error); } - }, function (error) { - console.log("Error while opening the file: "+error); - errorCallback(error); - }); - } - - }; + }, function (error) { + console.log("Error while opening the file: "+error); + errorCallback(error); + }); + } + + }; - require("cordova/exec/proxy").add("FileOpener2", module.exports); + require("cordova/exec/proxy").add("FileOpener2", module.exports); From 4d70f315dfd4205b21a0b22a2746416a9c3c0595 Mon Sep 17 00:00:00 2001 From: shnist Date: Tue, 11 Dec 2018 17:11:39 +0000 Subject: [PATCH 19/47] docs(): added docs for installing apk / ipa file from marketplace. closes #57 --- README.md | 150 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 85 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 71a2a40..37672f1 100644 --- a/README.md +++ b/README.md @@ -16,58 +16,77 @@ Requirements Installation ------------- - $ cordova plugin add cordova-plugin-file-opener2 - $ cordova plugin add cordova-plugin-file-opener2 --variable ANDROID_SUPPORT_VERSION={required version} +```shell +$ cordova plugin add cordova-plugin-file-opener2 +$ cordova plugin add cordova-plugin-file-opener2 --variable ANDROID_SUPPORT_VERSION={required version} +``` Usage ------ - cordova.plugins.fileOpener2.open( - filePath, - fileMIMEType, - { - error : function(){ }, - success : function(){ } - } - ); +```javascript +cordova.plugins.fileOpener2.open( + filePath, + fileMIMEType, + { + error : function(){ }, + success : function(){ } + } +); +``` Examples -------- Open an APK install dialog: - cordova.plugins.fileOpener2.open( - '/sdcard/Download/gmail.apk', - 'application/vnd.android.package-archive' - ); +```javascript +cordova.plugins.fileOpener2.open( + '/sdcard/Download/gmail.apk', + 'application/vnd.android.package-archive' +); +``` + +Install From Market: to install an APK from a market place, such as Google Play or the App Store, you can use an `` tag in combination with the `market://` protocol: + +```html +Install from Google Play +Install from App Store +``` + +or in code: +```javascript +window.open("[market:// or itms-apps:// link]","_system"); +``` Open a PDF document with the default PDF reader and optional callback object: - - cordova.plugins.fileOpener2.open( - '/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf - 'application/pdf', - { - error : function(e) { - console.log('Error status: ' + e.status + ' - Error message: ' + e.message); - }, - success : function () { - console.log('file opened successfully'); - } +```javascript +cordova.plugins.fileOpener2.open( + '/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf + 'application/pdf', + { + error : function(e) { + console.log('Error status: ' + e.status + ' - Error message: ' + e.message); + }, + success : function () { + console.log('file opened successfully'); } - ); - + } +); +``` Open a system modal to open PDF document with one of the already installed app and optional callback object: - - cordova.plugins.fileOpener2.showOpenWithDialog( - '/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf - 'application/pdf', - { - error : function(e) { - console.log('Error status: ' + e.status + ' - Error message: ' + e.message); - }, - success : function () { - console.log('file opened successfully'); - } +```javascript +cordova.plugins.fileOpener2.showOpenWithDialog( + '/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf + 'application/pdf', + { + error : function(e) { + console.log('Error status: ' + e.status + ' - Error message: ' + e.message); + }, + success : function () { + console.log('file opened successfully'); } - ); + } +); +``` Notes ------ @@ -78,16 +97,17 @@ Notes - If you are wondering what MIME-type should you pass as the second argument to `open` function, [here is a list of all known MIME-types](http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=co) + Android APK installation limitation --- The following limitations apply when opening an APK file for installation: - On Android 8+, your application must have the `ACTION_INSTALL_PACKAGE` permission. You can add it by adding this to your app's `config.xml` file: -``` - - - - - +```xml + + + + + ``` - Before Android 7, you can only install APKs from the "external" partition. For example, you can install from `cordova.file.externalDataDirectory`, but **not** from `cordova.file.dataDirectory`. Android 7+ does not have this limitation. @@ -99,30 +119,30 @@ The following functions are available in Android platform: `.uninstall(packageId, callbackContext)` --- Uninstall a package with its id. - - cordova.plugins.fileOpener2.uninstall('com.zynga.FarmVille2CountryEscape', { - error : function(e) { - console.log('Error status: ' + e.status + ' - Error message: ' + e.message); - }, - success : function() { - console.log('Uninstall intent activity started.'); - } - }); - +```javascript +cordova.plugins.fileOpener2.uninstall('com.zynga.FarmVille2CountryEscape', { + error : function(e) { + console.log('Error status: ' + e.status + ' - Error message: ' + e.message); + }, + success : function() { + console.log('Uninstall intent activity started.'); + } +}); +``` `.appIsInstalled(packageId, callbackContext)` --- Check if an app is already installed. - - cordova.plugins.fileOpener2.appIsInstalled('com.adobe.reader', { - success : function(res) { - if (res.status === 0) { - console.log('Adobe Reader is not installed.'); - } else { - console.log('Adobe Reader is installed.') - } +```javascript +cordova.plugins.fileOpener2.appIsInstalled('com.adobe.reader', { + success : function(res) { + if (res.status === 0) { + console.log('Adobe Reader is not installed.'); + } else { + console.log('Adobe Reader is installed.') } - }); - + } +}); +``` --- LICENSE From 8a884711c10ca9671fe277ae101752d40287af68 Mon Sep 17 00:00:00 2001 From: shnist Date: Tue, 11 Dec 2018 17:14:06 +0000 Subject: [PATCH 20/47] docs(): updated contributors list in readme and moved to bottom. --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 37672f1..4111eaa 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,3 @@ -Contributors ------------- -[@Gillardo](https://github.com/Gillardo/), [@TankOs](https://github.com/TankOs), [@Rovi23](https://github.com/Rovi23), [@josemanuelbd](https://github.com/josemanuelbd), [@ielcoro](https://github.com/ielcoro), [@keturn](https://github.com/keturn), [@conform](https://github.com/conform), [@guyc](https://github.com/guyc), [@J3r0M3D3V](https://github.com/J3r0M3D3V), [@WuglyakBolgoink](https://github.com/WuglyakBolgoink), [@lincolnthree](https://github.com/lincolnthree), [@rocco](https://github.com/rocco/), [@FrankFenton](https://github.com/FrankFenton), [@MHolmes91](https://github.com/MHolmes91), [@souly1](https://github.com/souly1), [@diogodias86](https://github.com/diogodias86), [@Arxi](https://github.com/Arxi), [@vzharkov](https://github.com/vzharkov), [@lp1bp](https://github.com/lp1bp), [@stalniy](https://github.com/stalniy), [@liugogal](https://github.com/liugogal), [@lcaprini](https://github.com/lcaprini), [@jcdickman](https://github.com/jcdickman) [@shnist](https://github.com/shnist) - - A File Opener Plugin for Cordova (The Original Version) ========================== This plugin will open a file on your device file system with its default application. @@ -145,6 +140,12 @@ cordova.plugins.fileOpener2.appIsInstalled('com.adobe.reader', { ``` --- +Contributors +------------ +[@Gillardo](https://github.com/Gillardo/), [@TankOs](https://github.com/TankOs), [@Rovi23](https://github.com/Rovi23), [@josemanuelbd](https://github.com/josemanuelbd), [@ielcoro](https://github.com/ielcoro), [@keturn](https://github.com/keturn), [@conform](https://github.com/conform), [@guyc](https://github.com/guyc), [@J3r0M3D3V](https://github.com/J3r0M3D3V), [@WuglyakBolgoink](https://github.com/WuglyakBolgoink), [@lincolnthree](https://github.com/lincolnthree), [@rocco](https://github.com/rocco/), [@FrankFenton](https://github.com/FrankFenton), [@MHolmes91](https://github.com/MHolmes91), [@souly1](https://github.com/souly1), [@diogodias86](https://github.com/diogodias86), [@Arxi](https://github.com/Arxi), [@vzharkov](https://github.com/vzharkov), [@lp1bp](https://github.com/lp1bp), [@stalniy](https://github.com/stalniy), [@liugogal](https://github.com/liugogal), [@lcaprini](https://github.com/lcaprini), [@jcdickman](https://github.com/jcdickman) [@shnist](https://github.com/shnist) [@Eeems](https://github.com/Eeems) + +--- + LICENSE -------- The MIT License (MIT) From fbdb79dee5ea17fb190ac000c633deed633ee7f9 Mon Sep 17 00:00:00 2001 From: Vincent Roth Date: Tue, 11 Dec 2018 19:07:33 +0100 Subject: [PATCH 21/47] Reset appIsInstalled signature --- www/plugins.FileOpener2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/plugins.FileOpener2.js b/www/plugins.FileOpener2.js index e6f0e6c..725a4ad 100644 --- a/www/plugins.FileOpener2.js +++ b/www/plugins.FileOpener2.js @@ -43,8 +43,8 @@ FileOpener2.prototype.uninstall = function (packageId, callbackContext) { exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'uninstall', [packageId]); }; -FileOpener2.prototype.appIsInstalled = function (packageId, options) { - options = options || {}; +FileOpener2.prototype.appIsInstalled = function (packageId, callbackContext) { + callbackContext = callbackContext || {}; exec(options.success || null, options.error || null, 'FileOpener2', 'appIsInstalled', [packageId]); }; From 6865e950a1f46368bef3ba0a77f82dbb0173d950 Mon Sep 17 00:00:00 2001 From: Vincent Roth Date: Tue, 11 Dec 2018 19:08:24 +0100 Subject: [PATCH 22/47] reset appIsInstalled exec --- www/plugins.FileOpener2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/plugins.FileOpener2.js b/www/plugins.FileOpener2.js index 725a4ad..7e064c4 100644 --- a/www/plugins.FileOpener2.js +++ b/www/plugins.FileOpener2.js @@ -45,7 +45,7 @@ FileOpener2.prototype.uninstall = function (packageId, callbackContext) { FileOpener2.prototype.appIsInstalled = function (packageId, callbackContext) { callbackContext = callbackContext || {}; - exec(options.success || null, options.error || null, 'FileOpener2', 'appIsInstalled', [packageId]); + exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'appIsInstalled', [packageId]); }; module.exports = new FileOpener2(); From b3e7d28212caed6c1948bc4a8ccc3ea56ba439e9 Mon Sep 17 00:00:00 2001 From: shnist Date: Wed, 12 Dec 2018 12:31:21 +0000 Subject: [PATCH 23/47] docs(): updated requirements --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e9d980..002dd99 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,13 @@ This plugin will open a file on your device file system with its default applica Requirements ------------- -- Android 4 or higher / iOS 6 or higher / WP8 -- Cordova 3.0 or higher +The following platforms and versions are supported: + +- Android 4.4+ / iOS 9+ / WP8 +- Cordova 6.0 or higher + +Versions lower than this may still work, but are not tested. + Installation ------------- From a0be6605b79cc7d123d5686fe4d32dd6e146f59f Mon Sep 17 00:00:00 2001 From: shnist Date: Wed, 12 Dec 2018 12:35:17 +0000 Subject: [PATCH 24/47] chore(): format fixes for ios fileopener --- src/ios/FileOpener2.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ios/FileOpener2.m b/src/ios/FileOpener2.m index fdebf6c..ee8a935 100644 --- a/src/ios/FileOpener2.m +++ b/src/ios/FileOpener2.m @@ -38,14 +38,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. if ([command.arguments count] >= 3) { showPreview = [[command.arguments objectAtIndex:2] boolValue]; } - - CGRect rect; - if ([command.arguments count] >= 4) { - NSArray *positionValues = command.arguments[3]; - rect = CGRectMake(0,0,[[positionValues objectAtIndex:0] floatValue],[[positionValues objectAtIndex:1] floatValue]); - } else { - rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height); - } + + CGRect rect; + if ([command.arguments count] >= 4) { + NSArray *positionValues = command.arguments[3]; + rect = CGRectMake(0,0,[[positionValues objectAtIndex:0] floatValue],[[positionValues objectAtIndex:1] floatValue]); + } else { + rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height); + } CDVViewController* cont = (CDVViewController*)[super viewController]; self.cdvViewController = cont; From 9b4a15833efdc8df6824009fcbfd8701430b0880 Mon Sep 17 00:00:00 2001 From: shnist Date: Wed, 12 Dec 2018 12:38:43 +0000 Subject: [PATCH 25/47] fix(): fixed engine definition in package.json --- package.json | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index c543242..4b6b84d 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,9 @@ "cordova-wp8", "cordova-windows" ], - "engines": [ - { - "name": "cordova", - "version": ">=3.0.0" - } - ], + "engines": { + "cordova": ">=6.0.0" + }, "author": { "name": "pwlin05@gmail.com" }, @@ -36,4 +33,4 @@ "url": "https://github.com/pwlin/cordova-plugin-file-opener2/issues" }, "homepage": "https://github.com/pwlin/cordova-plugin-file-opener2#readme" -} +} \ No newline at end of file From 257482f323128f992c179c2d2f2f5f907d78eb88 Mon Sep 17 00:00:00 2001 From: shnist Date: Thu, 13 Dec 2018 10:24:42 +0000 Subject: [PATCH 26/47] fix(): fixed compilation error in preview dialog position for ios --- src/ios/FileOpener2.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ios/FileOpener2.m b/src/ios/FileOpener2.m index ee8a935..925e871 100644 --- a/src/ios/FileOpener2.m +++ b/src/ios/FileOpener2.m @@ -44,7 +44,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. NSArray *positionValues = command.arguments[3]; rect = CGRectMake(0,0,[[positionValues objectAtIndex:0] floatValue],[[positionValues objectAtIndex:1] floatValue]); } else { - rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height); + rect = CGRectMake(0, 0, 1000.0f, 150.0f); } CDVViewController* cont = (CDVViewController*)[super viewController]; From a5ae67e6c81e1099fecd8ea19e29011185c911e0 Mon Sep 17 00:00:00 2001 From: Aaron Faber Date: Fri, 14 Dec 2018 12:04:51 +0000 Subject: [PATCH 27/47] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. From f7c73cec106018f814ea4e07cbac53a48983460a Mon Sep 17 00:00:00 2001 From: shnist Date: Fri, 14 Dec 2018 12:10:36 +0000 Subject: [PATCH 28/47] docs(): updated bug report template --- .github/ISSUE_TEMPLATE/bug_report.md | 45 ++++++++++------------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index dd84ea7..ded6e7d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,38 +1,23 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' +### Expected Behaviour ---- +### Actual Behaviour -**Describe the bug** -A clear and concise description of what the bug is. +### Reproduce Scenario (including but not limited to) -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error +#### Steps to Reproduce -**Expected behavior** -A clear and concise description of what you expected to happen. +#### Platform and Version (eg. Android 5.0 or iOS 9.2.1) -**Screenshots** -If applicable, add screenshots to help explain your problem. +#### (Android) What device vendor (e.g. Samsung, HTC, Sony...) -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] +#### Cordova information -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] + cordova info -**Additional context** -Add any other context about the problem here. +#### Plugin version + + cordova plugin version | grep cordova-plugin-file-opener2 + +#### Sample Code that illustrates the problem + +#### Logs taken while reproducing problem From bfbb7521f40f8dcc58ae447e07486701b917bdb8 Mon Sep 17 00:00:00 2001 From: Aaron Faber Date: Fri, 14 Dec 2018 12:11:49 +0000 Subject: [PATCH 29/47] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 45 ++++++++++++++++++---------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ded6e7d..dd84ea7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,23 +1,38 @@ -### Expected Behaviour +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' -### Actual Behaviour +--- -### Reproduce Scenario (including but not limited to) +**Describe the bug** +A clear and concise description of what the bug is. -#### Steps to Reproduce +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error -#### Platform and Version (eg. Android 5.0 or iOS 9.2.1) +**Expected behavior** +A clear and concise description of what you expected to happen. -#### (Android) What device vendor (e.g. Samsung, HTC, Sony...) +**Screenshots** +If applicable, add screenshots to help explain your problem. -#### Cordova information +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] - cordova info +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] -#### Plugin version - - cordova plugin version | grep cordova-plugin-file-opener2 - -#### Sample Code that illustrates the problem - -#### Logs taken while reproducing problem +**Additional context** +Add any other context about the problem here. From 56fd205c7273058e6e722bfb9d629d4d5dca9950 Mon Sep 17 00:00:00 2001 From: shnist Date: Fri, 14 Dec 2018 12:13:34 +0000 Subject: [PATCH 30/47] docs(): fixed bug report template --- .github/ISSUE_TEMPLATE/bug_report.md | 40 ++++++++++++---------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index dd84ea7..3ce851b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,32 +7,26 @@ assignees: '' --- -**Describe the bug** -A clear and concise description of what the bug is. +### Expected Behaviour -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error +### Actual Behaviour -**Expected behavior** -A clear and concise description of what you expected to happen. +### Reproduce Scenario (including but not limited to) -**Screenshots** -If applicable, add screenshots to help explain your problem. +#### Steps to Reproduce -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] +#### Platform and Version (eg. Android 5.0 or iOS 9.2.1) -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] +#### (Android) What device vendor (e.g. Samsung, HTC, Sony...) -**Additional context** -Add any other context about the problem here. +#### Cordova CLI info + + cordova info + +#### Plugin version + + cordova plugin version | grep cordova-plugin-file-opener2 + +#### Sample Code that illustrates the problem + +#### Logs taken while reproducing problem From 64c514f0abc3d43fc13dfd8d616a4806c59664b0 Mon Sep 17 00:00:00 2001 From: shnist Date: Fri, 14 Dec 2018 12:16:02 +0000 Subject: [PATCH 31/47] docs(): tweaked bug report template --- .github/ISSUE_TEMPLATE/bug_report.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 3ce851b..85b6334 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -23,10 +23,16 @@ assignees: '' cordova info +Here is the output: + + #### Plugin version cordova plugin version | grep cordova-plugin-file-opener2 +Here is the output: + + #### Sample Code that illustrates the problem #### Logs taken while reproducing problem From 84c12a8c8d823d16540b3a8ef41b98af188ddf35 Mon Sep 17 00:00:00 2001 From: shnist Date: Fri, 14 Dec 2018 14:30:14 +0000 Subject: [PATCH 32/47] docs(): updated readme to highlight cordova cli support for 7+ now --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 002dd99..65a197a 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,16 @@ -A File Opener Plugin for Cordova (The Original Version) +A File Opener Plugin for Cordova (The Original Version) [![Latest Stable Version](https://img.shields.io/npm/v/cordova-plugin-file-opener2.svg)](https://www.npmjs.com/package/cordova-plugin-file-opener2) [![Total Downloads](https://img.shields.io/npm/dt/cordova-plugin-file-opener2.svg)](https://npm-stat.com/charts.html?package=cordova-plugin-file-opener2) ========================== This plugin will open a file on your device file system with its default application. -[![npm version](https://badge.fury.io/js/cordova-plugin-file-opener2.svg)](https://badge.fury.io/js/cordova-plugin-file-opener2) Requirements ------------- -The following platforms and versions are supported: +The following platforms and versions are supported by the latest release: - Android 4.4+ / iOS 9+ / WP8 -- Cordova 6.0 or higher +- Cordova 7.0 or higher -Versions lower than this may still work, but are not tested. +Cordova 6.0 is supported by 2.0.19, but there are a number of issues, particularly with Android builds (see [232](https://github.com/pwlin/cordova-plugin-file-opener2/issues/232) [203](https://github.com/pwlin/cordova-plugin-file-opener2/issues/203) [207](https://github.com/pwlin/cordova-plugin-file-opener2/issues/207)). Using the [cordova-android-support-gradle-release](https://github.com/dpa99c/cordova-android-support-gradle-release) may help. Installation From 6bde363d1a55f6db25515111f31fa1c1d2177861 Mon Sep 17 00:00:00 2001 From: shnist Date: Fri, 14 Dec 2018 14:31:08 +0000 Subject: [PATCH 33/47] docs(): added missing word --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 65a197a..55c48f5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The following platforms and versions are supported by the latest release: - Android 4.4+ / iOS 9+ / WP8 - Cordova 7.0 or higher -Cordova 6.0 is supported by 2.0.19, but there are a number of issues, particularly with Android builds (see [232](https://github.com/pwlin/cordova-plugin-file-opener2/issues/232) [203](https://github.com/pwlin/cordova-plugin-file-opener2/issues/203) [207](https://github.com/pwlin/cordova-plugin-file-opener2/issues/207)). Using the [cordova-android-support-gradle-release](https://github.com/dpa99c/cordova-android-support-gradle-release) may help. +Cordova 6.0 is supported by 2.0.19, but there are a number of issues, particularly with Android builds (see [232](https://github.com/pwlin/cordova-plugin-file-opener2/issues/232) [203](https://github.com/pwlin/cordova-plugin-file-opener2/issues/203) [207](https://github.com/pwlin/cordova-plugin-file-opener2/issues/207)). Using the [cordova-android-support-gradle-release](https://github.com/dpa99c/cordova-android-support-gradle-release) plugin may help. Installation From bd0add725622ad4ccec59f23c2521e7117e2bfe7 Mon Sep 17 00:00:00 2001 From: shnist Date: Fri, 14 Dec 2018 14:34:11 +0000 Subject: [PATCH 34/47] docs(): updated installation instructions to make it clearer from which release you can set the android support version --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 55c48f5..0dd57f5 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,13 @@ Cordova 6.0 is supported by 2.0.19, but there are a number of issues, particular Installation ------------- + ```shell $ cordova plugin add cordova-plugin-file-opener2 +``` + +From release `2.1.0` you can also set the android support version +```shell $ cordova plugin add cordova-plugin-file-opener2 --variable ANDROID_SUPPORT_VERSION={required version} ``` @@ -28,12 +33,11 @@ cordova.plugins.fileOpener2.open( fileMIMEType, { error : function(){ }, - success : function(){ }, - position : [x, y] + success : function(){ } } ); ``` -`position` array of coordinates from top-left device screen, use for iOS dialog positioning. + Examples -------- From 51af3d55f40db000886776cb3c6c721b562abc1a Mon Sep 17 00:00:00 2001 From: shnist Date: Thu, 20 Dec 2018 12:04:56 +0000 Subject: [PATCH 35/47] docs: updated readme according to latest cordova plugin standards --- README.md | 221 +++++++++++++++++++++++++++--------------------------- 1 file changed, 111 insertions(+), 110 deletions(-) diff --git a/README.md b/README.md index 0dd57f5..4b7ae98 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,10 @@ -A File Opener Plugin for Cordova (The Original Version) [![Latest Stable Version](https://img.shields.io/npm/v/cordova-plugin-file-opener2.svg)](https://www.npmjs.com/package/cordova-plugin-file-opener2) [![Total Downloads](https://img.shields.io/npm/dt/cordova-plugin-file-opener2.svg)](https://npm-stat.com/charts.html?package=cordova-plugin-file-opener2) -========================== +# A File Opener Plugin for Cordova (The Original Version) + +[![Latest Stable Version](https://img.shields.io/npm/v/cordova-plugin-file-opener2.svg)](https://www.npmjs.com/package/cordova-plugin-file-opener2) [![Total Downloads](https://img.shields.io/npm/dt/cordova-plugin-file-opener2.svg)](https://npm-stat.com/charts.html?package=cordova-plugin-file-opener2) [![Build Status](https://travis-ci.org/apache/cordova-plugin-file-opener2.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-file-opener2) + This plugin will open a file on your device file system with its default application. - -Requirements -------------- -The following platforms and versions are supported by the latest release: - -- Android 4.4+ / iOS 9+ / WP8 -- Cordova 7.0 or higher - -Cordova 6.0 is supported by 2.0.19, but there are a number of issues, particularly with Android builds (see [232](https://github.com/pwlin/cordova-plugin-file-opener2/issues/232) [203](https://github.com/pwlin/cordova-plugin-file-opener2/issues/203) [207](https://github.com/pwlin/cordova-plugin-file-opener2/issues/207)). Using the [cordova-android-support-gradle-release](https://github.com/dpa99c/cordova-android-support-gradle-release) plugin may help. - - -Installation -------------- - -```shell -$ cordova plugin add cordova-plugin-file-opener2 -``` - -From release `2.1.0` you can also set the android support version -```shell -$ cordova plugin add cordova-plugin-file-opener2 --variable ANDROID_SUPPORT_VERSION={required version} -``` - -Usage ------- -```javascript +```js cordova.plugins.fileOpener2.open( filePath, fileMIMEType, @@ -38,9 +15,38 @@ cordova.plugins.fileOpener2.open( ); ``` +## Installation -Examples --------- +```shell +$ cordova plugin add cordova-plugin-file-opener2 +``` + +From release `2.1.0` you can also set the android support version +```shell +$ cordova plugin add cordova-plugin-file-opener2 --variable ANDROID_SUPPORT_V4_VERSION={required version} +``` + +## Requirements + +The following platforms and versions are supported by the latest release: + +- Android 4.4+ / iOS 9+ / WP8 / Windows +- Cordova CLI 7.0 or higher + +Cordova CLI 6.0 is supported by 2.0.19, but there are a number of issues, particularly with Android builds (see [232](https://github.com/pwlin/cordova-plugin-file-opener2/issues/232) [203](https://github.com/pwlin/cordova-plugin-file-opener2/issues/203) [207](https://github.com/pwlin/cordova-plugin-file-opener2/issues/207)). Using the [cordova-android-support-gradle-release](https://github.com/dpa99c/cordova-android-support-gradle-release) plugin may help. + +## fileOpener2.open(filePath, mimeType, options) + +Opens a file + +### Supported Platforms + +- Android 4.4+ +- iOS 9+ +- Windows +- WP8 + +### Quick Examples Open an APK install dialog: ```javascript @@ -50,20 +56,9 @@ cordova.plugins.fileOpener2.open( ); ``` -Install From Market: to install an APK from a market place, such as Google Play or the App Store, you can use an `` tag in combination with the `market://` protocol: - -```html -Install from Google Play -Install from App Store -``` - -or in code: -```javascript -window.open("[market:// or itms-apps:// link]","_system"); -``` - Open a PDF document with the default PDF reader and optional callback object: -```javascript + +```js cordova.plugins.fileOpener2.open( '/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf 'application/pdf', @@ -77,8 +72,32 @@ cordova.plugins.fileOpener2.open( } ); ``` -Open a system modal to open PDF document with one of the already installed app and optional callback object: -```javascript + +### Market place installation +Install From Market: to install an APK from a market place, such as Google Play or the App Store, you can use an `` tag in combination with the `market://` protocol: + +```html +Install from Google Play +Install from App Store +``` +or in code: + +```js +window.open("[market:// or itms-apps:// link]","_system"); +``` + +## fileOpener2.showOpenWithDialog(filePath, mimeType, options) + +Opens with system modal to open file with an already installed app. + +### Supported Platforms + +- Android 4.4+ +- iOS 9+ + +### Quick Example + +```js cordova.plugins.fileOpener2.showOpenWithDialog( '/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf 'application/pdf', @@ -93,8 +112,50 @@ cordova.plugins.fileOpener2.showOpenWithDialog( ); ``` -Notes ------- +## fileOpener2.uninstall(packageId, callbackContext) + +Uninstall a package with its ID + +### Supported Platforms + +- Android 4.4+ + +### Quick Example +```js +cordova.plugins.fileOpener2.uninstall('com.zynga.FarmVille2CountryEscape', { + error : function(e) { + console.log('Error status: ' + e.status + ' - Error message: ' + e.message); + }, + success : function() { + console.log('Uninstall intent activity started.'); + } +}); +``` + +## fileOpener2.appIsInstalled(packageId, callbackContext) + +Check if an app is already installed. + +### Supported Platforms + +- Android 4.4+ + +### Quick Example +```javascript +cordova.plugins.fileOpener2.appIsInstalled('com.adobe.reader', { + success : function(res) { + if (res.status === 0) { + console.log('Adobe Reader is not installed.'); + } else { + console.log('Adobe Reader is installed.') + } + } +}); +``` + +--- + +## Notes - For properly opening _any_ file, you must already have a suitable reader for that particular file type installed on your device. Otherwise this will not work. @@ -102,9 +163,10 @@ Notes - If you are wondering what MIME-type should you pass as the second argument to `open` function, [here is a list of all known MIME-types](http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=co) - -Android APK installation limitation --- + +## Android APK installation limitation + The following limitations apply when opening an APK file for installation: - On Android 8+, your application must have the `ACTION_INSTALL_PACKAGE` permission. You can add it by adding this to your app's `config.xml` file: ```xml @@ -117,64 +179,3 @@ The following limitations apply when opening an APK file for installation: - Before Android 7, you can only install APKs from the "external" partition. For example, you can install from `cordova.file.externalDataDirectory`, but **not** from `cordova.file.dataDirectory`. Android 7+ does not have this limitation. -Additional Android Functions ---- -The following functions are available in Android platform: - -`.uninstall(packageId, callbackContext)` ---- -Uninstall a package with its id. -```javascript -cordova.plugins.fileOpener2.uninstall('com.zynga.FarmVille2CountryEscape', { - error : function(e) { - console.log('Error status: ' + e.status + ' - Error message: ' + e.message); - }, - success : function() { - console.log('Uninstall intent activity started.'); - } -}); -``` -`.appIsInstalled(packageId, callbackContext)` ---- -Check if an app is already installed. -```javascript -cordova.plugins.fileOpener2.appIsInstalled('com.adobe.reader', { - success : function(res) { - if (res.status === 0) { - console.log('Adobe Reader is not installed.'); - } else { - console.log('Adobe Reader is installed.') - } - } -}); -``` ---- - -Contributors ------------- -[@Gillardo](https://github.com/Gillardo/), [@TankOs](https://github.com/TankOs), [@Rovi23](https://github.com/Rovi23), [@josemanuelbd](https://github.com/josemanuelbd), [@ielcoro](https://github.com/ielcoro), [@keturn](https://github.com/keturn), [@conform](https://github.com/conform), [@guyc](https://github.com/guyc), [@J3r0M3D3V](https://github.com/J3r0M3D3V), [@WuglyakBolgoink](https://github.com/WuglyakBolgoink), [@lincolnthree](https://github.com/lincolnthree), [@rocco](https://github.com/rocco/), [@FrankFenton](https://github.com/FrankFenton), [@MHolmes91](https://github.com/MHolmes91), [@souly1](https://github.com/souly1), [@diogodias86](https://github.com/diogodias86), [@Arxi](https://github.com/Arxi), [@vzharkov](https://github.com/vzharkov), [@lp1bp](https://github.com/lp1bp), [@stalniy](https://github.com/stalniy), [@liugogal](https://github.com/liugogal), [@lcaprini](https://github.com/lcaprini), [@jcdickman](https://github.com/jcdickman) [@shnist](https://github.com/shnist) [@Eeems](https://github.com/Eeems) - ---- - -LICENSE --------- -The MIT License (MIT) - -Copyright (c) 2013 pwlin - pwlin05@gmail.com - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From a2d5df3182cb03144103ddd1e41ca20371f49926 Mon Sep 17 00:00:00 2001 From: shnist Date: Thu, 20 Dec 2018 12:07:24 +0000 Subject: [PATCH 36/47] 2.1.1 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4b6b84d..347dab0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-file-opener2", - "version": "2.1.0", + "version": "2.1.1", "description": "A File Opener Plugin for Cordova. (The Original Version)", "cordova": { "id": "cordova-plugin-file-opener2", @@ -33,4 +33,4 @@ "url": "https://github.com/pwlin/cordova-plugin-file-opener2/issues" }, "homepage": "https://github.com/pwlin/cordova-plugin-file-opener2#readme" -} \ No newline at end of file +} From cb09bea3c4c2ac602873c600ca8025b79f32ace1 Mon Sep 17 00:00:00 2001 From: shnist Date: Thu, 20 Dec 2018 12:16:19 +0000 Subject: [PATCH 37/47] chore: updated plugin.xml to 2.1.1 --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index a368e8c..7d5ed30 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + File Opener2 A File Opener Plugin for Cordova. (The Original Version) From d913b156f8d4aac0e2837b93443d0ee2004285a8 Mon Sep 17 00:00:00 2001 From: shnist Date: Thu, 20 Dec 2018 15:42:49 +0000 Subject: [PATCH 38/47] fix: fixed reference bug in open method --- www/plugins.FileOpener2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/plugins.FileOpener2.js b/www/plugins.FileOpener2.js index 7e064c4..a9bc263 100644 --- a/www/plugins.FileOpener2.js +++ b/www/plugins.FileOpener2.js @@ -27,9 +27,9 @@ var exec = require('cordova/exec'); function FileOpener2() {} FileOpener2.prototype.open = function (fileName, contentType, options) { - contentType = contentType || ''; + contentType = contentType || ''; options = options || {}; - exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType, false, options.position]); + exec(options.success || null, options.error || null, 'FileOpener2', 'open', [fileName, contentType, false, options.position]); }; FileOpener2.prototype.showOpenWithDialog = function (fileName, contentType, callbackContext) { From 50f64bac8fffed881f8f26598f1c0d7dd3a984ec Mon Sep 17 00:00:00 2001 From: shnist Date: Thu, 20 Dec 2018 15:46:01 +0000 Subject: [PATCH 39/47] chore: patch version for plugin.xml --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 7d5ed30..292e614 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + File Opener2 A File Opener Plugin for Cordova. (The Original Version) From 30fafeeeeffa13c08d9ab1bce83810eca2386317 Mon Sep 17 00:00:00 2001 From: shnist Date: Thu, 20 Dec 2018 16:03:28 +0000 Subject: [PATCH 40/47] 2.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 347dab0..38436e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-file-opener2", - "version": "2.1.1", + "version": "2.1.2", "description": "A File Opener Plugin for Cordova. (The Original Version)", "cordova": { "id": "cordova-plugin-file-opener2", From 7ef3a9db763a959b2ed4e5088b25f8c5284c179a Mon Sep 17 00:00:00 2001 From: shnist Date: Fri, 21 Dec 2018 10:11:11 +0000 Subject: [PATCH 41/47] fix: removed dialog position code from master branch until fixes are applied --- src/ios/FileOpener2.m | 9 +-------- www/plugins.FileOpener2.js | 6 +++--- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/ios/FileOpener2.m b/src/ios/FileOpener2.m index 925e871..257a356 100644 --- a/src/ios/FileOpener2.m +++ b/src/ios/FileOpener2.m @@ -39,14 +39,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. showPreview = [[command.arguments objectAtIndex:2] boolValue]; } - CGRect rect; - if ([command.arguments count] >= 4) { - NSArray *positionValues = command.arguments[3]; - rect = CGRectMake(0,0,[[positionValues objectAtIndex:0] floatValue],[[positionValues objectAtIndex:1] floatValue]); - } else { - rect = CGRectMake(0, 0, 1000.0f, 150.0f); - } - CDVViewController* cont = (CDVViewController*)[super viewController]; self.cdvViewController = cont; NSString *uti = nil; @@ -88,6 +80,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. wasOpened = [docController presentPreviewAnimated: NO]; } else { CDVViewController* cont = self.cdvViewController; + CGRect rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height); wasOpened = [docController presentOpenInMenuFromRect:rect inView:cont.view animated:YES]; } diff --git a/www/plugins.FileOpener2.js b/www/plugins.FileOpener2.js index a9bc263..e8b2258 100644 --- a/www/plugins.FileOpener2.js +++ b/www/plugins.FileOpener2.js @@ -26,10 +26,10 @@ var exec = require('cordova/exec'); function FileOpener2() {} -FileOpener2.prototype.open = function (fileName, contentType, options) { +FileOpener2.prototype.open = function (fileName, contentType, callbackContext) { contentType = contentType || ''; - options = options || {}; - exec(options.success || null, options.error || null, 'FileOpener2', 'open', [fileName, contentType, false, options.position]); + callbackContext = callbackContext || {}; + exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType]); }; FileOpener2.prototype.showOpenWithDialog = function (fileName, contentType, callbackContext) { From cba75e630d5f264aaa58a4995aaf49c5cebe3067 Mon Sep 17 00:00:00 2001 From: shnist Date: Fri, 21 Dec 2018 10:11:31 +0000 Subject: [PATCH 42/47] chore: bump plugin.xml file --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 292e614..6d8ba18 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + File Opener2 A File Opener Plugin for Cordova. (The Original Version) From b6db7cc7917786c4fb5e25b01469360238526014 Mon Sep 17 00:00:00 2001 From: shnist Date: Fri, 21 Dec 2018 10:13:34 +0000 Subject: [PATCH 43/47] docs: tweaked readme section order --- README.md | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4b7ae98..fe56e6d 100644 --- a/README.md +++ b/README.md @@ -152,17 +152,6 @@ cordova.plugins.fileOpener2.appIsInstalled('com.adobe.reader', { } }); ``` - ---- - -## Notes - -- For properly opening _any_ file, you must already have a suitable reader for that particular file type installed on your device. Otherwise this will not work. - -- [It is reported](https://github.com/pwlin/cordova-plugin-file-opener2/issues/2#issuecomment-41295793) that in iOS, you might need to remove `` from your `config.xml` - -- If you are wondering what MIME-type should you pass as the second argument to `open` function, [here is a list of all known MIME-types](http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=co) - --- ## Android APK installation limitation @@ -179,3 +168,17 @@ The following limitations apply when opening an APK file for installation: - Before Android 7, you can only install APKs from the "external" partition. For example, you can install from `cordova.file.externalDataDirectory`, but **not** from `cordova.file.dataDirectory`. Android 7+ does not have this limitation. +--- + +## Notes + +- For properly opening _any_ file, you must already have a suitable reader for that particular file type installed on your device. Otherwise this will not work. + +- [It is reported](https://github.com/pwlin/cordova-plugin-file-opener2/issues/2#issuecomment-41295793) that in iOS, you might need to remove `` from your `config.xml` + +- If you are wondering what MIME-type should you pass as the second argument to `open` function, [here is a list of all known MIME-types](http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=co) + + +--- + + From bb9df451fe7540c73cfe0722e4f8b04af3973546 Mon Sep 17 00:00:00 2001 From: shnist Date: Fri, 21 Dec 2018 10:17:05 +0000 Subject: [PATCH 44/47] 2.1.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 38436e9..611f9e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-file-opener2", - "version": "2.1.2", + "version": "2.1.3", "description": "A File Opener Plugin for Cordova. (The Original Version)", "cordova": { "id": "cordova-plugin-file-opener2", From 29ad35f405ef09dd5716b1b2040f38b7c2771b38 Mon Sep 17 00:00:00 2001 From: shnist Date: Fri, 21 Dec 2018 10:18:04 +0000 Subject: [PATCH 45/47] 2.1.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 611f9e0..bff246c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-file-opener2", - "version": "2.1.3", + "version": "2.1.4", "description": "A File Opener Plugin for Cordova. (The Original Version)", "cordova": { "id": "cordova-plugin-file-opener2", From 88ab8c14bfe8cc46d0f044090d6961e2285a75c5 Mon Sep 17 00:00:00 2001 From: shnist Date: Sat, 22 Dec 2018 21:00:15 +0000 Subject: [PATCH 46/47] chore: bumped plugin.xml version --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 6d8ba18..a261d14 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + File Opener2 A File Opener Plugin for Cordova. (The Original Version) From e90645bee087ec66dd897c72ce56e4c50ef633f5 Mon Sep 17 00:00:00 2001 From: Bruno-bm Date: Mon, 7 Jan 2019 10:55:45 -0200 Subject: [PATCH 47/47] Present notification view controller by inappbrowser v iew controller * (IOS) notification window does not show when inappbrowser window is presented --- src/ios/FileOpener2.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ios/FileOpener2.m b/src/ios/FileOpener2.m index 257a356..761096d 100644 --- a/src/ios/FileOpener2.m +++ b/src/ios/FileOpener2.m @@ -104,6 +104,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @implementation FileOpener2 (UIDocumentInteractionControllerDelegate) - (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller { - return self.cdvViewController; + UIViewController *presentingViewController = self.viewController; + if (presentingViewController.view.window != [UIApplication sharedApplication].keyWindow){ + presentingViewController = [UIApplication sharedApplication].keyWindow.rootViewController; + } + + while (presentingViewController.presentedViewController != nil && ![presentingViewController.presentedViewController isBeingDismissed]){ + presentingViewController = presentingViewController.presentedViewController; + } + return presentingViewController; } @end