You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/07/09 01:43:13 UTC
git commit: [CB-4125] remove dupe code
Updated Branches:
refs/heads/master 8251882e9 -> 976acf5fb
[CB-4125] remove dupe code
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/976acf5f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/tree/976acf5f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/diff/976acf5f
Branch: refs/heads/master
Commit: 976acf5fbaecfc3ffbdf4ad95e5c0f9517b273ee
Parents: 8251882
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Jul 8 16:42:54 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Jul 8 16:42:54 2013 -0700
----------------------------------------------------------------------
plugin.xml | 22 +++
src/wp/Vibration.cs | 57 ++++++
src/wp7/Notification.cs | 367 -----------------------------------
src/wp7/NotificationBox.xaml | 62 ------
src/wp7/NotificationBox.xaml.cs | 41 ----
src/wp8/Notification.cs | 367 -----------------------------------
src/wp8/NotificationBox.xaml | 62 ------
src/wp8/NotificationBox.xaml.cs | 41 ----
8 files changed, 79 insertions(+), 940 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/976acf5f/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 45d1976..623a8cb 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -5,4 +5,26 @@
version="0.1.0">
<name>vibration</name>
+
+ <!-- wp7 -->
+ <platform name="wp7">
+ <config-file target="config.xml" parent="/*">
+ <feature name="Vibration">
+ <param name="wp-package" value="Vibration"/>
+ </feature>
+ </config-file>
+
+ <source-file src="src/wp/Vibration.cs" />
+ </platform>
+
+ <!-- wp8 -->
+ <platform name="wp8">
+ <config-file target="config.xml" parent="/*">
+ <feature name="Vibration">
+ <param name="wp-package" value="Vibration"/>
+ </feature>
+ </config-file>
+
+ <source-file src="src/wp/Vibration.cs" />
+ </platform>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/976acf5f/src/wp/Vibration.cs
----------------------------------------------------------------------
diff --git a/src/wp/Vibration.cs b/src/wp/Vibration.cs
new file mode 100644
index 0000000..cd58d67
--- /dev/null
+++ b/src/wp/Vibration.cs
@@ -0,0 +1,57 @@
+/*
+ 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;
+using System.Windows;
+using System.Windows.Controls;
+using Microsoft.Devices;
+using System.Runtime.Serialization;
+using System.Threading;
+using System.Windows.Resources;
+using Microsoft.Phone.Controls;
+using System.Diagnostics;
+
+
+namespace WPCordovaClassLib.Cordova.Commands
+{
+ public class Vibration : BaseCommand
+ {
+
+ public void vibrate(string vibrateDuration)
+ {
+
+ int msecs = 200; // set default
+
+ try
+ {
+ string[] args = JSON.JsonHelper.Deserialize<string[]>(vibrateDuration);
+
+ msecs = int.Parse(args[0]);
+ if (msecs < 1)
+ {
+ msecs = 1;
+ }
+ }
+ catch (FormatException)
+ {
+
+ }
+
+ VibrateController.Default.Start(TimeSpan.FromMilliseconds(msecs));
+
+ // TODO: may need to add listener to trigger DispatchCommandResult when the vibration ends...
+ DispatchCommandResult();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/976acf5f/src/wp7/Notification.cs
----------------------------------------------------------------------
diff --git a/src/wp7/Notification.cs b/src/wp7/Notification.cs
deleted file mode 100644
index 11f14bd..0000000
--- a/src/wp7/Notification.cs
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- 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;
-using System.Windows;
-using System.Windows.Controls;
-using Microsoft.Devices;
-using System.Runtime.Serialization;
-using System.Threading;
-using System.Windows.Resources;
-using Microsoft.Phone.Controls;
-using Microsoft.Xna.Framework.Audio;
-using WPCordovaClassLib.Cordova.UI;
-using System.Diagnostics;
-
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
- public class Notification : BaseCommand
- {
- static ProgressBar progressBar = null;
- const int DEFAULT_DURATION = 5;
-
- private NotificationBox notifyBox;
-
- private class NotifBoxData
- {
- public NotificationBox previous;
- public string callbackId;
- }
-
- private PhoneApplicationPage Page
- {
- get
- {
- PhoneApplicationPage page = null;
- PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
- if (frame != null)
- {
- page = frame.Content as PhoneApplicationPage;
- }
- return page;
- }
- }
-
- // blink api - doesn't look like there is an equivalent api we can use...
-
- [DataContract]
- public class AlertOptions
- {
- [OnDeserializing]
- public void OnDeserializing(StreamingContext context)
- {
- // set defaults
- this.message = "message";
- this.title = "Alert";
- this.buttonLabel = "ok";
- }
-
- /// <summary>
- /// message to display in the alert box
- /// </summary>
- [DataMember]
- public string message;
-
- /// <summary>
- /// title displayed on the alert window
- /// </summary>
- [DataMember]
- public string title;
-
- /// <summary>
- /// text to display on the button
- /// </summary>
- [DataMember]
- public string buttonLabel;
- }
-
- public void alert(string options)
- {
- string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
- AlertOptions alertOpts = new AlertOptions();
- alertOpts.message = args[0];
- alertOpts.title = args[1];
- alertOpts.buttonLabel = args[2];
- string aliasCurrentCommandCallbackId = args[3];
-
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- PhoneApplicationPage page = Page;
- if (page != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- var previous = notifyBox;
- notifyBox = new NotificationBox();
- notifyBox.Tag = new NotifBoxData{ previous = previous, callbackId = aliasCurrentCommandCallbackId };
- notifyBox.PageTitle.Text = alertOpts.title;
- notifyBox.SubTitle.Text = alertOpts.message;
- Button btnOK = new Button();
- btnOK.Content = alertOpts.buttonLabel;
- btnOK.Click += new RoutedEventHandler(btnOK_Click);
- btnOK.Tag = 1;
- notifyBox.ButtonPanel.Children.Add(btnOK);
- grid.Children.Add(notifyBox);
-
- if (previous == null)
- {
- page.BackKeyPress += page_BackKeyPress;
- }
- }
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.INSTANTIATION_EXCEPTION));
- }
- });
- }
-
- public void confirm(string options)
- {
- string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
- AlertOptions alertOpts = new AlertOptions();
- alertOpts.message = args[0];
- alertOpts.title = args[1];
- alertOpts.buttonLabel = args[2];
- string aliasCurrentCommandCallbackId = args[3];
-
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- PhoneApplicationPage page = Page;
- if (page != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- var previous = notifyBox;
- notifyBox = new NotificationBox();
- notifyBox.Tag = new NotifBoxData{ previous = previous, callbackId = aliasCurrentCommandCallbackId };
- notifyBox.PageTitle.Text = alertOpts.title;
- notifyBox.SubTitle.Text = alertOpts.message;
-
- string[] labels = JSON.JsonHelper.Deserialize<string[]>(alertOpts.buttonLabel);
-
- if (labels == null)
- {
- labels = alertOpts.buttonLabel.Split(',');
- }
-
- for (int n = 0; n < labels.Length; n++)
- {
- Button btn = new Button();
- btn.Content = labels[n];
- btn.Tag = n;
- btn.Click += new RoutedEventHandler(btnOK_Click);
- notifyBox.ButtonPanel.Children.Add(btn);
- }
-
- grid.Children.Add(notifyBox);
- if (previous == null)
- {
- page.BackKeyPress += page_BackKeyPress;
- }
- }
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.INSTANTIATION_EXCEPTION));
- }
- });
- }
-
- void page_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
- {
- PhoneApplicationPage page = sender as PhoneApplicationPage;
- string callbackId = "";
- if (page != null && notifyBox != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- grid.Children.Remove(notifyBox);
- NotifBoxData notifBoxData = notifyBox.Tag as NotifBoxData;
- notifyBox = notifBoxData.previous;
- callbackId = notifBoxData.callbackId;
- }
- if (notifyBox == null)
- {
- page.BackKeyPress -= page_BackKeyPress;
- }
- e.Cancel = true;
- }
-
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, 0), callbackId);
- }
-
- void btnOK_Click(object sender, RoutedEventArgs e)
- {
- Button btn = sender as Button;
- FrameworkElement notifBoxParent = null;
- int retVal = 0;
- string callbackId = "";
- if (btn != null)
- {
- retVal = (int)btn.Tag + 1;
-
- notifBoxParent = btn.Parent as FrameworkElement;
- while ((notifBoxParent = notifBoxParent.Parent as FrameworkElement) != null &&
- !(notifBoxParent is NotificationBox)) ;
- }
- if (notifBoxParent != null)
- {
- PhoneApplicationPage page = Page;
- if (page != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- grid.Children.Remove(notifBoxParent);
- }
-
- NotifBoxData notifBoxData = notifBoxParent.Tag as NotifBoxData;
- notifyBox = notifBoxData.previous;
- callbackId = notifBoxData.callbackId;
-
- if (notifyBox == null)
- {
- page.BackKeyPress -= page_BackKeyPress;
- }
- }
-
- }
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, retVal),callbackId);
- }
-
-
-
- public void beep(string options)
- {
- string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
- int times = int.Parse(args[0]);
-
- string resourcePath = BaseCommand.GetBaseURL() + "resources/notification-beep.wav";
-
- StreamResourceInfo sri = Application.GetResourceStream(new Uri(resourcePath, UriKind.Relative));
-
- if (sri != null)
- {
- SoundEffect effect = SoundEffect.FromStream(sri.Stream);
- SoundEffectInstance inst = effect.CreateInstance();
- ThreadPool.QueueUserWorkItem((o) =>
- {
- // cannot interact with UI !!
- do
- {
- inst.Play();
- Thread.Sleep(effect.Duration + TimeSpan.FromMilliseconds(100));
- }
- while (--times > 0);
-
- });
-
- }
-
- // TODO: may need a listener to trigger DispatchCommandResult after the alarm has finished executing...
- DispatchCommandResult();
- }
-
- // Display an indeterminate progress indicator
- public void activityStart(string unused)
- {
-
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
-
- if (frame != null)
- {
- PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
-
- if (page != null)
- {
- var temp = page.FindName("LayoutRoot");
- Grid grid = temp as Grid;
- if (grid != null)
- {
- if (progressBar != null)
- {
- grid.Children.Remove(progressBar);
- }
- progressBar = new ProgressBar();
- progressBar.IsIndeterminate = true;
- progressBar.IsEnabled = true;
-
- grid.Children.Add(progressBar);
- }
- }
- }
- });
- }
-
-
- // Remove our indeterminate progress indicator
- public void activityStop(string unused)
- {
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- if (progressBar != null)
- {
- progressBar.IsEnabled = false;
- PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
- if (frame != null)
- {
- PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
- if (page != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- grid.Children.Remove(progressBar);
- }
- }
- }
- progressBar = null;
- }
- });
- }
-
- public void vibrate(string vibrateDuration)
- {
-
- int msecs = 200; // set default
-
- try
- {
- string[] args = JSON.JsonHelper.Deserialize<string[]>(vibrateDuration);
-
- msecs = int.Parse(args[0]);
- if (msecs < 1)
- {
- msecs = 1;
- }
- }
- catch (FormatException)
- {
-
- }
-
- VibrateController.Default.Start(TimeSpan.FromMilliseconds(msecs));
-
- // TODO: may need to add listener to trigger DispatchCommandResult when the vibration ends...
- DispatchCommandResult();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/976acf5f/src/wp7/NotificationBox.xaml
----------------------------------------------------------------------
diff --git a/src/wp7/NotificationBox.xaml b/src/wp7/NotificationBox.xaml
deleted file mode 100644
index 1ca5d5f..0000000
--- a/src/wp7/NotificationBox.xaml
+++ /dev/null
@@ -1,62 +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.
--->
-<UserControl x:Class="WPCordovaClassLib.Cordova.UI.NotificationBox"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d"
- FontFamily="{StaticResource PhoneFontFamilyNormal}"
- FontSize="{StaticResource PhoneFontSizeNormal}"
- Foreground="{StaticResource PhoneForegroundBrush}"
- d:DesignHeight="800" d:DesignWidth="480" VerticalAlignment="Stretch">
-
- <Grid x:Name="LayoutRoot"
- Background="{StaticResource PhoneSemitransparentBrush}" VerticalAlignment="Stretch">
-
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
-
-
- <!--TitlePanel contains the name of the application and page title-->
- <StackPanel x:Name="TitlePanel"
- Grid.Row="0"
- Background="{StaticResource PhoneSemitransparentBrush}">
- <TextBlock x:Name="PageTitle"
- Text="Title"
- Margin="10,10"
- Style="{StaticResource PhoneTextTitle2Style}"/>
-
- <TextBlock x:Name="SubTitle"
- Text="Subtitle"
- TextWrapping="Wrap"
- Margin="10,10"
- Style="{StaticResource PhoneTextTitle3Style}"/>
-
- <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
- <StackPanel x:Name="ButtonPanel"
- Margin="10,10"
- Orientation="Horizontal"/>
- </ScrollViewer>
-
- </StackPanel>
- </Grid>
-</UserControl>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/976acf5f/src/wp7/NotificationBox.xaml.cs
----------------------------------------------------------------------
diff --git a/src/wp7/NotificationBox.xaml.cs b/src/wp7/NotificationBox.xaml.cs
deleted file mode 100644
index 50b2f2a..0000000
--- a/src/wp7/NotificationBox.xaml.cs
+++ /dev/null
@@ -1,41 +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.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-
-namespace WPCordovaClassLib.Cordova.UI
-{
- public partial class NotificationBox : UserControl
- {
- public NotificationBox()
- {
- InitializeComponent();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/976acf5f/src/wp8/Notification.cs
----------------------------------------------------------------------
diff --git a/src/wp8/Notification.cs b/src/wp8/Notification.cs
deleted file mode 100644
index 6d4b93b..0000000
--- a/src/wp8/Notification.cs
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- 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;
-using System.Windows;
-using System.Windows.Controls;
-using Microsoft.Devices;
-using System.Runtime.Serialization;
-using System.Threading;
-using System.Windows.Resources;
-using Microsoft.Phone.Controls;
-using Microsoft.Xna.Framework.Audio;
-using WPCordovaClassLib.Cordova.UI;
-using System.Diagnostics;
-
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
- public class Notification : BaseCommand
- {
- static ProgressBar progressBar = null;
- const int DEFAULT_DURATION = 5;
-
- private NotificationBox notifyBox;
-
- private class NotifBoxData
- {
- public NotificationBox previous;
- public string callbackId;
- }
-
- private PhoneApplicationPage Page
- {
- get
- {
- PhoneApplicationPage page = null;
- PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
- if (frame != null)
- {
- page = frame.Content as PhoneApplicationPage;
- }
- return page;
- }
- }
-
- // blink api - doesn't look like there is an equivalent api we can use...
-
- [DataContract]
- public class AlertOptions
- {
- [OnDeserializing]
- public void OnDeserializing(StreamingContext context)
- {
- // set defaults
- this.message = "message";
- this.title = "Alert";
- this.buttonLabel = "ok";
- }
-
- /// <summary>
- /// message to display in the alert box
- /// </summary>
- [DataMember]
- public string message;
-
- /// <summary>
- /// title displayed on the alert window
- /// </summary>
- [DataMember]
- public string title;
-
- /// <summary>
- /// text to display on the button
- /// </summary>
- [DataMember]
- public string buttonLabel;
- }
-
- public void alert(string options)
- {
- string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
- AlertOptions alertOpts = new AlertOptions();
- alertOpts.message = args[0];
- alertOpts.title = args[1];
- alertOpts.buttonLabel = args[2];
- string aliasCurrentCommandCallbackId = args[3];
-
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- PhoneApplicationPage page = Page;
- if (page != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- var previous = notifyBox;
- notifyBox = new NotificationBox();
- notifyBox.Tag = new { previous = previous, callbackId = aliasCurrentCommandCallbackId };
- notifyBox.PageTitle.Text = alertOpts.title;
- notifyBox.SubTitle.Text = alertOpts.message;
- Button btnOK = new Button();
- btnOK.Content = alertOpts.buttonLabel;
- btnOK.Click += new RoutedEventHandler(btnOK_Click);
- btnOK.Tag = 1;
- notifyBox.ButtonPanel.Children.Add(btnOK);
- grid.Children.Add(notifyBox);
-
- if (previous == null)
- {
- page.BackKeyPress += page_BackKeyPress;
- }
- }
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.INSTANTIATION_EXCEPTION));
- }
- });
- }
-
- public void confirm(string options)
- {
- string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
- AlertOptions alertOpts = new AlertOptions();
- alertOpts.message = args[0];
- alertOpts.title = args[1];
- alertOpts.buttonLabel = args[2];
- string aliasCurrentCommandCallbackId = args[3];
-
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- PhoneApplicationPage page = Page;
- if (page != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- var previous = notifyBox;
- notifyBox = new NotificationBox();
- notifyBox.Tag = new { previous = previous, callbackId = aliasCurrentCommandCallbackId };
- notifyBox.PageTitle.Text = alertOpts.title;
- notifyBox.SubTitle.Text = alertOpts.message;
-
- string[] labels = JSON.JsonHelper.Deserialize<string[]>(alertOpts.buttonLabel);
-
- if (labels == null)
- {
- labels = alertOpts.buttonLabel.Split(',');
- }
-
- for (int n = 0; n < labels.Length; n++)
- {
- Button btn = new Button();
- btn.Content = labels[n];
- btn.Tag = n;
- btn.Click += new RoutedEventHandler(btnOK_Click);
- notifyBox.ButtonPanel.Children.Add(btn);
- }
-
- grid.Children.Add(notifyBox);
- if (previous == null)
- {
- page.BackKeyPress += page_BackKeyPress;
- }
- }
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.INSTANTIATION_EXCEPTION));
- }
- });
- }
-
- void page_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
- {
- PhoneApplicationPage page = sender as PhoneApplicationPage;
- string callbackId = "";
- if (page != null && notifyBox != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- grid.Children.Remove(notifyBox);
- NotifBoxData notifBoxData = notifyBox.Tag as NotifBoxData;
- notifyBox = notifBoxData.previous as NotificationBox;
- callbackId = notifBoxData.callbackId as string;
- }
- if (notifyBox == null)
- {
- page.BackKeyPress -= page_BackKeyPress;
- }
- e.Cancel = true;
- }
-
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, 0), callbackId);
- }
-
- void btnOK_Click(object sender, RoutedEventArgs e)
- {
- Button btn = sender as Button;
- FrameworkElement notifBoxParent = null;
- int retVal = 0;
- string callbackId = "";
- if (btn != null)
- {
- retVal = (int)btn.Tag + 1;
-
- notifBoxParent = btn.Parent as FrameworkElement;
- while ((notifBoxParent = notifBoxParent.Parent as FrameworkElement) != null &&
- !(notifBoxParent is NotificationBox)) ;
- }
- if (notifBoxParent != null)
- {
- PhoneApplicationPage page = Page;
- if (page != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- grid.Children.Remove(notifBoxParent);
- }
-
- NotifBoxData notifBoxData = notifBoxParent.Tag as NotifBoxData;
- notifyBox = notifBoxData.previous as NotificationBox;
- callbackId = notifBoxData.callbackId as string;
-
- if (notifyBox == null)
- {
- page.BackKeyPress -= page_BackKeyPress;
- }
- }
-
- }
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, retVal),callbackId);
- }
-
-
-
- public void beep(string options)
- {
- string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
- int times = int.Parse(args[0]);
-
- string resourcePath = BaseCommand.GetBaseURL() + "resources/notification-beep.wav";
-
- StreamResourceInfo sri = Application.GetResourceStream(new Uri(resourcePath, UriKind.Relative));
-
- if (sri != null)
- {
- SoundEffect effect = SoundEffect.FromStream(sri.Stream);
- SoundEffectInstance inst = effect.CreateInstance();
- ThreadPool.QueueUserWorkItem((o) =>
- {
- // cannot interact with UI !!
- do
- {
- inst.Play();
- Thread.Sleep(effect.Duration + TimeSpan.FromMilliseconds(100));
- }
- while (--times > 0);
-
- });
-
- }
-
- // TODO: may need a listener to trigger DispatchCommandResult after the alarm has finished executing...
- DispatchCommandResult();
- }
-
- // Display an indeterminate progress indicator
- public void activityStart(string unused)
- {
-
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
-
- if (frame != null)
- {
- PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
-
- if (page != null)
- {
- var temp = page.FindName("LayoutRoot");
- Grid grid = temp as Grid;
- if (grid != null)
- {
- if (progressBar != null)
- {
- grid.Children.Remove(progressBar);
- }
- progressBar = new ProgressBar();
- progressBar.IsIndeterminate = true;
- progressBar.IsEnabled = true;
-
- grid.Children.Add(progressBar);
- }
- }
- }
- });
- }
-
-
- // Remove our indeterminate progress indicator
- public void activityStop(string unused)
- {
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- if (progressBar != null)
- {
- progressBar.IsEnabled = false;
- PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
- if (frame != null)
- {
- PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
- if (page != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- grid.Children.Remove(progressBar);
- }
- }
- }
- progressBar = null;
- }
- });
- }
-
- public void vibrate(string vibrateDuration)
- {
-
- int msecs = 200; // set default
-
- try
- {
- string[] args = JSON.JsonHelper.Deserialize<string[]>(vibrateDuration);
-
- msecs = int.Parse(args[0]);
- if (msecs < 1)
- {
- msecs = 1;
- }
- }
- catch (FormatException)
- {
-
- }
-
- VibrateController.Default.Start(TimeSpan.FromMilliseconds(msecs));
-
- // TODO: may need to add listener to trigger DispatchCommandResult when the vibration ends...
- DispatchCommandResult();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/976acf5f/src/wp8/NotificationBox.xaml
----------------------------------------------------------------------
diff --git a/src/wp8/NotificationBox.xaml b/src/wp8/NotificationBox.xaml
deleted file mode 100644
index 1ca5d5f..0000000
--- a/src/wp8/NotificationBox.xaml
+++ /dev/null
@@ -1,62 +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.
--->
-<UserControl x:Class="WPCordovaClassLib.Cordova.UI.NotificationBox"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d"
- FontFamily="{StaticResource PhoneFontFamilyNormal}"
- FontSize="{StaticResource PhoneFontSizeNormal}"
- Foreground="{StaticResource PhoneForegroundBrush}"
- d:DesignHeight="800" d:DesignWidth="480" VerticalAlignment="Stretch">
-
- <Grid x:Name="LayoutRoot"
- Background="{StaticResource PhoneSemitransparentBrush}" VerticalAlignment="Stretch">
-
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
-
-
- <!--TitlePanel contains the name of the application and page title-->
- <StackPanel x:Name="TitlePanel"
- Grid.Row="0"
- Background="{StaticResource PhoneSemitransparentBrush}">
- <TextBlock x:Name="PageTitle"
- Text="Title"
- Margin="10,10"
- Style="{StaticResource PhoneTextTitle2Style}"/>
-
- <TextBlock x:Name="SubTitle"
- Text="Subtitle"
- TextWrapping="Wrap"
- Margin="10,10"
- Style="{StaticResource PhoneTextTitle3Style}"/>
-
- <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
- <StackPanel x:Name="ButtonPanel"
- Margin="10,10"
- Orientation="Horizontal"/>
- </ScrollViewer>
-
- </StackPanel>
- </Grid>
-</UserControl>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/976acf5f/src/wp8/NotificationBox.xaml.cs
----------------------------------------------------------------------
diff --git a/src/wp8/NotificationBox.xaml.cs b/src/wp8/NotificationBox.xaml.cs
deleted file mode 100644
index 50b2f2a..0000000
--- a/src/wp8/NotificationBox.xaml.cs
+++ /dev/null
@@ -1,41 +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.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-
-namespace WPCordovaClassLib.Cordova.UI
-{
- public partial class NotificationBox : UserControl
- {
- public NotificationBox()
- {
- InitializeComponent();
- }
- }
-}