incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [8/11] js commit: override with our own device, accelerometer is working
Date Fri, 20 Jul 2012 22:56:18 GMT
override with our own device, accelerometer is working


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

Branch: refs/heads/master
Commit: ef2e5697607808cf75e829a5ebb5c94c599c9519
Parents: 0c45841
Author: Jesse <purplecabbage@gmail.com>
Authored: Wed Jul 18 03:51:28 2012 -0700
Committer: Jesse <purplecabbage@gmail.com>
Committed: Wed Jul 18 03:51:28 2012 -0700

----------------------------------------------------------------------
 lib/win8metro/exec.js     |   29 ++++++++++++++---------------
 lib/win8metro/platform.js |    9 +++++----
 2 files changed, 19 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ef2e5697/lib/win8metro/exec.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/exec.js b/lib/win8metro/exec.js
index 7e3ea1d..8af0c29 100644
--- a/lib/win8metro/exec.js
+++ b/lib/win8metro/exec.js
@@ -27,25 +27,23 @@ var cordova = require('cordova');
 
 var NativeProxy = {
     "Accelerometer": { 
-        onDataChanged:function(e){
-            var reading = e.reading;
-            // reading.accelerationX.toFixed(2);
-            // reading.accelerationY.toFixed(2);
-            // reading.accelerationZ.toFixed(2);
-        },       
+        onDataChanged:null,       
         start:function(win,lose){
-            console.log("Accelerometer.start");
+
             var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
             if(!accel) {
                 lose("No accelerometer found");
             }
             else {
                 var self = this;
+                accel.reportInterval = Math.max(12,accel.minimumReportInterval);
+
                 // store our bound function
-                this.onDataChanged.bound = function(e) {
-                    self.onDataChanged(e);
+                this.onDataChanged = function(e) {
+                    var a = e.reading;
+                    win(new Acceleration(a.accelerationX,a.accelerationY,a.accelerationZ));
                 }
-                accel.addEventListener("readingchanged",this.onDataChanged.bound);
+                accel.addEventListener("readingchanged",this.onDataChanged);
             }
         },
         stop:function(win,lose){
@@ -55,10 +53,9 @@ var NativeProxy = {
                 lose("No accelerometer found");
             }
             else {
-                if(this.onDataChanged.bound) {
-                    accel.removeEventListener("readingchanged",this.onDataChanged.bound);
-                }
-                this.onDataChanged.bound = null;
+                accel.removeEventListener("readingchanged",this.onDataChanged);
+                this.onDataChanged = null;
+                accel.reportInterval = 0; // back to the default
             }
         }
     },
@@ -164,7 +161,7 @@ var NativeProxy = {
         getDeviceInfo:function(win,fail,args){
             console.log("NativeProxy::getDeviceInfo");
             setTimeout(function(){
-                win({platform:"win8metro", version:"0.1", name:"hmm", uuid:"42", cordova:"12"});
+                win({platform:"win8metro", version:"8", name:"metrova", uuid:"42", cordova:"2.0.1"});
             },0);
         }
     },
@@ -179,6 +176,7 @@ var NativeProxy = {
             var networkEncryptionInfo = winNetConn.NetworkEncryptionType;
 
             var profile = Windows.Networking.Connectivity.NetworkInformation.getInternetConnectionProfile();
+            if(profile) {
             var conLevel = profile.getNetworkConnectivityLevel();
 
             switch (conLevel) {
@@ -191,6 +189,7 @@ var NativeProxy = {
                 case Windows.Networking.Connectivity.NetworkConnectivityLevel.constrainedInternetAccess:
                     break;
             }
+        }
 
 
             // FYI

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ef2e5697/lib/win8metro/platform.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/platform.js b/lib/win8metro/platform.js
index 0516801..768e9bb 100644
--- a/lib/win8metro/platform.js
+++ b/lib/win8metro/platform.js
@@ -28,7 +28,7 @@ module.exports = {
         navigator: {
             children: {
                 device: {
-                    path: "cordova/plugin/device",
+                    path:"cordova/plugin/win8metro/device",
                     children:{
                         capture:{
                             path:"cordova/plugin/capture"
@@ -40,10 +40,11 @@ module.exports = {
 
                 }
             }
-        },
-        device:{
-          path:"cordova/plugin/win8metro/device"
         }
+        //,
+        // device:{
+        //   path:"cordova/plugin/win8metro/device"
+        // }
         // ,
         // console:{
         //   path: "cordova/plugin/win8metro/console"


Mime
View raw message