nativescript-camera-plus-fixed-distorted
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
global.__awaiter = | ||
@@ -16,3 +16,3 @@ (this && this.__awaiter) || | ||
try { | ||
step(generator["throw"](value)); | ||
step(generator['throw'](value)); | ||
} | ||
@@ -54,9 +54,6 @@ catch (e) { | ||
if (f) | ||
throw new TypeError("Generator is already executing."); | ||
throw new TypeError('Generator is already executing.'); | ||
while (_) | ||
try { | ||
if (((f = 1), | ||
y && | ||
(t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && | ||
!(t = t.call(y, op[1])).done)) | ||
if (((f = 1), y && (t = y[op[0] & 2 ? 'return' : op[0] ? 'throw' : 'next']) && !(t = t.call(y, op[1])).done)) | ||
return t; | ||
@@ -83,4 +80,3 @@ if (((y = 0), t)) | ||
default: | ||
if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && | ||
(op[0] === 6 || op[0] === 2)) { | ||
if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && (op[0] === 6 || op[0] === 2)) { | ||
_ = 0; | ||
@@ -87,0 +83,0 @@ continue; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var content_view_1 = require("tns-core-modules/ui/content-view"); | ||
var view_1 = require("tns-core-modules/ui/core/view"); | ||
var CameraUtil = (function () { | ||
@@ -114,2 +114,4 @@ function CameraUtil() { | ||
CameraPlusBase.videoRecordingReadyEvent = 'videoRecordingReadyEvent'; | ||
CameraPlusBase.confirmScreenShownEvent = 'confirmScreenShownEvent'; | ||
CameraPlusBase.confirmScreenDismissedEvent = 'confirmScreenDismissedEvent'; | ||
__decorate([ | ||
@@ -192,4 +194,14 @@ GetSetProperty(), | ||
return CameraPlusBase; | ||
}(content_view_1.ContentView)); | ||
}(view_1.View)); | ||
exports.CameraPlusBase = CameraPlusBase; | ||
var CameraVideoQuality; | ||
(function (CameraVideoQuality) { | ||
CameraVideoQuality["MAX_480P"] = "480p"; | ||
CameraVideoQuality["MAX_720P"] = "720p"; | ||
CameraVideoQuality["MAX_1080P"] = "1080p"; | ||
CameraVideoQuality["MAX_2160P"] = "2160p"; | ||
CameraVideoQuality["HIGHEST"] = "highest"; | ||
CameraVideoQuality["LOWEST"] = "lowest"; | ||
CameraVideoQuality["QVGA"] = "qvga"; | ||
})(CameraVideoQuality = exports.CameraVideoQuality || (exports.CameraVideoQuality = {})); | ||
function GetSetProperty() { | ||
@@ -196,0 +208,0 @@ return function (target, propertyKey) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var color_1 = require("tns-core-modules/color"); | ||
var fs = require("tns-core-modules/file-system/file-system"); | ||
var image_asset_1 = require("tns-core-modules/image-asset"); | ||
var types = require("tns-core-modules/utils/types"); | ||
var image_asset_1 = require("tns-core-modules/image-asset"); | ||
var color_1 = require("tns-core-modules/color"); | ||
var platform_1 = require("tns-core-modules/platform"); | ||
var camera_plus_common_1 = require("./camera-plus.common"); | ||
var view_1 = require("tns-core-modules/ui/core/view"); | ||
var camera_plus_common_2 = require("./camera-plus.common"); | ||
exports.CameraVideoQuality = camera_plus_common_2.CameraVideoQuality; | ||
var platform = require("tns-core-modules/platform"); | ||
var QBImagePickerControllerDelegateImpl = (function (_super) { | ||
@@ -45,3 +49,3 @@ __extends(QBImagePickerControllerDelegateImpl, _super); | ||
var _this = this; | ||
var images = []; | ||
var selection = []; | ||
var manager = PHImageManager.defaultManager(); | ||
@@ -54,21 +58,53 @@ var targetSize = PHImageManagerMaximumSize; | ||
requestOptions.normalizedCropRect = CGRectMake(0, 0, 1, 1); | ||
requestOptions.version = 2; | ||
requestOptions.networkAccessAllowed = true; | ||
var cnt = 0; | ||
var next = function () { | ||
cnt++; | ||
if (cnt === assets.count) { | ||
this._callback(selection); | ||
this._owner.get().closePicker(); | ||
} | ||
else { | ||
requestImg(cnt); | ||
} | ||
}; | ||
var requestImg = function (i) { | ||
var asset = assets.objectAtIndex(i); | ||
manager.requestImageForAssetTargetSizeContentModeOptionsResultHandler(asset, targetSize, 1, requestOptions, function (image, info) { | ||
var imageAsset = new image_asset_1.ImageAsset(image); | ||
if (_this._width) | ||
imageAsset.options.width = _this._width; | ||
if (_this._height) | ||
imageAsset.options.height = _this._height; | ||
images.push(imageAsset); | ||
cnt++; | ||
if (cnt === assets.count) { | ||
_this._callback(images); | ||
_this._owner.get().closePicker(); | ||
} | ||
else { | ||
requestImg(cnt); | ||
} | ||
}); | ||
if (asset.mediaType === 1) { | ||
manager.requestImageForAssetTargetSizeContentModeOptionsResultHandler(asset, targetSize, 1, requestOptions, function (image, info) { | ||
var imageAsset = new image_asset_1.ImageAsset(image); | ||
if (_this._width) | ||
imageAsset.options.width = _this._width; | ||
if (_this._height) | ||
imageAsset.options.height = _this._height; | ||
selection.push(imageAsset); | ||
next.call(_this); | ||
}); | ||
} | ||
else if (asset.mediaType === 2) { | ||
var requestOptions_1 = PHVideoRequestOptions.alloc().init(); | ||
requestOptions_1.version = 1; | ||
requestOptions_1.networkAccessAllowed = true; | ||
manager.requestAVAssetForVideoOptionsResultHandler(asset, requestOptions_1, function (videoAsset, audioMix, info) { | ||
if (videoAsset.isKindOfClass(AVURLAsset.class())) { | ||
var docsPath = fs.knownFolders.documents(); | ||
var pathParts = videoAsset.URL.toString().split(fs.path.separator); | ||
var filename = pathParts[pathParts.length - 1]; | ||
var localFilePath = fs.path.join(docsPath.path, 'camera-plus-videos', filename); | ||
var targetURL = NSURL.fileURLWithPath(localFilePath); | ||
if (fs.File.exists(localFilePath)) { | ||
docsPath.getFile('camera-plus-videos/' + filename).remove(); | ||
} | ||
else { | ||
docsPath.getFolder('camera-plus-videos'); | ||
} | ||
var result = NSFileManager.defaultManager.copyItemAtURLToURLError(videoAsset.URL, targetURL); | ||
if (result) { | ||
selection.push(localFilePath); | ||
} | ||
} | ||
next.call(_this); | ||
}); | ||
} | ||
}; | ||
@@ -93,2 +129,17 @@ requestImg(0); | ||
}; | ||
SwiftyDelegate.prototype.swiftyCamDidFailToConfigure = function (swiftyCam) { | ||
camera_plus_common_1.CLog('swiftyCamDidFailToConfigure:'); | ||
}; | ||
SwiftyDelegate.prototype.swiftyCamDidFailToRecordVideo = function (swiftyCam, error) { | ||
camera_plus_common_1.CLog('swiftyCamDidFailToRecordVideo:'); | ||
}; | ||
SwiftyDelegate.prototype.swiftyCamNotAuthorized = function (swiftyCam) { | ||
camera_plus_common_1.CLog('swiftyCamNotAuthorized:'); | ||
}; | ||
SwiftyDelegate.prototype.swiftyCamSessionDidStopRunning = function (swiftyCam) { | ||
camera_plus_common_1.CLog('swiftyCamSessionDidStopRunning:'); | ||
}; | ||
SwiftyDelegate.prototype.swiftyCamSessionDidStartRunning = function (swiftyCam) { | ||
camera_plus_common_1.CLog('swiftyCamSessionDidStartRunning:'); | ||
}; | ||
SwiftyDelegate.prototype.swiftyCamDidBeginRecordingVideo = function (swiftyCam, camera) { | ||
@@ -134,4 +185,3 @@ camera_plus_common_1.CLog('swiftyCamDidBeginRecordingVideo:', camera); | ||
} | ||
MySwifty.initWithOwner = function (owner, enableVideo, defaultCamera) { | ||
if (enableVideo === void 0) { enableVideo = false; } | ||
MySwifty.initWithOwner = function (owner, defaultCamera) { | ||
if (defaultCamera === void 0) { defaultCamera = 'rear'; } | ||
@@ -142,4 +192,2 @@ camera_plus_common_1.CLog('MySwifty initWithOwner'); | ||
ctrl._owner = owner; | ||
ctrl._enableVideo = enableVideo; | ||
ctrl.disableAudio = enableVideo === false; | ||
ctrl.defaultCamera = defaultCamera === 'rear' ? 0 : 1; | ||
@@ -150,2 +198,9 @@ camera_plus_common_1.CLog('ctrl.disableAudio:', ctrl.disableAudio); | ||
}; | ||
Object.defineProperty(MySwifty.prototype, "enableVideo", { | ||
set: function (value) { | ||
this._enableVideo = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MySwifty.prototype, "pickerDelegate", { | ||
@@ -182,17 +237,5 @@ set: function (value) { | ||
}; | ||
MySwifty.prototype.resize = function (width, height) { | ||
if (typeof width !== 'number') { | ||
width = platform_1.screen.mainScreen.widthDIPs; | ||
} | ||
if (typeof height !== 'number') { | ||
height = platform_1.screen.mainScreen.heightDIPs; | ||
} | ||
camera_plus_common_1.CLog('resizing to:', width + 'x' + height); | ||
this.view.frame = CGRectMake(0, 0, width, height); | ||
camera_plus_common_1.CLog('view.bounds:', this.view.bounds.size.width + 'x' + this.view.bounds.size.height); | ||
if (!this._resized) { | ||
this._resized = true; | ||
this._addButtons(); | ||
this.viewDidAppear(true); | ||
} | ||
MySwifty.prototype.viewWillAppear = function (animated) { | ||
_super.prototype.viewWillAppear.call(this, animated); | ||
camera_plus_common_1.CLog('MySwifty viewWillAppear'); | ||
}; | ||
@@ -215,2 +258,3 @@ MySwifty.prototype.snapPicture = function (options) { | ||
MySwifty.prototype.recordVideo = function (options) { | ||
var _this = this; | ||
if (this._enableVideo) { | ||
@@ -232,3 +276,37 @@ if (this.isVideoRecording) { | ||
} | ||
this.startVideoRecording(); | ||
if (parseFloat(platform.device.sdkVersion) >= 11) { | ||
this.videoCodecType = AVVideoCodecTypeHEVC; | ||
} | ||
switch (options ? options.quality : camera_plus_common_1.CameraVideoQuality.MAX_480P) { | ||
case camera_plus_common_1.CameraVideoQuality.MAX_2160P: | ||
this.videoQuality = 7; | ||
break; | ||
case camera_plus_common_1.CameraVideoQuality.MAX_1080P: | ||
this.videoQuality = 6; | ||
break; | ||
case camera_plus_common_1.CameraVideoQuality.MAX_720P: | ||
this.videoQuality = 5; | ||
break; | ||
case camera_plus_common_1.CameraVideoQuality.HIGHEST: | ||
this.videoQuality = 0; | ||
break; | ||
case camera_plus_common_1.CameraVideoQuality.LOWEST: | ||
this.videoQuality = 2; | ||
break; | ||
case camera_plus_common_1.CameraVideoQuality.QVGA: | ||
this.videoQuality = 3; | ||
break; | ||
default: | ||
this.videoQuality = 4; | ||
break; | ||
} | ||
var status_1 = PHPhotoLibrary.authorizationStatus(); | ||
if (status_1 === 0) { | ||
PHPhotoLibrary.requestAuthorization(function (status) { | ||
_this.startVideoRecording(); | ||
}); | ||
} | ||
else { | ||
this.startVideoRecording(); | ||
} | ||
} | ||
@@ -243,3 +321,6 @@ } | ||
this._owner.get().sendEvent(CameraPlus.videoRecordingReadyEvent, path); | ||
UISaveVideoAtPathToSavedPhotosAlbum(path, this, 'videoDidFinishSavingWithErrorContextInfo', null); | ||
var status_2 = PHPhotoLibrary.authorizationStatus(); | ||
if (status_2 === 3) { | ||
UISaveVideoAtPathToSavedPhotosAlbum(path, this, 'videoDidFinishSavingWithErrorContextInfo', null); | ||
} | ||
} | ||
@@ -277,3 +358,4 @@ else { | ||
var keepAspectRatio = this._owner.get().keepAspectRatio; | ||
this.chooseFromLibrary({ width: width, height: height, keepAspectRatio: keepAspectRatio }); | ||
var showVideos = this._enableVideo; | ||
this.chooseFromLibrary({ width: width, height: height, keepAspectRatio: keepAspectRatio, showVideos: showVideos }); | ||
}; | ||
@@ -292,4 +374,4 @@ MySwifty.prototype.tookPhoto = function (photo) { | ||
imageConfirm.frame = CGRectMake(0, 50, width, height - 40); | ||
var retakeBtn = createButton(this, CGRectMake(10, 10, 75, 50), this._snapPicOptions.confirmRetakeText, 'resetPreview'); | ||
var saveBtn = createButton(this, CGRectMake(width - 170, 10, 150, 50), this._snapPicOptions.confirmSaveText, 'savePhoto', 'right'); | ||
var retakeBtn = createButton(this, CGRectMake(10, 10, 75, 50), this._snapPicOptions.confirmRetakeText ? this._snapPicOptions.confirmRetakeText : 'Retake', 'resetPreview'); | ||
var saveBtn = createButton(this, CGRectMake(width - 170, 10, 150, 50), this._snapPicOptions.confirmSaveText ? this._snapPicOptions.confirmSaveText : 'Save', 'savePhoto', 'right'); | ||
this._imageConfirmBg.addSubview(imageConfirm); | ||
@@ -299,2 +381,3 @@ this._imageConfirmBg.addSubview(retakeBtn); | ||
this.view.addSubview(this._imageConfirmBg); | ||
this._owner.get().sendEvent(CameraPlus.confirmScreenShownEvent); | ||
} | ||
@@ -310,2 +393,3 @@ else { | ||
this._imageConfirmBg = null; | ||
this._owner.get().sendEvent(CameraPlus.confirmScreenDismissedEvent); | ||
} | ||
@@ -341,2 +425,8 @@ }; | ||
} | ||
else { | ||
options = { | ||
showImages: true, | ||
showVideos: _this._enableVideo | ||
}; | ||
} | ||
var authStatus = PHPhotoLibrary.authorizationStatus(); | ||
@@ -366,2 +456,15 @@ if (reqWidth && reqHeight) { | ||
imagePickerController.modalPresentationStyle = 3; | ||
var mediaType = 0; | ||
if (options.showImages === undefined) { | ||
options.showImages = true; | ||
} | ||
if (!options.showImages && options.showVideos) { | ||
mediaType = 2; | ||
} | ||
else { | ||
if (options.showImages && !options.showVideos) { | ||
mediaType = 1; | ||
} | ||
} | ||
imagePickerController.mediaType = mediaType; | ||
rootVC().presentViewControllerAnimatedCompletion(imagePickerController, true, null); | ||
@@ -387,6 +490,7 @@ }); | ||
if (this._owner.get().showCaptureIcon) { | ||
var picOutline = createButton(this, CGRectMake(width / 2 - 20, height - 80, 50, 50), null, null, null, createIcon('picOutline')); | ||
var heightOffset = this._owner.get().isIPhoneX ? 160 : 80; | ||
var picOutline = createButton(this, CGRectMake(width / 2 - 20, height - heightOffset, 50, 50), null, null, null, createIcon('picOutline')); | ||
picOutline.transform = CGAffineTransformMakeScale(1.5, 1.5); | ||
this.view.addSubview(picOutline); | ||
var takePicBtn = createButton(this, CGRectMake(width / 2 - 21.5, height - 80.7, 50, 50), null, this._enableVideo ? 'recordVideo' : 'snapPicture', null, createIcon('takePic')); | ||
var takePicBtn = createButton(this, CGRectMake(width / 2 - 21.5, height - (heightOffset + 0.7), 50, 50), null, this._enableVideo ? 'recordVideo' : 'snapPicture', null, createIcon('takePic')); | ||
this.view.addSubview(takePicBtn); | ||
@@ -430,37 +534,52 @@ } | ||
_this._galleryMax = 3; | ||
_this._onLayoutChangeListener = _this._onLayoutChangeFn.bind(_this); | ||
camera_plus_common_1.CLog('CameraPlus constructor'); | ||
_this._swifty = MySwifty.initWithOwner(new WeakRef(_this), CameraPlus.enableVideo, CameraPlus.defaultCamera); | ||
_this._swifty = MySwifty.initWithOwner(new WeakRef(_this), CameraPlus.defaultCamera); | ||
_this._swifty.shouldUseDeviceOrientation = CameraPlus.useDeviceOrientation; | ||
_this._detectDevice(); | ||
return _this; | ||
} | ||
CameraPlus.prototype.isVideoEnabled = function () { | ||
return this.enableVideo === true || CameraPlus.enableVideo; | ||
}; | ||
CameraPlus.prototype.createNativeView = function () { | ||
this.nativeView = this._swifty.view; | ||
this._swifty.enableVideo = this.isVideoEnabled(); | ||
this._swifty.disableAudio = !this.isVideoEnabled(); | ||
camera_plus_common_1.CLog('CameraPlus createNativeView'); | ||
camera_plus_common_1.CLog('video enabled:', CameraPlus.enableVideo); | ||
camera_plus_common_1.CLog('video enabled:', this.isVideoEnabled()); | ||
camera_plus_common_1.CLog('default camera:', CameraPlus.defaultCamera); | ||
camera_plus_common_1.CLog(this.nativeView); | ||
return this.nativeView; | ||
camera_plus_common_1.CLog(this._swifty.view); | ||
this._swifty.view.autoresizingMask = 2 | 16; | ||
return this._swifty.view; | ||
}; | ||
CameraPlus.prototype._onLayoutChangeFn = function (args) { | ||
var size = this.getActualSize(); | ||
camera_plus_common_1.CLog('xml width/height:', size.width + 'x' + size.height); | ||
}; | ||
CameraPlus.prototype.initNativeView = function () { | ||
var _this = this; | ||
camera_plus_common_1.CLog('initNativeView.'); | ||
camera_plus_common_1.CLog('xml width/height:', this.width + 'x' + this.height); | ||
var changedDimensions = false; | ||
if (this.width == 'auto') { | ||
camera_plus_common_1.CLog('no width set, defaulting to mainScreen.widthDIPs'); | ||
this.width = platform_1.screen.mainScreen.widthDIPs; | ||
changedDimensions = true; | ||
} | ||
if (this.height == 'auto') { | ||
camera_plus_common_1.CLog('no height set, defaulting to mainScreen.heightDIPs'); | ||
this.height = platform_1.screen.mainScreen.heightDIPs; | ||
changedDimensions = true; | ||
} | ||
camera_plus_common_1.CLog('after modifying xml width/height:', this.width + 'x' + this.height); | ||
this._swifty.resize(this.width, this.height); | ||
setTimeout(function () { | ||
if (changedDimensions) | ||
_this.requestLayout(); | ||
}); | ||
this.on(view_1.View.layoutChangedEvent, this._onLayoutChangeListener); | ||
this._swifty.viewWillAppear(true); | ||
}; | ||
CameraPlus.prototype.disposeNativeView = function () { | ||
camera_plus_common_1.CLog('disposeNativeView.'); | ||
this.off(view_1.View.layoutChangedEvent, this._onLayoutChangeListener); | ||
_super.prototype.disposeNativeView.call(this); | ||
}; | ||
CameraPlus.prototype.onLoaded = function () { | ||
_super.prototype.onLoaded.call(this); | ||
this._swifty._addButtons(); | ||
this._swifty.viewDidAppear(true); | ||
}; | ||
CameraPlus.prototype.onUnloaded = function () { | ||
this._swifty.viewDidDisappear(true); | ||
_super.prototype.onUnloaded.call(this); | ||
}; | ||
Object.defineProperty(CameraPlus.prototype, "isIPhoneX", { | ||
get: function () { | ||
return this._isIPhoneX; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(CameraPlus.prototype, "galleryPickerWidth", { | ||
@@ -525,3 +644,3 @@ get: function () { | ||
CameraPlus.prototype.stop = function () { | ||
if (CameraPlus.enableVideo) { | ||
if (this.isVideoEnabled()) { | ||
this._swifty.stopVideoRecording(); | ||
@@ -542,3 +661,25 @@ } | ||
}; | ||
CameraPlus.prototype._detectDevice = function () { | ||
if (typeof this._isIPhoneX === 'undefined') { | ||
var _SYS_NAMELEN = 256; | ||
var buffer = interop.alloc(5 * _SYS_NAMELEN); | ||
uname(buffer); | ||
var name_1 = NSString.stringWithUTF8String(buffer.add(_SYS_NAMELEN * 4)).toString(); | ||
if (name_1 === 'x86_64' || name_1 === 'i386') { | ||
name_1 = NSProcessInfo.processInfo.environment.objectForKey('SIMULATOR_MODEL_IDENTIFIER'); | ||
} | ||
this._isIPhoneX = | ||
name_1.indexOf('iPhone10,3') === 0 || | ||
name_1.indexOf('iPhone10,6') === 0 || | ||
name_1.indexOf('iPhone11,2') === 0 || | ||
name_1.indexOf('iPhone11,4') === 0 || | ||
name_1.indexOf('iPhone11,6') === 0 || | ||
name_1.indexOf('iPhone11,8') === 0; | ||
} | ||
}; | ||
CameraPlus.useDeviceOrientation = false; | ||
__decorate([ | ||
camera_plus_common_1.GetSetProperty(), | ||
__metadata("design:type", Boolean) | ||
], CameraPlus.prototype, "enableVideo", void 0); | ||
return CameraPlus; | ||
@@ -573,3 +714,3 @@ }(camera_plus_common_1.CameraPlusBase)); | ||
btn.contentHorizontalAlignment = | ||
align == 'right' ? 2 : 1; | ||
align === 'right' ? 2 : 1; | ||
} | ||
@@ -576,0 +717,0 @@ if (eventName) { |
@@ -63,4 +63,4 @@ "use strict"; | ||
camera_plus_common_1.CLog("targetHeight = " + targetHeight); | ||
for (var i = 0; i < sizes.size(); i++) { | ||
var element = sizes.get(i); | ||
for (var i_1 = 0; i_1 < sizes.size(); i_1++) { | ||
var element = sizes.get(i_1); | ||
camera_plus_common_1.CLog("size.width = " + element.width + ", size.height = " + element.height); | ||
@@ -107,2 +107,48 @@ if (selfie) { | ||
exports.getOptimalPreviewSize = getOptimalPreviewSize; | ||
function getOptimalPictureSize(sizes, width, height) { | ||
var sizeSet = false; | ||
if (sizes === null) | ||
return null; | ||
var optimalSize = null; | ||
var minDiff = Number.MAX_SAFE_INTEGER; | ||
var targetHeight = height; | ||
camera_plus_common_1.CLog("targetHeight = " + targetHeight); | ||
var targetWidth = height; | ||
camera_plus_common_1.CLog("targetWidth = " + targetWidth); | ||
for (var i = 0; i < sizes.size(); i++) { | ||
var size = sizes.get(i); | ||
var desiredMinimumWidth = void 0; | ||
var desiredMaximumWidth = void 0; | ||
if (width > 1000) { | ||
desiredMinimumWidth = width - 200; | ||
desiredMaximumWidth = width + 200; | ||
} | ||
else { | ||
desiredMinimumWidth = 800; | ||
desiredMaximumWidth = 1200; | ||
} | ||
if (size.width > desiredMinimumWidth && size.width < desiredMaximumWidth && size.height < size.width) { | ||
optimalSize = size; | ||
camera_plus_common_1.CLog('setting size width', size.width + ''); | ||
camera_plus_common_1.CLog('setting size height', size.height + ''); | ||
sizeSet = true; | ||
break; | ||
} | ||
} | ||
if (!sizeSet) { | ||
minDiff = Number.MAX_SAFE_INTEGER; | ||
for (var i = 0; i < sizes.size(); i++) { | ||
var element = sizes.get(i); | ||
camera_plus_common_1.CLog("size.width = " + element.width + ", size.height = " + element.height); | ||
if (Math.abs(element.height - targetHeight) < minDiff) { | ||
optimalSize = element; | ||
minDiff = Math.abs(element.height - targetHeight); | ||
} | ||
} | ||
sizeSet = true; | ||
} | ||
camera_plus_common_1.CLog("optimalPictureSize = " + optimalSize + ", optimalPictureSize.width = " + optimalSize.width + ", optimalPictureSize.height = " + optimalSize.height); | ||
return optimalSize; | ||
} | ||
exports.getOptimalPictureSize = getOptimalPictureSize; | ||
function calculateInSampleSize(options, reqWidth, reqHeight) { | ||
@@ -154,7 +200,6 @@ var height = options.outHeight; | ||
function createImageConfirmationDialog(data, retakeText, saveText) { | ||
if (retakeText === void 0) { retakeText = null; } | ||
if (saveText === void 0) { saveText = null; } | ||
if (retakeText === void 0) { retakeText = 'Retake'; } | ||
if (saveText === void 0) { saveText = 'Save'; } | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
debugger; | ||
var alert_1 = new android.app.AlertDialog.Builder(app.android.foregroundActivity); | ||
@@ -161,0 +206,0 @@ alert_1.setOnDismissListener(new android.content.DialogInterface.OnDismissListener({ |
@@ -1,5 +0,4 @@ | ||
import { EventData } from 'tns-core-modules/data/observable'; | ||
import { ContentView } from 'tns-core-modules/ui/content-view'; | ||
import { View } from 'tns-core-modules/ui/core/view'; | ||
export declare class CameraPlus extends ContentView { | ||
export declare class CameraPlus extends View { | ||
events: ICameraPlusEvents; | ||
@@ -57,2 +56,12 @@ | ||
/** | ||
* String value when hooking into the confirmScreenShownEvent. This event fires when the confirm dialog is shown. | ||
*/ | ||
public static confirmScreenShownEvent: 'confirmScreenShownEvent'; | ||
/** | ||
* String value when hooking into the confirmScreenDismissedEvent. This event fires when the confirm dialog is dismissed either by Retake or Save. | ||
*/ | ||
public static confirmScreenDismissedEvent: 'confirmScreenDismissedEvent'; | ||
/** | ||
* If true console logs will be output to help debug the Camera Plus events. | ||
@@ -249,3 +258,13 @@ */ | ||
export declare enum CameraVideoQuality { | ||
MAX_480P = '480p', | ||
MAX_720P = '720p', | ||
MAX_1080P = '1080p', | ||
MAX_2160P = '2160p', | ||
HIGHEST = 'highest', | ||
LOWEST = 'lowest', | ||
QVGA = 'qvga' | ||
} | ||
export interface IVideoOptions { | ||
quality?: CameraVideoQuality; | ||
confirm?: boolean; | ||
@@ -261,2 +280,4 @@ saveToGallery?: boolean; | ||
keepAspectRatio?: boolean; | ||
showImages?: boolean; | ||
showVideos?: boolean; | ||
} | ||
@@ -263,0 +284,0 @@ |
{ | ||
"name": "nativescript-camera-plus-fixed-distorted", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "An advanced, embeddable camera for NativeScript.", | ||
@@ -9,4 +9,4 @@ "main": "camera-plus", | ||
"platforms": { | ||
"android": "3.0.0", | ||
"ios": "3.0.0" | ||
"android": "5.0.0", | ||
"ios": "5.0.0" | ||
} | ||
@@ -16,2 +16,3 @@ }, | ||
"precommit": "lint-staged", | ||
"clean": "rm -rf node_modules package-lock.json", | ||
"tsc": "tsc -skipLibCheck", | ||
@@ -24,3 +25,3 @@ "build": "npm i && tsc", | ||
"nuke": "rm -rf node_modules && cd ../demo && rm -rf hooks node_modules platforms && cd ../demo-ng && rm -rf hooks node_modules platforms", | ||
"demo.ios": "npm run preparedemo && cd ../demo && tns run ios --syncAllFiles", | ||
"demo.ios": "npm run preparedemo && cd ../demo && tns run ios --emulator --syncAllFiles", | ||
"demo.ios.device": "npm run preparedemo && cd ../demo && tns run ios", | ||
@@ -36,4 +37,4 @@ "demo.ng.ios": "npm run preparedemong && cd ../demo-ng && tns run ios --emulator", | ||
"test.android": "cd ../demo && tns test android", | ||
"preparedemo": "npm run build && cd ../demo && tns plugin remove nativescript-camera-plus-fixed-distorted && tns plugin add ../src && tns install", | ||
"preparedemong": "npm run build && cd ../demo-ng && tns plugin remove nativescript-camera-plus-fixed-distorted && tns plugin add ../src && tns install", | ||
"preparedemo": "npm run build && cd ../demo && tns plugin remove nativescript-camera-plus-fixed-distorted && tns plugin add ../src", | ||
"preparedemong": "npm run build && cd ../demo-ng && tns plugin remove nativescript-camera-plus-fixed-distorted && tns plugin add ../src", | ||
"setup": "npm i && cd ../demo && npm i && cd .. && npm run build && cd ../demo && tns plugin add .. && cd ..", | ||
@@ -89,11 +90,11 @@ "postclone": "npm i && node scripts/postclone.js" | ||
"devDependencies": { | ||
"husky": "^0.14.3", | ||
"lint-staged": "^6.1.0", | ||
"prettier": "^1.12.0", | ||
"tns-core-modules": "~4.0.0", | ||
"tns-platform-declarations": "~4.0.0", | ||
"typescript": "~2.8.1", | ||
"husky": "^1.1.2", | ||
"lint-staged": "^7.3.0", | ||
"prettier": "^1.14.3", | ||
"tns-core-modules": "~5.1.2", | ||
"tns-platform-declarations": "~5.1.2", | ||
"typescript": "~3.1.6", | ||
"prompt": "^1.0.0", | ||
"rimraf": "^2.5.0", | ||
"tslint": "^5.0.0", | ||
"tslint": "^5.11.0", | ||
"semver": "^5.5.0" | ||
@@ -100,0 +101,0 @@ }, |
@@ -97,6 +97,6 @@ <a align="center" href="https://www.npmjs.com/package/@nstudio/nativescript-camera-plus"> | ||
| **showGalleryIcon** | boolean | If true the choose from gallery/library icon/button will show on the Camera Plus layout. Default is true. | | ||
| **enableVideo** | boolean | If true the CameraPlus instance can record video. | | ||
| **enableVideo** | boolean | If true the CameraPlus instance can record video and videos are shown in the gallery.| | ||
## Static Properties | ||
_Note: These properties need set before the initialization of the camera. Users should set these in a component constructor before their view creates the component if the wish to change the default values._ | ||
_Note: These properties need set before the initialization of the camera. Users should set these in a component constructor before their view creates the component if the wish to change the default values. In case of enableVideo, this will be true if either the static property or the component property is true._ | ||
@@ -153,3 +153,3 @@ | Name | Type | Description | | ||
| ----------------------- | ------------------------------------------------------------------ | | ||
| **errorEvent** | Executes when an error is emitted from CameraPlu | | ||
| **errorEvent** | Executes when an error is emitted from CameraPlus | | ||
| **photoCapturedEvent** | Executes when a photo is taken. | | ||
@@ -161,2 +161,4 @@ | **toggleCameraEvent** | Executes when the device camera is toggled. | | ||
| **videoRecordingReadyEvent** | Executes when video has completed processing and is ready to be used. | | ||
| **confirmScreenShownEvent** | Executes when the picture confirm dialog is shown.. | | ||
| **confirmScreenDismissedEvent** | Executes when the picture confirm dialog is dismissed either by Retake or Save button. | | ||
@@ -182,2 +184,4 @@ | ||
keepAspectRatio?: boolean; | ||
showImages?: boolean; | ||
showVideos?: boolean; | ||
} | ||
@@ -193,2 +197,2 @@ ``` | ||
} | ||
``` | ||
``` |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var application = require("tns-core-modules/application"); | ||
var image_asset_1 = require("tns-core-modules/image-asset"); | ||
var image_source_1 = require("tns-core-modules/image-source"); | ||
var image_asset_1 = require("tns-core-modules/image-asset"); | ||
var application = require("tns-core-modules/application"); | ||
var MediaStore = function () { return android.provider.MediaStore; }; | ||
@@ -7,0 +7,0 @@ var DocumentsContract = function () { return android.provider.DocumentsContract; }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
214061
3455
194