cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject android commit: CB-9042 reverted changes to cordova.js, should be same as 3.7.1
Date Wed, 20 May 2015 23:31:59 GMT
Repository: cordova-android
Updated Branches:
  refs/heads/3.7.x 86f9b618e -> d654de809


CB-9042 reverted changes to cordova.js, should be same as 3.7.1


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/d654de80
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/d654de80
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/d654de80

Branch: refs/heads/3.7.x
Commit: d654de809aaf5eebd5f7ac60fe1f86dbcd0ded38
Parents: 86f9b61
Author: Steve Gill <stevengill97@gmail.com>
Authored: Wed May 20 16:31:28 2015 -0700
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Wed May 20 16:31:28 2015 -0700

----------------------------------------------------------------------
 framework/assets/www/cordova.js | 136 +++++++++++++++++------------------
 1 file changed, 68 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/d654de80/framework/assets/www/cordova.js
----------------------------------------------------------------------
diff --git a/framework/assets/www/cordova.js b/framework/assets/www/cordova.js
index 89485c7..07c7c6e 100644
--- a/framework/assets/www/cordova.js
+++ b/framework/assets/www/cordova.js
@@ -1,5 +1,5 @@
 // Platform: android
-// 23738581906992092a43ad2e643b1e0c43bba38a
+// 24ab6855470f2dc0662624b597c98585e56a1666
 /*
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
@@ -101,15 +101,10 @@ if (typeof module === "object" && typeof require === "function")
{
 // file: src/cordova.js
 define("cordova", function(require, exports, module) {
 
-if(window.cordova){
-    throw new Error("cordova already defined");
-}
-
 
 var channel = require('cordova/channel');
 var platform = require('cordova/platform');
 
-
 /**
  * Intercept calls to addEventListener + removeEventListener and handle deviceready,
  * resume, and pause events.
@@ -328,7 +323,7 @@ module.exports = cordova;
 
 });
 
-// file: node_modules/cordova-android/cordova-js-src/android/nativeapiprovider.js
+// file: src/android/android/nativeapiprovider.js
 define("cordova/android/nativeapiprovider", function(require, exports, module) {
 
 /**
@@ -351,7 +346,7 @@ module.exports = {
 
 });
 
-// file: node_modules/cordova-android/cordova-js-src/android/promptbasednativeapi.js
+// file: src/android/android/promptbasednativeapi.js
 define("cordova/android/promptbasednativeapi", function(require, exports, module) {
 
 /**
@@ -861,7 +856,7 @@ module.exports = channel;
 
 });
 
-// file: node_modules/cordova-android/cordova-js-src/exec.js
+// file: src/android/exec.js
 define("cordova/exec", function(require, exports, module) {
 
 /**
@@ -905,13 +900,9 @@ var cordova = require('cordova'),
     jsToNativeBridgeMode,  // Set lazily.
     nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
     pollEnabled = false,
+    messagesFromNative = [],
     bridgeSecret = -1;
 
-var messagesFromNative = [];
-var isProcessing = false;
-var resolvedPromise = typeof Promise == 'undefined' ? null : Promise.resolve();
-var nextTick = resolvedPromise ? function(fn) { resolvedPromise.then(fn); } : function(fn)
{ setTimeout(fn); };
-
 function androidExec(success, fail, service, action, args) {
     if (bridgeSecret < 0) {
         // If we ever catch this firing, we'll need to queue up exec()s
@@ -940,17 +931,16 @@ function androidExec(success, fail, service, action, args) {
         cordova.callbacks[callbackId] = {success:success, fail:fail};
     }
 
-    var msgs = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId, argsJson);
+    var messages = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId,
argsJson);
     // If argsJson was received by Java as null, try again with the PROMPT bridge mode.
     // This happens in rare circumstances, such as when certain Unicode characters are passed
over the bridge on a Galaxy S2.  See CB-2666.
-    if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT && msgs === "@Null arguments.")
{
+    if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT && messages === "@Null
arguments.") {
         androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT);
         androidExec(success, fail, service, action, args);
         androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
-    } else if (msgs) {
-        messagesFromNative.push(msgs);
-        // Always process async to avoid exceptions messing up stack.
-        nextTick(processMessages);
+        return;
+    } else {
+        androidExec.processMessages(messages, true);
     }
 }
 
@@ -969,12 +959,8 @@ function pollOnce(opt_fromOnlineEvent) {
         // We know there's nothing to retrieve, so no need to poll.
         return;
     }
-    var msgs = nativeApiProvider.get().retrieveJsMessages(bridgeSecret, !!opt_fromOnlineEvent);
-    if (msgs) {
-        messagesFromNative.push(msgs);
-        // Process sync since we know we're already top-of-stack.
-        processMessages();
-    }
+    var msg = nativeApiProvider.get().retrieveJsMessages(bridgeSecret, !!opt_fromOnlineEvent);
+    androidExec.processMessages(msg);
 }
 
 function pollingTimerFunc() {
@@ -1067,51 +1053,63 @@ function buildPayload(payload, message) {
 
 // Processes a single message, as encoded by NativeToJsMessageQueue.java.
 function processMessage(message) {
-    var firstChar = message.charAt(0);
-    if (firstChar == 'J') {
-        // This is deprecated on the .java side. It doesn't work with CSP enabled.
-        eval(message.slice(1));
-    } else if (firstChar == 'S' || firstChar == 'F') {
-        var success = firstChar == 'S';
-        var keepCallback = message.charAt(1) == '1';
-        var spaceIdx = message.indexOf(' ', 2);
-        var status = +message.slice(2, spaceIdx);
-        var nextSpaceIdx = message.indexOf(' ', spaceIdx + 1);
-        var callbackId = message.slice(spaceIdx + 1, nextSpaceIdx);
-        var payloadMessage = message.slice(nextSpaceIdx + 1);
-        var payload = [];
-        buildPayload(payload, payloadMessage);
-        cordova.callbackFromNative(callbackId, success, status, payload, keepCallback);
-    } else {
-        console.log("processMessage failed: invalid message: " + JSON.stringify(message));
+    try {
+        var firstChar = message.charAt(0);
+        if (firstChar == 'J') {
+            eval(message.slice(1));
+        } else if (firstChar == 'S' || firstChar == 'F') {
+            var success = firstChar == 'S';
+            var keepCallback = message.charAt(1) == '1';
+            var spaceIdx = message.indexOf(' ', 2);
+            var status = +message.slice(2, spaceIdx);
+            var nextSpaceIdx = message.indexOf(' ', spaceIdx + 1);
+            var callbackId = message.slice(spaceIdx + 1, nextSpaceIdx);
+            var payloadMessage = message.slice(nextSpaceIdx + 1);
+            var payload = [];
+            buildPayload(payload, payloadMessage);
+            cordova.callbackFromNative(callbackId, success, status, payload, keepCallback);
+        } else {
+            console.log("processMessage failed: invalid message: " + JSON.stringify(message));
+        }
+    } catch (e) {
+        console.log("processMessage failed: Error: " + e);
+        console.log("processMessage failed: Stack: " + e.stack);
+        console.log("processMessage failed: Message: " + message);
     }
 }
 
-function processMessages() {
+var isProcessing = false;
+
+// This is called from the NativeToJsMessageQueue.java.
+androidExec.processMessages = function(messages, opt_useTimeout) {
+    if (messages) {
+        messagesFromNative.push(messages);
+    }
     // Check for the reentrant case.
     if (isProcessing) {
         return;
     }
-    if (messagesFromNative.length === 0) {
+    if (opt_useTimeout) {
+        window.setTimeout(androidExec.processMessages, 0);
         return;
     }
     isProcessing = true;
     try {
-        var msg = popMessageFromQueue();
-        // The Java side can send a * message to indicate that it
-        // still has messages waiting to be retrieved.
-        if (msg == '*' && messagesFromNative.length === 0) {
-            nextTick(pollOnce);
-            return;
+        // TODO: add setImmediate polyfill and process only one message at a time.
+        while (messagesFromNative.length) {
+            var msg = popMessageFromQueue();
+            // The Java side can send a * message to indicate that it
+            // still has messages waiting to be retrieved.
+            if (msg == '*' && messagesFromNative.length === 0) {
+                setTimeout(pollOnce, 0);
+                return;
+            }
+            processMessage(msg);
         }
-        processMessage(msg);
     } finally {
         isProcessing = false;
-        if (messagesFromNative.length > 0) {
-            nextTick(processMessages);
-        }
     }
-}
+};
 
 function popMessageFromQueue() {
     var messageBatch = messagesFromNative.shift();
@@ -1504,7 +1502,7 @@ exports.reset();
 
 });
 
-// file: node_modules/cordova-android/cordova-js-src/platform.js
+// file: src/android/platform.js
 define("cordova/platform", function(require, exports, module) {
 
 module.exports = {
@@ -1568,6 +1566,9 @@ function onMessageFromNative(msg) {
         // App life cycle events
         case 'pause':
         case 'resume':
+        // Keyboard events
+        case 'hidekeyboard':
+        case 'showkeyboard':
         // Volume events
         case 'volumedownbutton':
         case 'volumeupbutton':
@@ -1580,18 +1581,17 @@ function onMessageFromNative(msg) {
 
 });
 
-// file: node_modules/cordova-android/cordova-js-src/plugin/android/app.js
+// file: src/android/plugin/android/app.js
 define("cordova/plugin/android/app", function(require, exports, module) {
 
 var exec = require('cordova/exec');
-var APP_PLUGIN_NAME = Number(require('cordova').platformVersion.split('.')[0]) >= 4 ?
'CoreAndroid' : 'App';
 
 module.exports = {
     /**
     * Clear the resource cache.
     */
     clearCache:function() {
-        exec(null, null, APP_PLUGIN_NAME, "clearCache", []);
+        exec(null, null, "App", "clearCache", []);
     },
 
     /**
@@ -1609,14 +1609,14 @@ module.exports = {
     *      navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading
App", loadUrlTimeoutValue: 60000});
     */
     loadUrl:function(url, props) {
-        exec(null, null, APP_PLUGIN_NAME, "loadUrl", [url, props]);
+        exec(null, null, "App", "loadUrl", [url, props]);
     },
 
     /**
     * Cancel loadUrl that is waiting to be loaded.
     */
     cancelLoadUrl:function() {
-        exec(null, null, APP_PLUGIN_NAME, "cancelLoadUrl", []);
+        exec(null, null, "App", "cancelLoadUrl", []);
     },
 
     /**
@@ -1624,7 +1624,7 @@ module.exports = {
     * Instead of BACK button loading the previous web page, it will exit the app.
     */
     clearHistory:function() {
-        exec(null, null, APP_PLUGIN_NAME, "clearHistory", []);
+        exec(null, null, "App", "clearHistory", []);
     },
 
     /**
@@ -1632,7 +1632,7 @@ module.exports = {
     * This is the same as pressing the backbutton on Android device.
     */
     backHistory:function() {
-        exec(null, null, APP_PLUGIN_NAME, "backHistory", []);
+        exec(null, null, "App", "backHistory", []);
     },
 
     /**
@@ -1645,7 +1645,7 @@ module.exports = {
     * @param override        T=override, F=cancel override
     */
     overrideBackbutton:function(override) {
-        exec(null, null, APP_PLUGIN_NAME, "overrideBackbutton", [override]);
+        exec(null, null, "App", "overrideBackbutton", [override]);
     },
 
     /**
@@ -1660,14 +1660,14 @@ module.exports = {
     * @param override        T=override, F=cancel override
     */
     overrideButton:function(button, override) {
-        exec(null, null, APP_PLUGIN_NAME, "overrideButton", [button, override]);
+        exec(null, null, "App", "overrideButton", [button, override]);
     },
 
     /**
     * Exit and terminate the application.
     */
     exitApp:function() {
-        return exec(null, null, APP_PLUGIN_NAME, "exitApp", []);
+        return exec(null, null, "App", "exitApp", []);
     }
 };
 
@@ -1977,4 +1977,4 @@ window.cordova = require('cordova');
 
 require('cordova/init');
 
-})();
\ No newline at end of file
+})();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message