summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/android/assets/www/cordova-js-src
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2017-02-16 01:24:12 +0100
committerJules Laplace <jules@okfoc.us>2017-02-16 01:24:12 +0100
commit30c49550c89c1b69c680170d2dc247eac76bd463 (patch)
tree8732652298b630b9ba15def97e59738f1c9bf7b6 /StoneIsland/platforms/android/assets/www/cordova-js-src
parent8f1f626384e6ba75f4fb24c27e0973260a74421b (diff)
push plugin
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/cordova-js-src')
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/android/assets/www/cordova-js-src/android/nativeapiprovider.js0
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/android/assets/www/cordova-js-src/android/promptbasednativeapi.js0
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/android/assets/www/cordova-js-src/exec.js20
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/android/assets/www/cordova-js-src/platform.js36
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/android/assets/www/cordova-js-src/plugin/android/app.js0
5 files changed, 52 insertions, 4 deletions
diff --git a/StoneIsland/platforms/android/assets/www/cordova-js-src/android/nativeapiprovider.js b/StoneIsland/platforms/android/assets/www/cordova-js-src/android/nativeapiprovider.js
index 2e9aa67b..2e9aa67b 100755..100644
--- a/StoneIsland/platforms/android/assets/www/cordova-js-src/android/nativeapiprovider.js
+++ b/StoneIsland/platforms/android/assets/www/cordova-js-src/android/nativeapiprovider.js
diff --git a/StoneIsland/platforms/android/assets/www/cordova-js-src/android/promptbasednativeapi.js b/StoneIsland/platforms/android/assets/www/cordova-js-src/android/promptbasednativeapi.js
index f7fb6bc7..f7fb6bc7 100755..100644
--- a/StoneIsland/platforms/android/assets/www/cordova-js-src/android/promptbasednativeapi.js
+++ b/StoneIsland/platforms/android/assets/www/cordova-js-src/android/promptbasednativeapi.js
diff --git a/StoneIsland/platforms/android/assets/www/cordova-js-src/exec.js b/StoneIsland/platforms/android/assets/www/cordova-js-src/exec.js
index fa8b41be..f73d87a1 100755..100644
--- a/StoneIsland/platforms/android/assets/www/cordova-js-src/exec.js
+++ b/StoneIsland/platforms/android/assets/www/cordova-js-src/exec.js
@@ -51,10 +51,11 @@ var cordova = require('cordova'),
// For the ONLINE_EVENT to be viable, it would need to intercept all event
// listeners (both through addEventListener and window.ononline) as well
// as set the navigator property itself.
- ONLINE_EVENT: 2
+ ONLINE_EVENT: 2,
+ EVAL_BRIDGE: 3
},
jsToNativeBridgeMode, // Set lazily.
- nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
+ nativeToJsBridgeMode = nativeToJsModes.EVAL_BRIDGE,
pollEnabled = false,
bridgeSecret = -1;
@@ -77,6 +78,9 @@ function androidExec(success, fail, service, action, args) {
androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
}
+ // If args is not provided, default to an empty array
+ args = args || [];
+
// Process any ArrayBuffers in the args into a string.
for (var i = 0; i < args.length; i++) {
if (utils.typeName(args[i]) == 'ArrayBuffer') {
@@ -86,7 +90,6 @@ function androidExec(success, fail, service, action, args) {
var callbackId = service + cordova.callbackId++,
argsJson = JSON.stringify(args);
-
if (success || fail) {
cordova.callbacks[callbackId] = {success:success, fail:fail};
}
@@ -106,6 +109,17 @@ function androidExec(success, fail, service, action, args) {
}
androidExec.init = function() {
+ //CB-11828
+ //This failsafe checks the version of Android and if it's Jellybean, it switches it to
+ //using the Online Event bridge for communicating from Native to JS
+ //
+ //It's ugly, but it's necessary.
+ var check = navigator.userAgent.toLowerCase().match(/android\s[0-9].[0-9]/);
+ var version_code = check && check[0].match(/4.[0-3].*/);
+ if (version_code != null && nativeToJsBridgeMode == nativeToJsModes.EVAL_BRIDGE) {
+ nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT;
+ }
+
bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
channel.onNativeReady.fire();
};
diff --git a/StoneIsland/platforms/android/assets/www/cordova-js-src/platform.js b/StoneIsland/platforms/android/assets/www/cordova-js-src/platform.js
index bffc6751..2bfd0247 100755..100644
--- a/StoneIsland/platforms/android/assets/www/cordova-js-src/platform.js
+++ b/StoneIsland/platforms/android/assets/www/cordova-js-src/platform.js
@@ -19,6 +19,9 @@
*
*/
+// The last resume event that was received that had the result of a plugin call.
+var lastResumeEvent = null;
+
module.exports = {
id: 'android',
bootstrap: function() {
@@ -58,6 +61,19 @@ module.exports = {
bindButtonChannel('volumeup');
bindButtonChannel('volumedown');
+ // The resume event is not "sticky", but it is possible that the event
+ // will contain the result of a plugin call. We need to ensure that the
+ // plugin result is delivered even after the event is fired (CB-10498)
+ var cordovaAddEventListener = document.addEventListener;
+
+ document.addEventListener = function(evt, handler, capture) {
+ cordovaAddEventListener(evt, handler, capture);
+
+ if (evt === 'resume' && lastResumeEvent) {
+ handler(lastResumeEvent);
+ }
+ };
+
// Let native code know we are all done on the JS side.
// Native code will then un-hide the WebView.
channel.onCordovaReady.subscribe(function() {
@@ -79,12 +95,30 @@ function onMessageFromNative(msg) {
case 'searchbutton':
// App life cycle events
case 'pause':
- case 'resume':
// Volume events
case 'volumedownbutton':
case 'volumeupbutton':
cordova.fireDocumentEvent(action);
break;
+ case 'resume':
+ if(arguments.length > 1 && msg.pendingResult) {
+ if(arguments.length === 2) {
+ msg.pendingResult.result = arguments[1];
+ } else {
+ // The plugin returned a multipart message
+ var res = [];
+ for(var i = 1; i < arguments.length; i++) {
+ res.push(arguments[i]);
+ }
+ msg.pendingResult.result = res;
+ }
+
+ // Save the plugin result so that it can be delivered to the js
+ // even if they miss the initial firing of the event
+ lastResumeEvent = msg;
+ }
+ cordova.fireDocumentEvent(action, msg);
+ break;
default:
throw new Error('Unknown event action ' + action);
}
diff --git a/StoneIsland/platforms/android/assets/www/cordova-js-src/plugin/android/app.js b/StoneIsland/platforms/android/assets/www/cordova-js-src/plugin/android/app.js
index 22cf96e8..22cf96e8 100755..100644
--- a/StoneIsland/platforms/android/assets/www/cordova-js-src/plugin/android/app.js
+++ b/StoneIsland/platforms/android/assets/www/cordova-js-src/plugin/android/app.js