You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by he...@apache.org on 2013/12/03 22:15:12 UTC

[1/2] git commit: getPicture via web activities

Updated Branches:
  refs/heads/dev a6736cda7 -> 3424ddb39


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/e8e42089
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/e8e42089
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/e8e42089

Branch: refs/heads/dev
Commit: e8e420895eb45bf0b5d5094060429c164ef38364
Parents: a6736cd
Author: Piotr Zalewa <pi...@zalewa.info>
Authored: Fri Sep 20 19:59:05 2013 +0200
Committer: hermwong <he...@gmail.com>
Committed: Tue Dec 3 13:09:27 2013 -0800

----------------------------------------------------------------------
 plugin.xml              | 12 ++++++++++++
 src/firefoxos/camera.js | 32 ++++++++++++++++++++++++++++++++
 www/Camera.js           |  8 +++++---
 3 files changed, 49 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/e8e42089/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index fda60c6..078a6c6 100644
--- a/plugin.xml
+++ b/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="/*">

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

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/e8e42089/www/Camera.js
----------------------------------------------------------------------
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) {


[2/2] git commit: fix camera for firefox os

Posted by he...@apache.org.
fix camera for firefox os


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/3424ddb3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/3424ddb3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/3424ddb3

Branch: refs/heads/dev
Commit: 3424ddb39c25d28ccb976a817b7af9d371381447
Parents: e8e4208
Author: James Long <lo...@gmail.com>
Authored: Tue Oct 29 15:40:18 2013 -0400
Committer: hermwong <he...@gmail.com>
Committed: Tue Dec 3 13:10:25 2013 -0800

----------------------------------------------------------------------
 src/firefoxos/CameraProxy.js | 49 +++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/3424ddb3/src/firefoxos/CameraProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/CameraProxy.js b/src/firefoxos/CameraProxy.js
index bbed304..9afb343 100644
--- a/src/firefoxos/CameraProxy.js
+++ b/src/firefoxos/CameraProxy.js
@@ -17,36 +17,35 @@
  * specific language governing permissions and limitations
  * under the License.
  *
-*/
+ */
 
+function takePicture(success, error, opts) {
+    var pick = new MozActivity({
+        name: "pick",
+        data: {
+            type: ["image/*"]
+        }
+    });
 
+    pick.onerror = error || function() {};
 
-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.destinationType || cameraOptions.destinationType > 0) {
-      // url
-      return cameraSuccess(window.URL.createObjectURL(this.result.blob));
-    }
-  };
+    pick.onsuccess = function() {
+        // image is returned as Blob in this.result.blob
+        // we need to call success with url or base64 encoded image
+        if (opts && opts.destinationType == 0) {
+            // TODO: base64
+            return;
+        }
+        if (!opts || !opts.destinationType || opts.destinationType > 0) {
+            // url
+            return success(window.URL.createObjectURL(this.result.blob));
+        }
+    };
 }
 
 module.exports = {
-  getPicture: getPicture,
-  cleanup: function(){}
+    takePicture: takePicture,
+    cleanup: function(){}
 };
 
-require("cordova/firefoxos/commandProxy").add("Camera", module.exports);
\ No newline at end of file
+require("cordova/firefoxos/commandProxy").add("Camera", module.exports);