[ 
https://issues.apache.org/jira/browse/CB-8804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14594169#comment-14594169
 ] 

ASF GitHub Bot commented on CB-8804:
------------------------------------

Github user dpolivy commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-camera/pull/97#discussion_r32879337
  
    --- Diff: www/Camera.js ---
    @@ -72,4 +72,28 @@ cameraExport.cleanup = function(successCallback, 
errorCallback) {
         exec(successCallback, errorCallback, "Camera", "cleanup", []);
     };
     
    +cameraExport.checkForSavedResult = function(successCallback, 
errorCallback, options) {
    +    argscheck.checkArgs('fFO', 'Camera.checkForSavedResult', arguments);
    +    options = options || {};
    +    var getValue = argscheck.getValue;
    +
    +    var quality = getValue(options.quality, 80);
    +    var destinationType = getValue(options.destinationType, 
Camera.DestinationType.FILE_URI);
    +    var sourceType = getValue(options.sourceType, 
Camera.PictureSourceType.CAMERA);
    +    var targetWidth = getValue(options.targetWidth, -1);
    +    var targetHeight = getValue(options.targetHeight, -1);
    +    var encodingType = getValue(options.encodingType, 
Camera.EncodingType.JPEG);
    +    var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE);
    +    var allowEdit = !!options.allowEdit;
    +    var correctOrientation = !!options.correctOrientation;
    +    var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
    +    var popoverOptions = getValue(options.popoverOptions, null);
    +    var cameraDirection = getValue(options.cameraDirection, 
Camera.Direction.BACK);
    +
    +    var args = [quality, destinationType, sourceType, targetWidth, 
targetHeight, encodingType,
    +                mediaType, allowEdit, correctOrientation, 
saveToPhotoAlbum, popoverOptions, cameraDirection];
    --- End diff --
    
    It would be much better to refactor this as it's shared code with the 
getPicture API. Here's a refactor:
    
    ````
    // Put this before the getPicture method definition
    
    var prepareArgs = function(options) {
        options = options || {};
        var getValue = argscheck.getValue;
    
        var quality = getValue(options.quality, 50);
        var destinationType = getValue(options.destinationType, 
Camera.DestinationType.FILE_URI);
        var sourceType = getValue(options.sourceType, 
Camera.PictureSourceType.CAMERA);
        var targetWidth = getValue(options.targetWidth, -1);
        var targetHeight = getValue(options.targetHeight, -1);
        var encodingType = getValue(options.encodingType, 
Camera.EncodingType.JPEG);
        var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE);
        var allowEdit = !!options.allowEdit;
        var correctOrientation = !!options.correctOrientation;
        var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
        var popoverOptions = getValue(options.popoverOptions, null);
        var cameraDirection = getValue(options.cameraDirection, 
Camera.Direction.BACK);
    
        return [quality, destinationType, sourceType, targetWidth, 
targetHeight, encodingType,
                    mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, 
popoverOptions,
                    cameraDirection];
    };
    
    ...
    
    cameraExport.getPicture = function(successCallback, errorCallback, options) 
{
        argscheck.checkArgs('fFO', 'Camera.getPicture', arguments);
        var args = prepareArgs(options);
    
        exec(successCallback, errorCallback, "Camera", "takePicture", args);
        // XXX: commented out
        //return new CameraPopoverHandle();
    };
    
    ...
    
    cameraExport.checkForSavedResult = function(successCallback, errorCallback, 
options) {
        argscheck.checkArgs('fFO', 'Camera.checkForSavedResult', arguments);
        var args = prepareArgs(options);
    
        exec(successCallback, errorCallback, "Camera", "checkForSavedResult", 
args);
    };
    ````


> https://github.com/apache/cordova-plugin-camera#android-quirks
> --------------------------------------------------------------
>
>                 Key: CB-8804
>                 URL: https://issues.apache.org/jira/browse/CB-8804
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: Plugin Camera
>         Environment: Android
>            Reporter: Serge Huijben
>
> Android Quirks
> Android uses intents to launch the camera activity on the device to capture 
> images, and on phones with low memory, the Cordova activity may be killed. In 
> this scenario, the image may not appear when the Cordova activity is restored.
> It can be solved bij implementing this PR: 
> https://github.com/apache/cordova-plugin-camera/pull/97



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to