@nativescript-community/ui-share-file
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -6,2 +6,6 @@ # Change Log | ||
## [1.3.2](https://github.com/nativescript-community/ui-share-file/compare/v1.3.1...v1.3.2) (2023-10-27) | ||
**Note:** Version bump only for package @nativescript-community/ui-share-file | ||
## [1.3.1](https://github.com/nativescript-community/ui-share-file/compare/v1.3.0...v1.3.1) (2023-02-27) | ||
@@ -8,0 +12,0 @@ |
{ | ||
"name": "@nativescript-community/ui-share-file", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Send/share file to other apps.", | ||
@@ -34,3 +34,3 @@ "main": "share-file", | ||
"bootstrapper": "nativescript-plugin-seed", | ||
"gitHead": "bd7d4751b84d9bf1bef4709f24e037247672880d" | ||
"gitHead": "77f84ac9e12c51d9264541ad99a049f30e47d52c" | ||
} |
@@ -45,3 +45,3 @@ # Nativescript Share File | ||
path: this.path, | ||
intentTitle: 'Open text file with:', // optional Android | ||
title: 'Open text file with:', // optional Android | ||
rect: { // optional iPad | ||
@@ -70,3 +70,3 @@ x: 110, | ||
#### intentTitle | ||
#### title | ||
Title for the intent on Android. | ||
@@ -94,2 +94,2 @@ | ||
`Boolean`: (Optional) | ||
Default: `false`. | ||
Default: `false`. |
@@ -1,4 +0,2 @@ | ||
import { Utils } from '@nativescript/core'; | ||
import { AndroidApplication, android as androidApp } from '@nativescript/core/application'; | ||
import { File, Folder, path } from '@nativescript/core/file-system'; | ||
import { Application, File, Folder, Utils, path } from '@nativescript/core'; | ||
const REQUEST_CODE = 2343; | ||
@@ -10,3 +8,4 @@ export class ShareFile { | ||
try { | ||
const intent = new android.content.Intent(); | ||
const Intent = android.content.Intent; | ||
const intent = new Intent(); | ||
const context = Utils.android.getApplicationContext(); | ||
@@ -16,3 +15,3 @@ // const map = android.webkit.MimeTypeMap.getSingleton(); | ||
if (args.dontGrantReadUri !== true) { | ||
intent.addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION); | ||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | ||
} | ||
@@ -22,4 +21,4 @@ if (Array.isArray(args.path)) { | ||
args.path.forEach((p) => uris.add(this._getUriForPath(p, this.fileName(p), context))); | ||
intent.putParcelableArrayListExtra(android.content.Intent.EXTRA_STREAM, uris); | ||
intent.setAction(android.content.Intent.ACTION_SEND_MULTIPLE); | ||
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); | ||
intent.setAction(Intent.ACTION_SEND_MULTIPLE); | ||
} | ||
@@ -29,4 +28,4 @@ else { | ||
const uri = this._getUriForPath(path, this.fileName(path), context); | ||
intent.putExtra(android.content.Intent.EXTRA_STREAM, uri); | ||
intent.setAction(android.content.Intent.ACTION_SEND); | ||
intent.putExtra(Intent.EXTRA_STREAM, uri); | ||
intent.setAction(Intent.ACTION_SEND); | ||
} | ||
@@ -36,5 +35,5 @@ const builder = new android.os.StrictMode.VmPolicy.Builder(); | ||
intent.setType((args === null || args === void 0 ? void 0 : args.type) || '*/*'); | ||
const activity = androidApp.foregroundActivity || androidApp.startActivity; | ||
const activity = Application.android.startActivity; | ||
const onActivityResultHandler = (data) => { | ||
androidApp.off(AndroidApplication.activityResultEvent, onActivityResultHandler); | ||
Application.android.off(Application.android.activityResultEvent, onActivityResultHandler); | ||
if (data.requestCode === REQUEST_CODE) { | ||
@@ -44,4 +43,4 @@ resolve(data.resultCode); | ||
}; | ||
androidApp.on(AndroidApplication.activityResultEvent, onActivityResultHandler); | ||
activity.startActivityForResult(android.content.Intent.createChooser(intent, args.title || 'Open file:'), REQUEST_CODE); | ||
Application.android.on(Application.android.activityResultEvent, onActivityResultHandler); | ||
activity.startActivityForResult(Intent.createChooser(intent, args.title || 'Open file:'), REQUEST_CODE); | ||
} | ||
@@ -67,3 +66,3 @@ catch (e) { | ||
const file = new java.io.File(filePath); | ||
return androidx.core.content.FileProvider.getUriForFile(androidApp.foregroundActivity || androidApp.startActivity, androidApp.packageName + '.provider', file); | ||
return androidx.core.content.FileProvider.getUriForFile(Application.android.startActivity, Utils.android.getPackageName() + '.provider', file); | ||
} | ||
@@ -95,3 +94,3 @@ catch (err) { | ||
if (!file.exists()) { | ||
console.log('File not found: ' + file.getAbsolutePath()); | ||
console.error('File not found: ' + file.getAbsolutePath()); | ||
return null; | ||
@@ -106,3 +105,3 @@ } | ||
if (!File.exists(filePath)) { | ||
console.log('File does not exist: ' + filePath); | ||
console.error('File does not exist: ' + filePath); | ||
return null; | ||
@@ -127,3 +126,3 @@ } | ||
catch (ex) { | ||
console.log('Invalid Base64 string: ' + resData); | ||
console.error('Invalid Base64 string: ' + resData); | ||
return android.net.Uri.EMPTY; | ||
@@ -137,3 +136,3 @@ } | ||
if (dir === null) { | ||
console.log('Missing external cache dir'); | ||
console.error('Missing external cache dir'); | ||
return null; | ||
@@ -140,0 +139,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Application } from '@nativescript/core'; | ||
import { Application, Utils } from '@nativescript/core'; | ||
// we need to store both the controller and the delegate. | ||
@@ -39,3 +39,6 @@ // UIDocumentInteractionController is not retained by iOS | ||
controller.name = args.title; | ||
const presentingController = Application.ios.rootController; | ||
// attempt to use the visible view controller to support modals and such, if not fall back to root | ||
let presentingController = Utils.ios.getVisibleViewController(Application.ios.rootController); | ||
if (!presentingController) | ||
presentingController = Application.ios.rootController; | ||
const delegate = UIDocumentInteractionControllerDelegateImpl.new().initWithOwnerController(this, presentingController); | ||
@@ -92,16 +95,12 @@ controller.delegate = delegate; | ||
} | ||
var UIDocumentInteractionControllerDelegateImpl = /** @class */ (function (_super) { | ||
__extends(UIDocumentInteractionControllerDelegateImpl, _super); | ||
function UIDocumentInteractionControllerDelegateImpl() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
let UIDocumentInteractionControllerDelegateImpl = class UIDocumentInteractionControllerDelegateImpl extends NSObject { | ||
static new() { | ||
return super.new(); | ||
} | ||
UIDocumentInteractionControllerDelegateImpl.new = function () { | ||
return _super.new.call(this); | ||
}; | ||
UIDocumentInteractionControllerDelegateImpl.prototype.initWithOwnerController = function (owner, controller) { | ||
initWithOwnerController(owner, controller) { | ||
this._owner = owner; | ||
this.controller = controller; | ||
return this; | ||
}; | ||
UIDocumentInteractionControllerDelegateImpl.prototype.documentInteractionControllerWillBeginSendingToApplication = function (controller, app) { | ||
} | ||
documentInteractionControllerWillBeginSendingToApplication(controller, app) { | ||
// console.log( | ||
@@ -111,33 +110,35 @@ // "documentInteractionControllerWillBeginSendingToApplication", | ||
// ); | ||
var owner = this._owner; | ||
const owner = this._owner; | ||
if (owner) { | ||
owner.dismissed(); | ||
} | ||
}; | ||
UIDocumentInteractionControllerDelegateImpl.prototype.documentInteractionControllerDidDismissOpenInMenu = function (controller) { | ||
} | ||
documentInteractionControllerDidDismissOpenInMenu(controller) { | ||
// console.log("documentInteractionControllerDidDismissOpenInMenu"); | ||
var owner = this._owner; | ||
const owner = this._owner; | ||
if (owner) { | ||
owner.dismissed(); | ||
} | ||
}; | ||
UIDocumentInteractionControllerDelegateImpl.prototype.documentInteractionControllerDidDismissOptionsMenu = function (controller) { | ||
} | ||
documentInteractionControllerDidDismissOptionsMenu(controller) { | ||
// console.log("documentInteractionControllerDidDismissOptionsMenu"); | ||
var owner = this._owner; | ||
const owner = this._owner; | ||
if (owner) { | ||
owner.dismissed(); | ||
} | ||
}; | ||
UIDocumentInteractionControllerDelegateImpl.prototype.documentInteractionControllerViewControllerForPreview = function (controller) { | ||
} | ||
documentInteractionControllerViewControllerForPreview(controller) { | ||
return this.controller; | ||
}; | ||
UIDocumentInteractionControllerDelegateImpl.prototype.documentInteractionControllerViewForPreview = function (controller) { | ||
} | ||
documentInteractionControllerViewForPreview(controller) { | ||
return this.controller.view; | ||
}; | ||
UIDocumentInteractionControllerDelegateImpl.prototype.documentInteractionControllerRectForPreview = function (controller) { | ||
} | ||
documentInteractionControllerRectForPreview(controller) { | ||
return this.controller.view.bounds; | ||
}; | ||
UIDocumentInteractionControllerDelegateImpl.ObjCProtocols = [UIDocumentInteractionControllerDelegate]; | ||
return UIDocumentInteractionControllerDelegateImpl; | ||
}(NSObject)); | ||
} | ||
}; | ||
UIDocumentInteractionControllerDelegateImpl.ObjCProtocols = [UIDocumentInteractionControllerDelegate]; | ||
UIDocumentInteractionControllerDelegateImpl = __decorate([ | ||
NativeClass | ||
], UIDocumentInteractionControllerDelegateImpl); | ||
//# sourceMappingURL=share-file.ios.js.map |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93
33137