Adding focus handler to make sure filepicker gets launched when app is active

This commit is contained in:
Raghav Katyal 2016-02-26 13:51:34 -08:00
parent 20dcaf2cb3
commit 5f7f4f3e55

View File

@ -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);
}); });
} }