[
https://issues.apache.org/jira/browse/CB-13045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16288188#comment-16288188
]
ASF GitHub Bot commented on CB-13045:
-------------------------------------
maverickmishra closed pull request #60: CB-13045: Removed android
implementation and Updated README
URL: https://github.com/apache/cordova-plugin-vibration/pull/60
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/README.md b/README.md
index d559058..d989247 100644
--- a/README.md
+++ b/README.md
@@ -59,13 +59,10 @@ navigator.notification.vibrate
- Windows Phone 7 and 8
- Windows (Windows Phone 8.1 devices only)
-navigator.notification.vibrateWithPattern<br />
-navigator.notification.cancelVibration
-- Android
-- Windows Phone 8
-- Windows (Windows Phone 8.1 devices only)
-## vibrate (recommended)
+The Android webview (API level 19 and up) supports the [W3C Vibration
API](https://www.w3.org/TR/vibration/) natively and therefore, the Android
specific implementation of this plugin has been dropped.
+
+## vibrate
This function has three different functionalities based on parameters passed
to it.
@@ -138,52 +135,6 @@ or
Passing in a parameter of 0, an empty array, or an array with one element of
value 0 will cancel any vibrations.
-## *notification.vibrate (deprecated)
-
-Vibrates the device for a given amount of time.
-
- navigator.notification.vibrate(time)
-
-- __time__: Milliseconds to vibrate the device. _(Number)_
-
-### Example
-
- // Vibrate for 2.5 seconds
- navigator.notification.vibrate(2500);
-
-### iOS Quirks
-
-- __time__: Ignores the specified time and vibrates for a pre-set amount of
time.
-
- navigator.notification.vibrate();
- navigator.notification.vibrate(2500); // 2500 is ignored
-
-## *notification.vibrateWithPattern (deprecated)
-Vibrates the device with a given pattern.
-
- navigator.notification.vibrateWithPattern(pattern, repeat)
-
-- __pattern__: Sequence of durations (in milliseconds) for which to turn on or
off the vibrator. _(Array of Numbers)_
-- __repeat__: Optional index into the pattern array at which to start
repeating (will repeat until canceled), or -1 for no repetition (default).
_(Number)_
-
-### Example
-
- // Immediately start vibrating
- // vibrate for 100ms,
- // wait for 100ms,
- // vibrate for 200ms,
- // wait for 100ms,
- // vibrate for 400ms,
- // wait for 100ms,
- // vibrate for 800ms,
- // (do not repeat)
- navigator.notification.vibrateWithPattern([0, 100, 100, 200, 100, 400,
100, 800]);
-
-## *notification.cancelVibration (deprecated)
-
-Immediately cancels any currently running vibration.
- navigator.notification.cancelVibration()
-*Note - due to alignment with w3c spec, the starred methods will be phased out
diff --git a/package.json b/package.json
index 641f3ea..02792a4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-vibration",
- "version": "2.1.7-dev",
+ "version": "3.0.0-dev",
"description": "Cordova Vibration Plugin",
"types": "./types/index.d.ts",
"cordova": {
diff --git a/plugin.xml b/plugin.xml
index b707c89..8a88502 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -21,7 +21,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-vibration"
- version="2.1.7-dev">
+ version="3.0.0-dev">
<name>Vibration</name>
<description>Cordova Vibration Plugin</description>
@@ -45,6 +45,10 @@
<js-module src="src/firefoxos/VibrationProxy.js" name="VibrationProxy">
<runs />
</js-module>
+ <js-module src="www/vibration.js" name="notification">
+ <merges target="navigator.notification" />
+ <merges target="navigator" />
+ </js-module>
</platform>
<!-- wp7 -->
@@ -54,6 +58,10 @@
<param name="wp-package" value="Vibration"/>
</feature>
</config-file>
+ <js-module src="www/vibration.js" name="notification">
+ <merges target="navigator.notification" />
+ <merges target="navigator" />
+ </js-module>
<source-file src="src/wp/Vibration.cs" />
</platform>
@@ -65,6 +73,10 @@
<param name="wp-package" value="Vibration"/>
</feature>
</config-file>
+ <js-module src="www/vibration.js" name="notification">
+ <merges target="navigator.notification" />
+ <merges target="navigator" />
+ </js-module>
<source-file src="src/wp/Vibration.cs" />
</platform>
@@ -74,6 +86,10 @@
<js-module src="src/windows/VibrationProxy.js" name="VibrationProxy">
<runs />
</js-module>
+ <js-module src="www/vibration.js" name="notification">
+ <merges target="navigator.notification" />
+ <merges target="navigator" />
+ </js-module>
<framework src="src/windows/Vibration/Vibration.csproj" target="phone"
type="projectReference" custom="true" versions="<10.0.0" />
@@ -81,14 +97,6 @@
<!-- android -->
<platform name="android">
- <config-file target="res/xml/config.xml" parent="/*">
- <feature name="Vibration">
- <param name="android-package"
value="org.apache.cordova.vibration.Vibration"/>
- </feature>
- </config-file>
-
- <source-file src="src/android/Vibration.java"
target-dir="src/org/apache/cordova/vibration" />
-
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.VIBRATE"/>
</config-file>
@@ -101,6 +109,10 @@
<param name="android-package"
value="org.apache.cordova.vibration.Vibration"/>
</feature>
</config-file>
+ <js-module src="www/vibration.js" name="notification">
+ <merges target="navigator.notification" />
+ <merges target="navigator" />
+ </js-module>
<source-file src="src/android/Vibration.java"
target-dir="src/org/apache/cordova/vibration" />
@@ -113,6 +125,10 @@
<platform name="ubuntu">
<header-file src="src/ubuntu/vibration.h" />
<source-file src="src/ubuntu/vibration.cpp" />
+ <js-module src="www/vibration.js" name="notification">
+ <merges target="navigator.notification" />
+ <merges target="navigator" />
+ </js-module>
</platform>
<!-- ios -->
@@ -124,6 +140,10 @@
</config-file>
<header-file src="src/ios/CDVVibration.h" />
<source-file src="src/ios/CDVVibration.m" />
+ <js-module src="www/vibration.js" name="notification">
+ <merges target="navigator.notification" />
+ <merges target="navigator" />
+ </js-module>
<framework src="AudioToolbox.framework" weak="true" />
</platform>
@@ -136,6 +156,10 @@
<config-file target="www/config.xml" parent="/widget">
<feature name="Vibration" value="Vibration" />
</config-file>
+ <js-module src="www/vibration.js" name="notification">
+ <merges target="navigator.notification" />
+ <merges target="navigator" />
+ </js-module>
</platform>
<!-- browser -->
@@ -144,6 +168,10 @@
<merges target="navigator.notification" />
<merges target="navigator" />
</js-module>
+ <js-module src="www/vibration.js" name="notification">
+ <merges target="navigator.notification" />
+ <merges target="navigator" />
+ </js-module>
</platform>
<!-- tizen -->
@@ -151,5 +179,9 @@
<js-module src="src/tizen/VibrationProxy.js" name="VibrationProxy">
<runs />
</js-module>
+ <js-module src="www/vibration.js" name="notification">
+ <merges target="navigator.notification" />
+ <merges target="navigator" />
+ </js-module>
</platform>
</plugin>
diff --git a/src/android/Vibration.java b/src/android/Vibration.java
deleted file mode 100644
index 7a2537f..0000000
--- a/src/android/Vibration.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- 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.vibration;
-
-import org.apache.cordova.CallbackContext;
-import org.apache.cordova.CordovaPlugin;
-import org.json.JSONArray;
-import org.json.JSONException;
-import android.content.Context;
-import android.os.Vibrator;
-import android.media.AudioManager;
-
-/**
- * This class provides access to vibration on the device.
- */
-public class Vibration extends CordovaPlugin {
-
- /**
- * Constructor.
- */
- public Vibration() {
- }
-
- /**
- * Executes the request and returns PluginResult.
- *
- * @param action The action to execute.
- * @param args JSONArray of arguments for the plugin.
- * @param callbackContext The callback context used when calling back
into JavaScript.
- * @return True when the action was valid, false
otherwise.
- */
- public boolean execute(String action, JSONArray args, CallbackContext
callbackContext) throws JSONException {
- if (action.equals("vibrate")) {
- this.vibrate(args.getLong(0));
- }
- else if (action.equals("vibrateWithPattern")) {
- JSONArray pattern = args.getJSONArray(0);
- int repeat = args.getInt(1);
- //add a 0 at the beginning of pattern to align with w3c
- long[] patternArray = new long[pattern.length()+1];
- patternArray[0] = 0;
- for (int i = 0; i < pattern.length(); i++) {
- patternArray[i+1] = pattern.getLong(i);
- }
- this.vibrateWithPattern(patternArray, repeat);
- }
- else if (action.equals("cancelVibration")) {
- this.cancelVibration();
- }
- else {
- return false;
- }
-
- // Only alert and confirm are async.
- callbackContext.success();
-
- return true;
- }
-
-
//--------------------------------------------------------------------------
- // LOCAL METHODS
-
//--------------------------------------------------------------------------
-
- /**
- * Vibrates the device for a given amount of time.
- *
- * @param time Time to vibrate in ms.
- */
- public void vibrate(long time) {
- // Start the vibration, 0 defaults to half a second.
- if (time == 0) {
- time = 500;
- }
- AudioManager manager = (AudioManager)
this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE);
- if (manager.getRingerMode() != AudioManager.RINGER_MODE_SILENT) {
- Vibrator vibrator = (Vibrator)
this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
- vibrator.vibrate(time);
- }
- }
-
- /**
- * Vibrates the device with a given pattern.
- *
- * @param pattern Pattern with which to vibrate the device.
- * Pass in an array of longs 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
- * number of milliseconds for which
- * to keep the vibrator on before
- * turning it off. Subsequent values
- * alternate between durations in
- * milliseconds to turn the vibrator
- * off or to turn the vibrator on.
- *
- * @param repeat Optional index into the pattern array at which
- * to start repeating, or -1 for no repetition
(default).
- */
- public void vibrateWithPattern(long[] pattern, int repeat) {
- AudioManager manager = (AudioManager)
this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE);
- if (manager.getRingerMode() != AudioManager.RINGER_MODE_SILENT) {
- Vibrator vibrator = (Vibrator)
this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
- vibrator.vibrate(pattern, repeat);
- }
- }
-
- /**
- * Immediately cancels any currently running vibration.
- */
- public void cancelVibration() {
- Vibrator vibrator = (Vibrator)
this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
- vibrator.cancel();
- }
-}
diff --git a/www/vibration.js b/www/vibration.js
index 8b78e3c..28dbc99 100644
--- a/www/vibration.js
+++ b/www/vibration.js
@@ -77,40 +77,5 @@ module.exports = {
} else { exec(null, null, 'Vibration', 'cancelVibration', []); }
return true;
- },
-
- /**
- * Vibrates the device with a given pattern.
- *
- * @param {Array of Integer} pattern Pattern with which to vibrate the
device.
- * 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
- * number of milliseconds for which
- * to keep the vibrator on before
- * turning it off. Subsequent values
- * alternate between durations in
- * milliseconds to turn the vibrator
- * off or to turn the vibrator on.
- *
- * @param {Integer} repeat Optional index into the pattern
array at which
- * to start repeating (will repeat
until canceled),
- * or -1 for no repetition (default).
- */
- vibrateWithPattern: function (pattern, repeat) {
- repeat = (typeof repeat !== 'undefined') ? repeat : -1;
- pattern = pattern.unshift(0); // add a 0 at beginning for backwards
compatibility from w3c spec
- exec(null, null, 'Vibration', 'vibrateWithPattern', [pattern, repeat]);
- },
-
- /**
- * Immediately cancels any currently running vibration.
- */
- cancelVibration: function () {
- exec(null, null, 'Vibration', 'cancelVibration', []);
}
};
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Drop android implementation of cordova-plugin-vibration
> -------------------------------------------------------
>
> Key: CB-13045
> URL: https://issues.apache.org/jira/browse/CB-13045
> Project: Apache Cordova
> Issue Type: Task
> Components: cordova-plugin-vibration
> Reporter: Filip Maj
> Assignee: Vishal Mishra
> Labels: plugins-next
>
> Android webviews should support this API natively now. WE should test which
> Android versions support this and if its feasible. If it is, the minimum
> Android version it supports should also give us a good hint as to which
> minimum cordova-android versions the new version of this plugin could support.
> This will require a major version bump for the plugin.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]