mirror of
https://github.com/apache/cordova-android.git
synced 2025-05-14 07:10:40 +08:00
Minor changes to droidgap to make it work on my shell (cygwin), merging in Joe`s changes/fixes to geo + JavaScript
This commit is contained in:
parent
f53b4ec109
commit
24d5948d0d
5
droidgap
5
droidgap
@ -43,8 +43,9 @@ class Build
|
|||||||
# TODO validate Android SDK
|
# TODO validate Android SDK
|
||||||
# TODO fix 'android' shell call so that it works on Windows. Can't prepend android command with path to it.
|
# TODO fix 'android' shell call so that it works on Windows. Can't prepend android command with path to it.
|
||||||
def create_android
|
def create_android
|
||||||
target_id = 5 # `android list targets` =~ /id:\s*(\d+).*android-5/ ? $1 : 5
|
android_exec = File.join(@android_sdk_path, "tools", "android");
|
||||||
puts "Creating Android project for SDK target level #{ target_id }"
|
target_id = 5
|
||||||
|
puts "Creating Android project for target level #{ target_id }"
|
||||||
`android create project -t #{ target_id } -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }`
|
`android create project -t #{ target_id } -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }`
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -693,7 +693,7 @@ FileReader.prototype.readAsText = function(file)
|
|||||||
this.fileName = file;
|
this.fileName = file;
|
||||||
navigator.fileMgr.addFileReader(this.fileName,this);
|
navigator.fileMgr.addFileReader(this.fileName,this);
|
||||||
|
|
||||||
return FileUtil.read(fileName);
|
return FileUtil.read(this.fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// File Writer
|
// File Writer
|
||||||
@ -734,12 +734,11 @@ function Geolocation() {
|
|||||||
*/
|
*/
|
||||||
this.lastPosition = null;
|
this.lastPosition = null;
|
||||||
this.lastError = null;
|
this.lastError = null;
|
||||||
this.callbacks = {
|
this.listeners = null;
|
||||||
onLocationChanged: [],
|
|
||||||
onError: []
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var geoListeners = [];
|
||||||
|
|
||||||
Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallback, options)
|
Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallback, options)
|
||||||
{
|
{
|
||||||
var position = Geo.getCurrentLocation();
|
var position = Geo.getCurrentLocation();
|
||||||
@ -747,63 +746,6 @@ Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallba
|
|||||||
this.fail = errorCallback;
|
this.fail = errorCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Asynchronously aquires the position repeatedly at a given interval.
|
|
||||||
* @param {Function} successCallback The function to call each time the position
|
|
||||||
* data is available
|
|
||||||
* @param {Function} errorCallback The function to call when there is an error
|
|
||||||
* getting the position data.
|
|
||||||
* @param {PositionOptions} options The options for getting the position data
|
|
||||||
* such as timeout and the frequency of the watch.
|
|
||||||
*/
|
|
||||||
Geolocation.prototype.watchPosition = function(successCallback, errorCallback, options) {
|
|
||||||
// Invoke the appropriate callback with a new Position object every time the implementation
|
|
||||||
// determines that the position of the hosting device has changed.
|
|
||||||
|
|
||||||
this.getCurrentPosition(successCallback, errorCallback, options);
|
|
||||||
var frequency = 10000;
|
|
||||||
if (typeof(options) == 'object' && options.frequency)
|
|
||||||
frequency = options.frequency;
|
|
||||||
|
|
||||||
var that = this;
|
|
||||||
return setInterval(function() {
|
|
||||||
that.getCurrentPosition(successCallback, errorCallback, options);
|
|
||||||
}, frequency);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears the specified position watch.
|
|
||||||
* @param {String} watchId The ID of the watch returned from #watchPosition.
|
|
||||||
*/
|
|
||||||
Geolocation.prototype.clearWatch = function(watchId) {
|
|
||||||
clearInterval(watchId);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by the geolocation framework when the current location is found.
|
|
||||||
* @param {PositionOptions} position The current position.
|
|
||||||
*/
|
|
||||||
Geolocation.prototype.setLocation = function(position) {
|
|
||||||
this.lastPosition = position;
|
|
||||||
for (var i = 0; i < this.callbacks.onLocationChanged.length; i++) {
|
|
||||||
var f = this.callbacks.onLocationChanged.shift();
|
|
||||||
f(position);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by the geolocation framework when an error occurs while looking up the current position.
|
|
||||||
* @param {String} message The text of the error message.
|
|
||||||
*/
|
|
||||||
Geolocation.prototype.setError = function(message) {
|
|
||||||
this.lastError = message;
|
|
||||||
for (var i = 0; i < this.callbacks.onError.length; i++) {
|
|
||||||
var f = this.callbacks.onError.shift();
|
|
||||||
f(message);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Run the global callback
|
// Run the global callback
|
||||||
Geolocation.prototype.gotCurrentPosition = function(lat, lng, alt, altacc, head, vel, stamp)
|
Geolocation.prototype.gotCurrentPosition = function(lat, lng, alt, altacc, head, vel, stamp)
|
||||||
{
|
{
|
||||||
@ -829,16 +771,11 @@ Geolocation.prototype.gotCurrentPosition = function(lat, lng, alt, altacc, head,
|
|||||||
Geolocation.prototype.watchPosition = function(successCallback, errorCallback, options)
|
Geolocation.prototype.watchPosition = function(successCallback, errorCallback, options)
|
||||||
{
|
{
|
||||||
var frequency = (options != undefined)? options.frequency : 10000;
|
var frequency = (options != undefined)? options.frequency : 10000;
|
||||||
|
|
||||||
if (!this.listeners)
|
var key = geoListeners.push( {"success" : successCallback, "fail" : errorCallback }) - 1;
|
||||||
{
|
|
||||||
this.listeners = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
var key = this.listeners.push( {"success" : successCallback, "fail" : failCallback }) - 1;
|
|
||||||
|
|
||||||
// TO-DO: Get the names of the method and pass them as strings to the Java.
|
// TO-DO: Get the names of the method and pass them as strings to the Java.
|
||||||
return Geolocation.start(frequency, key);
|
return Geo.start(frequency, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -849,18 +786,19 @@ Geolocation.prototype.success = function(key, lat, lng, alt, altacc, head, vel,
|
|||||||
{
|
{
|
||||||
var coords = new Coordinates(lat, lng, alt, altacc, head, vel);
|
var coords = new Coordinates(lat, lng, alt, altacc, head, vel);
|
||||||
var loc = new Position(coords, stamp);
|
var loc = new Position(coords, stamp);
|
||||||
this.listeners[key].success(loc);
|
geoListeners[key].success(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
Geolocation.prototype.fail = function(key)
|
Geolocation.prototype.fail = function(key)
|
||||||
{
|
{
|
||||||
this.listeners[key].fail();
|
geoListeners[key].fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
Geolocation.prototype.clearWatch = function(watchId)
|
Geolocation.prototype.clearWatch = function(watchId)
|
||||||
{
|
{
|
||||||
Geo.stop(watchId);
|
Geo.stop(watchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taken from Jesse's geo fix (similar problem) in PhoneGap iPhone. Go figure, same browser!
|
// Taken from Jesse's geo fix (similar problem) in PhoneGap iPhone. Go figure, same browser!
|
||||||
function __proxyObj(origObj, proxyObj, funkList) {
|
function __proxyObj(origObj, proxyObj, funkList) {
|
||||||
for (var v in funkList) {
|
for (var v in funkList) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user