diff --git a/plugin.xml b/plugin.xml index fda60c6..078a6c6 100644 --- a/plugin.xml +++ b/plugin.xml @@ -25,6 +25,18 @@ + + + + + + + + + + + + diff --git a/src/firefoxos/camera.js b/src/firefoxos/camera.js new file mode 100644 index 0000000..270f221 --- /dev/null +++ b/src/firefoxos/camera.js @@ -0,0 +1,32 @@ + +var firefoxos = require('cordova/platform'); + +function getPicture(cameraSuccess, cameraError, cameraOptions) { + cameraError = cameraError || function(){}; + var pick = new MozActivity({ + name: "pick", + data: { + type: ["image/png", "image/jpg", "image/jpeg"] + } + }); + pick.onerror = cameraError; + pick.onsuccess = function() { + // image is returned as Blob in this.result.blob + // we need to call cameraSuccess with url or base64 encoded image + if (cameraOptions && cameraOptions.destinationType == 0) { + // TODO: base64 + return; + } + if (!cameraOptions || !cameraOptions.destinationTyoe || cameraOptions.destinationType > 0) { + // url + return cameraSuccess(window.URL.createObjectURL(this.result.blob)); + } + }; +} +var Camera = { + takePicture: getPicture, + cleanup: function(){} +}; + +firefoxos.registerPlugin('Camera', Camera); + diff --git a/www/Camera.js b/www/Camera.js index b2da5da..555bb5e 100644 --- a/www/Camera.js +++ b/www/Camera.js @@ -21,8 +21,9 @@ var argscheck = require('cordova/argscheck'), exec = require('cordova/exec'), - Camera = require('./Camera'), - CameraPopoverHandle = require('./CameraPopoverHandle'); + Camera = require('./Camera'); + // XXX: commented out + //CameraPopoverHandle = require('./CameraPopoverHandle'); var cameraExport = {}; @@ -63,7 +64,8 @@ cameraExport.getPicture = function(successCallback, errorCallback, options) { mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection]; exec(successCallback, errorCallback, "Camera", "takePicture", args); - return new CameraPopoverHandle(); + // XXX: commented out + //return new CameraPopoverHandle(); }; cameraExport.cleanup = function(successCallback, errorCallback) {