You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/02/11 00:21:16 UTC

[08/15] git commit: getPicture via web activities

getPicture via web activities


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/464c37eb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/464c37eb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/464c37eb

Branch: refs/heads/master
Commit: 464c37eb50467a7aed91e51aac371c8aed298811
Parents: 9b0d17e
Author: Piotr Zalewa <pi...@zalewa.info>
Authored: Fri Sep 20 19:59:05 2013 +0200
Committer: Herm Wong <he...@gmail.com>
Committed: Tue Jan 14 12:25:28 2014 -0800

----------------------------------------------------------------------
 plugin.xml              |  4 ++--
 src/firefoxos/camera.js | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/464c37eb/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 0f9ad2e..efcf471 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -32,8 +32,8 @@
                 <param name="firefoxos-package" value="Camera" />
             </feature>
         </config-file>                                         
-        
-        <js-module src="src/firefoxos/CameraProxy.js" name="CameraProxy">
+
+        <js-module src="src/firefoxos/camera.js" name="camera-impl">
           <runs />
         </js-module>
     </platform>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/464c37eb/src/firefoxos/camera.js
----------------------------------------------------------------------
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);
+