You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by je...@apache.org on 2013/08/21 20:24:32 UTC

git commit: [CB-3687] Added compass plugin support for blackberry10

Updated Branches:
  refs/heads/dev 6f408923a -> 79b0908ac


[CB-3687] Added compass plugin support for blackberry10


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/commit/79b0908a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/tree/79b0908a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/diff/79b0908a

Branch: refs/heads/dev
Commit: 79b0908ac595f6c776ed9b8bbe71b70c8f854977
Parents: 6f40892
Author: Kristoffer Flores <kf...@blackberry.com>
Authored: Fri Aug 16 12:13:55 2013 -0400
Committer: Jeffrey Heifetz <jh...@blackberry.com>
Committed: Wed Aug 21 14:08:05 2013 -0400

----------------------------------------------------------------------
 plugin.xml                 | 24 ++++++++++++++++--------
 src/blackberry10/README.md | 25 -------------------------
 src/blackberry10/index.js  | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/blob/79b0908a/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 3cfee54..a40be82 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -4,7 +4,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     id="org.apache.cordova.core.device-orientation"
     version="0.2.0">
-    
+
     <name>Device Orientation</name>
     <description>Cordova Device Orientation Plugin</description>
     <license>Apache 2.0</license>
@@ -17,7 +17,7 @@
     <js-module src="www/CompassHeading.js" name="CompassHeading">
         <clobbers target="CompassHeading" />
     </js-module>
-    
+
     <js-module src="www/compass.js" name="compass">
         <clobbers target="navigator.compass" />
     </js-module>
@@ -29,7 +29,7 @@
 	            <param name="android-package" value="org.apache.cordova.deviceorientation.CompassListener"/>
 	        </feature>
 	    </config-file>
-	
+
 	    <config-file target="AndroidManifest.xml" parent="/*">
 	        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
             <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
@@ -37,19 +37,27 @@
 
 	    <source-file src="src/android/CompassListener.java" target-dir="src/org/apache/cordova/deviceorientation" />
     </platform>
-    
+
+    <!-- blackberry10 -->
+    <platform name="blackberry10">
+        <config-file target="www/config.xml" parent="/widget">
+            <feature name="Compass" value="Compass" />
+        </config-file>
+        <source-file src="src/blackberry10/index.js" target-dir="Compass" />
+    </platform>
+
     <!-- ios -->
     <platform name="ios">
-        
+
         <config-file target="config.xml" parent="/*">
 	        <feature name="Compass">
 	            <param name="ios-package" value="CDVCompass"/>
 	        </feature>
         </config-file>
-        
+
 	    <header-file src="src/ios/CDVCompass.h" />
 	    <source-file src="src/ios/CDVCompass.m" />
-        
+
     </platform>
 
     <!-- wp7 -->
@@ -88,5 +96,5 @@
             <merges target="" />
         </js-module>
     </platform>
-    
+
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/blob/79b0908a/src/blackberry10/README.md
----------------------------------------------------------------------
diff --git a/src/blackberry10/README.md b/src/blackberry10/README.md
deleted file mode 100644
index 2039d3c..0000000
--- a/src/blackberry10/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# BlackBerry 10 Device Orientation Plugin
-
-Cordova Device Orientation Plugin (compass) functionality is entirely contained within common js and the BB10 js runtime. There is no native implementation required.
-To install this plugin, follow the [Command-line Interface Guide](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface).
-
-If you are not using the Cordova Command-line Interface, follow [Using Plugman to Manage Plugins](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html).
-./cordova-plugin-battery-status/README.md
-./cordova-plugin-camera/README.md
-./cordova-plugin-console/README.md
-./cordova-plugin-contacts/README.md
-./cordova-plugin-device/README.md
-./cordova-plugin-device-motion/README.md
-./cordova-plugin-device-orientation/README.md
-./cordova-plugin-device-orientation/src/blackberry10/README.md
-./cordova-plugin-file/README.md
-./cordova-plugin-file-transfer/README.md
-./cordova-plugin-geolocation/README.md
-./cordova-plugin-globalization/README.md
-./cordova-plugin-inappbrowser/README.md
-./cordova-plugin-inappbrowser/src/blackberry10/README.md
-./cordova-plugin-media/README.md
-./cordova-plugin-media-capture/README.md
-./cordova-plugin-network-information/README.md
-./cordova-plugin-splashscreen/README.md
-./cordova-plugin-vibration/README.md

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/blob/79b0908a/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
new file mode 100644
index 0000000..e3f0f94
--- /dev/null
+++ b/src/blackberry10/index.js
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2013 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports = {
+    getHeading: function (success, fail, args, env) {
+        var result = new PluginResult(args, env),
+            callback = function (orientation) {
+                var info = {
+                    magneticHeading: orientation.alpha,
+                    trueHeading: 360-orientation.alpha,
+                    headingAccuracy: 360-(2*orientation.alpha),
+                    timestamp: new Date().getTime
+                };
+                window.removeEventListener("deviceorientation", callback);
+                result.callbackOk(info, false);
+            };
+        window.addEventListener("deviceorientation", callback);
+        result.noResult(true);
+    }
+};