CR fixes
This commit is contained in:
parent
29c9ea387d
commit
9e11ab4dfb
@ -158,7 +158,10 @@ function takePictureFromFile(successCallback, errorCallback, mediaType, destinat
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileOpenPicker.pickSingleFileAsync().done(function (file) {
|
fileOpenPicker.pickSingleFileAsync().done(function (file) {
|
||||||
if (file) {
|
if (!file) {
|
||||||
|
errorCallback("User didn't choose a file.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (destinationType == Camera.DestinationType.FILE_URI || destinationType == Camera.DestinationType.NATIVE_URI) {
|
if (destinationType == Camera.DestinationType.FILE_URI || destinationType == Camera.DestinationType.NATIVE_URI) {
|
||||||
if (targetHeight > 0 && targetWidth > 0) {
|
if (targetHeight > 0 && targetWidth > 0) {
|
||||||
resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType);
|
resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType);
|
||||||
@ -183,9 +186,6 @@ function takePictureFromFile(successCallback, errorCallback, mediaType, destinat
|
|||||||
}, errorCallback);
|
}, errorCallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
errorCallback("User didn't choose a file.");
|
|
||||||
}
|
|
||||||
}, function () {
|
}, function () {
|
||||||
errorCallback("User didn't choose a file.");
|
errorCallback("User didn't choose a file.");
|
||||||
});
|
});
|
||||||
@ -240,7 +240,12 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
var expectedPanel = cameraDirection === 1 ? Windows.Devices.Enumeration.Panel.front : Windows.Devices.Enumeration.Panel.back;
|
var expectedPanel = cameraDirection === 1 ? Windows.Devices.Enumeration.Panel.front : Windows.Devices.Enumeration.Panel.back;
|
||||||
Windows.Devices.Enumeration.DeviceInformation.findAllAsync(Windows.Devices.Enumeration.DeviceClass.videoCapture)
|
Windows.Devices.Enumeration.DeviceInformation.findAllAsync(Windows.Devices.Enumeration.DeviceClass.videoCapture)
|
||||||
.done(function (devices) {
|
.done(function (devices) {
|
||||||
if (devices.length > 0) {
|
if (devices.length <= 0) {
|
||||||
|
destroyCameraPreview();
|
||||||
|
errorCallback('Camera not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
devices.forEach(function(currDev) {
|
devices.forEach(function(currDev) {
|
||||||
if (currDev.enclosureLocation.panel && currDev.enclosureLocation.panel == expectedPanel) {
|
if (currDev.enclosureLocation.panel && currDev.enclosureLocation.panel == expectedPanel) {
|
||||||
captureSettings.videoDeviceId = currDev.id;
|
captureSettings.videoDeviceId = currDev.id;
|
||||||
@ -270,10 +275,6 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
destroyCameraPreview();
|
destroyCameraPreview();
|
||||||
errorCallback('Camera intitialization error ' + err);
|
errorCallback('Camera intitialization error ' + err);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
destroyCameraPreview();
|
|
||||||
errorCallback('Camera not found');
|
|
||||||
}
|
|
||||||
}, errorCallback);
|
}, errorCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -341,7 +342,11 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (saveToPhotoAlbum) {
|
if (!saveToPhotoAlbum) {
|
||||||
|
success(capturedFile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Need to add and remove an event listener to catch activation state
|
Need to add and remove an event listener to catch activation state
|
||||||
Using FileSavePicker will suspend the app and it's required to catch the pickSaveFileContinuation
|
Using FileSavePicker will suspend the app and it's required to catch the pickSaveFileContinuation
|
||||||
@ -383,9 +388,6 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
savePicker.suggestedFileName = fileName;
|
savePicker.suggestedFileName = fileName;
|
||||||
Windows.UI.WebUI.WebUIApplication.addEventListener("activated", cameraActivationHandler);
|
Windows.UI.WebUI.WebUIApplication.addEventListener("activated", cameraActivationHandler);
|
||||||
savePicker.pickSaveFileAndContinue();
|
savePicker.pickSaveFileAndContinue();
|
||||||
} else {
|
|
||||||
success(capturedFile);
|
|
||||||
}
|
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
destroyCameraPreview();
|
destroyCameraPreview();
|
||||||
errorCallback(err);
|
errorCallback(err);
|
||||||
@ -432,7 +434,11 @@ function takePictureFromCameraWindows(successCallback, errorCallback, args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cameraCaptureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).done(function(picture) {
|
cameraCaptureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).done(function(picture) {
|
||||||
if (picture) {
|
if (!picture) {
|
||||||
|
errorCallback("User didn't capture a photo.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// save to photo album successCallback
|
// save to photo album successCallback
|
||||||
var success = function() {
|
var success = function() {
|
||||||
if (destinationType == Camera.DestinationType.FILE_URI) {
|
if (destinationType == Camera.DestinationType.FILE_URI) {
|
||||||
@ -462,7 +468,11 @@ function takePictureFromCameraWindows(successCallback, errorCallback, args) {
|
|||||||
errorCallback("Save fail.");
|
errorCallback("Save fail.");
|
||||||
};
|
};
|
||||||
|
|
||||||
if (saveToPhotoAlbum) {
|
if (!saveToPhotoAlbum) {
|
||||||
|
success();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var savePicker = new Windows.Storage.Pickers.FileSavePicker();
|
var savePicker = new Windows.Storage.Pickers.FileSavePicker();
|
||||||
|
|
||||||
savePicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.documentsLibrary;
|
savePicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.documentsLibrary;
|
||||||
@ -496,12 +506,6 @@ function takePictureFromCameraWindows(successCallback, errorCallback, args) {
|
|||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
}, fail);
|
}, fail);
|
||||||
} else {
|
|
||||||
success();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
errorCallback("User didn't capture a photo.");
|
|
||||||
}
|
|
||||||
}, function() {
|
}, function() {
|
||||||
errorCallback("Fail to capture a photo.");
|
errorCallback("Fail to capture a photo.");
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user