You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2015/03/31 19:58:28 UTC
[2/4] cordova-plugin-vibration git commit: CB-7970 Add
cordova-plugin-vibration support for Windows Phone 8.1
CB-7970 Add cordova-plugin-vibration support for Windows Phone 8.1
Added Windows Phone 8.1 support
Updated documentation
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/3c784336
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/tree/3c784336
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/diff/3c784336
Branch: refs/heads/old-ID
Commit: 3c784336c6851649f740f0ae9e82c390a871aa70
Parents: 59bd842
Author: daserge <da...@yandex.ru>
Authored: Wed Nov 26 00:16:45 2014 +0300
Committer: sgrebnov <v-...@microsoft.com>
Committed: Thu Mar 26 12:59:45 2015 +0300
----------------------------------------------------------------------
README.md | 11 +++-
plugin.xml | 9 +++
src/windows/Vibration.winmd | Bin 0 -> 5632 bytes
src/windows/Vibration/Vibration.sln | 22 +++++++
src/windows/Vibration/Vibration/.gitignore | 3 +
.../Vibration/Properties/AssemblyInfo.cs | 30 ++++++++++
src/windows/Vibration/Vibration/Vibration.cs | 36 +++++++++++
.../Vibration/Vibration/Vibration.csproj | 54 +++++++++++++++++
src/windows/VibrationProxy.js | 60 +++++++++++++++++++
9 files changed, 223 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/3c784336/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 842e771..30da4b0 100644
--- a/README.md
+++ b/README.md
@@ -48,10 +48,13 @@ navigator.notification.vibrate
- Firefox OS
- iOS
- Windows Phone 7 and 8
+- Windows (Windows Phone 8.1 devices only)
-navigator.notification.vibrateWithPattern,<br />navigator.notification.cancelVibration
+navigator.notification.vibrateWithPattern<br />
+navigator.notification.cancelVibration
- Android
- Windows Phone 8
+- Windows (Windows Phone 8.1 devices only)
## vibrate (recommended)
@@ -110,6 +113,10 @@ Vibrates the device with a given pattern
- vibrate(pattern) falls back on vibrate with default duration
+####Windows Quirks
+
+- vibrate(pattern) falls back on vibrate with default duration
+
###Cancel vibration (not supported in iOS)
Immediately cancels any currently running vibration.
@@ -174,4 +181,4 @@ Immediately cancels any currently running vibration.
navigator.notification.cancelVibration()
-*Note - due to alignment with w3c spec, the starred methods will be phased out
+*Note - due to alignment with w3c spec, the starred methods will be phased out
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/3c784336/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index cb98b29..4847d36 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -69,6 +69,15 @@
<source-file src="src/wp/Vibration.cs" />
</platform>
+ <!-- windows -->
+ <platform name="windows">
+ <js-module src="src/windows/VibrationProxy.js" name="VibrationProxy">
+ <runs />
+ </js-module>
+
+ <framework src="src/windows/Vibration.winmd" custom="true"/>
+ </platform>
+
<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/3c784336/src/windows/Vibration.winmd
----------------------------------------------------------------------
diff --git a/src/windows/Vibration.winmd b/src/windows/Vibration.winmd
new file mode 100644
index 0000000..84a9319
Binary files /dev/null and b/src/windows/Vibration.winmd differ
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/3c784336/src/windows/Vibration/Vibration.sln
----------------------------------------------------------------------
diff --git a/src/windows/Vibration/Vibration.sln b/src/windows/Vibration/Vibration.sln
new file mode 100644
index 0000000..1f3d9d4
--- /dev/null
+++ b/src/windows/Vibration/Vibration.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30723.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vibration", "Vibration\Vibration.csproj", "{D4F9F695-ECD5-49FC-B58A-B1E0E754E159}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D4F9F695-ECD5-49FC-B58A-B1E0E754E159}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D4F9F695-ECD5-49FC-B58A-B1E0E754E159}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D4F9F695-ECD5-49FC-B58A-B1E0E754E159}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D4F9F695-ECD5-49FC-B58A-B1E0E754E159}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/3c784336/src/windows/Vibration/Vibration/.gitignore
----------------------------------------------------------------------
diff --git a/src/windows/Vibration/Vibration/.gitignore b/src/windows/Vibration/Vibration/.gitignore
new file mode 100644
index 0000000..b84aa9d
--- /dev/null
+++ b/src/windows/Vibration/Vibration/.gitignore
@@ -0,0 +1,3 @@
+/bin/
+/obj/
+*.suo
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/3c784336/src/windows/Vibration/Vibration/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/windows/Vibration/Vibration/Properties/AssemblyInfo.cs b/src/windows/Vibration/Vibration/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..ad89fad
--- /dev/null
+++ b/src/windows/Vibration/Vibration/Properties/AssemblyInfo.cs
@@ -0,0 +1,30 @@
+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")]
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/3c784336/src/windows/Vibration/Vibration/Vibration.cs
----------------------------------------------------------------------
diff --git a/src/windows/Vibration/Vibration/Vibration.cs b/src/windows/Vibration/Vibration/Vibration.cs
new file mode 100644
index 0000000..66f278c
--- /dev/null
+++ b/src/windows/Vibration/Vibration/Vibration.cs
@@ -0,0 +1,36 @@
+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();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/3c784336/src/windows/Vibration/Vibration/Vibration.csproj
----------------------------------------------------------------------
diff --git a/src/windows/Vibration/Vibration/Vibration.csproj b/src/windows/Vibration/Vibration/Vibration.csproj
new file mode 100644
index 0000000..a803b4e
--- /dev/null
+++ b/src/windows/Vibration/Vibration/Vibration.csproj
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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>
+ <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" />
+ <PropertyGroup>
+ <PostBuildEvent>xcopy /Y /Q "$(TargetPath)" "$(SolutionDir).."</PostBuildEvent>
+ </PropertyGroup>
+ <!-- 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>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/3c784336/src/windows/VibrationProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/VibrationProxy.js b/src/windows/VibrationProxy.js
new file mode 100644
index 0000000..63c2aa7
--- /dev/null
+++ b/src/windows/VibrationProxy.js
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+function checkReqs(actionName, fail) {
+ if (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);
+ }
+}
+
+var DEFAULT_DURATION = 200;
+
+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);
+ }
+};
+
+require("cordova/exec/proxy").add("Vibration", module.exports);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org