cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [22/26] js commit: CB-8210 android: Add message channel for events (closes #96)
Date Wed, 07 Jan 2015 01:27:21 GMT
CB-8210 android: Add message channel for events (closes #96)

- Initialize a message channel for native -> Javascript via the core App plugin
- Use channel to receive events from native to be fired in Javascript
- Keyboard detection events implemented via this new channel


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

Branch: refs/heads/3.7.x
Commit: 36bb1f19619ff2bf1fe9eea474583cd53900b6f2
Parents: 75a5420
Author: Jason Chase <jasonpchase@gmail.com>
Authored: Wed Dec 24 12:25:30 2014 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Dec 30 22:01:59 2014 -0500

----------------------------------------------------------------------
 src/android/platform.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/36bb1f19/src/android/platform.js
----------------------------------------------------------------------
diff --git a/src/android/platform.js b/src/android/platform.js
index 4d613c3..d11daba 100644
--- a/src/android/platform.js
+++ b/src/android/platform.js
@@ -59,7 +59,23 @@ module.exports = {
         // Let native code know we are all done on the JS side.
         // Native code will then un-hide the WebView.
         channel.onCordovaReady.subscribe(function() {
+            exec(onMessageFromNative, null, 'App', 'messageChannel', []);
             exec(null, null, "App", "show", []);
         });
     }
 };
+
+function onMessageFromNative(msg) {
+    var cordova = require('cordova');
+    var action = msg.action;
+
+    switch (action)
+    {
+        case 'hidekeyboard':
+        case 'showkeyboard':
+            cordova.fireDocumentEvent(action);
+            break;
+        default:
+            throw new Error('Unknown event action ' + action);
+    }
+}


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


Mime
View raw message