From 9185848cbcdc14229dd7d7a9f43c1f751c268ff3 Mon Sep 17 00:00:00 2001 From: brianleroux Date: Thu, 2 Sep 2010 16:44:56 -0700 Subject: [PATCH] fixing dasherish --- framework/assets/www/phonegap.js | 73 ++++++++++++++++++++++---------- lib/create.rb | 4 +- 2 files changed, 53 insertions(+), 24 deletions(-) diff --git a/framework/assets/www/phonegap.js b/framework/assets/www/phonegap.js index 8b0c1d24..d775c39d 100644 --- a/framework/assets/www/phonegap.js +++ b/framework/assets/www/phonegap.js @@ -561,41 +561,70 @@ PhoneGap.addConstructor(function() { }); /** * This class provides access to the device camera. + * * @constructor */ function Camera() { - -} + this.successCallback = null; + this.errorCallback = null; + this.options = null; +}; /** - * + * Takes a photo and returns the image as a base64 encoded `String`. + * * @param {Function} successCallback * @param {Function} errorCallback * @param {Object} options */ Camera.prototype.getPicture = function(successCallback, errorCallback, options) { - this.winCallback = successCallback; - this.failCallback = errorCallback; - if (options.quality) - { - GapCam.takePicture(options.quality); - } - else - { - GapCam.takePicture(80); - } -} + // successCallback required + if (typeof successCallback != "function") { + console.log("Camera Error: successCallback is not a function"); + return; + } -Camera.prototype.win = function(picture) -{ - this.winCallback(picture); -} + // errorCallback optional + if (errorCallback && (typeof errorCallback != "function")) { + console.log("Camera Error: errorCallback is not a function"); + return; + } -Camera.prototype.fail = function(err) -{ - this.failCallback(err); -} + this.successCallback = successCallback; + this.errorCallback = errorCallback; + this.options = options; + if (options.quality) { + GapCam.takePicture(options.quality); + } + else { + GapCam.takePicture(80); + } +}; + +/** + * Callback function from native code that is called when image has been captured. + * + * @param picture The base64 encoded string of the image + */ +Camera.prototype.success = function(picture) { + if (this.successCallback) { + this.successCallback(picture); + } +}; + + +/** + * Callback function from native code that is called when there is an error + * capturing an image, or the capture is cancelled. + * + * @param err The error message + */ +Camera.prototype.error = function(err) { + if (this.errorCallback) { + this.errorCallback(err); + } +}; PhoneGap.addConstructor(function() { if (typeof navigator.camera == "undefined") navigator.camera = new Camera(); diff --git a/lib/create.rb b/lib/create.rb index caec17d6..3fac2f17 100644 --- a/lib/create.rb +++ b/lib/create.rb @@ -30,11 +30,11 @@ class Create raise 'No index.html found!' unless File.exists? File.join(path, 'index.html') # setup default vars - @name = path.split("/").last + @name = path.split("/").last.gsub('-','') @path = File.join(path, '..', "#{ name }-android") @www = path @name = path.split('/').last - @pkg = "com.phonegap.#{ name.gsub('-','') }" + @pkg = "com.phonegap.#{ name }" # android sdk discovery ... could be better @android_sdk_path = Dir.getwd[0,1] != "/" ? `android-sdk-path.bat android.bat`.gsub('\\tools','').gsub('\\', '\\\\\\\\') : `which android`.gsub('/tools/android','')