mirror of
https://gitee.com/shuto/cordova-plugin-file-opener2.git
synced 2025-01-31 12:02:49 +08:00
Merge pull request #112 from stalniy/feat/showOpenWithDialog
feat(ios): adds method for opening openWith dialog on iOS
This commit is contained in:
commit
10253b6b69
@ -33,11 +33,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
NSString *path = [[command.arguments objectAtIndex:0] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
NSString *contentType = nil;
|
||||
BOOL showPreview = YES;
|
||||
|
||||
if([command.arguments count] == 2) { // Includes contentType
|
||||
contentType = [command.arguments objectAtIndex:1];
|
||||
}
|
||||
|
||||
if ([command.arguments count] == 3) {
|
||||
showPreview = [[command.arguments objectAtIndex:2] boolValue];
|
||||
}
|
||||
|
||||
CDVViewController* cont = (CDVViewController*)[super viewController];
|
||||
self.cdvViewController = cont;
|
||||
|
||||
@ -68,7 +73,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
CDVPluginResult* pluginResult = nil;
|
||||
|
||||
//Opens the file preview
|
||||
BOOL wasOpened = [docController presentPreviewAnimated: NO];
|
||||
BOOL wasOpened = NO;
|
||||
|
||||
if (showPreview) {
|
||||
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];
|
||||
}
|
||||
|
||||
if(wasOpened) {
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @""];
|
||||
|
@ -31,6 +31,11 @@ FileOpener2.prototype.open = function (fileName, contentType, callbackContext) {
|
||||
exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType]);
|
||||
};
|
||||
|
||||
FileOpener2.prototype.showOpenWithDialog = function (fileName, contentType, callbackContext) {
|
||||
callbackContext = callbackContext || {};
|
||||
exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType, false]);
|
||||
};
|
||||
|
||||
FileOpener2.prototype.uninstall = function (packageId, callbackContext) {
|
||||
callbackContext = callbackContext || {};
|
||||
exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'uninstall', [packageId]);
|
||||
@ -41,4 +46,4 @@ FileOpener2.prototype.appIsInstalled = function (packageId, callbackContext) {
|
||||
exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'appIsInstalled', [packageId]);
|
||||
};
|
||||
|
||||
module.exports = new FileOpener2();
|
||||
module.exports = new FileOpener2();
|
||||
|
Loading…
Reference in New Issue
Block a user