'初始化提交'

This commit is contained in:
2025-08-11 22:55:39 +08:00
parent 3deaf322c6
commit 9ec6daa82b
212 changed files with 45916 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
# appveyor file
# http://www.appveyor.com/docs/appveyor-yml
max_jobs: 1
shallow_clone: true
init:
- git config --global core.autocrlf true
image:
- Visual Studio 2017
environment:
nodejs_version: "4"
matrix:
- PLATFORM: windows-10-store
JUST_BUILD: --justBuild
install:
- npm cache clean -f
- node --version
- npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git
- npm install -g cordova
build: off
test_script:
- cordova-paramedic --config pr\%PLATFORM% --plugin . %JUST_BUILD%

View File

@@ -0,0 +1,10 @@
root: true
extends: semistandard
rules:
indent:
- error
- 4
camelcase: off
padded-blocks: off
operator-linebreak: off
no-throw-literal: off

View File

@@ -0,0 +1,42 @@
<!--
Please have a look at the issue templates you get when you click "New issue" in the GitHub UI.
We very much prefer issues created by using one of these templates.
-->
### Issue Type
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
- [ ] Bug Report
- [ ] Feature Request
- [ ] Support Question
## Description
## Information
<!-- Include all relevant information that might help understand and reproduce the problem -->
### Command or Code
<!-- What command or code is needed to reproduce the problem? -->
### Environment, Platform, Device
<!-- In what environment, on what platform or on which device are you experiencing the issue? -->
### Version information
<!--
What are relevant versions you are using?
For example:
Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
Other Frameworks: Ionic Framework and CLI version
Operating System, Android Studio, Xcode etc.
-->
## Checklist
<!-- Please check the boxes by putting an `x` in the `[ ]` like so: `[x]` -->
- [ ] I searched for already existing GitHub issues about this
- [ ] I updated all Cordova tooling to their most recent version
- [ ] I included all the necessary information above

View File

@@ -0,0 +1,50 @@
---
name: 🐛 Bug Report
about: If something isn't working as expected.
---
# Bug Report
## Problem
### What is expected to happen?
### What does actually happen?
## Information
<!-- Include all relevant information that might help understand and reproduce the problem -->
### Command or Code
<!-- What command or code is needed to reproduce the problem? -->
### Environment, Platform, Device
<!-- In what environment, on what platform or on which device are you experiencing the issue? -->
### Version information
<!--
What are relevant versions you are using?
For example:
Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
Other Frameworks: Ionic Framework and CLI version
Operating System, Android Studio, Xcode etc.
-->
## Checklist
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
- [ ] I searched for existing GitHub issues
- [ ] I updated all Cordova tooling to most recent version
- [ ] I included all the necessary information above

View File

@@ -0,0 +1,29 @@
---
name: 🚀 Feature Request
about: A suggestion for a new functionality
---
# Feature Request
## Motivation Behind Feature
<!-- Why should this feature be implemented? What problem does it solve? -->
## Feature Description
<!--
Describe your feature request in detail
Please provide any code examples or screenshots of what this feature would look like
Are there any drawbacks? Will this break anything for existing users?
-->
## Alternatives or Workarounds
<!--
Describe alternatives or workarounds you are currently using
Are there ways to do this with existing functionality?
-->

View File

