You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ld...@apache.org on 2014/08/07 18:58:42 UTC

[02/12] git commit: changes to vibration.java to align with w3c, changes to vibration.js for backwards compatibility

changes to vibration.java to align with w3c, changes to vibration.js for backwards compatibility


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/commit/1d0afd7d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/tree/1d0afd7d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/diff/1d0afd7d

Branch: refs/heads/master
Commit: 1d0afd7d0f5a5e0f3238117093d618bacbe5bb04
Parents: bf582d3
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Mon Jul 21 16:24:40 2014 -0400
Committer: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Committed: Mon Jul 21 16:24:40 2014 -0400

----------------------------------------------------------------------
 src/android/Vibration.java |  8 +++++++-
 www/vibration.js           | 14 ++++++++------
 2 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/1d0afd7d/src/android/Vibration.java
----------------------------------------------------------------------
diff --git a/src/android/Vibration.java b/src/android/Vibration.java
index 9e82315..b412f9a 100755
--- a/src/android/Vibration.java
+++ b/src/android/Vibration.java
@@ -111,7 +111,13 @@ public class Vibration extends CordovaPlugin {
      */
     public void vibrateWithPattern(long[] pattern, int repeat) {
         Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
-        vibrator.vibrate(pattern, repeat);
+        
+        //add 0 at beginning of pattern to align with w3c spec
+        long[] newPattern = new long[pattern.length+1];
+        newPattern[0] = 0;
+        System.arraycopy(pattern, 0, newPattern, 1, pattern.length);
+        
+        vibrator.vibrate(newPattern, repeat);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/1d0afd7d/www/vibration.js
----------------------------------------------------------------------
diff --git a/www/vibration.js b/www/vibration.js
index d1206ed..270a536 100644
--- a/www/vibration.js
+++ b/www/vibration.js
@@ -37,13 +37,14 @@ module.exports = {
      *                                      Pass in an array of integers that
      *                                      are the durations for which to
      *                                      turn on or off the vibrator in
-     *                                      milliseconds. The first value
-     *                                      indicates the number of milliseconds
-     *                                      to wait before turning the vibrator
-     *                                      on. The next value indicates the
+     *                                      milliseconds. The FIRST value
+     *                                      indicates the
      *                                      number of milliseconds for which
-     *                                      to keep the vibrator on before
-     *                                      turning it off. Subsequent values
+     *                                      to keep the vibrator ON before
+     *                                      turning it off. The NEXT value indicates the
+     *                                      number of milliseconds for which
+     *                                      to keep the vibrator OFF before
+     *                                      turning it on. Subsequent values
      *                                      alternate between durations in
      *                                      milliseconds to turn the vibrator
      *                                      off or to turn the vibrator on.
@@ -93,6 +94,7 @@ module.exports = {
      */
     vibrateWithPattern: function(pattern, repeat) {
         repeat = (typeof repeat !== "undefined") ? repeat : -1;
+        pattern.unshift(0); //add a 0 at beginning for backwards compatibility from w3c spec
         exec(null, null, "Vibration", "vibrateWithPattern", [pattern, repeat]);
     },