Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/jokio/jok-pitching.git

  • Loading branch information...
commit bfef8b40327304e69c8f8f12cae62f0fb2a3f15c 2 parents 856150c + a036f68
@playerx playerx authored
Showing with 2,862 additions and 8 deletions.
  1. +1 −1  Mobile/config.xml
  2. +24 −1 Mobile/platforms/ios/.staging/www/cordova_plugins.js
  3. +22 −0 Mobile/platforms/ios/.staging/www/plugins/gamecenter/www/gamecenter.js
  4. +31 −0 Mobile/platforms/ios/.staging/www/plugins/org.apache.cordova.device-motion/www/Acceleration.js
  5. +171 −0 Mobile/platforms/ios/.staging/www/plugins/org.apache.cordova.device-motion/www/accelerometer.js
  6. +25 −2 Mobile/platforms/ios/Pitching.xcodeproj/project.pbxproj
  7. BIN  ...atforms/ios/Pitching.xcodeproj/project.xcworkspace/xcuserdata/ez.xcuserdatad/UserInterfaceState.xcuserstate
  8. BIN  Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default-568h@2x~iphone.png
  9. BIN  Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default-Landscape@2x~ipad.png
  10. BIN  Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default-Landscape~ipad.png
  11. BIN  Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default@2x~iphone.png
  12. BIN  Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default~iphone.png
  13. +5 −1 Mobile/platforms/ios/Pitching/Pitching-Info.plist
  14. +17 −0 Mobile/platforms/ios/Pitching/Plugins/gamecenter/GameCenter.h
  15. +140 −0 Mobile/platforms/ios/Pitching/Plugins/gamecenter/GameCenter.m
  16. +39 −0 Mobile/platforms/ios/Pitching/Plugins/org.apache.cordova.device-motion/CDVAccelerometer.h
  17. +138 −0 Mobile/platforms/ios/Pitching/Plugins/org.apache.cordova.device-motion/CDVAccelerometer.m
  18. +7 −1 Mobile/platforms/ios/Pitching/config.xml
  19. +24 −1 Mobile/platforms/ios/www/cordova_plugins.js
  20. +22 −0 Mobile/platforms/ios/www/plugins/gamecenter/www/gamecenter.js
  21. +31 −0 Mobile/platforms/ios/www/plugins/org.apache.cordova.device-motion/www/Acceleration.js
  22. +171 −0 Mobile/platforms/ios/www/plugins/org.apache.cordova.device-motion/www/accelerometer.js
  23. +1 −0  Mobile/plugins/gamecenter/.fetch.json
  24. +61 −0 Mobile/plugins/gamecenter/README.md
  25. +23 −0 Mobile/plugins/gamecenter/plugin.xml
  26. +17 −0 Mobile/plugins/gamecenter/src/ios/GameCenter.h
  27. +140 −0 Mobile/plugins/gamecenter/src/ios/GameCenter.m
  28. +20 −0 Mobile/plugins/gamecenter/www/gamecenter.js
  29. +1 −1  Mobile/plugins/ios.json
  30. +1 −0  Mobile/plugins/org.apache.cordova.device-motion/.fetch.json
  31. +202 −0 Mobile/plugins/org.apache.cordova.device-motion/LICENSE
  32. +22 −0 Mobile/plugins/org.apache.cordova.device-motion/README.md
  33. +57 −0 Mobile/plugins/org.apache.cordova.device-motion/RELEASENOTES.md
  34. +156 −0 Mobile/plugins/org.apache.cordova.device-motion/doc/index.md
  35. +15 −0 Mobile/plugins/org.apache.cordova.device-motion/package.json
  36. +133 −0 Mobile/plugins/org.apache.cordova.device-motion/plugin.xml
  37. +295 −0 Mobile/plugins/org.apache.cordova.device-motion/src/android/AccelListener.java
  38. +45 −0 Mobile/plugins/org.apache.cordova.device-motion/src/blackberry10/index.js
  39. +21 −0 Mobile/plugins/org.apache.cordova.device-motion/src/firefoxos/accelerometer.js
  40. +39 −0 Mobile/plugins/org.apache.cordova.device-motion/src/ios/CDVAccelerometer.h
  41. +138 −0 Mobile/plugins/org.apache.cordova.device-motion/src/ios/CDVAccelerometer.m
  42. +30 −0 Mobile/plugins/org.apache.cordova.device-motion/src/tizen/AccelerometerProxy.js
  43. +58 −0 Mobile/plugins/org.apache.cordova.device-motion/src/ubuntu/accelerometer.cpp
  44. +55 −0 Mobile/plugins/org.apache.cordova.device-motion/src/ubuntu/accelerometer.h
  45. +70 −0 Mobile/plugins/org.apache.cordova.device-motion/src/windows8/AccelerometerProxy.js
  46. +196 −0 Mobile/plugins/org.apache.cordova.device-motion/src/wp/Accelerometer.cs
  47. +29 −0 Mobile/plugins/org.apache.cordova.device-motion/www/Acceleration.js
  48. +169 −0 Mobile/plugins/org.apache.cordova.device-motion/www/accelerometer.js