@@ -0,0 +1,27 @@
---
name: 💬 Support Question
about: If you have a question, please check out our Slack or StackOverflow!
---
<!------------^ Click "Preview" for a nicer view! -->
Apache Cordova uses GitHub Issues as a feature request and bug tracker _only_.
For usage and support questions, please check out the resources below. Thanks!
---
You can get answers to your usage and support questions about **Apache Cordova** on:
* Slack Community Chat: https://cordova.slack.com (you can sign-up at http://slack.cordova.io/)
* StackOverflow: https://stackoverflow.com/questions/tagged/cordova using the tag `cordova`
---
If you are using a tool that uses Cordova internally, like e.g. Ionic, check their support channels:
* **Ionic Framework**
* [Ionic Community Forum](https://forum.ionicframework.com/)
* [Ionic Worldwide Slack](https://ionicworldwide.herokuapp.com/)
* **PhoneGap**
* [PhoneGap Developer Community](https://forums.adobe.com/community/phonegap)

View File

@@ -0,0 +1,35 @@
<!--
Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines:
http://cordova.apache.org/contribute/contribute_guidelines.html
Thanks!
-->
### Platforms affected
### Motivation and Context
<!-- Why is this change required? What problem does it solve? -->
<!-- If it fixes an open issue, please link to the issue here. -->
### Description
<!-- Describe your changes in detail -->
### Testing
<!-- Please describe in detail how you tested your changes. -->
### Checklist
- [ ] I've run the tests to see all new and existing tests pass
- [ ] I added automated test coverage as appropriate for this change
- [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
- [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
- [ ] I've updated the documentation if necessary

View File

@@ -0,0 +1,2 @@
tokenizer.cpp
tokenizer.h

View File

@@ -0,0 +1,115 @@
sudo: false
addons:
jwt:
# sauce labs key
secure: jVSvu9mlFqqifMcAQpEg+rWYDG43wzTovyptz097PQk/JXGX7TKd90aBWyE3ef/Qbjq+OV7PDxSRTUQwuMXhE9+FUYQs6PiW62CmDMwumForaV2NVbmoTREl1gQIgenx++bdWSN+V5ebh6iLj58ZUxZeSAZBsfM6a+G++w5QptU=
env:
global:
- SAUCE_USERNAME=snay
- TRAVIS_NODE_VERSION=6
- ANDROID_API_LEVEL=28
- ANDROID_BUILD_TOOLS_VERSION=28.0.3
language: node_js
node_js: 6
# yaml anchor/alias: https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027
_ios: &_ios
os: osx
osx_image: xcode10.2
_android: &_android
language: android
os: linux
jdk: oraclejdk8
android:
components:
- tools
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
- android-$ANDROID_API_LEVEL
licenses:
- 'android-sdk-preview-license-.+'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
matrix:
include:
# local tests, without saucelabs
- env: PLATFORM=local/browser
<<: *_ios
- env: PLATFORM=local/ios-10.0
<<: *_ios
# many tests with saucelabs
- env: PLATFORM=browser-chrome
- env: PLATFORM=browser-firefox
- env: PLATFORM=browser-safari
- env: PLATFORM=browser-edge
- env: PLATFORM=ios-11.3
<<: *_ios
- env: PLATFORM=ios-12.0
<<: *_ios
- env: PLATFORM=ios-12.2
<<: *_ios
- env: PLATFORM=android-4.4
<<: *_android
- env: PLATFORM=android-5.1
<<: *_android
- env: PLATFORM=android-6.0
<<: *_android
- env: PLATFORM=android-7.0
<<: *_android
- env: PLATFORM=android-7.1
<<: *_android
- env: PLATFORM=android-8.0
<<: *_android
- env: PLATFORM=android-8.1
<<: *_android
before_install:
# manually install Node for `language: android`
- if [[ "$PLATFORM" =~ android ]]; then nvm install $TRAVIS_NODE_VERSION; fi
- node --version
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
- npm install -g cordova
# install paramedic if not running on paramedic repo
- if ! [[ "$TRAVIS_REPO_SLUG" =~ cordova-paramedic ]]; then npm install -g github:apache/cordova-paramedic; fi
install:
- npm install
before_script:
- |
if [[ "$TRAVIS_REPO_SLUG" =~ cordova-paramedic ]]; then
# when used in the cordova-paramedic repo
TEST_COMMAND="npm run eslint"
PARAMEDIC_PLUGIN_TO_TEST="./spec/testable-plugin/"
PARAMEDIC_COMMAND="node main.js"
else
# when used in any other (plugin) repo
TEST_COMMAND="npm test"
PARAMEDIC_PLUGIN_TO_TEST=$(pwd)
PARAMEDIC_COMMAND="cordova-paramedic"
fi
- PARAMEDIC_BUILDNAME=travis-$TRAVIS_REPO_SLUG-$TRAVIS_JOB_NUMBER
- |
echo "Variables now are set to:"
echo "TEST_COMMAND=$TEST_COMMAND"
echo "ADDITIONAL_TESTS=$ADDITIONAL_TESTS"
echo "PARAMEDIC_COMMAND=$PARAMEDIC_COMMAND"
echo "PLATFORM=$PLATFORM"
echo "PARAMEDIC_PLUGIN_TO_TEST=$PARAMEDIC_PLUGIN_TO_TEST"
echo "PARAMEDIC_BUILDNAME=$PARAMEDIC_BUILDNAME"
script:
- $TEST_COMMAND
- if [[ "$ADDITIONAL_TESTS_DIR" != "" ]]; then
cd $ADDITIONAL_TESTS_DIR && npm install && npm test;
else
$PARAMEDIC_COMMAND --config ./pr/$PLATFORM --plugin $PARAMEDIC_PLUGIN_TO_TEST --buildName $PARAMEDIC_BUILDNAME;
fi

View File

@@ -0,0 +1,37 @@
<!--
#
# 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.
#
-->
# Contributing to Apache Cordova
Anyone can contribute to Cordova. And we need your contributions.
There are multiple ways to contribute: report bugs, improve the docs, and
contribute code.
For instructions on this, start with the
[contribution overview](http://cordova.apache.org/contribute/).
The details are explained there, but the important items are:
- Sign and submit an Apache ICLA (Contributor License Agreement).
- Have a Jira issue open that corresponds to your contribution.
- Run the tests so your patch doesn't break existing functionality.
We look forward to your contributions!

View File

@@ -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 File

@@ -0,0 +1,7 @@
Apache Cordova
Copyright 2012 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
This product includes software developed by Joerg Wiedenmann under the zlib license (http://www.gzip.org/zlib/zlib_license.html)

View File

@@ -0,0 +1,136 @@
---
title: Vibration
description: Vibrate the device.
---
<!--
# 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.
-->
|AppVeyor|Travis CI|
|:-:|:-:|
|[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-vibration?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-vibration)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-vibration.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-vibration)|
# cordova-plugin-vibration
This plugin aligns with the W3C vibration specification http://www.w3.org/TR/vibration/
This plugin provides a way to vibrate the device.
This plugin defines global objects including `navigator.vibrate`.
Although in the global scope, they are not available until after the `deviceready` event.
```javascript
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(navigator.vibrate);
}
```
## Installation
```console
cordova plugin add cordova-plugin-vibration
```
## Supported Platforms
navigator.vibrate
- Android
- iOS
- Windows
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.
### Standard vibrate
Vibrates the device for a given amount of time.
```javascript
navigator.vibrate(time)
```
or
```javascript
navigator.vibrate([time])
```
-__time__: Milliseconds to vibrate the device. _(Number)_
#### Example
```javascript
// Vibrate for 3 seconds
navigator.vibrate(3000);
// Vibrate for 3 seconds
navigator.vibrate([3000]);
```
### Android Quirks
Calls to `navigator.vibrate` will immediately return `false` if user hasn't tapped on the frame or any embedded frame yet. Please checkout https://issues.apache.org/jira/browse/CB-14022 for more information.
#### iOS Quirks
- __time__: Ignores the specified time and vibrates for a pre-set amount of time.
```javascript
navigator.vibrate(3000); // 3000 is ignored
```
#### Windows Quirks
- __time__: Max time is 5000ms (5s) and min time is 1ms
```javascript
navigator.vibrate(8000); // will be truncated to 5000
```
### Vibrate with a pattern (Android and Windows only)
Vibrates the device with a given pattern
```javascript
navigator.vibrate(pattern);
```
- __pattern__: Sequence of durations (in milliseconds) for which to turn on or off the vibrator. _(Array of Numbers)_
#### Example
```javascript
// Vibrate for 1 second
// Wait for 1 second
// Vibrate for 3 seconds
// Wait for 1 second
// Vibrate for 5 seconds
navigator.vibrate([1000, 1000, 3000, 1000, 5000]);
```
### Cancel vibration (not supported in iOS)
Immediately cancels any currently running vibration.
```javascript
navigator.vibrate(0)
```
or
```javascript
navigator.vibrate([])
```
or
```javascript
navigator.vibrate([0])
```
Passing in a parameter of 0, an empty array, or an array with one element of value 0 will cancel any vibrations.

View File

@@ -0,0 +1,198 @@
<!--
#
# 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
### 3.1.1 (May 16, 2019)
* Update CI configuration and README ([#80](https://github.com/apache/cordova-plugin-vibration/pull/80), [#77](https://github.com/apache/cordova-plugin-vibration/pull/77), [#69](https://github.com/apache/cordova-plugin-vibration/pull/69), [#68](https://github.com/apache/cordova-plugin-vibration/pull/68))
* fix(typescript): update types ([#75](https://github.com/apache/cordova-plugin-vibration/pull/75), [#78](https://github.com/apache/cordova-plugin-vibration/pull/78))
* Add or update GitHub pull request and issue template
### 3.1.0 (Apr 12, 2018)
* [CB-14022](https://issues.apache.org/jira/browse/CB-14022) documented **Android** quirk with vibration
* [CB-13892](https://issues.apache.org/jira/browse/CB-13892) (all) Remove `navigator.notification`
### 3.0.1 (Dec 27, 2017)
* [CB-13711](https://issues.apache.org/jira/browse/CB-13711) Fix to allow 3.0.0 version install (#63)
### 3.0.0 (Dec 15, 2017)
* [CB-13666](https://issues.apache.org/jira/browse/CB-13666) : Removed deprecated platforms
* Removed deprecated components and bumped version
* [CB-13045](https://issues.apache.org/jira/browse/CB-13045) Removed **Android** implementation and Updated `README`
### 2.1.6 (Nov 06, 2017)
* [CB-12895](https://issues.apache.org/jira/browse/CB-12895) added `eslint` and removed `jshint`
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
### 2.1.5 (Apr 27, 2017)
* [CB-12622](https://issues.apache.org/jira/browse/CB-12622) Added **Android 6.0** build badge to `README`
* [CB-12685](https://issues.apache.org/jira/browse/CB-12685) added `package.json` to tests folder
### 2.1.4 (Feb 28, 2017)
* fix `vibrateWithPattern`, function doesn't update the pattern variable reference
* [CB-12369](https://issues.apache.org/jira/browse/CB-12369) Add plugin typings from `DefinitelyTyped`
* [CB-12363](https://issues.apache.org/jira/browse/CB-12363) Added build badges for **iOS 9.3** and **iOS 10.0**
* [CB-12230](https://issues.apache.org/jira/browse/CB-12230) Removed **Windows 8.1** build badges
### 2.1.3 (Dec 07, 2016)
* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Updated version and RELEASENOTES.md for release 2.1.3
* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been submitted…"
* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
### 2.1.2 (Sep 08, 2016)
* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
* add JIRA issue tracker link
* Add badges for paramedic builds on Jenkins
* Add pull request template.
* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
### 2.1.1 (Apr 15, 2016)
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins
### 2.1.0 (Jan 15, 2016)
* [CB-9365](https://issues.apache.org/jira/browse/CB-9365) Add support for 'vibrateWithPattern' to **Windows Phone 8.1 / Windows 10**
### 2.0.0 (Nov 18, 2015)
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
* Fixing contribute link.
* Fixed **browser** platform to pass tests and combined tests
* Removed call to add `proxy` and renamed **browser** file
* [CB-7966](https://issues.apache.org/jira/browse/CB-7966) Add cordova-plugin-vibration support for **browser** platform
* [CB-9166](https://issues.apache.org/jira/browse/CB-9166): Changed `plugin.xml` framework reference condition to be valid XML.
### 1.2.0 (Jun 17, 2015)
* Adding .ratignore file.
* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-vibration documentation translation: cordova-plugin-vibration
* fix npm md issue
* used min/max statics in vibrate with pattern. Use callbackId in callbacks, catch json format exceptions
* static-ized MIN_DURATION and MAX_DURATION
* [CB-7216](https://issues.apache.org/jira/browse/CB-7216) changed cancelWasCalled boolean
* [CB-7218](https://issues.apache.org/jira/browse/CB-7218) truncate vibration to 5 secs for WP8
* [CB-6916](https://issues.apache.org/jira/browse/CB-6916) added vibrateWithPattern for wp8
* [CB-6914](https://issues.apache.org/jira/browse/CB-6914) added cancelVibration for wp8
* android: respect silent audio setting
### 1.1.0 (May 06, 2015)
* [CB-8930](https://issues.apache.org/jira/browse/CB-8930): Vibration on **Windows** fails without a helpful error message when vibration functionality is missing from the platform. This detects such a case and instead fails gracefully that the feature isn't available. Also supports the **Windows 10** vibration mechanism.
### 1.0.0 (Apr 15, 2015)
* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump
* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id
* [CB-7970](https://issues.apache.org/jira/browse/CB-7970) Reference proxy project instead of compiled winmd
* [CB-7970](https://issues.apache.org/jira/browse/CB-7970) Add cordova-plugin-vibration support for Windows Phone 8.1
* Use TRAVIS_BUILD_DIR, install paramedic by npm
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme
* [CB-8576](https://issues.apache.org/jira/browse/CB-8576) Integrate TravisCI
* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-vibration documentation translation: cordova-plugin-vibration
* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
### 0.3.13 (Feb 04, 2015)
* [CB-8243](https://issues.apache.org/jira/browse/CB-8243) cordova-plugin-vibration documentation translation: cordova-plugin-vibration
### 0.3.12 (Dec 02, 2014)
* [CB-8018](https://issues.apache.org/jira/browse/CB-8018) Add `vibrate(pattern)` fallback on vibrate for **Windows Phone 8**
* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs
* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-vibration documentation translation: cordova-plugin-vibration
* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin
### 0.3.11 (Sep 17, 2014)
* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-vibration documentation translation
* [CB-6724](https://issues.apache.org/jira/browse/CB-6724) documented Windows support for vibrate with pattern and cancel vibrate in manual test doc and moved tests to tests dir
* add longer pattern sequence for testing, change expected result for old vibrate with pattern test
* added more test cases, changed vibrate with pattern durations, changed where vibrateOn is set to true
* clear settimeout when user cancels vibration
* add setTimeout function to update vibrateOn var if user doesn't cancel vibrate, add note about iOS
* on/off button for cancel tests, add results box and msgs
* added tests for old vibrateWithPattern and cancelVibration calls
* added 'Android only' to buttons for specific tests, changed where console.log is executed for user to see earlier
* added tests to ensure compliance with w3c spec
* [CB-6963](https://issues.apache.org/jira/browse/CB-6963) ported vibration automated & manual tests
* [CB-6966](https://issues.apache.org/jira/browse/CB-6966) renamed folder to tests + added nested plugin.xml
* [CB-6966](https://issues.apache.org/jira/browse/CB-6966) Ported Vibration automated & manual tests
* removed duplicate messaging
* [CB-5459](https://issues.apache.org/jira/browse/CB-5459) slight change to the vibration documentation for pattern due to merge issue
* changes to how 0 is getting added to array in order to align with w3c spec
* changes to vibration.java to align with w3c, changes to vibration.js for backwards compatibility
* changes made to align with w3c spec
* Updated doc with Windows support for vibrate with pattern
* Added note to doc about w3c alignment and min time for Windows
* update doc with another way to cancel vibration
* update doc to show vibrate([num]) is a standard vibrate
* vibrate([num]) is treated as a vibrate not vibrate with pattern
* added new example to documentation
* updated doc for w3c alignment
* changes to how 0 is getting added to array in order to align with w3c spec
* changes to vibration.java to align with w3c, changes to vibration.js for backwards compatibility
* changes made to align with w3c spec
### 0.3.10 (Aug 06, 2014)
* ubuntu: Implemented vibrateWithPattern/cancelVibration
* **FFOS** update VibrationProxy.js
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs
### 0.3.9 (Jun 05, 2014)
* updated notice file
* Github close #11
* Extended vibrateWithPattern to allow for pattern repetition, implemented a complementary cancelVibration function and adapted documentation.
* Implemented vibrateWithPattern (for android) and adapted documentation.
* [CB-6811](https://issues.apache.org/jira/browse/CB-6811) Add license to CONTRIBUTING.md
* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
### 0.3.8 (Apr 17, 2014)
* [CB-6465](https://issues.apache.org/jira/browse/CB-6465): Add license headers to Tizen code
* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers
* Add NOTICE file
### 0.3.7 (Feb 05, 2014)
* Add support for Tizen.
* [CB-3206](https://issues.apache.org/jira/browse/CB-3206) - Supported platforms updated
### 0.3.6 (Jan 02, 2014)
* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Vibration plugin
### 0.3.5 (Dec 4, 2013)
* add ubuntu platform
* Added amazon-fireos platform. Change to include amazon-fireos as a platform if the user agent string contains 'cordova-amazon-fireos'
* [CB-4747](https://issues.apache.org/jira/browse/CB-4747) Fixed Blackberry background vibrate
### 0.3.4 (Oct 28, 2013)
* add repo + issue tag to plugin.xml for vibration plugin
* corrected plugin.xml to write properly to config.xml for ffos
* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Incremented plugin version on dev branch.
### 0.3.3 (Oct 9, 2013)
* add missing android namespace
* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch.
### 0.3.2 (Sept 25, 2013)
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.vibration to org.apache.cordova.vibration
* Rename CHANGELOG.md -> RELEASENOTES.md
* updated to work with ffos commandProxy
* fixed plugin.xml for vibration
* [CB-4593](https://issues.apache.org/jira/browse/CB-4593) [Blackberry10] Added vibration support for bb10
* updated plugin to work with ffos
* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch.
### 0.3.0 (Sept 5, 2013)
* Initial FirefoxOS support
* [CB-4661](https://issues.apache.org/jira/browse/CB-4661) VIBRATE permission for Android

View File

@@ -0,0 +1,51 @@
{
"name": "cordova-plugin-vibration",
"version": "3.1.1",
"description": "Cordova Vibration Plugin",
"types": "./types/index.d.ts",
"cordova": {
"id": "cordova-plugin-vibration",
"platforms": [
"android",
"ios",
"windows"
]
},
"repository": {
"type": "git",
"url": "https://github.com/apache/cordova-plugin-vibration"
},
"bugs": {
"url": "https://issues.apache.org/jira/browse/CB"
},
"keywords": [
"cordova",
"vibration",
"ecosystem:cordova",
"cordova-android",
"cordova-ios",
"cordova-windows"
],
"scripts": {
"test": "npm run eslint",
"eslint": "eslint www && eslint src && eslint tests"
},
"author": "Apache Software Foundation",
"license": "Apache-2.0",
"engines": {
"cordovaDependencies": {
"4.0.0": {
"cordova": ">100"
}
}
},
"devDependencies": {
"eslint": "^4.0.0",
"eslint-config-semistandard": "^11.0.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-node": "^5.0.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1"
}
}

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-vibration"
version="3.1.1">
<name>Vibration</name>
<description>Cordova Vibration Plugin</description>
<license>Apache 2.0</license>
<keywords>cordova,vibration</keywords>
<repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration.git</repo>
<issue>https://issues.apache.org/jira/browse/CB/component/12320639</issue>
<!-- android -->
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.VIBRATE"/>
</config-file>
</platform>
<!-- ios -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="Vibration">
<param name="ios-package" value="CDVVibration"/>
</feature>
</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" />
</js-module>
<framework src="AudioToolbox.framework" weak="true" />
</platform>
<!-- windows -->
<platform name="windows">
<js-module src="src/windows/VibrationProxy.js" name="VibrationProxy">
<runs />
</js-module>
<js-module src="www/vibration.js" name="notification">
<merges target="navigator" />
</js-module>
<framework src="src/windows/Vibration/Vibration.csproj" target="phone"
type="projectReference" custom="true" versions="&lt;10.0.0" />
</platform>
<!-- browser -->
<platform name="browser">
<js-module src="src/browser/Vibration.js" name="Vibration">
<merges target="navigator" />
</js-module>
<js-module src="www/vibration.js" name="notification">
<merges target="navigator" />
</js-module>
</platform>
</plugin>

View File

@@ -0,0 +1,27 @@
/*
*
* 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.
*
*/
module.exports = {
vibrate: function (success, fail, milliseconds) {
console.log('Vibration is not supported');
return false;
}
};

View File

@@ -0,0 +1,29 @@
/*
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 <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioServices.h>
#import <Cordova/CDVPlugin.h>
@interface CDVVibration : CDVPlugin {}
- (void)vibrate:(CDVInvokedUrlCommand*)command;
@end

View File

@@ -0,0 +1,29 @@
/*
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 "CDVVibration.h"
@implementation CDVVibration
- (void)vibrate:(CDVInvokedUrlCommand*)command
{
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
@end

View File

@@ -0,0 +1,44 @@
/*
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.
*/
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Vibration")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Vibration")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,55 @@
/*
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.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using Windows.Phone.Devices.Notification;
namespace Vibration
{
public sealed class Vibration
{
private static VibrationDevice _vibrationDevice = VibrationDevice.GetDefault();
public static void vibrate([ReadOnlyArray()] object[] args)
{
// set default
int duration = 200;
try
{
duration = Convert.ToInt32(args[0]);
}
catch
{
}
_vibrationDevice.Vibrate(TimeSpan.FromMilliseconds(duration));
}
public static void cancelVibration()
{
_vibrationDevice.Cancel();
}
}
}

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D4F9F695-ECD5-49FC-B58A-B1E0E754E159}</ProjectGuid>
<ProjectName>Vibration</ProjectName>
<OutputType>winmdobj</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vibration</RootNamespace>
<AssemblyName>Vibration</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{76F1466A-8B6D-4E39-A767-685A06062A39};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetPlatformIdentifier>WindowsPhoneApp</TargetPlatformIdentifier>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
</ItemGroup>
<ItemGroup>
<Compile Include="Vibration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,253 @@
/*
*
* 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.
*
*/
/* global Windows, WinJS, Vibration */
function checkReqs (actionName, fail) {
if (!(Windows.Phone && Windows.Phone.Devices && Windows.Phone.Devices.Notification && Windows.Phone.Devices.Notification.VibrationDevice) && WinJS.Utilities.isPhone !== true) {
fail(actionName + ' is unsupported by this platform.');
return false;
}
return true;
}
function tryDoAction (actionName, success, fail, args, action) {
try {
if (checkReqs(actionName, fail) !== true) {
return;
}
action(args);
success();
} catch (e) {
fail('Error occured while trying to ' + actionName + ': ' + e);
}
}
/**
* @typedef patternParsingResult
* @type {Object}
* @property {Array} result.parsed - Array with parsed integers
* @property {Boolean} result.passed - false in case of parsing error
* @property {*} result.failedItem - The item, which could not be parsed
*/
/**
* Tries to convert pattern values to int
* @param {Array} pattern Array of delays
* @returns {patternParsingResult} result
*/
function tryParsePatternValues (pattern) {
var passed = true;
var failedItem;
pattern = pattern.map(function (item) {
var num = parseInt(item, 10);
if (isNaN(num)) {
failedItem = item;
passed = false;
}
return num;
});
return {
parsed: pattern,
passed: passed,
failedItem: failedItem
};
}
/**
* @typedef checkPatternReqsResult
* @type {Object}
* @property {Array} result.patternParsingResult - Array with parsed integers
* @property {Boolean} result.passed - true if all params are OK
*/
/**
* Checks params for vibrateWithPattern function
* @return {checkPatternReqsResult}
*/
function checkPatternReqs (args, fail) {
var patternParsingResult = tryParsePatternValues(args[0]);
var repeat = args[1];
var passed = true;
var errMsg = '';
if (!patternParsingResult.passed) {
errMsg += 'Could not parse ' + patternParsingResult.failedItem + ' in the vibration pattern';
passed = false;
}
if (repeat !== -1 && (repeat < 0 || repeat > args[0].length - 1)) {
errMsg += '\nrepeat parameter is out of range: ' + repeat;
passed = false;
}
if (!passed) {
console.error(errMsg);
if (fail) {
fail(errMsg);
}
}
return {
passed: passed,
patternParsingResult: patternParsingResult
};
}
/**
* vibrateWithPattern with `repeat` support
* @param {Array} patternArr Full pattern array
* @param {Boolean} shouldRepeat Indication on whether the vibration should be cycled
* @param {Function} fail Fail callback
* @param {Array} patternCycle Cycled part of the pattern array
* @return {Promise} Promise chaining single vibrate/pause actions
*/
function vibratePattern (patternArr, shouldRepeat, fail, patternCycle) {
return patternArr.reduce(function (previousValue, currentValue, index) {
if (index % 2 === 0) {
return previousValue.then(function () {
module.exports.vibrate(function () { }, function (err) {
console.error(err);
if (fail) {
fail(err);
}
}, [currentValue]);
if (index === patternArr.length - 1 && shouldRepeat) {
return WinJS.Promise.timeout(currentValue).then(function () {
return vibratePattern(patternCycle, true, fail, patternCycle);
});
} else {
return WinJS.Promise.timeout(currentValue);
}
});
} else {
return previousValue.then(function () {
if (index === patternArr.length - 1 && shouldRepeat) {
return WinJS.Promise.timeout(currentValue).then(function () {
return vibratePattern(patternCycle, true, fail, patternCycle);
});
} else {
return WinJS.Promise.timeout(currentValue);
}
});
}
}, WinJS.Promise.as());
}
var DEFAULT_DURATION = 200;
var patternChainPromise;
var VibrationDevice = (Windows.Phone && Windows.Phone.Devices && Windows.Phone.Devices.Notification && Windows.Phone.Devices.Notification.VibrationDevice && Windows.Phone.Devices.Notification.VibrationDevice);
if (VibrationDevice) {
// Windows Phone 10 code paths
module.exports = {
vibrate: function (success, fail, args) {
try {
var duration = parseInt(args[0]);
if (isNaN(duration)) {
duration = DEFAULT_DURATION;
}
VibrationDevice.getDefault().vibrate(duration);
success();
} catch (e) {
fail(e);
}
},
vibrateWithPattern: function (success, fail, args) {
// Cancel current vibrations first
module.exports.cancelVibration(function () {
var checkReqsResult = checkPatternReqs(args, fail);
if (!checkReqsResult.passed) {
return;
}
var pattern = checkReqsResult.patternParsingResult.parsed;
var repeatFromIndex = args[1];
var shouldRepeat = (repeatFromIndex !== -1);
var patternCycle;
if (shouldRepeat) {
patternCycle = pattern.slice(repeatFromIndex);
}
patternChainPromise = vibratePattern(pattern, shouldRepeat, fail, patternCycle);
}, fail);
},
cancelVibration: function (success, fail, args) {
try {
if (patternChainPromise) {
patternChainPromise.cancel();
}
VibrationDevice.getDefault().cancel();
if (success) {
success();
}
} catch (e) {
if (fail) {
fail(e);
}
}
}
};
} else if (typeof Vibration !== 'undefined' && Vibration.Vibration) {
// Windows Phone 8.1 code paths
module.exports = {
vibrate: function (success, fail, args) {
tryDoAction('vibrate', success, fail, args, Vibration.Vibration.vibrate);
},
vibrateWithPattern: function (success, fail, args) {
tryDoAction('vibrate', success, fail, [DEFAULT_DURATION], Vibration.Vibration.vibrate);
},
cancelVibration: function (success, fail, args) {
tryDoAction('cancelVibration', success, fail, args, Vibration.Vibration.cancelVibration);
}
};
} else {
// code paths where no vibration mechanism is present
module.exports = {
vibrate: function (success, fail) {
if (fail) {
fail('"vibrate" is unsupported by this device.');
}
},
vibrateWithPattern: function (success, fail, args) {
if (fail) {
fail('"vibrateWithPattern" is unsupported by this device.');
}
},
cancelVibration: function (success, fail, args) {
if (success) {
success();
}
}
};
}
require('cordova/exec/proxy').add('Vibration', module.exports);

View File

@@ -0,0 +1,14 @@
{
"name": "cordova-plugin-vibration-tests",
"version": "3.1.1",
"description": "",
"cordova": {
"id": "cordova-plugin-vibration-tests",
"platforms": []
},
"keywords": [
"ecosystem:cordova"
],
"author": "",
"license": "Apache 2.0"
}

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:rim="http://www.blackberry.com/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-vibration-tests"
version="3.1.1">
<name>Cordova Vibration Plugin Tests</name>
<license>Apache 2.0</license>
<js-module src="tests.js" name="tests">
</js-module>
</plugin>

View File

@@ -0,0 +1,213 @@
/*
*
* 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.
*
*/
/* eslint-env jasmine */
exports.defineManualTests = function (contentEl, createActionButton) {
var logMessage = function (message, color) {
var log = document.getElementById('info');
var logLine = document.createElement('div');
if (color) {
logLine.style.color = color;
}
logLine.innerHTML = message;
log.appendChild(logLine);
};
var clearLog = function () {
var log = document.getElementById('info');
log.innerHTML = '';
};
// -------------------------------------------------------------------------
// Vibrations
// -------------------------------------------------------------------------
// new standard vibrate call that aligns to w3c spec with param long
var vibrateWithInt = function () {
clearLog();
navigator.vibrate(3000);
logMessage('navigator.vibrate(3000)', 'green');
};
// new standard vibrate call that aligns to w3c spec with param array
var vibrateWithArray = function () {
clearLog();
navigator.vibrate([3000]);
logMessage('navigator.vibrate([3000])', 'green');
};
// vibrate with a pattern using w3c spec
var vibrateWithPattern = function () {
clearLog();
navigator.vibrate([1000, 2000, 3000, 2000, 5000]);
logMessage('navigator.vibrate([1000, 2000, 3000, 2000, 5000])', 'green');
};
// cancel existing vibration using w3c spec navigator.vibrate(0)
var cancelWithZero = function () {
clearLog();
navigator.vibrate(0);
logMessage('navigator.vibrate(0)', 'green');
};
// cancel existing vibration using w3c spec navigator.vibrate([])
var cancelWithEmpty = function () {
clearLog();
navigator.vibrate([]);
logMessage('navigator.vibrate([])', 'green');
};
// reference to the timeout variable
var timeout;
// check whether there is an ongoing vibration
var vibrateOn = false;
// special long vibrate used to test cancel
var longVibrate = function () {
clearLog();
navigator.vibrate(60000);
vibrateOn = true;
logMessage('navigator.vibrate(60000)', 'green');
timeout = setTimeout(resetVibrateOn, 60000); // if user doesn't cancel vibrate, reset vibrateOn var after 60 seconds
};
// special long vibrate with pattern used to test cancel
var longVibrateWithPattern = function () {
clearLog();
navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000]);
vibrateOn = true;
logMessage('navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000])', 'green');
timeout = setTimeout(resetVibrateOn, 45000); // if user doesn't cancel vibrate, reset vibrateOn var after 45 seconds
};
// initiate two vibrations to test cancel
var multipleVibrations = function () {
clearLog();
navigator.vibrate(20000);
navigator.vibrate(45000);
vibrateOn = true;
logMessage('navigator.vibrate(15000)\nnavigator.vibrate(45000)', 'green');
timeout = setTimeout(resetVibrateOn, 45000); // if user doesn't cancel vibrate, reset vibrateOn var after 45 seconds
};
function resetVibrateOn () {
vibrateOn = false;
}
var vibrate_tests = '<h1>Vibrate Tests</h1>' +
'<h3>Starred tests only work for Android and Windows. </h3>' +
'<h3>iOS ignores the time given for a vibrate </h3>' +
'<p/> <div id="vibrate_int"></div>' +
'Expected result: Vibrate once for 3 seconds.' +
'<p/> <div id="vibrate_array"></div>' +
'Expected result: Vibrate once for 3 seconds.' +
'<p/> <div id="vibrate_with_pattern"></div>' +
'Expected result: Vibrate for 1s, pause for 2s, vibrate for 3s, pause for 2s, vibrate for 5s.' +
'<p/> <div id="cancel_zero"></div>' +
'Expected result: Press once to initiate vibrate for 60 seconds. Press again to cancel vibrate immediately.' +
'<p/><div id="cancel_array"></div>' +
'Expected result: Press once to initiate vibrate for 60 seconds. Press again to cancel vibrate immediately.' +
'<p/> <div id="cancelWithPattern_zero"></div>' +
'Expected result: Press once to initiate vibrate with pattern for 45s. Press again to cancel vibrate immediately.' +
'<p/> <div id="cancelWithPattern_array"></div>' +
'Expected result: Press once to initiate vibrate with pattern for 45s. Press again to cancel vibrate immediately.' +
'<p/> <div id="cancelMultipleVibrations"></div>' +
'Expected result: Press once to initiate two vibrations simultaneously (one for 20s the other for 45s so total of 45s). Press again to cancel both vibrations immediately.';
contentEl.innerHTML = '<div id="info"></div>' + vibrate_tests;
// standard vibrate with new call param int
createActionButton('Vibrate with int', function () {
vibrateWithInt();
}, 'vibrate_int');
// standard vibrate with new call param array
createActionButton('Vibrate with array', function () {
vibrateWithArray();
}, 'vibrate_array');
// vibrate with a pattern
createActionButton('* Vibrate with a pattern', function () {
vibrateWithPattern();
}, 'vibrate_with_pattern');
// cancel any existing vibrations with param 0
createActionButton('* Cancel vibration with 0', function () {
if (!vibrateOn) {
longVibrate();
} else {
cancelWithZero();
resetVibrateOn();
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate
}
}, 'cancel_zero');
// cancel any existing vibrations with param []
createActionButton('* Cancel vibration with []', function () {
if (!vibrateOn) {
longVibrate();
} else {
cancelWithEmpty();
resetVibrateOn();
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate
}
}, 'cancel_array');
// cancel vibration with pattern with param 0
createActionButton('* Cancel vibration with pattern with 0', function () {
if (!vibrateOn) {
longVibrateWithPattern();
} else {
cancelWithZero();
resetVibrateOn();
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate
}
}, 'cancelWithPattern_zero');
// cancel vibration with pattern with param []
createActionButton('* Cancel vibration with pattern with []', function () {
if (!vibrateOn) {
longVibrateWithPattern();
} else {
cancelWithEmpty();
resetVibrateOn();
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate
}
}, 'cancelWithPattern_array');
// cancel multiple vibrations
createActionButton('* Cancel multiple vibrations', function () {
if (!vibrateOn) {
multipleVibrations();
} else {
cancelWithZero();
resetVibrateOn();
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate
}
}, 'cancelMultipleVibrations');
};

View File

@@ -0,0 +1,22 @@
// Type definitions for cordova-plugin-vibration 3.1
// Project: https://github.com/apache/cordova-plugin-vibration
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Louis Lagrange <https://github.com/Minishlink>
// Tim Brust <https://github.com/timbru31>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Navigator {
/**
* Vibrates the device for the specified amount of time.
*
* @param time - Milliseconds to vibrate the device. 0 cancels the vibration. Ignored on iOS.
*/
vibrate(time: number): void;
/**
* Vibrates the device with a given pattern.
*
* @param time - Sequence of durations (in milliseconds) for which to turn on or off the vibrator. Ignored on iOS.
*/
vibrate(time: number[]): void;
}

View File

@@ -0,0 +1,81 @@
/*
*
* 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 exec = require('cordova/exec');
/**
* Provides access to the vibration mechanism on the device.
*/
module.exports = {
/**
* Vibrates the device for a given amount of time or for a given pattern or immediately cancels any ongoing vibrations (depending on the parameter).
*
* @param {Integer} param The number of milliseconds to vibrate (if 0, cancels vibration)
*
*
* @param {Array of Integer} param 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 for which
* 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.
* (if empty, cancels vibration)
*/
vibrate: function (param) {
/* Aligning with w3c spec */
// vibrate
if ((typeof param === 'number') && param !== 0) {
exec(null, null, 'Vibration', 'vibrate', [param]);
// vibrate with array ( i.e. vibrate([3000]) )
} else if ((typeof param === 'object') && param.length === 1) {
// cancel if vibrate([0])
if (param[0] === 0) {
exec(null, null, 'Vibration', 'cancelVibration', []);
// else vibrate
} else {
exec(null, null, 'Vibration', 'vibrate', [param[0]]);
}
// vibrate with a pattern
} else if ((typeof param === 'object') && param.length > 1) {
var repeat = -1; // no repeat
exec(null, null, 'Vibration', 'vibrateWithPattern', [param, repeat]);
// cancel vibration (param = 0 or [])
} else { exec(null, null, 'Vibration', 'cancelVibration', []); }
return true;
}
};