mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 23:25:11 +08:00
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-cordova-android
This commit is contained in:
commit
4d0824f4a4
@ -1,6 +1,6 @@
|
|||||||
// commit 6881d72b96f476a1e8cd6e03fe1465a0fb88b000
|
// commit 8119d0b96958dfa3a0ce8590a90b24242ec4e31a
|
||||||
|
|
||||||
// File generated at :: Wed Oct 24 2012 16:27:17 GMT-0400 (EDT)
|
// File generated at :: Thu Oct 25 2012 15:01:24 GMT-0400 (EDT)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
@ -966,22 +966,32 @@ function androidExec(success, fail, service, action, args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var callbackId = service + cordova.callbackId++,
|
var callbackId = service + cordova.callbackId++,
|
||||||
argsJson = JSON.stringify(args);
|
argsJson = JSON.stringify(args),
|
||||||
if (success || fail) {
|
returnValue;
|
||||||
cordova.callbacks[callbackId] = {success:success, fail:fail};
|
|
||||||
|
// TODO: Returning the payload of a synchronous call was deprecated in 2.2.0.
|
||||||
|
// Remove it after 6 months.
|
||||||
|
function captureReturnValue(value) {
|
||||||
|
returnValue = value;
|
||||||
|
success(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cordova.callbacks[callbackId] = {success:captureReturnValue, fail:fail};
|
||||||
|
|
||||||
if (jsToNativeBridgeMode == jsToNativeModes.LOCATION_CHANGE) {
|
if (jsToNativeBridgeMode == jsToNativeModes.LOCATION_CHANGE) {
|
||||||
window.location = 'http://cdv_exec/' + service + '#' + action + '#' + callbackId + '#' + argsJson;
|
window.location = 'http://cdv_exec/' + service + '#' + action + '#' + callbackId + '#' + argsJson;
|
||||||
} else {
|
} else {
|
||||||
var messages = nativeApiProvider.get().exec(service, action, callbackId, argsJson);
|
var messages = nativeApiProvider.get().exec(service, action, callbackId, argsJson);
|
||||||
// Explicit cast to string is required on Android 2.1 to convert from
|
|
||||||
// a Java string to a JS string.
|
|
||||||
if (messages) {
|
|
||||||
messages = String(messages);
|
|
||||||
}
|
|
||||||
androidExec.processMessages(messages);
|
androidExec.processMessages(messages);
|
||||||
}
|
}
|
||||||
|
if (cordova.callbacks[callbackId]) {
|
||||||
|
if (success || fail) {
|
||||||
|
cordova.callbacks[callbackId].success = success;
|
||||||
|
} else {
|
||||||
|
delete cordova.callbacks[callbackId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pollOnce() {
|
function pollOnce() {
|
||||||
@ -1065,6 +1075,8 @@ function processMessage(message) {
|
|||||||
payload = true;
|
payload = true;
|
||||||
} else if (payloadKind == 'f') {
|
} else if (payloadKind == 'f') {
|
||||||
payload = false;
|
payload = false;
|
||||||
|
} else if (payloadKind == 'N') {
|
||||||
|
payload = null;
|
||||||
} else if (payloadKind == 'n') {
|
} else if (payloadKind == 'n') {
|
||||||
payload = +message.slice(nextSpaceIdx + 2);
|
payload = +message.slice(nextSpaceIdx + 2);
|
||||||
} else {
|
} else {
|
||||||
@ -1095,8 +1107,6 @@ androidExec.processMessages = function(messages) {
|
|||||||
window.setTimeout(pollOnce, 0);
|
window.setTimeout(pollOnce, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Needed for Android 2.2
|
|
||||||
messages = "" + messages;
|
|
||||||
var spaceIdx = messages.indexOf(' ');
|
var spaceIdx = messages.indexOf(' ');
|
||||||
var msgLen = +messages.slice(0, spaceIdx);
|
var msgLen = +messages.slice(0, spaceIdx);
|
||||||
var message = messages.substr(spaceIdx + 1, msgLen);
|
var message = messages.substr(spaceIdx + 1, msgLen);
|
||||||
@ -3940,6 +3950,10 @@ module.exports = {
|
|||||||
get: function() { return currentApi; },
|
get: function() { return currentApi; },
|
||||||
setPreferPrompt: function(value) {
|
setPreferPrompt: function(value) {
|
||||||
currentApi = value ? require('cordova/plugin/android/promptbasednativeapi') : nativeApi;
|
currentApi = value ? require('cordova/plugin/android/promptbasednativeapi') : nativeApi;
|
||||||
|
},
|
||||||
|
// Used only by tests.
|
||||||
|
set: function(value) {
|
||||||
|
currentApi = value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -272,8 +272,14 @@ public class CordovaWebView extends WebView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void exposeJsInterface() {
|
private void exposeJsInterface() {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
|
||||||
|
Log.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");
|
||||||
|
// Bug being that Java Strings do not get converted to JS strings automatically.
|
||||||
|
// This isn't hard to work-around on the JS side, but it's easier to just
|
||||||
|
// use the prompt bridge instead.
|
||||||
|
return;
|
||||||
|
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && Build.MANUFACTURER.equals("unknown")) {
|
||||||
// addJavascriptInterface crashes on the 2.3 emulator.
|
// addJavascriptInterface crashes on the 2.3 emulator.
|
||||||
if (Build.VERSION.RELEASE.startsWith("2.3") && Build.MANUFACTURER.equals("unknown")) {
|
|
||||||
Log.i(TAG, "Disabled addJavascriptInterface() bridge callback due to a bug on the 2.3 emulator");
|
Log.i(TAG, "Disabled addJavascriptInterface() bridge callback due to a bug on the 2.3 emulator");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user