View
2  Mobile/config.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<widget id="io.jok.pitching" version="0.1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+<widget id="io.jok.pitching" version="1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Pitching</name>
View
25 Mobile/platforms/ios/.staging/www/cordova_plugins.js
@@ -41,6 +41,27 @@ module.exports = [
"clobbers": [
"window.Media"
]
+ },
+ {
+ "file": "plugins/org.apache.cordova.device-motion/www/Acceleration.js",
+ "id": "org.apache.cordova.device-motion.Acceleration",
+ "clobbers": [
+ "Acceleration"
+ ]
+ },
+ {
+ "file": "plugins/org.apache.cordova.device-motion/www/accelerometer.js",
+ "id": "org.apache.cordova.device-motion.accelerometer",
+ "clobbers": [
+ "navigator.accelerometer"
+ ]
+ },
+ {
+ "file": "plugins/gamecenter/www/gamecenter.js",
+ "id": "gamecenter.GameCenter",
+ "clobbers": [
+ "gamecenter"
+ ]
}
];
module.exports.metadata =
@@ -51,7 +72,9 @@ module.exports.metadata =
"org.apache.cordova.inappbrowser": "0.3.1",
"org.apache.cordova.vibration": "0.3.7",
"com.phonegap.plugins.jokutils": "0.1.0",
- "org.apache.cordova.media": "0.2.8"
+ "org.apache.cordova.media": "0.2.8",
+ "org.apache.cordova.device-motion": "0.2.6",
+ "gamecenter": "0.2.3"
}
// BOTTOM OF METADATA
});
View
22 Mobile/platforms/ios/.staging/www/plugins/gamecenter/www/gamecenter.js
@@ -0,0 +1,22 @@
+cordova.define("gamecenter.GameCenter", function(require, exports, module) {
+var exec = require("cordova/exec");
+
+var GameCenter = function () {
+ this.name = "GameCenter";
+};
+
+GameCenter.prototype.auth = function (success, failure) {
+ exec(success, failure, "GameCenter", "auth", []);
+};
+
+GameCenter.prototype.submitScore = function (success, failure, data) {
+ exec(success, failure, "GameCenter", "submitScore", [data]);
+};
+
+GameCenter.prototype.showLeaderboard = function (success, failure, data) {
+ exec(success, failure, "GameCenter", "showLeaderboard", [data]);
+};
+
+module.exports = new GameCenter();
+
+});
View
31 Mobile/platforms/ios/.staging/www/plugins/org.apache.cordova.device-motion/www/Acceleration.js
@@ -0,0 +1,31 @@
+cordova.define("org.apache.cordova.device-motion.Acceleration", function(require, exports, module) { /*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+*/
+
+var Acceleration = function(x, y, z, timestamp) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.timestamp = timestamp || (new Date()).getTime();
+};
+
+module.exports = Acceleration;
+
+});
View
171 Mobile/platforms/ios/.staging/www/plugins/org.apache.cordova.device-motion/www/accelerometer.js
@@ -0,0 +1,171 @@
+cordova.define("org.apache.cordova.device-motion.accelerometer", function(require, exports, module) { /*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+*/
+
+/**
+ * This class provides access to device accelerometer data.
+ * @constructor
+ */
+var argscheck = require('cordova/argscheck'),
+ utils = require("cordova/utils"),
+ exec = require("cordova/exec"),
+ Acceleration = require('./Acceleration');
+
+// Is the accel sensor running?
+var running = false;
+
+// Keeps reference to watchAcceleration calls.
+var timers = {};
+
+// Array of listeners; used to keep track of when we should call start and stop.
+var listeners = [];
+
+// Last returned acceleration object from native
+var accel = null;
+
+// Tells native to start.
+function start() {
+ exec(function(a) {
+ var tempListeners = listeners.slice(0);
+ accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
+ for (var i = 0, l = tempListeners.length; i < l; i++) {
+ tempListeners[i].win(accel);
+ }
+ }, function(e) {
+ var tempListeners = listeners.slice(0);
+ for (var i = 0, l = tempListeners.length; i < l; i++) {
+ tempListeners[i].fail(e);
+ }
+ }, "Accelerometer", "start", []);
+ running = true;
+}
+
+// Tells native to stop.
+function stop() {
+ exec(null, null, "Accelerometer", "stop", []);
+ running = false;
+}
+
+// Adds a callback pair to the listeners array
+function createCallbackPair(win, fail) {
+ return {win:win, fail:fail};
+}
+
+// Removes a win/fail listener pair from the listeners array
+function removeListeners(l) {
+ var idx = listeners.indexOf(l);
+ if (idx > -1) {
+ listeners.splice(idx, 1);
+ if (listeners.length === 0) {
+ stop();
+ }
+ }
+}
+
+var accelerometer = {
+ /**
+ * Asynchronously acquires the current acceleration.
+ *
+ * @param {Function} successCallback The function to call when the acceleration data is available
+ * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
+ * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
+ */
+ getCurrentAcceleration: function(successCallback, errorCallback, options) {
+ argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);
+
+ var p;
+ var win = function(a) {
+ removeListeners(p);
+ successCallback(a);
+ };
+ var fail = function(e) {
+ removeListeners(p);
+ errorCallback && errorCallback(e);
+ };
+
+ p = createCallbackPair(win, fail);
+ listeners.push(p);
+
+ if (!running) {
+ start();
+ }
+ },
+
+ /**
+ * Asynchronously acquires the acceleration repeatedly at a given interval.
+ *
+ * @param {Function} successCallback The function to call each time the acceleration data is available
+ * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
+ * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
+ * @return String The watch id that must be passed to #clearWatch to stop watching.
+ */
+ watchAcceleration: function(successCallback, errorCallback, options) {
+ argscheck.checkArgs('fFO', 'accelerometer.watchAcceleration', arguments);
+ // Default interval (10 sec)
+ var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
+
+ // Keep reference to watch id, and report accel readings as often as defined in frequency
+ var id = utils.createUUID();
+
+ var p = createCallbackPair(function(){}, function(e) {
+ removeListeners(p);
+ errorCallback && errorCallback(e);
+ });
+ listeners.push(p);
+
+ timers[id] = {
+ timer:window.setInterval(function() {
+ if (accel) {
+ successCallback(accel);
+ }
+ }, frequency),
+ listeners:p
+ };
+
+ if (running) {
+ // If we're already running then immediately invoke the success callback
+ // but only if we have retrieved a value, sample code does not check for null ...
+ if (accel) {
+ successCallback(accel);
+ }
+ } else {
+ start();
+ }
+
+ return id;
+ },
+
+ /**
+ * Clears the specified accelerometer watch.
+ *
+ * @param {String} id The id of the watch returned from #watchAcceleration.
+ */
+ clearWatch: function(id) {
+ // Stop javascript timer & remove from timer list
+ if (id && timers[id]) {
+ window.clearInterval(timers[id].timer);
+ removeListeners(timers[id].listeners);
+ delete timers[id];
+ }
+ }
+};
+module.exports = accelerometer;
+
+});
View
27 Mobile/platforms/ios/Pitching.xcodeproj/project.pbxproj
@@ -11,6 +11,7 @@
1D3623260D0F684500981E51 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* AppDelegate.m */; };
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
1F766FE113BBADB100FB74C0 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1F766FDC13BBADB100FB74C0 /* Localizable.strings */; };
+ 277CF33318BE736000610299 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1359B36CB1244CAB8065793D /* GameKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
27D9B53418BD0622005B9455 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 27D9B53318BD0622005B9455 /* Images.xcassets */; };
27D9B53718BD06F3005B9455 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D9B53618BD06F3005B9455 /* AVFoundation.framework */; };
27D9B53918BD07A2005B9455 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D9B53818BD07A2005B9455 /* MediaPlayer.framework */; };
@@ -46,9 +47,12 @@
7E7966E71810823500FA85AD /* icon-small@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7E7966DD1810823500FA85AD /* icon-small@2x.png */; };
8B4D213D204A4827944A6025 /* CDVJokUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D83BD41A2244D4FB5AC300C /* CDVJokUtils.m */; };
A1612FEFF60C46EE938731E3 /* CDVDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = F5228BD34417438DA5445A6F /* CDVDevice.m */; };
+ C3339A006671402EAE3BD421 /* GameCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A940C2294354773A7A484EC /* GameCenter.m */; };
+ CED15D7B66CB4EA497F931C0 /* CDVAccelerometer.m in Sources */ = {isa = PBXBuildFile; fileRef = F72DAAFE349147E19A4B0308 /* CDVAccelerometer.m */; };
D4A0D8761607E02300AEF8BB /* Default-568h@2x~iphone.png in Resources */ = {isa = PBXBuildFile; fileRef = D4A0D8751607E02300AEF8BB /* Default-568h@2x~iphone.png */; };
D57D1EC11CAC45D3B7714FEA /* CDVNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F63DA9BC7424E01938AC80C /* CDVNotification.m */; };
D581DC6A958341A69F98448E /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 507F2F98A3DC452986EC1572 /* AudioToolbox.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
+ F53F3C2E58724DBE92AFACDE /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B93AC7FA0F494F988968F254 /* CoreMotion.framework */; };
F9F5B2D0226B4365843BC6C5 /* CDVSound.m in Sources */ = {isa = PBXBuildFile; fileRef = B4EFD945C99247F3B433F791 /* CDVSound.m */; };
/* End PBXBuildFile section */
@@ -71,6 +75,7 @@
/* Begin PBXFileReference section */
0FBA6FC538384B8085AD0BBA /* CDVNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVNotification.h; path = org.apache.cordova.dialogs/CDVNotification.h; sourceTree = "<group>"; };
+ 1359B36CB1244CAB8065793D /* GameKit.framework */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };
1D3623240D0F684500981E51 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
1D3623250D0F684500981E51 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
1D6058910D05DD3D006BFB54 /* Pitching.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pitching.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -78,6 +83,7 @@
1F766FDD13BBADB100FB74C0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Localizable.strings; sourceTree = "<group>"; };
1F766FE013BBADB100FB74C0 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = Localizable.strings; sourceTree = "<group>"; };
254834491F2D46BF994B8C07 /* CDVNotification.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = CDVNotification.bundle; sourceTree = "<group>"; };
+ 26C498F4BE3B46689E7A7F70 /* CDVAccelerometer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVAccelerometer.h; path = "org.apache.cordova.device-motion/CDVAccelerometer.h"; sourceTree = "<group>"; };
27D9B53318BD0622005B9455 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = Pitching/Images.xcassets; sourceTree = SOURCE_ROOT; };
27D9B53618BD06F3005B9455 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
27D9B53818BD07A2005B9455 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
@@ -107,6 +113,8 @@
51A3FF2E788241E0AF314E47 /* CDVVibration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVVibration.m; path = org.apache.cordova.vibration/CDVVibration.m; sourceTree = "<group>"; };
5AEE5B34173C68D80009041E /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
5B1594DC16A7569C00FEF299 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
+ 6515DF323A2A42018AF81EFF /* GameCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GameCenter.h; path = gamecenter/GameCenter.h; sourceTree = "<group>"; };
+ 6A940C2294354773A7A484EC /* GameCenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GameCenter.m; path = gamecenter/GameCenter.m; sourceTree = "<group>"; };
7D53E715800243BCAB1C55D4 /* CDVInAppBrowser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVInAppBrowser.h; path = org.apache.cordova.inappbrowser/CDVInAppBrowser.h; sourceTree = "<group>"; };
7E7966D41810823500FA85AD /* icon-40.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-40.png"; sourceTree = "<group>"; };
7E7966D51810823500FA85AD /* icon-40@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-40@2x.png"; sourceTree = "<group>"; };
@@ -123,6 +131,7 @@
900710A7FDA04B88A7EF69E7 /* CDVDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVDevice.h; path = org.apache.cordova.device/CDVDevice.h; sourceTree = "<group>"; };
9D83BD41A2244D4FB5AC300C /* CDVJokUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVJokUtils.m; path = com.phonegap.plugins.jokutils/CDVJokUtils.m; sourceTree = "<group>"; };
B4EFD945C99247F3B433F791 /* CDVSound.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSound.m; path = org.apache.cordova.media/CDVSound.m; sourceTree = "<group>"; };
+ B93AC7FA0F494F988968F254 /* CoreMotion.framework */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
D4A0D8751607E02300AEF8BB /* Default-568h@2x~iphone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x~iphone.png"; sourceTree = "<group>"; };
E22BF64466FE4BBBB978770E /* CDVSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSound.h; path = org.apache.cordova.media/CDVSound.h; sourceTree = "<group>"; };
EB87FDF21871DA7A0020F90C /* merges */ = {isa = PBXFileReference; lastKnownFileType = folder; name = merges; path = ../../merges; sourceTree = "<group>"; };
@@ -130,6 +139,7 @@
EB87FDF41871DAF40020F90C /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = ../../config.xml; sourceTree = "<group>"; };
EFB57FDA910F479398941482 /* CDVJokUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVJokUtils.h; path = com.phonegap.plugins.jokutils/CDVJokUtils.h; sourceTree = "<group>"; };
F5228BD34417438DA5445A6F /* CDVDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVDevice.m; path = org.apache.cordova.device/CDVDevice.m; sourceTree = "<group>"; };
+ F72DAAFE349147E19A4B0308 /* CDVAccelerometer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVAccelerometer.m; path = "org.apache.cordova.device-motion/CDVAccelerometer.m"; sourceTree = "<group>"; };
F840E1F0165FE0F500CFE078 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = Pitching/config.xml; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -138,6 +148,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 277CF33318BE736000610299 /* GameKit.framework in Frameworks */,
27D9B53918BD07A2005B9455 /* MediaPlayer.framework in Frameworks */,
D581DC6A958341A69F98448E /* AudioToolbox.framework in Frameworks */,
27D9B53718BD06F3005B9455 /* AVFoundation.framework in Frameworks */,
@@ -146,6 +157,7 @@
288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */,
305D5FD1115AB8F900A74A75 /* MobileCoreServices.framework in Frameworks */,
5AEE5B35173C68D80009041E /* CoreLocation.framework in Frameworks */,
+ F53F3C2E58724DBE92AFACDE /* CoreMotion.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -244,6 +256,8 @@
288765FC0DF74451002DB57D /* CoreGraphics.framework */,
305D5FD0115AB8F900A74A75 /* MobileCoreServices.framework */,
507F2F98A3DC452986EC1572 /* AudioToolbox.framework */,
+ B93AC7FA0F494F988968F254 /* CoreMotion.framework */,
+ 1359B36CB1244CAB8065793D /* GameKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -271,6 +285,10 @@
EFB57FDA910F479398941482 /* CDVJokUtils.h */,
B4EFD945C99247F3B433F791 /* CDVSound.m */,
E22BF64466FE4BBBB978770E /* CDVSound.h */,
+ F72DAAFE349147E19A4B0308 /* CDVAccelerometer.m */,
+ 26C498F4BE3B46689E7A7F70 /* CDVAccelerometer.h */,
+ 6A940C2294354773A7A484EC /* GameCenter.m */,
+ 6515DF323A2A42018AF81EFF /* GameCenter.h */,
);
name = Plugins;
path = Pitching/Plugins;
@@ -365,6 +383,11 @@
isa = PBXProject;
attributes = {
LastUpgradeCheck = 500;
+ TargetAttributes = {
+ 1D6058900D05DD3D006BFB54 = {
+ DevelopmentTeam = T37ZNSJLEK;
+ };
+ };
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Pitching" */;
compatibilityVersion = "Xcode 3.2";
@@ -473,6 +496,8 @@
755383D60B9547579784DE90 /* CDVVibration.m in Sources */,
8B4D213D204A4827944A6025 /* CDVJokUtils.m in Sources */,
F9F5B2D0226B4365843BC6C5 /* CDVSound.m in Sources */,
+ CED15D7B66CB4EA497F931C0 /* CDVAccelerometer.m in Sources */,
+ C3339A006671402EAE3BD421 /* GameCenter.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -527,7 +552,6 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
@@ -562,7 +586,6 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
View
BIN  ...orms/ios/Pitching.xcodeproj/project.xcworkspace/xcuserdata/ez.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown
View
BIN  Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default-568h@2x~iphone.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default-Landscape@2x~ipad.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default-Landscape~ipad.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default@2x~iphone.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Mobile/platforms/ios/Pitching/Images.xcassets/LaunchImage.launchimage/Default~iphone.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
6 Mobile/platforms/ios/Pitching/Pitching-Info.plist
@@ -23,7 +23,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>0.1.0</string>
+ <string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
@@ -32,6 +32,10 @@
<true/>
<key>NSMainNibFile</key>
<string></string>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>gamekit</string>
+ </array>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
View
17 Mobile/platforms/ios/Pitching/Plugins/gamecenter/GameCenter.h
@@ -0,0 +1,17 @@
+//
+// GameCenter.h
+// Copyright (c) 2013 Lee Crossley - http://ilee.co.uk
+//
+
+#import "Foundation/Foundation.h"
+#import "Cordova/CDV.h"
+#import "GameCenter.h"
+#import "GameKit/GameKit.h"
+
+@interface GameCenter : CDVPlugin <GKGameCenterControllerDelegate>
+
+- (void) auth:(CDVInvokedUrlCommand*)command;
+- (void) submitScore:(CDVInvokedUrlCommand*)command;
+- (void) showLeaderboard:(CDVInvokedUrlCommand*)command;
+
+@end
View
140 Mobile/platforms/ios/Pitching/Plugins/gamecenter/GameCenter.m
@@ -0,0 +1,140 @@
+//
+// GameCenter.m
+// Copyright (c) 2013 Lee Crossley - http://ilee.co.uk
+//
+
+#import "Cordova/CDV.h"
+#import "Cordova/CDVViewController.h"
+#import "GameCenter.h"
+
+@implementation GameCenter
+
+- (void) auth:(CDVInvokedUrlCommand*)command;
+{
+ // __weak to avoid retain cycle
+ __weak GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
+
+ localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) {
+ CDVPluginResult* pluginResult = nil;
+ if (viewController != nil)
+ {
+ // Login required
+ [self.viewController presentViewController:viewController animated:YES completion:nil];
+ }
+ else
+ {
+ if (localPlayer.isAuthenticated)
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ }
+ else if (error != nil)
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]];
+ }
+ else
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
+ }
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ }
+ };
+}
+
+- (void) submitScore:(CDVInvokedUrlCommand*)command;
+{
+ NSMutableDictionary *args = [command.arguments objectAtIndex:0];
+ int64_t score = [[args objectForKey:@"score"] integerValue];
+ NSString *leaderboardId = [args objectForKey:@"leaderboardId"];
+
+ __block CDVPluginResult* pluginResult = nil;
+
+ // Different methods depending on iOS version
+ if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
+ {
+ GKScore *scoreSubmitter = [[GKScore alloc] initWithLeaderboardIdentifier: leaderboardId];
+ scoreSubmitter.value = score;
+ scoreSubmitter.context = 0;
+
+ [GKScore reportScores:@[scoreSubmitter] withCompletionHandler:^(NSError *error) {
+ if (error)
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]];
+ }
+ else
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ }
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ }];
+ }
+ else
+ {
+ GKScore *scoreSubmitter = [[GKScore alloc] initWithCategory:leaderboardId];
+ scoreSubmitter.value = score;
+
+ [scoreSubmitter reportScoreWithCompletionHandler:^(NSError *error) {
+ if (error)
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]];
+ }
+ else
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ }
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ }];
+ }
+}
+
+- (void) showLeaderboard:(CDVInvokedUrlCommand*)command;
+{
+ NSMutableDictionary *args = [command.arguments objectAtIndex:0];
+ NSString *leaderboardId = [args objectForKey:@"leaderboardId"];
+ NSString *period = [args objectForKey:@"period"];
+
+ CDVPluginResult* pluginResult = nil;
+
+ GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
+ if (gameCenterController != nil)
+ {
+ if ([period isEqualToString:@"today"])
+ {
+ gameCenterController.leaderboardTimeScope = GKLeaderboardTimeScopeToday;
+ }
+ else if ([period isEqualToString:@"week"])
+ {
+ gameCenterController.leaderboardTimeScope = GKLeaderboardTimeScopeWeek;
+ }
+ else
+ {
+ gameCenterController.leaderboardTimeScope = GKLeaderboardTimeScopeAllTime;
+ }
+
+ gameCenterController.gameCenterDelegate = self;
+
+ if (leaderboardId.length > 0)
+ {
+ gameCenterController.leaderboardCategory = leaderboardId;
+ gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
+ }
+ else
+ {
+ gameCenterController.viewState = GKGameCenterViewControllerStateDefault;
+ }
+
+ [self.viewController presentViewController:gameCenterController animated:YES completion:nil];
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ }
+ else
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
+ }
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+}
+
+- (void) gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController
+{
+ [gameCenterViewController dismissViewControllerAnimated:YES completion:nil];
+}
+
+@end
View
39 Mobile/platforms/ios/Pitching/Plugins/org.apache.cordova.device-motion/CDVAccelerometer.h
@@ -0,0 +1,39 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+ */
+
+#import <UIKit/UIKit.h>
+#import <Cordova/CDVPlugin.h>
+
+@interface CDVAccelerometer : CDVPlugin
+{
+ double x;
+ double y;
+ double z;
+ NSTimeInterval timestamp;
+}
+
+@property (readonly, assign) BOOL isRunning;
+@property (nonatomic, strong) NSString* callbackId;
+
+- (CDVAccelerometer*)init;
+
+- (void)start:(CDVInvokedUrlCommand*)command;
+- (void)stop:(CDVInvokedUrlCommand*)command;
+
+@end
View
138 Mobile/platforms/ios/Pitching/Plugins/org.apache.cordova.device-motion/CDVAccelerometer.m
@@ -0,0 +1,138 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+ */
+
+#import <CoreMotion/CoreMotion.h>
+#import "CDVAccelerometer.h"
+
+@interface CDVAccelerometer () {}
+@property (readwrite, assign) BOOL isRunning;
+@property (readwrite, assign) BOOL haveReturnedResult;
+@property (readwrite, strong) CMMotionManager* motionManager;
+@end
+
+@implementation CDVAccelerometer
+
+@synthesize callbackId, isRunning;
+
+// defaults to 10 msec
+#define kAccelerometerInterval 10
+// g constant: -9.81 m/s^2
+#define kGravitationalConstant -9.81
+
+- (CDVAccelerometer*)init
+{
+ self = [super init];
+ if (self) {
+ x = 0;
+ y = 0;
+ z = 0;
+ timestamp = 0;
+ self.callbackId = nil;
+ self.isRunning = NO;
+ self.haveReturnedResult = YES;
+ self.motionManager = nil;
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [self stop:nil];
+}
+
+- (void)start:(CDVInvokedUrlCommand*)command
+{
+ self.haveReturnedResult = NO;
+ self.callbackId = command.callbackId;
+
+ if (!self.motionManager)
+ {
+ self.motionManager = [[CMMotionManager alloc] init];
+ }
+
+ if ([self.motionManager isAccelerometerAvailable] == YES) {
+ // Assign the update interval to the motion manager and start updates
+ [self.motionManager setAccelerometerUpdateInterval:kAccelerometerInterval/1000]; // expected in seconds
+ __weak CDVAccelerometer* weakSelf = self;
+ [self.motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
+ x = accelerometerData.acceleration.x;
+ y = accelerometerData.acceleration.y;
+ z = accelerometerData.acceleration.z;
+ timestamp = ([[NSDate date] timeIntervalSince1970] * 1000);
+ [weakSelf returnAccelInfo];
+ }];
+
+ if (!self.isRunning) {
+ self.isRunning = YES;
+ }
+ }
+
+}
+
+- (void)onReset
+{
+ [self stop:nil];
+}
+
+- (void)stop:(CDVInvokedUrlCommand*)command
+{
+ if ([self.motionManager isAccelerometerAvailable] == YES) {
+ if (self.haveReturnedResult == NO){
+ // block has not fired before stop was called, return whatever result we currently have
+ [self returnAccelInfo];
+ }
+ [self.motionManager stopAccelerometerUpdates];
+ }
+ self.isRunning = NO;
+}
+
+- (void)returnAccelInfo
+{
+ // Create an acceleration object
+ NSMutableDictionary* accelProps = [NSMutableDictionary dictionaryWithCapacity:4];
+
+ [accelProps setValue:[NSNumber numberWithDouble:x * kGravitationalConstant] forKey:@"x"];
+ [accelProps setValue:[NSNumber numberWithDouble:y * kGravitationalConstant] forKey:@"y"];
+ [accelProps setValue:[NSNumber numberWithDouble:z * kGravitationalConstant] forKey:@"z"];
+ [accelProps setValue:[NSNumber numberWithDouble:timestamp] forKey:@"timestamp"];
+
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:accelProps];
+ [result setKeepCallback:[NSNumber numberWithBool:YES]];
+ [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
+ self.haveReturnedResult = YES;
+}
+
+// TODO: Consider using filtering to isolate instantaneous data vs. gravity data -jm
+
+/*
+ #define kFilteringFactor 0.1
+
+ // Use a basic low-pass filter to keep only the gravity component of each axis.
+ grav_accelX = (acceleration.x * kFilteringFactor) + ( grav_accelX * (1.0 - kFilteringFactor));
+ grav_accelY = (acceleration.y * kFilteringFactor) + ( grav_accelY * (1.0 - kFilteringFactor));
+ grav_accelZ = (acceleration.z * kFilteringFactor) + ( grav_accelZ * (1.0 - kFilteringFactor));
+
+ // Subtract the low-pass value from the current value to get a simplified high-pass filter
+ instant_accelX = acceleration.x - ( (acceleration.x * kFilteringFactor) + (instant_accelX * (1.0 - kFilteringFactor)) );
+ instant_accelY = acceleration.y - ( (acceleration.y * kFilteringFactor) + (instant_accelY * (1.0 - kFilteringFactor)) );
+ instant_accelZ = acceleration.z - ( (acceleration.z * kFilteringFactor) + (instant_accelZ * (1.0 - kFilteringFactor)) );
+
+
+ */
+@end
View
8 Mobile/platforms/ios/Pitching/config.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<widget id="io.jok.pitching" version="0.1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+<widget id="io.jok.pitching" version="1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="BackupWebStorage" value="cloud" />
@@ -22,9 +22,15 @@
<feature name="JokUtils">
<param name="ios-package" value="CDVJokUtils" />
</feature>
+ <feature name="GameCenter">
+ <param name="ios-package" value="GameCenter" />
+ </feature>
<feature name="Device">
<param name="ios-package" value="CDVDevice" />
</feature>
+ <feature name="Accelerometer">
+ <param name="ios-package" value="CDVAccelerometer" />
+ </feature>
<feature name="Notification">
<param name="ios-package" value="CDVNotification" />
</feature>
View
25 Mobile/platforms/ios/www/cordova_plugins.js
@@ -41,6 +41,27 @@ module.exports = [
"clobbers": [
"window.Media"
]
+ },
+ {
+ "file": "plugins/org.apache.cordova.device-motion/www/Acceleration.js",
+ "id": "org.apache.cordova.device-motion.Acceleration",
+ "clobbers": [
+ "Acceleration"
+ ]
+ },
+ {
+ "file": "plugins/org.apache.cordova.device-motion/www/accelerometer.js",
+ "id": "org.apache.cordova.device-motion.accelerometer",
+ "clobbers": [
+ "navigator.accelerometer"
+ ]
+ },
+ {
+ "file": "plugins/gamecenter/www/gamecenter.js",
+ "id": "gamecenter.GameCenter",
+ "clobbers": [
+ "gamecenter"
+ ]
}
];
module.exports.metadata =
@@ -51,7 +72,9 @@ module.exports.metadata =
"org.apache.cordova.inappbrowser": "0.3.1",
"org.apache.cordova.vibration": "0.3.7",
"com.phonegap.plugins.jokutils": "0.1.0",
- "org.apache.cordova.media": "0.2.8"
+ "org.apache.cordova.media": "0.2.8",
+ "org.apache.cordova.device-motion": "0.2.6",
+ "gamecenter": "0.2.3"
}
// BOTTOM OF METADATA
});
View
22 Mobile/platforms/ios/www/plugins/gamecenter/www/gamecenter.js
@@ -0,0 +1,22 @@
+cordova.define("gamecenter.GameCenter", function(require, exports, module) {
+var exec = require("cordova/exec");
+
+var GameCenter = function () {
+ this.name = "GameCenter";
+};
+
+GameCenter.prototype.auth = function (success, failure) {
+ exec(success, failure, "GameCenter", "auth", []);
+};
+
+GameCenter.prototype.submitScore = function (success, failure, data) {
+ exec(success, failure, "GameCenter", "submitScore", [data]);
+};
+
+GameCenter.prototype.showLeaderboard = function (success, failure, data) {
+ exec(success, failure, "GameCenter", "showLeaderboard", [data]);
+};
+
+module.exports = new GameCenter();
+
+});
View
31 Mobile/platforms/ios/www/plugins/org.apache.cordova.device-motion/www/Acceleration.js
@@ -0,0 +1,31 @@
+cordova.define("org.apache.cordova.device-motion.Acceleration", function(require, exports, module) { /*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+*/
+
+var Acceleration = function(x, y, z, timestamp) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.timestamp = timestamp || (new Date()).getTime();
+};
+
+module.exports = Acceleration;
+
+});
View
171 Mobile/platforms/ios/www/plugins/org.apache.cordova.device-motion/www/accelerometer.js
@@ -0,0 +1,171 @@
+cordova.define("org.apache.cordova.device-motion.accelerometer", function(require, exports, module) { /*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+*/
+
+/**
+ * This class provides access to device accelerometer data.
+ * @constructor
+ */
+var argscheck = require('cordova/argscheck'),
+ utils = require("cordova/utils"),
+ exec = require("cordova/exec"),
+ Acceleration = require('./Acceleration');
+
+// Is the accel sensor running?
+var running = false;
+
+// Keeps reference to watchAcceleration calls.
+var timers = {};
+
+// Array of listeners; used to keep track of when we should call start and stop.
+var listeners = [];
+
+// Last returned acceleration object from native
+var accel = null;
+
+// Tells native to start.
+function start() {
+ exec(function(a) {
+ var tempListeners = listeners.slice(0);
+ accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
+ for (var i = 0, l = tempListeners.length; i < l; i++) {
+ tempListeners[i].win(accel);
+ }
+ }, function(e) {
+ var tempListeners = listeners.slice(0);
+ for (var i = 0, l = tempListeners.length; i < l; i++) {
+ tempListeners[i].fail(e);
+ }
+ }, "Accelerometer", "start", []);
+ running = true;
+}
+
+// Tells native to stop.
+function stop() {
+ exec(null, null, "Accelerometer", "stop", []);
+ running = false;
+}
+
+// Adds a callback pair to the listeners array
+function createCallbackPair(win, fail) {
+ return {win:win, fail:fail};
+}
+
+// Removes a win/fail listener pair from the listeners array
+function removeListeners(l) {
+ var idx = listeners.indexOf(l);
+ if (idx > -1) {
+ listeners.splice(idx, 1);
+ if (listeners.length === 0) {
+ stop();
+ }
+ }
+}
+
+var accelerometer = {
+ /**
+ * Asynchronously acquires the current acceleration.
+ *
+ * @param {Function} successCallback The function to call when the acceleration data is available
+ * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
+ * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
+ */
+ getCurrentAcceleration: function(successCallback, errorCallback, options) {
+ argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);
+
+ var p;
+ var win = function(a) {
+ removeListeners(p);
+ successCallback(a);
+ };
+ var fail = function(e) {
+ removeListeners(p);
+ errorCallback && errorCallback(e);
+ };
+
+ p = createCallbackPair(win, fail);
+ listeners.push(p);
+
+ if (!running) {
+ start();
+ }
+ },
+
+ /**
+ * Asynchronously acquires the acceleration repeatedly at a given interval.
+ *
+ * @param {Function} successCallback The function to call each time the acceleration data is available
+ * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
+ * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
+ * @return String The watch id that must be passed to #clearWatch to stop watching.
+ */
+ watchAcceleration: function(successCallback, errorCallback, options) {
+ argscheck.checkArgs('fFO', 'accelerometer.watchAcceleration', arguments);
+ // Default interval (10 sec)
+ var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
+
+ // Keep reference to watch id, and report accel readings as often as defined in frequency
+ var id = utils.createUUID();
+
+ var p = createCallbackPair(function(){}, function(e) {
+ removeListeners(p);
+ errorCallback && errorCallback(e);
+ });
+ listeners.push(p);
+
+ timers[id] = {
+ timer:window.setInterval(function() {
+ if (accel) {
+ successCallback(accel);
+ }
+ }, frequency),
+ listeners:p
+ };
+
+ if (running) {
+ // If we're already running then immediately invoke the success callback
+ // but only if we have retrieved a value, sample code does not check for null ...
+ if (accel) {
+ successCallback(accel);
+ }
+ } else {
+ start();
+ }
+
+ return id;
+ },
+
+ /**
+ * Clears the specified accelerometer watch.
+ *
+ * @param {String} id The id of the watch returned from #watchAcceleration.
+ */
+ clearWatch: function(id) {
+ // Stop javascript timer & remove from timer list
+ if (id && timers[id]) {
+ window.clearInterval(timers[id].timer);
+ removeListeners(timers[id].listeners);
+ delete timers[id];
+ }
+ }
+};
+module.exports = accelerometer;
+
+});
View
1  Mobile/plugins/gamecenter/.fetch.json
@@ -0,0 +1 @@
+{"source":{"type":"git","url":"https://github.com/leecrossley/cordova-plugin-game-center.git","subdir":"."}}
View
61 Mobile/plugins/gamecenter/README.md
@@ -0,0 +1,61 @@
+## Game Center Plugin for Apache Cordova
+
+This plugin allows developers to utilise the iOS Game Center in their Cordova / PhoneGap app.
+
+The code under active development and currently has support for [auth](#auth), [submitting a score](#submit-score) and [showing leaderboards](#show-leaderboard) using the native viewcontroller.
+
+### Before you start
+
+Adding Game Center support requires more than simple coding changes. To create a Game Center-aware game, you need to understand these basics before you begin writing code. The full outline of all the Game Center concepts and impacts can be viewed [here](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/GameKit_Guide/GameCenterOverview/GameCenterOverview.html).
+
+## Install
+
+```
+cordova plugin add https://github.com/leecrossley/cordova-plugin-game-center.git
+```
+
+You **do not** need to reference any JavaScript, the Cordova plugin architecture will add a gamecenter object to your root automatically when you build. It will also automatically add the GameKit framework dependency.
+
+## Usage
+
+### Auth
+
+You should do this as soon as your deviceready event has been fired. The plug handles the various auth scenarios for you.
+
+```
+gamecenter.auth(successCallback, failureCallback);
+```
+
+### Submit Score
+
+Ensure you have had a successful callback from `gamecenter.auth()` first before attempting to submit a score. You should also have set up your leaderboard(s) in iTunes connect and use the leaderboard identifier assigned there as the leaderboardId.
+
+```
+var data = {
+ score: 10,
+ leaderboardId: "board1"
+};
+gamecenter.submitScore(successCallback, failureCallback, data);
+```
+
+### Show leaderboard
+
+Launches the native Game Center leaderboard view controller for a given period and leaderboard.
+
+```
+var data = {
+ period: "today",
+ leaderboardId: "board1"
+};
+gamecenter.showLeaderboard(successCallback, failureCallback, data);
+```
+
+The period options are "today", "week" or "all".
+
+## Platforms
+
+Supports iOS 6 and iOS 7 (there are differences in the native implementation). The Game Center is Apple specific and not applicable to other platforms.
+
+## License
+
+[MIT License](http://ilee.mit-license.org)
View
23 Mobile/plugins/gamecenter/plugin.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="gamecenter" version="0.2.3">
+ <name>Game Center</name>
+ <author>Lee Crossley (http://ilee.co.uk/)</author>
+ <description>Cordova Game Center Plugin to utilise the iOS Game Center in your app. There is currently support for authentication, submitting a score to a leaderboard and displaying a native leaderboard.</description>
+ <keywords>cordova, game, game center, gamecenter, leaderboard</keywords>
+ <engines>
+ <engine name="cordova" version=">=3.0.0" />
+ </engines>
+ <js-module src="www/gamecenter.js" name="GameCenter">
+ <clobbers target="gamecenter" />
+ </js-module>
+ <platform name="ios">
+ <config-file target="config.xml" parent="/*">
+ <feature name="GameCenter">
+ <param name="ios-package" value="GameCenter" />
+ </feature>
+ </config-file>
+ <header-file src="src/ios/GameCenter.h" />
+ <source-file src="src/ios/GameCenter.m" />
+ <framework src="GameKit.framework" />
+ </platform>
+</plugin>
View
17 Mobile/plugins/gamecenter/src/ios/GameCenter.h
@@ -0,0 +1,17 @@
+//
+// GameCenter.h
+// Copyright (c) 2013 Lee Crossley - http://ilee.co.uk
+//
+
+#import "Foundation/Foundation.h"
+#import "Cordova/CDV.h"
+#import "GameCenter.h"
+#import "GameKit/GameKit.h"
+
+@interface GameCenter : CDVPlugin <GKGameCenterControllerDelegate>
+
+- (void) auth:(CDVInvokedUrlCommand*)command;
+- (void) submitScore:(CDVInvokedUrlCommand*)command;
+- (void) showLeaderboard:(CDVInvokedUrlCommand*)command;
+
+@end
View
140 Mobile/plugins/gamecenter/src/ios/GameCenter.m
@@ -0,0 +1,140 @@
+//
+// GameCenter.m
+// Copyright (c) 2013 Lee Crossley - http://ilee.co.uk
+//
+
+#import "Cordova/CDV.h"
+#import "Cordova/CDVViewController.h"
+#import "GameCenter.h"
+
+@implementation GameCenter
+
+- (void) auth:(CDVInvokedUrlCommand*)command;
+{
+ // __weak to avoid retain cycle
+ __weak GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
+
+ localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) {
+ CDVPluginResult* pluginResult = nil;
+ if (viewController != nil)
+ {
+ // Login required
+ [self.viewController presentViewController:viewController animated:YES completion:nil];
+ }
+ else
+ {
+ if (localPlayer.isAuthenticated)
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ }
+ else if (error != nil)
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]];
+ }
+ else
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
+ }
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ }
+ };
+}
+
+- (void) submitScore:(CDVInvokedUrlCommand*)command;
+{
+ NSMutableDictionary *args = [command.arguments objectAtIndex:0];
+ int64_t score = [[args objectForKey:@"score"] integerValue];
+ NSString *leaderboardId = [args objectForKey:@"leaderboardId"];
+
+ __block CDVPluginResult* pluginResult = nil;
+
+ // Different methods depending on iOS version
+ if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
+ {
+ GKScore *scoreSubmitter = [[GKScore alloc] initWithLeaderboardIdentifier: leaderboardId];
+ scoreSubmitter.value = score;
+ scoreSubmitter.context = 0;
+
+ [GKScore reportScores:@[scoreSubmitter] withCompletionHandler:^(NSError *error) {
+ if (error)
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]];
+ }
+ else
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ }
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ }];
+ }
+ else
+ {
+ GKScore *scoreSubmitter = [[GKScore alloc] initWithCategory:leaderboardId];
+ scoreSubmitter.value = score;
+
+ [scoreSubmitter reportScoreWithCompletionHandler:^(NSError *error) {
+ if (error)
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]];
+ }
+ else
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ }
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ }];
+ }
+}
+
+- (void) showLeaderboard:(CDVInvokedUrlCommand*)command;
+{
+ NSMutableDictionary *args = [command.arguments objectAtIndex:0];
+ NSString *leaderboardId = [args objectForKey:@"leaderboardId"];
+ NSString *period = [args objectForKey:@"period"];
+
+ CDVPluginResult* pluginResult = nil;
+
+ GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
+ if (gameCenterController != nil)
+ {
+ if ([period isEqualToString:@"today"])
+ {
+ gameCenterController.leaderboardTimeScope = GKLeaderboardTimeScopeToday;
+ }
+ else if ([period isEqualToString:@"week"])
+ {
+ gameCenterController.leaderboardTimeScope = GKLeaderboardTimeScopeWeek;
+ }
+ else
+ {
+ gameCenterController.leaderboardTimeScope = GKLeaderboardTimeScopeAllTime;
+ }
+
+ gameCenterController.gameCenterDelegate = self;
+
+ if (leaderboardId.length > 0)
+ {
+ gameCenterController.leaderboardCategory = leaderboardId;
+ gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
+ }
+ else
+ {
+ gameCenterController.viewState = GKGameCenterViewControllerStateDefault;
+ }
+
+ [self.viewController presentViewController:gameCenterController animated:YES completion:nil];
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ }
+ else
+ {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
+ }
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+}
+
+- (void) gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController
+{
+ [gameCenterViewController dismissViewControllerAnimated:YES completion:nil];
+}
+
+@end
View
20 Mobile/plugins/gamecenter/www/gamecenter.js
@@ -0,0 +1,20 @@
+
+var exec = require("cordova/exec");
+
+var GameCenter = function () {
+ this.name = "GameCenter";
+};
+
+GameCenter.prototype.auth = function (success, failure) {
+ exec(success, failure, "GameCenter", "auth", []);
+};
+
+GameCenter.prototype.submitScore = function (success, failure, data) {
+ exec(success, failure, "GameCenter", "submitScore", [data]);
+};
+
+GameCenter.prototype.showLeaderboard = function (success, failure, data) {
+ exec(success, failure, "GameCenter", "showLeaderboard", [data]);
+};
+
+module.exports = new GameCenter();
View
2  Mobile/plugins/ios.json
@@ -1 +1 @@
-{"prepare_queue":{"installed":[],"uninstalled":[]},"config_munge":{"config.xml":{"/*":{"<feature name=\"Device\"><param name=\"ios-package\" value=\"CDVDevice\" /></feature>":1,"<feature name=\"Notification\"><param name=\"ios-package\" value=\"CDVNotification\" /></feature>":1,"<feature name=\"InAppBrowser\"><param name=\"ios-package\" value=\"CDVInAppBrowser\" /></feature>":1,"<feature name=\"Vibration\"><param name=\"ios-package\" value=\"CDVVibration\" /></feature>":1,"<feature name=\"JokUtils\"><param name=\"ios-package\" value=\"CDVJokUtils\" /></feature>":1,"<feature name=\"Media\"><param name=\"ios-package\" value=\"CDVSound\" /></feature>":1}},"framework":{"AudioToolbox.framework":{"true":2},"CoreGraphics.framework":{"false":1}}},"installed_plugins":{"org.apache.cordova.device":{"PACKAGE_NAME":"io.jok.pitching"},"org.apache.cordova.dialogs":{"PACKAGE_NAME":"io.jok.pitching"},"org.apache.cordova.inappbrowser":{"PACKAGE_NAME":"io.jok.pitching"},"org.apache.cordova.vibration":{"PACKAGE_NAME":"io.jok.pitching"},"com.phonegap.plugins.jokutils":{"PACKAGE_NAME":"io.jok.pitching"},"org.apache.cordova.media":{"PACKAGE_NAME":"io.jok.pitching"}},"dependent_plugins":{}}
+{"prepare_queue":{"installed":[],"uninstalled":[]},"config_munge":{"config.xml":{"/*":{"<feature name=\"Device\"><param name=\"ios-package\" value=\"CDVDevice\" /></feature>":1,"<feature name=\"Notification\"><param name=\"ios-package\" value=\"CDVNotification\" /></feature>":1,"<feature name=\"InAppBrowser\"><param name=\"ios-package\" value=\"CDVInAppBrowser\" /></feature>":1,"<feature name=\"Vibration\"><param name=\"ios-package\" value=\"CDVVibration\" /></feature>":1,"<feature name=\"JokUtils\"><param name=\"ios-package\" value=\"CDVJokUtils\" /></feature>":1,"<feature name=\"Media\"><param name=\"ios-package\" value=\"CDVSound\" /></feature>":1,"<feature name=\"Accelerometer\"><param name=\"ios-package\" value=\"CDVAccelerometer\" /></feature>":1,"<feature name=\"GameCenter\"><param name=\"ios-package\" value=\"GameCenter\" /></feature>":1}},"framework":{"AudioToolbox.framework":{"true":2},"CoreGraphics.framework":{"false":1},"CoreMotion.framework":{"false":1},"GameKit.framework":{"false":1}}},"installed_plugins":{"org.apache.cordova.device":{"PACKAGE_NAME":"io.jok.pitching"},"org.apache.cordova.dialogs":{"PACKAGE_NAME":"io.jok.pitching"},"org.apache.cordova.inappbrowser":{"PACKAGE_NAME":"io.jok.pitching"},"org.apache.cordova.vibration":{"PACKAGE_NAME":"io.jok.pitching"},"com.phonegap.plugins.jokutils":{"PACKAGE_NAME":"io.jok.pitching"},"org.apache.cordova.media":{"PACKAGE_NAME":"io.jok.pitching"},"org.apache.cordova.device-motion":{"PACKAGE_NAME":"io.jok.pitching"},"gamecenter":{"PACKAGE_NAME":"io.jok.pitching"}},"dependent_plugins":{}}
View
1  Mobile/plugins/org.apache.cordova.device-motion/.fetch.json
@@ -0,0 +1 @@
+{"source":{"type":"local","path":"/var/folders/2z/x2m50m5d3wvg8_w4kk1nwslh0000gn/T/org.apache.cordova.device-motion/package"}}
View
202 Mobile/plugins/org.apache.cordova.device-motion/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
View
22 Mobile/plugins/org.apache.cordova.device-motion/README.md
@@ -0,0 +1,22 @@
+<!---
+ license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+
+# org.apache.cordova.device-motion
+
+Plugin documentation: [doc/index.md](doc/index.md)
View
57 Mobile/plugins/org.apache.cordova.device-motion/RELEASENOTES.md
@@ -0,0 +1,57 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#
+-->
+# Release Notes
+
+### 0.2.2 (Sept 25, 2013)
+* CB-4889 bumping&resetting version
+* [windows8] commandProxy was moved
+* CB-4889
+* CB-4889 renaming core inside windows8
+* CB-4889 renaming org.apache.cordova.core.device-motion to org.apache.cordova.device-motion
+* Rename CHANGELOG.md -> RELEASENOTES.md
+* [CB-4752] Incremented plugin version on dev branch.
+
+### 0.2.3 (Oct 28, 2013)
+* tweak scoping
+* fixed the scope
+* properly stop watching...
+* adding timestamp to the response
+* fix acceleromter for firefox os
+* update firefoxos integration
+* fixed callbacks
+* accelerometer registers, but is not responding
+* fxos added, not working
+* CB-5128: added repo + issue tag to plugin.xml for device motion
+* CB-5012 ensure result is returned
+* [CB-4825] Add CoreMotion.framework to plugin.xml
+* [CB-4825] avoid retain cycle in update block
+* [CB-4825] use CoreMotion framework for accelerometer
+* [CB-4915] Incremented plugin version on dev branch.
+
+### 0.2.4 (Dec 4, 2013)
+* add ubuntu platform
+* 1. Added amazon-fireos platform. 2. Change to use amazon-fireos as the platform if the user agent string contains 'cordova-amazon-fireos'
+
+### 0.2.5 (Jan 02, 2014)
+* CB-5658 Add doc/index.md for Device Motion plugin
+
+### 0.2.6 (Feb 05, 2014)
+* Add Tizen support
View
156 Mobile/plugins/org.apache.cordova.device-motion/doc/index.md
@@ -0,0 +1,156 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+
+# org.apache.cordova.device-motion
+
+This plugin provides access to the device's accelerometer. The accelerometer is
+a motion sensor that detects the change (_delta_) in movement relative to the
+current device orientation, in three dimensions along the _x_, _y_, and _z_
+axis.
+
+## Installation
+
+ cordova plugin add org.apache.cordova.device-motion
+
+## Supported Platforms
+
+- Amazon Fire OS
+- Android
+- BlackBerry 10
+- iOS
+- Tizen
+- Windows Phone 7 and 8
+- Windows 8
+
+## Methods
+
+- navigator.accelerometer.getCurrentAcceleration
+- navigator.accelerometer.watchAcceleration
+- navigator.accelerometer.clearWatch
+
+## Objects
+
+- Acceleration
+
+## navigator.accelerometer.getCurrentAcceleration
+
+Get the current acceleration along the _x_, _y_, and _z_ axes.
+
+These acceleration values are returned to the `accelerometerSuccess`
+callback function.
+
+ navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
+
+
+### Example
+
+ function onSuccess(acceleration) {
+ alert('Acceleration X: ' + acceleration.x + '\n' +
+ 'Acceleration Y: ' + acceleration.y + '\n' +
+ 'Acceleration Z: ' + acceleration.z + '\n' +
+ 'Timestamp: ' + acceleration.timestamp + '\n');
+ };
+
+ function onError() {
+ alert('onError!');
+ };
+
+ navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
+
+### iOS Quirks
+
+- iOS doesn't recognize the concept of getting the current acceleration at any given point.
+
+- You must watch the acceleration and capture the data at given time intervals.
+
+- Thus, the `getCurrentAcceleration` function yields the last value reported from a `watchAccelerometer` call.
+
+## navigator.accelerometer.watchAcceleration
+
+Retrieves the device's current `Acceleration` at a regular interval, executing
+the `accelerometerSuccess` callback function each time. Specify the interval in
+milliseconds via the `acceleratorOptions` object's `frequency` parameter.
+
+The returned watch ID references the accelerometer's watch interval,
+and can be used with `navigator.accelerometer.clearWatch` to stop watching the
+accelerometer.
+
+ var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
+ accelerometerError,
+ [accelerometerOptions]);
+
+- __accelerometerOptions__: An object with the following optional keys:
+ - __frequency__: How often to retrieve the `Acceleration` in milliseconds. _(Number)_ (Default: 10000)
+
+
+### Example
+
+ function onSuccess(acceleration) {
+ alert('Acceleration X: ' + acceleration.x + '\n' +
+ 'Acceleration Y: ' + acceleration.y + '\n' +
+ 'Acceleration Z: ' + acceleration.z + '\n' +
+ 'Timestamp: ' + acceleration.timestamp + '\n');
+ };
+
+ function onError() {
+ alert('onError!');
+ };
+
+ var options = { frequency: 3000 }; // Update every 3 seconds
+
+ var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
+
+### iOS Quirks
+
+The API calls the success callback function at the interval requested,
+but restricts the range of requests to the device between 40ms and
+1000ms. For example, if you request an interval of 3 seconds,
+(3000ms), the API requests data from the device every 1 second, but
+only executes the success callback every 3 seconds.
+
+## navigator.accelerometer.clearWatch
+
+Stop watching the `Acceleration` referenced by the `watchID` parameter.
+
+ navigator.accelerometer.clearWatch(watchID);
+
+- __watchID__: The ID returned by `navigator.accelerometer.watchAcceleration`.
+
+### Example
+
+ var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
+
+ // ... later on ...
+
+ navigator.accelerometer.clearWatch(watchID);
+
+## Acceleration
+
+Contains `Accelerometer` data captured at a specific point in time.
+Acceleration values include the effect of gravity (9.81 m/s^2), so that when a
+device lies flat and facing up, _x_, _y_, and _z_ values returned should be
+`0`, `0`, and `9.81`.
+
+### Properties
+
+- __x__: Amount of acceleration on the x-axis. (in m/s^2) _(Number)_
+- __y__: Amount of acceleration on the y-axis. (in m/s^2) _(Number)_
+- __z__: Amount of acceleration on the z-axis. (in m/s^2) _(Number)_
+- __timestamp__: Creation timestamp in milliseconds. _(DOMTimeStamp)_
+
View
15 Mobile/plugins/org.apache.cordova.device-motion/package.json
@@ -0,0 +1,15 @@
+{
+ "version": "0.2.6",
+ "name": "org.apache.cordova.device-motion",
+ "cordova_name": "Device Motion",
+ "description": "Cordova Device Motion Plugin",
+ "license": "Apache 2.0",
+ "repo": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git",
+ "issue": "https://issues.apache.org/jira/browse/CB/component/12320636",
+ "keywords": [
+ "cordova",
+ "device",
+ "motion"
+ ],
+ "engines": []
+}
View
133 Mobile/plugins/org.apache.cordova.device-motion/plugin.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
+ id="org.apache.cordova.device-motion"
+ version="0.2.6">
+
+ <name>Device Motion</name>
+ <description>Cordova Device Motion Plugin</description>
+ <license>Apache 2.0</license>
+ <keywords>cordova,device,motion</keywords>
+ <repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git</repo>
+ <issue>https://issues.apache.org/jira/browse/CB/component/12320636</issue>
+
+ <js-module src="www/Acceleration.js" name="Acceleration">
+ <clobbers target="Acceleration" />
+ </js-module>
+
+ <js-module src="www/accelerometer.js" name="accelerometer">
+ <clobbers target="navigator.accelerometer" />
+ </js-module>
+
+ <!-- firefoxos -->
+ <platform name="firefoxos">
+ <config-file target="config.xml" parent="/*">
+ <feature name="Accelerometer">
+ <param name="firefoxos-package" value="Accelerometer" />
+ </feature>
+ </config-file>
+
+ <js-module src="src/firefoxos/accelerometer.js" name="accelerometer-impl">
+ <runs />
+ </js-module>
+ </platform>
+
+ <!-- android -->
+ <platform name="android">
+
+ <config-file target="res/xml/config.xml" parent="/*">
+ <feature name="Accelerometer">
+ <param name="android-package" value="org.apache.cordova.devicemotion.AccelListener"/>
+ </feature>
+ </config-file>
+
+ <source-file src="src/android/AccelListener.java" target-dir="src/org/apache/cordova/devicemotion" />
+
+ </platform>
+
+ <!-- amazon-fireos -->
+ <platform name="amazon-fireos">
+
+ <config-file target="res/xml/config.xml" parent="/*">
+ <feature name="Accelerometer">
+ <param name="android-package" value="org.apache.cordova.devicemotion.AccelListener"/>
+ </feature>
+ </config-file>
+
+ <source-file src="src/android/AccelListener.java" target-dir="src/org/apache/cordova/devicemotion" />
+
+ </platform>
+
+ <!-- ubuntu -->
+ <platform name="ubuntu">
+ <header-file src="src/ubuntu/accelerometer.h" />
+ <source-file src="src/ubuntu/accelerometer.cpp" />
+ </platform>
+
+ <!-- ios -->
+ <platform name="ios">
+
+ <config-file target="config.xml" parent="/*">
+ <feature name="Accelerometer">
+ <param name="ios-package" value="CDVAccelerometer"/>
+ </feature>
+ </config-file>
+
+ <header-file src="src/ios/CDVAccelerometer.h" />
+ <source-file src="src/ios/CDVAccelerometer.m" />
+
+ <framework src="CoreMotion.framework" />
+ </platform>
+
+ <!-- blackberry10 -->
+ <platform name="blackberry10">
+ <config-file target="www/config.xml" parent="/widget">
+ <feature name="Accelerometer" value="Accelerometer"/>
+ </config-file>
+ <source-file src="src/blackberry10/index.js" target-dir="Accelerometer" />
+ </platform>
+
+ <!-- wp7 -->
+ <platform name="wp7">
+ <config-file target="config.xml" parent="/*">
+ <feature name="Accelerometer">
+ <param name="wp-package" value="Accelerometer"/>
+ </feature>
+ </config-file>
+
+ <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
+ <Capability Name="ID_CAP_SENSORS" />
+ </config-file>
+
+ <source-file src="src/wp/Accelerometer.cs" />
+ </platform>
+
+ <!-- wp8 -->
+ <platform name="wp8">
+ <config-file target="config.xml" parent="/*">
+ <feature name="Accelerometer">
+ <param name="wp-package" value="Accelerometer"/>
+ </feature>
+ </config-file>
+
+ <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
+ <Capability Name="ID_CAP_SENSORS" />
+ </config-file>
+
+ <source-file src="src/wp/Accelerometer.cs" />
+ </platform>
+
+ <!-- windows8 -->
+ <platform name="windows8">
+ <js-module src="src/windows8/AccelerometerProxy.js" name="AccelerometerProxy">
+ <merges target="" />
+ </js-module>
+ </platform>
+
+ <!-- tizen -->
+ <platform name="tizen">
+ <js-module src="src/tizen/AccelerometerProxy.js" name="AccelerometerProxy">
+ <runs/>
+ </js-module>
+ </platform>
+</plugin>
View
295 Mobile/plugins/org.apache.cordova.device-motion/src/android/AccelListener.java
@@ -0,0 +1,295 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+package org.apache.cordova.devicemotion;
+
+import java.util.List;
+
+import org.apache.cordova.CordovaWebView;
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.CordovaInterface;
+import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.PluginResult;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+
+import android.os.Handler;
+import android.os.Looper;
+
+/**
+ * This class listens to the accelerometer sensor and stores the latest
+ * acceleration values x,y,z.
+ */
+public class AccelListener extends CordovaPlugin implements SensorEventListener {
+
+ public static int STOPPED = 0;
+ public static int STARTING = 1;
+ public static int RUNNING = 2;
+ public static int ERROR_FAILED_TO_START = 3;
+
+ private float x,y,z; // most recent acceleration values
+ private long timestamp; // time of most recent value
+ private int status; // status of listener
+ private int accuracy = SensorManager.SENSOR_STATUS_UNRELIABLE;
+
+ private SensorManager sensorManager; // Sensor manager
+ private Sensor mSensor; // Acceleration sensor returned by sensor manager
+
+ private CallbackContext callbackContext; // Keeps track of the JS callback context.
+
+ private Handler mainHandler=null;
+ private Runnable mainRunnable =new Runnable() {
+ public void run() {
+ AccelListener.this.timeout();
+ }
+ };
+
+ /**
+ * Create an accelerometer listener.
+ */
+ public AccelListener() {
+ this.x = 0;
+ this.y = 0;
+ this.z = 0;
+ this.timestamp = 0;
+ this.setStatus(AccelListener.STOPPED);
+ }
+
+ /**
+ * Sets the contex