mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 12:03:28 +08:00
fixing dasherish
This commit is contained in:
parent
d2e19d8818
commit
9185848cbc
@ -561,13 +561,17 @@ PhoneGap.addConstructor(function() {
|
|||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* This class provides access to the device camera.
|
* This class provides access to the device camera.
|
||||||
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Camera() {
|
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} successCallback
|
||||||
* @param {Function} errorCallback
|
* @param {Function} errorCallback
|
||||||
@ -575,27 +579,52 @@ function Camera() {
|
|||||||
*/
|
*/
|
||||||
Camera.prototype.getPicture = function(successCallback, errorCallback, options) {
|
Camera.prototype.getPicture = function(successCallback, errorCallback, options) {
|
||||||
|
|
||||||
this.winCallback = successCallback;
|
// successCallback required
|
||||||
this.failCallback = errorCallback;
|
if (typeof successCallback != "function") {
|
||||||
if (options.quality)
|
console.log("Camera Error: successCallback is not a function");
|
||||||
{
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// errorCallback optional
|
||||||
|
if (errorCallback && (typeof errorCallback != "function")) {
|
||||||
|
console.log("Camera Error: errorCallback is not a function");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.successCallback = successCallback;
|
||||||
|
this.errorCallback = errorCallback;
|
||||||
|
this.options = options;
|
||||||
|
if (options.quality) {
|
||||||
GapCam.takePicture(options.quality);
|
GapCam.takePicture(options.quality);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
GapCam.takePicture(80);
|
GapCam.takePicture(80);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
Camera.prototype.win = function(picture)
|
/**
|
||||||
{
|
* Callback function from native code that is called when image has been captured.
|
||||||
this.winCallback(picture);
|
*
|
||||||
|
* @param picture The base64 encoded string of the image
|
||||||
|
*/
|
||||||
|
Camera.prototype.success = function(picture) {
|
||||||
|
if (this.successCallback) {
|
||||||
|
this.successCallback(picture);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Camera.prototype.fail = function(err)
|
|
||||||
{
|
/**
|
||||||
this.failCallback(err);
|
* 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() {
|
PhoneGap.addConstructor(function() {
|
||||||
if (typeof navigator.camera == "undefined") navigator.camera = new Camera();
|
if (typeof navigator.camera == "undefined") navigator.camera = new Camera();
|
||||||
|
@ -30,11 +30,11 @@ class Create
|
|||||||
raise 'No index.html found!' unless File.exists? File.join(path, 'index.html')
|
raise 'No index.html found!' unless File.exists? File.join(path, 'index.html')
|
||||||
|
|
||||||
# setup default vars
|
# setup default vars
|
||||||
@name = path.split("/").last
|
@name = path.split("/").last.gsub('-','')
|
||||||
@path = File.join(path, '..', "#{ name }-android")
|
@path = File.join(path, '..', "#{ name }-android")
|
||||||
@www = path
|
@www = path
|
||||||
@name = path.split('/').last
|
@name = path.split('/').last
|
||||||
@pkg = "com.phonegap.#{ name.gsub('-','') }"
|
@pkg = "com.phonegap.#{ name }"
|
||||||
|
|
||||||
# android sdk discovery ... could be better
|
# 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','')
|
@android_sdk_path = Dir.getwd[0,1] != "/" ? `android-sdk-path.bat android.bat`.gsub('\\tools','').gsub('\\', '\\\\\\\\') : `which android`.gsub('/tools/android','')
|
||||||
|
Loading…
Reference in New Issue
Block a user