mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
Rename PhoneGap.execAsync() to PhoneGap.exec() and change all JS files that use it.
This commit is contained in:
parent
29549b835a
commit
6b7fc8119f
@ -55,7 +55,7 @@ Accelerometer.prototype.getCurrentAcceleration = function(successCallback, error
|
||||
}
|
||||
|
||||
// Get acceleration
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||
PhoneGap.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -84,10 +84,10 @@ Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallb
|
||||
}
|
||||
|
||||
// Make sure accelerometer timeout > frequency + 10 sec
|
||||
PhoneGap.execAsync(
|
||||
PhoneGap.exec(
|
||||
function(timeout) {
|
||||
if (timeout < (frequency + 10000)) {
|
||||
PhoneGap.execAsync(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
|
||||
PhoneGap.exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
|
||||
}
|
||||
},
|
||||
function(e) { }, "Accelerometer", "getTimeout", []);
|
||||
@ -95,7 +95,7 @@ Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallb
|
||||
// Start watch timer
|
||||
var id = PhoneGap.createUUID();
|
||||
navigator.accelerometer.timers[id] = setInterval(function() {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||
PhoneGap.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||
}, (frequency ? frequency : 1));
|
||||
|
||||
return id;
|
||||
|
@ -85,7 +85,7 @@ Camera.prototype.getPicture = function(successCallback, errorCallback, options)
|
||||
if (typeof this.options.sourceType == "number") {
|
||||
sourceType = this.options.sourceType;
|
||||
}
|
||||
PhoneGap.execAsync(null, null, "Camera", "takePicture", [quality, destinationType, sourceType]);
|
||||
PhoneGap.exec(null, null, "Camera", "takePicture", [quality, destinationType, sourceType]);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ Compass.prototype.getCurrentHeading = function(successCallback, errorCallback, o
|
||||
}
|
||||
|
||||
// Get heading
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||
PhoneGap.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -75,10 +75,10 @@ Compass.prototype.watchHeading= function(successCallback, errorCallback, options
|
||||
}
|
||||
|
||||
// Make sure compass timeout > frequency + 10 sec
|
||||
PhoneGap.execAsync(
|
||||
PhoneGap.exec(
|
||||
function(timeout) {
|
||||
if (timeout < (frequency + 10000)) {
|
||||
PhoneGap.execAsync(null, null, "Compass", "setTimeout", [frequency + 10000]);
|
||||
PhoneGap.exec(null, null, "Compass", "setTimeout", [frequency + 10000]);
|
||||
}
|
||||
},
|
||||
function(e) { }, "Compass", "getTimeout", []);
|
||||
@ -87,7 +87,7 @@ Compass.prototype.watchHeading= function(successCallback, errorCallback, options
|
||||
var id = PhoneGap.createUUID();
|
||||
navigator.compass.timers[id] = setInterval(
|
||||
function() {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||
PhoneGap.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||
}, (frequency ? frequency : 1));
|
||||
|
||||
return id;
|
||||
|
@ -66,13 +66,13 @@ var Contact = function(id, displayName, name, nickname, phoneNumbers, emails, ad
|
||||
* @param errorCB error callback
|
||||
*/
|
||||
Contact.prototype.remove = function(successCB, errorCB) {
|
||||
if (this.id == null) {
|
||||
var errorObj = new ContactError();
|
||||
errorObj.code = ContactError.NOT_FOUND_ERROR;
|
||||
errorCB(errorObj);
|
||||
}
|
||||
|
||||
PhoneGap.execAsync(successCB, errorCB, "Contacts", "remove", [this.id]);
|
||||
if (this.id == null) {
|
||||
var errorObj = new ContactError();
|
||||
errorObj.code = ContactError.NOT_FOUND_ERROR;
|
||||
errorCB(errorObj);
|
||||
}
|
||||
|
||||
PhoneGap.exec(successCB, errorCB, "Contacts", "remove", [this.id]);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -81,8 +81,8 @@ Contact.prototype.remove = function(successCB, errorCB) {
|
||||
* @return copy of this Contact
|
||||
*/
|
||||
Contact.prototype.clone = function() {
|
||||
var clonedContact = PhoneGap.clone(this);
|
||||
clonedContact.id = null;
|
||||
var clonedContact = PhoneGap.clone(this);
|
||||
clonedContact.id = null;
|
||||
return clonedContact;
|
||||
};
|
||||
|
||||
@ -183,14 +183,14 @@ var Contacts = function() {
|
||||
}
|
||||
/**
|
||||
* Returns an array of Contacts matching the search criteria.
|
||||
* @param fields that should be searched
|
||||
* @param fields that should be searched
|
||||
* @param successCB success callback
|
||||
* @param errorCB error callback
|
||||
* @param {ContactFindOptions} options that can be applied to contact searching
|
||||
* @return array of Contacts matching search criteria
|
||||
*/
|
||||
Contacts.prototype.find = function(fields, successCB, errorCB, options) {
|
||||
PhoneGap.execAsync(successCB, errorCB, "Contacts", "search", [fields, options]);
|
||||
PhoneGap.exec(successCB, errorCB, "Contacts", "search", [fields, options]);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -201,13 +201,13 @@ Contacts.prototype.find = function(fields, successCB, errorCB, options) {
|
||||
* @returns new Contact object
|
||||
*/
|
||||
Contacts.prototype.create = function(properties) {
|
||||
var contact = new Contact();
|
||||
for (i in properties) {
|
||||
if (contact[i]!='undefined') {
|
||||
contact[i]=properties[i];
|
||||
}
|
||||
}
|
||||
return contact;
|
||||
var contact = new Contact();
|
||||
for (i in properties) {
|
||||
if (contact[i]!='undefined') {
|
||||
contact[i]=properties[i];
|
||||
}
|
||||
}
|
||||
return contact;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -232,7 +232,7 @@ var ContactError = function() {
|
||||
this.code=null;
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* Error codes
|
||||
*/
|
||||
ContactError.UNKNOWN_ERROR = 0;
|
||||
|
@ -13,12 +13,12 @@ var Crypto = function() {
|
||||
|
||||
Crypto.prototype.encrypt = function(seed, string, callback) {
|
||||
this.encryptWin = callback;
|
||||
PhoneGap.execAsync(null, null, "Crypto", "encrypt", [seed, string]);
|
||||
PhoneGap.exec(null, null, "Crypto", "encrypt", [seed, string]);
|
||||
};
|
||||
|
||||
Crypto.prototype.decrypt = function(seed, string, callback) {
|
||||
this.decryptWin = callback;
|
||||
PhoneGap.execAsync(null, null, "Crypto", "decrypt", [seed, string]);
|
||||
PhoneGap.exec(null, null, "Crypto", "decrypt", [seed, string]);
|
||||
};
|
||||
|
||||
Crypto.prototype.gotCryptedString = function(string) {
|
||||
|
@ -57,7 +57,7 @@ Device.prototype.getInfo = function(successCallback, errorCallback) {
|
||||
}
|
||||
|
||||
// Get info
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
||||
PhoneGap.exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -68,43 +68,43 @@ FileMgr.prototype.getFileBasePaths = function() {
|
||||
};
|
||||
|
||||
FileMgr.prototype.testSaveLocationExists = function(successCallback, errorCallback) {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "File", "testSaveLocationExists", []);
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "testSaveLocationExists", []);
|
||||
};
|
||||
|
||||
FileMgr.prototype.testFileExists = function(fileName, successCallback, errorCallback) {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "File", "testFileExists", [fileName]);
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "testFileExists", [fileName]);
|
||||
};
|
||||
|
||||
FileMgr.prototype.testDirectoryExists = function(dirName, successCallback, errorCallback) {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "File", "testDirectoryExists", [dirName]);
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "testDirectoryExists", [dirName]);
|
||||
};
|
||||
|
||||
FileMgr.prototype.createDirectory = function(dirName, successCallback, errorCallback) {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "File", "createDirectory", [dirName]);
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "createDirectory", [dirName]);
|
||||
};
|
||||
|
||||
FileMgr.prototype.deleteDirectory = function(dirName, successCallback, errorCallback) {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "File", "deleteDirectory", [dirName]);
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "deleteDirectory", [dirName]);
|
||||
};
|
||||
|
||||
FileMgr.prototype.deleteFile = function(fileName, successCallback, errorCallback) {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "File", "deleteFile", [fileName]);
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "deleteFile", [fileName]);
|
||||
};
|
||||
|
||||
FileMgr.prototype.getFreeDiskSpace = function(successCallback, errorCallback) {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "File", "getFreeDiskSpace", []);
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "getFreeDiskSpace", []);
|
||||
};
|
||||
|
||||
FileMgr.prototype.writeAsText = function(fileName, data, append, successCallback, errorCallback) {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "File", "writeAsText", [fileName, data, append]);
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "writeAsText", [fileName, data, append]);
|
||||
};
|
||||
|
||||
FileMgr.prototype.readAsText = function(fileName, encoding, successCallback, errorCallback) {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "File", "readAsText", [fileName, encoding]);
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "readAsText", [fileName, encoding]);
|
||||
};
|
||||
|
||||
FileMgr.prototype.readAsDataURL = function(fileName, successCallback, errorCallback) {
|
||||
PhoneGap.execAsync(successCallback, errorCallback, "File", "readAsDataURL", [fileName]);
|
||||
PhoneGap.exec(successCallback, errorCallback, "File", "readAsDataURL", [fileName]);
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
|
@ -65,7 +65,7 @@ Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallba
|
||||
}
|
||||
}
|
||||
navigator._geo.listeners["global"] = {"success" : successCallback, "fail" : errorCallback };
|
||||
PhoneGap.execAsync(null, null, "Geolocation", "getCurrentLocation", [enableHighAccuracy, timeout, maximumAge]);
|
||||
PhoneGap.exec(null, null, "Geolocation", "getCurrentLocation", [enableHighAccuracy, timeout, maximumAge]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,7 +97,7 @@ Geolocation.prototype.watchPosition = function(successCallback, errorCallback, o
|
||||
}
|
||||
var id = PhoneGap.createUUID();
|
||||
navigator._geo.listeners[id] = {"success" : successCallback, "fail" : errorCallback };
|
||||
PhoneGap.execAsync(null, null, "Geolocation", "start", [id, enableHighAccuracy, timeout, maximumAge]);
|
||||
PhoneGap.exec(null, null, "Geolocation", "start", [id, enableHighAccuracy, timeout, maximumAge]);
|
||||
return id;
|
||||
};
|
||||
|
||||
@ -158,7 +158,7 @@ Geolocation.prototype.fail = function(id, code, msg) {
|
||||
* @param {String} id The ID of the watch returned from #watchPosition
|
||||
*/
|
||||
Geolocation.prototype.clearWatch = function(id) {
|
||||
PhoneGap.execAsync(null, null, "Geolocation", "stop", [id]);
|
||||
PhoneGap.exec(null, null, "Geolocation", "stop", [id]);
|
||||
delete navigator._geo.listeners[id];
|
||||
};
|
||||
|
||||
|
@ -142,21 +142,21 @@ MediaError.MEDIA_ERR_NONE_SUPPORTED = 4;
|
||||
* Start or resume playing audio file.
|
||||
*/
|
||||
Media.prototype.play = function() {
|
||||
PhoneGap.execAsync(null, null, "Media", "startPlayingAudio", [this.id, this.src]);
|
||||
PhoneGap.exec(null, null, "Media", "startPlayingAudio", [this.id, this.src]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop playing audio file.
|
||||
*/
|
||||
Media.prototype.stop = function() {
|
||||
return PhoneGap.execAsync(null, null, "Media", "stopPlayingAudio", [this.id]);
|
||||
return PhoneGap.exec(null, null, "Media", "stopPlayingAudio", [this.id]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Pause playing audio file.
|
||||
*/
|
||||
Media.prototype.pause = function() {
|
||||
PhoneGap.execAsync(null, null, "Media", "pausePlayingAudio", [this.id]);
|
||||
PhoneGap.exec(null, null, "Media", "pausePlayingAudio", [this.id]);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -175,20 +175,20 @@ Media.prototype.getDuration = function() {
|
||||
* @return
|
||||
*/
|
||||
Media.prototype.getCurrentPosition = function(success, fail) {
|
||||
PhoneGap.execAsync(success, fail, "Media", "getCurrentPositionAudio", [this.id]);
|
||||
PhoneGap.exec(success, fail, "Media", "getCurrentPositionAudio", [this.id]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Start recording audio file.
|
||||
*/
|
||||
Media.prototype.startRecord = function() {
|
||||
PhoneGap.execAsync(null, null, "Media", "startRecordingAudio", [this.id, this.src]);
|
||||
PhoneGap.exec(null, null, "Media", "startRecordingAudio", [this.id, this.src]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop recording audio file.
|
||||
*/
|
||||
Media.prototype.stopRecord = function() {
|
||||
PhoneGap.execAsync(null, null, "Media", "stopRecordingAudio", [this.id]);
|
||||
PhoneGap.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
|
||||
};
|
||||
|
||||
|
@ -26,10 +26,10 @@ NetworkStatus.REACHABLE_VIA_WIFI_NETWORK = 2;
|
||||
function Network() {
|
||||
/**
|
||||
* The last known Network status.
|
||||
* { hostName: string, ipAddress: string,
|
||||
remoteHostStatus: int(0/1/2), internetConnectionStatus: int(0/1/2), localWiFiConnectionStatus: int (0/2) }
|
||||
* { hostName: string, ipAddress: string,
|
||||
remoteHostStatus: int(0/1/2), internetConnectionStatus: int(0/1/2), localWiFiConnectionStatus: int (0/2) }
|
||||
*/
|
||||
this.lastReachability = null;
|
||||
this.lastReachability = null;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ Network.prototype.isReachable = function(uri, callback, options) {
|
||||
if (options && options.isIpAddress) {
|
||||
isIpAddress = options.isIpAddress;
|
||||
}
|
||||
PhoneGap.execAsync(callback, null, "Network Status", "isReachable", [uri, isIpAddress]);
|
||||
PhoneGap.exec(callback, null, "Network Status", "isReachable", [uri, isIpAddress]);
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
|
@ -22,7 +22,7 @@ function Notification() {
|
||||
Notification.prototype.alert = function(message, title, buttonLabel) {
|
||||
var _title = (title || "Alert");
|
||||
var _buttonLabel = (buttonLabel || "OK");
|
||||
PhoneGap.execAsync(null, null, "Notification", "alert", [message,_title,_buttonLabel]);
|
||||
PhoneGap.exec(null, null, "Notification", "alert", [message,_title,_buttonLabel]);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -36,21 +36,21 @@ Notification.prototype.alert = function(message, title, buttonLabel) {
|
||||
Notification.prototype.confirm = function(message, title, buttonLabels) {
|
||||
var _title = (title || "Confirm");
|
||||
var _buttonLabels = (buttonLabels || "OK,Cancel");
|
||||
return PhoneGap.execAsync(null, null, "Notification", "confirm", [message,_title,_buttonLabels]);
|
||||
return PhoneGap.exec(null, null, "Notification", "confirm", [message,_title,_buttonLabels]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Start spinning the activity indicator on the statusbar
|
||||
*/
|
||||
Notification.prototype.activityStart = function() {
|
||||
PhoneGap.execAsync(null, null, "Notification", "activityStart", ["Busy","Please wait..."]);
|
||||
PhoneGap.exec(null, null, "Notification", "activityStart", ["Busy","Please wait..."]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop spinning the activity indicator on the statusbar, if it's currently spinning
|
||||
*/
|
||||
Notification.prototype.activityStop = function() {
|
||||
PhoneGap.execAsync(null, null, "Notification", "activityStop", []);
|
||||
PhoneGap.exec(null, null, "Notification", "activityStop", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -60,7 +60,7 @@ Notification.prototype.activityStop = function() {
|
||||
* @param {String} message Message to display in the dialog.
|
||||
*/
|
||||
Notification.prototype.progressStart = function(title, message) {
|
||||
PhoneGap.execAsync(null, null, "Notification", "progressStart", [title, message]);
|
||||
PhoneGap.exec(null, null, "Notification", "progressStart", [title, message]);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -69,14 +69,14 @@ Notification.prototype.progressStart = function(title, message) {
|
||||
* @param {Number} value 0-100
|
||||
*/
|
||||
Notification.prototype.progressValue = function(value) {
|
||||
PhoneGap.execAsync(null, null, "Notification", "progressValue", [value]);
|
||||
PhoneGap.exec(null, null, "Notification", "progressValue", [value]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Close the progress dialog.
|
||||
*/
|
||||
Notification.prototype.progressStop = function() {
|
||||
PhoneGap.execAsync(null, null, "Notification", "progressStop", []);
|
||||
PhoneGap.exec(null, null, "Notification", "progressStop", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ Notification.prototype.blink = function(count, colour) {
|
||||
* @param {Integer} mills The number of milliseconds to vibrate for.
|
||||
*/
|
||||
Notification.prototype.vibrate = function(mills) {
|
||||
PhoneGap.execAsync(null, null, "Notification", "vibrate", [mills]);
|
||||
PhoneGap.exec(null, null, "Notification", "vibrate", [mills]);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -105,7 +105,7 @@ Notification.prototype.vibrate = function(mills) {
|
||||
* @param {Integer} count The number of beeps.
|
||||
*/
|
||||
Notification.prototype.beep = function(count) {
|
||||
PhoneGap.execAsync(null, null, "Notification", "beep", [count]);
|
||||
PhoneGap.exec(null, null, "Notification", "beep", [count]);
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
|
@ -376,35 +376,6 @@ PhoneGap.clone = function(obj) {
|
||||
PhoneGap.callbackId = 0;
|
||||
PhoneGap.callbacks = {};
|
||||
|
||||
/**
|
||||
* Execute a PhoneGap command in a queued fashion, to ensure commands do not
|
||||
* execute with any race conditions, and only run when PhoneGap is ready to
|
||||
* recieve them.
|
||||
* @param {String} command Command to be run in PhoneGap, e.g. "ClassName.method"
|
||||
* @param {String[]} [args] Zero or more arguments to pass to the method
|
||||
*/
|
||||
// TODO: Not used anymore, should be removed.
|
||||
PhoneGap.exec = function(clazz, action, args) {
|
||||
try {
|
||||
var callbackId = 0;
|
||||
var r = PluginManager.exec(clazz, action, callbackId, this.stringify(args), false);
|
||||
eval("var v="+r+";");
|
||||
|
||||
// If status is OK, then return value back to caller
|
||||
if (v.status == 0) {
|
||||
return v.message;
|
||||
}
|
||||
|
||||
// If error, then display error
|
||||
else {
|
||||
console.log("Error: Status="+r.status+" Message="+v.message);
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Error: "+e);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Execute a PhoneGap command. It is up to the native side whether this action is synch or async.
|
||||
* The native side can return:
|
||||
|
@ -263,7 +263,7 @@ DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCa
|
||||
query.errorCallback = errorCallback;
|
||||
|
||||
// Call native code
|
||||
PhoneGap.execAsync(null, null, "Storage", "executeSql", [sql, params, query.id]);
|
||||
PhoneGap.exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -303,7 +303,7 @@ DroidDB_Rows.prototype.item = function(row) {
|
||||
* @return Database object
|
||||
*/
|
||||
DroidDB_openDatabase = function(name, version, display_name, size) {
|
||||
PhoneGap.execAsync(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
|
||||
PhoneGap.exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
|
||||
var db = new DatabaseShell();
|
||||
return db;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user