From 8b5dd5eb0139fdff35595f7e26f214659bde1fa6 Mon Sep 17 00:00:00 2001 From: VincentRoth Date: Wed, 29 Jun 2016 18:01:42 +0200 Subject: [PATCH 1/8] 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 2/8] 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 3/8] 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 4/8] 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 5/8] 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 6/8] 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 fbdb79dee5ea17fb190ac000c633deed633ee7f9 Mon Sep 17 00:00:00 2001 From: Vincent Roth Date: Tue, 11 Dec 2018 19:07:33 +0100 Subject: [PATCH 7/8] 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 8/8] 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();