mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-31 12:42:50 +08:00
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera
This commit is contained in:
commit
1a495492c6
@ -202,7 +202,6 @@
|
|||||||
<!-- windows8 -->
|
<!-- windows8 -->
|
||||||
<platform name="windows8">
|
<platform name="windows8">
|
||||||
|
|
||||||
<dependency id="org.apache.cordova.file" />
|
|
||||||
<config-file target="package.appxmanifest" parent="/Package/Capabilities">
|
<config-file target="package.appxmanifest" parent="/Package/Capabilities">
|
||||||
<Capability Name="picturesLibrary" />
|
<Capability Name="picturesLibrary" />
|
||||||
<DeviceCapability Name="webcam" />
|
<DeviceCapability Name="webcam" />
|
||||||
|
@ -22,12 +22,8 @@
|
|||||||
/*global Windows:true, URL:true */
|
/*global Windows:true, URL:true */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var cordova = require('cordova'),
|
var cordova = require('cordova'),
|
||||||
Camera = require('./Camera'),
|
Camera = require('./Camera');
|
||||||
FileEntry = require('org.apache.cordova.file.FileEntry'),
|
|
||||||
FileError = require('org.apache.cordova.file.FileError'),
|
|
||||||
FileReader = require('org.apache.cordova.file.FileReader');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
@ -54,13 +50,6 @@ module.exports = {
|
|||||||
var mediaType = args[6];
|
var mediaType = args[6];
|
||||||
var saveToPhotoAlbum = args[9];
|
var saveToPhotoAlbum = args[9];
|
||||||
|
|
||||||
var pkg = Windows.ApplicationModel.Package.current;
|
|
||||||
var packageId = pkg.installedLocation;
|
|
||||||
|
|
||||||
var fail = function (fileError) {
|
|
||||||
errorCallback("FileError, code:" + fileError.code);
|
|
||||||
};
|
|
||||||
|
|
||||||
// resize method :)
|
// resize method :)
|
||||||
var resizeImage = function (file) {
|
var resizeImage = function (file) {
|
||||||
var tempPhotoFileName = "";
|
var tempPhotoFileName = "";
|
||||||
@ -164,9 +153,7 @@ module.exports = {
|
|||||||
file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) {
|
file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) {
|
||||||
successCallback(URL.createObjectURL(storageFile));
|
successCallback(URL.createObjectURL(storageFile));
|
||||||
}, function () {
|
}, function () {
|
||||||
fail(FileError.INVALID_MODIFICATION_ERR);
|
errorCallback("Can't access localStorage folder.");
|
||||||
}, function () {
|
|
||||||
errorCallback("Folder not access.");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -228,7 +215,7 @@ module.exports = {
|
|||||||
cameraCaptureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (picture) {
|
cameraCaptureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (picture) {
|
||||||
if (picture) {
|
if (picture) {
|
||||||
// save to photo album successCallback
|
// save to photo album successCallback
|
||||||
var success = function (fileEntry) {
|
var success = function () {
|
||||||
if (destinationType == Camera.DestinationType.FILE_URI) {
|
if (destinationType == Camera.DestinationType.FILE_URI) {
|
||||||
if (targetHeight > 0 && targetWidth > 0) {
|
if (targetHeight > 0 && targetWidth > 0) {
|
||||||
resizeImage(picture);
|
resizeImage(picture);
|
||||||
@ -238,9 +225,7 @@ module.exports = {
|
|||||||
picture.copyAsync(storageFolder, picture.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) {
|
picture.copyAsync(storageFolder, picture.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) {
|
||||||
successCallback("ms-appdata:///local/" + storageFile.name);
|
successCallback("ms-appdata:///local/" + storageFile.name);
|
||||||
}, function () {
|
}, function () {
|
||||||
fail(FileError.INVALID_MODIFICATION_ERR);
|
errorCallback("Can't access localStorage folder.");
|
||||||
}, function () {
|
|
||||||
errorCallback("Folder not access.");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -263,7 +248,7 @@ module.exports = {
|
|||||||
if (saveToPhotoAlbum) {
|
if (saveToPhotoAlbum) {
|
||||||
Windows.Storage.StorageFile.getFileFromPathAsync(picture.path).then(function (storageFile) {
|
Windows.Storage.StorageFile.getFileFromPathAsync(picture.path).then(function (storageFile) {
|
||||||
storageFile.copyAsync(Windows.Storage.KnownFolders.picturesLibrary, picture.name, Windows.Storage.NameCollisionOption.generateUniqueName).then(function (storageFile) {
|
storageFile.copyAsync(Windows.Storage.KnownFolders.picturesLibrary, picture.name, Windows.Storage.NameCollisionOption.generateUniqueName).then(function (storageFile) {
|
||||||
success(storageFile);
|
success();
|
||||||
}, function () {
|
}, function () {
|
||||||
fail();
|
fail();
|
||||||
});
|
});
|
||||||
@ -280,9 +265,7 @@ module.exports = {
|
|||||||
picture.copyAsync(storageFolder, picture.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) {
|
picture.copyAsync(storageFolder, picture.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) {
|
||||||
successCallback("ms-appdata:///local/" + storageFile.name);
|
successCallback("ms-appdata:///local/" + storageFile.name);
|
||||||
}, function () {
|
}, function () {
|
||||||
fail(FileError.INVALID_MODIFICATION_ERR);
|
errorCallback("Can't access localStorage folder.");
|
||||||
}, function () {
|
|
||||||
errorCallback("Folder not access.");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user