mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-19 03:42:52 +08:00
Adding focus handler to make sure filepicker gets launched when app is active
This commit is contained in:
parent
20dcaf2cb3
commit
5f7f4f3e55
@ -731,21 +731,32 @@ function takePictureFromCameraWindows(successCallback, errorCallback, args) {
|
|||||||
|
|
||||||
cameraCaptureUI.photoSettings.maxResolution = maxRes;
|
cameraCaptureUI.photoSettings.maxResolution = maxRes;
|
||||||
|
|
||||||
cameraCaptureUI.captureFileAsync(WMCapture.CameraCaptureUIMode.photo).done(function(picture) {
|
var cameraPicture;
|
||||||
if (!picture) {
|
var savePhotoOnFocus = function() {
|
||||||
errorCallback("User didn't capture a photo.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
savePhoto(picture, {
|
window.removeEventListener("focus", savePhotoOnFocus);
|
||||||
|
// call only when the app is in focus again
|
||||||
|
savePhoto(cameraPicture, {
|
||||||
destinationType: destinationType,
|
destinationType: destinationType,
|
||||||
targetHeight: targetHeight,
|
targetHeight: targetHeight,
|
||||||
targetWidth: targetWidth,
|
targetWidth: targetWidth,
|
||||||
encodingType: encodingType,
|
encodingType: encodingType,
|
||||||
saveToPhotoAlbum: saveToPhotoAlbum
|
saveToPhotoAlbum: saveToPhotoAlbum
|
||||||
}, successCallback, errorCallback);
|
}, successCallback, errorCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add and delete focus eventHandler to capture the focus back from cameraUI to app
|
||||||
|
window.addEventListener("focus", savePhotoOnFocus);
|
||||||
|
cameraCaptureUI.captureFileAsync(WMCapture.CameraCaptureUIMode.photo).done(function(picture) {
|
||||||
|
if (!picture) {
|
||||||
|
errorCallback("User didn't capture a photo.");
|
||||||
|
window.removeEventListener("focus", savePhotoOnFocus);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cameraPicture = picture;
|
||||||
}, function() {
|
}, function() {
|
||||||
errorCallback("Fail to capture a photo.");
|
errorCallback("Fail to capture a photo.");
|
||||||
|
window.removeEventListener("focus", savePhotoOnFocus);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user