You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/03/01 21:57:42 UTC

[2/2] android commit: Updating cordova.android.js to override FileReader

Updating cordova.android.js to override FileReader


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/a69bd651
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/a69bd651
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/a69bd651

Branch: refs/heads/master
Commit: a69bd651520e7afefe2abeb3e5cc8d6ae19967c5
Parents: 73aa5cc
Author: macdonst <si...@gmail.com>
Authored: Thu Mar 1 15:57:21 2012 -0500
Committer: macdonst <si...@gmail.com>
Committed: Thu Mar 1 15:57:21 2012 -0500

----------------------------------------------------------------------
 framework/assets/js/cordova.android.js |  126 ++++++++++++++------------
 1 files changed, 68 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/a69bd651/framework/assets/js/cordova.android.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/cordova.android.js b/framework/assets/js/cordova.android.js
index e344af4..2779f14 100644
--- a/framework/assets/js/cordova.android.js
+++ b/framework/assets/js/cordova.android.js
@@ -1067,6 +1067,9 @@ module.exports = {
     File: { // exists natively on Android WebView, override
       path: "cordova/plugin/File"
     },
+    FileReader: { // exists natively on Android WebView, override
+      path: "cordova/plugin/FileReader"
+    },
     FileError: { //exists natively on Android WebView on Android 4.x
       path: "cordova/plugin/FileError"
     }
@@ -1435,78 +1438,85 @@ define('cordova/plugin/Camera', function(require, exports, module) {
 var exec = require('cordova/exec'),
     Camera = require('cordova/plugin/CameraConstants');
 
-module.exports = {
-    /**
-     * Gets a picture from source defined by "options.sourceType", and returns the
-     * image as defined by the "options.destinationType" option.
+var cameraExport = {};
 
-     * The defaults are sourceType=CAMERA and destinationType=FILE_URL.
-     *
-     * @param {Function} successCallback
-     * @param {Function} errorCallback
-     * @param {Object} options
-     */
-    getPicture: function (successCallback, errorCallback, options) {
+// Tack on the Camera Constants to the base camera plugin.
+for (var key in Camera) {
+    cameraExport[key] = Camera[key];
+}
 
-        // successCallback required
-        if (typeof successCallback != "function") {
-            console.log("Camera Error: successCallback is not a function");
-            return;
-        }
+/**
+ * Gets a picture from source defined by "options.sourceType", and returns the
+ * image as defined by the "options.destinationType" option.
 
-        // errorCallback optional
-        if (errorCallback && (typeof errorCallback != "function")) {
-            console.log("Camera Error: errorCallback is not a function");
-            return;
-        }
+ * The defaults are sourceType=CAMERA and destinationType=FILE_URL.
+ *
+ * @param {Function} successCallback
+ * @param {Function} errorCallback
+ * @param {Object} options
+ */
+cameraExport.getPicture = function(successCallback, errorCallback, options) {
+    // successCallback required
+    if (typeof successCallback != "function") {
+        console.log("Camera Error: successCallback is not a function");
+        return;
+    }
 
-        if (options && typeof options.quality == "number") {
-            quality = options.quality;
-        } else if (options && typeof options.quality == "string") {
-            var qlity = parseInt(options.quality, 10);
-            if (isNaN(qlity) === false) {
-                quality = qlity.valueOf();
-            }
-        }
+    // errorCallback optional
+    if (errorCallback && (typeof errorCallback != "function")) {
+        console.log("Camera Error: errorCallback is not a function");
+        return;
+    }
 
-        var destinationType = Camera.DestinationType.FILE_URL;
-        if (options.destinationType) {
-            destinationType = options.destinationType;
-        }
 
-        var sourceType = Camera.PictureSourceType.CAMERA;
-        if (typeof options.sourceType == "number") {
-            sourceType = options.sourceType;
+    if (options && typeof options.quality == "number") {
+        quality = options.quality;
+    } else if (options && typeof options.quality == "string") {
+        var qlity = parseInt(options.quality, 10);
+        if (isNaN(qlity) === false) {
+            quality = qlity.valueOf();
         }
+    }
 
-        var targetWidth = -1;
-        if (typeof options.targetWidth == "number") {
-            targetWidth = options.targetWidth;
-        } else if (typeof options.targetWidth == "string") {
-            var width = parseInt(options.targetWidth, 10);
-            if (isNaN(width) === false) {
-                targetWidth = width.valueOf();
-            }
-        }
+    var destinationType = Camera.DestinationType.FILE_URL;
+    if (typeof options.destinationType == "number") {
+        destinationType = options.destinationType;
+    }
 
-        var targetHeight = -1;
-        if (typeof options.targetHeight == "number") {
-            targetHeight = options.targetHeight;
-        } else if (typeof options.targetHeight == "string") {
-            var height = parseInt(options.targetHeight, 10);
-            if (isNaN(height) === false) {
-                targetHeight = height.valueOf();
-            }
+    var sourceType = Camera.PictureSourceType.CAMERA;
+    if (typeof options.sourceType == "number") {
+        sourceType = options.sourceType;
+    }
+
+    var targetWidth = -1;
+    if (typeof options.targetWidth == "number") {
+        targetWidth = options.targetWidth;
+    } else if (typeof options.targetWidth == "string") {
+        var width = parseInt(options.targetWidth, 10);
+        if (isNaN(width) === false) {
+            targetWidth = width.valueOf();
         }
+    }
 
-        var encodingType = Camera.EncodingType.JPEG;
-        if (typeof options.encodingType == "number") {
-            encodingType = options.encodingType;
+    var targetHeight = -1;
+    if (typeof options.targetHeight == "number") {
+        targetHeight = options.targetHeight;
+    } else if (typeof options.targetHeight == "string") {
+        var height = parseInt(options.targetHeight, 10);
+        if (isNaN(height) === false) {
+            targetHeight = height.valueOf();
         }
+    }
 
-        exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType]);
+    var encodingType = Camera.EncodingType.JPEG;
+    if (typeof options.encodingType == "number") {
+        encodingType = options.encodingType;
     }
-};
+
+    exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType]);
+}
+
+module.exports = cameraExport;
 
 });