Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

getPicture via web activities

  • Loading branch information...
commit e8e420895eb45bf0b5d5094060429c164ef38364 1 parent a6736cd
@zalun zalun authored hermwong committed
Showing with 49 additions and 3 deletions.
  1. +12 −0 plugin.xml
  2. +32 −0 src/firefoxos/camera.js
  3. +5 −3 www/Camera.js
View
12 plugin.xml
@@ -25,6 +25,18 @@
<clobbers target="navigator.camera" />
</js-module>
+ <!-- firefoxos -->
+ <platform name="firefoxos">
+ <config-file target="config.xml" parent="/*">
+ <feature name="Camera">
+ <param name="firefoxos-package" value="Camera" />
+ </feature>
+ </config-file>
+
+ <js-module src="src/firefoxos/camera.js" name="camera-impl">
+ <runs />
+ </js-module>
+ </platform>
<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
View
32 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);
+
View
8 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) {
Please sign in to comment.
Something went wrong with that request. Please try again.