You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by be...@apache.org on 2013/05/28 02:14:11 UTC
[1/5] wp7 commit: removed compass plugin dependencies
Updated Branches:
refs/heads/3.0.0 b68ec5313 -> 86d27fc97 (forced update)
removed compass plugin dependencies
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp7/commit/640e5051
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp7/tree/640e5051
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp7/diff/640e5051
Branch: refs/heads/3.0.0
Commit: 640e50515ef792228d209b4483e0dca4624698d6
Parents: 4836031
Author: Benn Mapes <be...@gmail.com>
Authored: Tue May 21 18:20:05 2013 -0700
Committer: Benn Mapes <be...@gmail.com>
Committed: Mon May 27 17:12:29 2013 -0700
----------------------------------------------------------------------
templates/standalone/CordovaAppProj.csproj | 1 -
templates/standalone/Plugins/Compass.cs | 362 -----------------------
templates/standalone/config.xml | 1 -
3 files changed, 0 insertions(+), 364 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/640e5051/templates/standalone/CordovaAppProj.csproj
----------------------------------------------------------------------
diff --git a/templates/standalone/CordovaAppProj.csproj b/templates/standalone/CordovaAppProj.csproj
index 15e674c..3e0bc51 100644
--- a/templates/standalone/CordovaAppProj.csproj
+++ b/templates/standalone/CordovaAppProj.csproj
@@ -170,7 +170,6 @@
<Compile Include="Plugins\AudioPlayer.cs" />
<Compile Include="Plugins\Battery.cs" />
<Compile Include="Plugins\Camera.cs" />
- <Compile Include="Plugins\Compass.cs" />
<Compile Include="Plugins\Contacts.cs" />
<Compile Include="Plugins\DebugConsole.cs" />
<Compile Include="Plugins\Device.cs" />
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/640e5051/templates/standalone/Plugins/Compass.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/Plugins/Compass.cs b/templates/standalone/Plugins/Compass.cs
deleted file mode 100644
index c9e1c4d..0000000
--- a/templates/standalone/Plugins/Compass.cs
+++ /dev/null
@@ -1,362 +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.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using DeviceCompass = Microsoft.Devices.Sensors.Compass;
-using System.Windows.Threading;
-using System.Runtime.Serialization;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Globalization;
-using System.Threading;
-using Microsoft.Devices.Sensors;
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
-
- public class Compass : BaseCommand
- {
- #region Static members
-
- /// <summary>
- /// Status of listener
- /// </summary>
- private static int currentStatus;
-
- /// <summary>
- /// Id for get getCompass method
- /// </summary>
- private static string getCompassId = "getCompassId";
-
- /// <summary>
- /// Compass
- /// </summary>
- private static DeviceCompass compass = new DeviceCompass();
-
- /// <summary>
- /// Listeners for callbacks
- /// </summary>
- private static Dictionary<string, Compass> watchers = new Dictionary<string, Compass>();
-
- #endregion
-
- #region Status codes
-
- public const int Stopped = 0;
- public const int Starting = 1;
- public const int Running = 2;
- public const int ErrorFailedToStart = 4;
- public const int Not_Supported = 20;
-
- /*
- * // Capture error codes
- CompassError.COMPASS_INTERNAL_ERR = 0;
- CompassError.COMPASS_NOT_SUPPORTED = 20;
- * */
-
- #endregion
-
- #region CompassOptions class
- /// <summary>
- /// Represents Accelerometer options.
- /// </summary>
- [DataContract]
- public class CompassOptions
- {
- /// <summary>
- /// How often to retrieve the Acceleration in milliseconds
- /// </summary>
- [DataMember(IsRequired = false, Name = "frequency")]
- public int Frequency { get; set; }
-
- /// <summary>
- /// The change in degrees required to initiate a watchHeadingFilter success callback.
- /// </summary>
- [DataMember(IsRequired = false, Name = "filter")]
- public int Filter { get; set; }
-
- /// <summary>
- /// Watcher id
- /// </summary>
- [DataMember(IsRequired = false, Name = "id")]
- public string Id { get; set; }
-
- }
- #endregion
-
-
- /// <summary>
- /// Time the value was last changed
- /// </summary>
- //private DateTime lastValueChangedTime;
-
- /// <summary>
- /// Accelerometer options
- /// </summary>
- private CompassOptions compassOptions;
-
- //bool isDataValid;
-
- //bool calibrating = false;
-
- public Compass()
- {
-
- }
-
- /// <summary>
- /// Formats current coordinates into JSON format
- /// </summary>
- /// <returns>Coordinates in JSON format</returns>
- private string GetHeadingFormatted(CompassReading reading)
- {
- // NOTE: timestamp is generated on the JS side, to avoid issues with format conversions
- string result = String.Format("\"magneticHeading\":{0},\"headingAccuracy\":{1},\"trueHeading\":{2}",
- reading.MagneticHeading.ToString("0.0", CultureInfo.InvariantCulture),
- reading.HeadingAccuracy.ToString("0.0", CultureInfo.InvariantCulture),
- reading.TrueHeading.ToString("0.0", CultureInfo.InvariantCulture));
- return "{" + result + "}";
- }
-
- public void getHeading(string options)
- {
- if (!DeviceCompass.IsSupported)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "{code:" + Not_Supported + "}"));
- }
- else
- {
- //if (compass == null)
- //{
- // // Instantiate the compass.
- // compass = new DeviceCompass();
- // compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(40);
- // compass.CurrentValueChanged += new EventHandler<Microsoft.Devices.Sensors.SensorReadingEventArgs<Microsoft.Devices.Sensors.CompassReading>>(compass_CurrentValueChanged);
- // compass.Calibrate += new EventHandler<Microsoft.Devices.Sensors.CalibrationEventArgs>(compass_Calibrate);
- //}
-
-
- //compass.Start();
-
- }
-
- try
- {
- if (currentStatus != Running)
- {
- lock (compass)
- {
- compass.CurrentValueChanged += compass_SingleHeadingValueChanged;
- compass.Start();
- this.SetStatus(Starting);
- }
-
- long timeout = 2000;
- while ((currentStatus == Starting) && (timeout > 0))
- {
- timeout = timeout - 100;
- Thread.Sleep(100);
- }
-
- if (currentStatus != Running)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ErrorFailedToStart));
- return;
- }
- }
- lock (compass)
- {
- compass.CurrentValueChanged -= compass_SingleHeadingValueChanged;
- if (watchers.Count < 1)
- {
- compass.Stop();
- this.SetStatus(Stopped);
- }
- }
- }
- catch (UnauthorizedAccessException)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION, ErrorFailedToStart));
- }
- catch (Exception)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ErrorFailedToStart));
- }
- }
-
- void compass_SingleHeadingValueChanged(object sender, Microsoft.Devices.Sensors.SensorReadingEventArgs<CompassReading> e)
- {
- this.SetStatus(Running);
- if (compass.IsDataValid)
- {
- // trueHeading :: The heading in degrees from 0 - 359.99 at a single moment in time.
- // magneticHeading:: The heading relative to the geographic North Pole in degrees 0 - 359.99 at a single moment in time.
- // A negative value indicates that the true heading could not be determined.
- // headingAccuracy :: The deviation in degrees between the reported heading and the true heading.
- //rawMagnetometerReading = e.SensorReading.MagnetometerReading;
-
- //Debug.WriteLine("Compass Result :: " + GetHeadingFormatted(e.SensorReading));
-
- PluginResult result = new PluginResult(PluginResult.Status.OK, GetHeadingFormatted(e.SensorReading));
-
- DispatchCommandResult(result);
- }
- }
-
- /// <summary>
- /// Starts listening for compass sensor
- /// </summary>
- /// <returns>status of listener</returns>
- private int start()
- {
- if ((currentStatus == Running) || (currentStatus == Starting))
- {
- return currentStatus;
- }
- try
- {
- lock (compass)
- {
- watchers.Add(getCompassId, this);
- compass.CurrentValueChanged += watchers[getCompassId].compass_CurrentValueChanged;
- compass.Start();
- this.SetStatus(Starting);
- }
- }
- catch (Exception)
- {
- this.SetStatus(ErrorFailedToStart);
- }
- return currentStatus;
- }
-
- public void startWatch(string options)
- {
- if (!DeviceCompass.IsSupported)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, Not_Supported));
- }
-
- try
- {
- compassOptions = JSON.JsonHelper.Deserialize<CompassOptions>(options);
- }
- catch (Exception ex)
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
- return;
- }
-
- if (string.IsNullOrEmpty(compassOptions.Id))
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
- return;
- }
-
- try
- {
- lock (compass)
- {
- watchers.Add(compassOptions.Id, this);
- compass.CurrentValueChanged += watchers[compassOptions.Id].compass_CurrentValueChanged;
- compass.Start();
- this.SetStatus(Starting);
- }
- }
- catch (Exception)
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ErrorFailedToStart));
- return;
- }
- }
-
- public void stopWatch(string options)
- {
- try
- {
- compassOptions = JSON.JsonHelper.Deserialize<CompassOptions>(options);
- }
- catch (Exception ex)
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
- return;
- }
-
- if (string.IsNullOrEmpty(compassOptions.Id))
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
- return;
- }
-
- if (currentStatus != Stopped)
- {
- lock (compass)
- {
- Compass watcher = watchers[compassOptions.Id];
- compass.CurrentValueChanged -= watcher.compass_CurrentValueChanged;
- watchers.Remove(compassOptions.Id);
- watcher.Dispose();
- }
- }
- this.SetStatus(Stopped);
-
- this.DispatchCommandResult();
- }
-
- void compass_Calibrate(object sender, Microsoft.Devices.Sensors.CalibrationEventArgs e)
- {
- //throw new NotImplementedException();
- // TODO: pass calibration error to JS
- }
-
- void compass_CurrentValueChanged(object sender, Microsoft.Devices.Sensors.SensorReadingEventArgs<CompassReading> e)
- {
- this.SetStatus(Running);
- if (compass.IsDataValid)
- {
- // trueHeading :: The heading in degrees from 0 - 359.99 at a single moment in time.
- // magneticHeading:: The heading relative to the geographic North Pole in degrees 0 - 359.99 at a single moment in time.
- // A negative value indicates that the true heading could not be determined.
- // headingAccuracy :: The deviation in degrees between the reported heading and the true heading.
- //rawMagnetometerReading = e.SensorReading.MagnetometerReading;
-
- //Debug.WriteLine("Compass Result :: " + GetHeadingFormatted(e.SensorReading));
-
- PluginResult result = new PluginResult(PluginResult.Status.OK, GetHeadingFormatted(e.SensorReading));
- result.KeepCallback = true;
-
- DispatchCommandResult(result);
- }
- }
-
- /// <summary>
- /// Sets current status
- /// </summary>
- /// <param name="status">current status</param>
- private void SetStatus(int status)
- {
- currentStatus = status;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/640e5051/templates/standalone/config.xml
----------------------------------------------------------------------
diff --git a/templates/standalone/config.xml b/templates/standalone/config.xml
index 93ac43a..715c7d0 100644
--- a/templates/standalone/config.xml
+++ b/templates/standalone/config.xml
@@ -24,7 +24,6 @@
<plugins>
<plugin name="Device"/>
<plugin name="Logger"/>
- <plugin name="Compass"/>
<plugin name="Camera"/>
<plugin name="NetworkStatus"/>
<plugin name="Contacts"/>
[3/5] wp7 commit: Allow app names with spaces
Posted by be...@apache.org.
Allow app names with spaces
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp7/commit/890045fa
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp7/tree/890045fa
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp7/diff/890045fa
Branch: refs/heads/3.0.0
Commit: 890045fae9eee73dc2df6defc73d65984a5bded4
Parents: 4d05619
Author: Benn Mapes <be...@gmail.com>
Authored: Fri May 24 18:01:19 2013 -0700
Committer: Benn Mapes <be...@gmail.com>
Committed: Mon May 27 17:12:58 2013 -0700
----------------------------------------------------------------------
bin/create.js | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/890045fa/bin/create.js
----------------------------------------------------------------------
diff --git a/bin/create.js b/bin/create.js
index 7d89d0a..d8b67a9 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -171,11 +171,12 @@ function create(path, namespace, name) {
replaceInFile(path + "\\MainPage.xaml",/\$safeprojectname\$/g,namespace);
replaceInFile(path + "\\MainPage.xaml.cs",/\$safeprojectname\$/g,namespace);
replaceInFile(path + "\\CordovaAppProj.csproj",/\$safeprojectname\$/g,namespace);
- if (NAME != "CordovaAppProj") {
- replaceInFile(path + "\\CordovaSolution.sln",/CordovaAppProj/g,NAME);
+ if (name != "CordovaAppProj") {
+ var valid_name = name.replace(/(\.\s|\s\.|\s+|\.+)/g, '_');
+ replaceInFile(path + "\\CordovaSolution.sln", /CordovaAppProj/g, valid_name);
// rename project and solution
- exec('%comspec% /c ren ' + path + "\\CordovaSolution.sln " + NAME + '.sln');
- exec('%comspec% /c ren ' + path + "\\CordovaAppProj.csproj " + NAME + '.csproj');
+ exec('%comspec% /c ren ' + path + "\\CordovaSolution.sln " + valid_name + '.sln');
+ exec('%comspec% /c ren ' + path + "\\CordovaAppProj.csproj " + valid_name + '.csproj');
}
//copy .dll if necessary
[4/5] wp7 commit: removed dependencies for InAppBrowser plugin
Posted by be...@apache.org.
removed dependencies for InAppBrowser plugin
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp7/commit/ec356291
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp7/tree/ec356291
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp7/diff/ec356291
Branch: refs/heads/3.0.0
Commit: ec35629191544561958bfd26fed446675d98eeee
Parents: 890045f
Author: Benn Mapes <be...@gmail.com>
Authored: Mon May 27 15:04:09 2013 -0700
Committer: Benn Mapes <be...@gmail.com>
Committed: Mon May 27 17:13:00 2013 -0700
----------------------------------------------------------------------
templates/standalone/CordovaAppProj.csproj | 1 -
templates/standalone/Plugins/InAppBrowser.cs | 268 ---------------------
templates/standalone/config.xml | 1 -
3 files changed, 0 insertions(+), 270 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/ec356291/templates/standalone/CordovaAppProj.csproj
----------------------------------------------------------------------
diff --git a/templates/standalone/CordovaAppProj.csproj b/templates/standalone/CordovaAppProj.csproj
index 8d4c3e0..2b43554 100644
--- a/templates/standalone/CordovaAppProj.csproj
+++ b/templates/standalone/CordovaAppProj.csproj
@@ -178,7 +178,6 @@
<Compile Include="Plugins\GeoLocation.cs" />
<Compile Include="Plugins\Globalization.cs" />
<Compile Include="Plugins\ImageExifHelper.cs" />
- <Compile Include="Plugins\InAppBrowser.cs" />
<Compile Include="Plugins\Media.cs" />
<Compile Include="Plugins\MimeTypeMapper.cs" />
<Compile Include="Plugins\NetworkStatus.cs" />
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/ec356291/templates/standalone/Plugins/InAppBrowser.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/Plugins/InAppBrowser.cs b/templates/standalone/Plugins/InAppBrowser.cs
deleted file mode 100644
index 425f5ae..0000000
--- a/templates/standalone/Plugins/InAppBrowser.cs
+++ /dev/null
@@ -1,268 +0,0 @@
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using Microsoft.Phone.Controls;
-using System.Diagnostics;
-using System.Runtime.Serialization;
-using WPCordovaClassLib.Cordova;
-using WPCordovaClassLib.Cordova.Commands;
-using WPCordovaClassLib.Cordova.JSON;
-using Microsoft.Phone.Shell;
-using Microsoft.Phone.Tasks;
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
- [DataContract]
- public class BrowserOptions
- {
- [DataMember]
- public string url;
-
- [DataMember]
- public bool isGeolocationEnabled;
- }
-
- public class InAppBrowser : BaseCommand
- {
-
- private static WebBrowser browser;
- private static ApplicationBarIconButton backButton;
- private static ApplicationBarIconButton fwdButton;
-
- public void open(string options)
- {
- string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
- //BrowserOptions opts = JSON.JsonHelper.Deserialize<BrowserOptions>(options);
- string urlLoc = args[0];
- string target = args[1];
- /*
- _self - opens in the Cordova WebView if url is in the white-list, else it opens in the InAppBrowser
- _blank - always open in the InAppBrowser
- _system - always open in the system web browser
- */
- switch (target)
- {
- case "_blank":
- ShowInAppBrowser(urlLoc);
- break;
- case "_self":
- ShowCordovaBrowser(urlLoc);
- break;
- case "_system":
- ShowSystemBrowser(urlLoc);
- break;
- }
-
-
- }
-
- private void ShowCordovaBrowser(string url)
- {
- Uri loc = new Uri(url, UriKind.RelativeOrAbsolute);
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
- if (frame != null)
- {
- PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
- if (page != null)
- {
- CordovaView cView = page.FindName("CordovaView") as CordovaView;
- if (cView != null)
- {
- WebBrowser br = cView.Browser;
- br.Navigate(loc);
- }
- }
-
- }
- });
- }
-
- private void ShowSystemBrowser(string url)
- {
- WebBrowserTask webBrowserTask = new WebBrowserTask();
- webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
- webBrowserTask.Show();
- }
-
-
- // Display an inderminate progress indicator
- private void ShowInAppBrowser(string url)
- {
- Uri loc = new Uri(url);
-
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- if (browser != null)
- {
- //browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
- browser.Navigate(loc);
- }
- else
- {
- 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)
- {
- browser = new WebBrowser();
- browser.IsScriptEnabled = true;
- browser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted);
- browser.Navigating += new EventHandler<NavigatingEventArgs>(browser_Navigating);
- browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed);
- browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(browser_Navigated);
-
- browser.Navigate(loc);
- //browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
- grid.Children.Add(browser);
- }
-
- ApplicationBar bar = new ApplicationBar();
- bar.BackgroundColor = Colors.Gray;
- bar.IsMenuEnabled = false;
-
- backButton = new ApplicationBarIconButton();
- backButton.Text = "Back";
- backButton.IconUri = new Uri("/Images/appbar.back.rest.png", UriKind.Relative);
- backButton.Click += new EventHandler(backButton_Click);
- //backButton.IsEnabled = false;
- bar.Buttons.Add(backButton);
-
-
- fwdButton = new ApplicationBarIconButton();
- fwdButton.Text = "Forward";
- fwdButton.IconUri = new Uri("/Images/appbar.next.rest.png", UriKind.Relative);
- fwdButton.Click += new EventHandler(fwdButton_Click);
- //fwdButton.IsEnabled = false;
- bar.Buttons.Add(fwdButton);
-
- ApplicationBarIconButton closeBtn = new ApplicationBarIconButton();
- closeBtn.Text = "Close";
- closeBtn.IconUri = new Uri("/Images/appbar.close.rest.png", UriKind.Relative);
- closeBtn.Click += new EventHandler(closeBtn_Click);
- bar.Buttons.Add(closeBtn);
-
- page.ApplicationBar = bar;
- }
-
- }
- }
- });
- }
-
- void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
- {
-
- }
-
- void fwdButton_Click(object sender, EventArgs e)
- {
- if (browser != null)
- {
- try
- {
- //browser.GoForward();
- browser.InvokeScript("execScript", "history.forward();");
- }
- catch (Exception)
- {
-
- }
- }
- }
-
- void backButton_Click(object sender, EventArgs e)
- {
- if (browser != null)
- {
- try
- {
- //browser.GoBack();
- browser.InvokeScript("execScript", "history.back();");
- }
- catch (Exception)
- {
-
- }
- }
- }
-
- void closeBtn_Click(object sender, EventArgs e)
- {
- this.close();
- }
-
-
- public void close(string options = "")
- {
- if (browser != null)
- {
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- 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(browser);
- }
- page.ApplicationBar = null;
- }
- }
- browser = null;
- string message = "{\"type\":\"exit\"}";
- PluginResult result = new PluginResult(PluginResult.Status.OK, message);
- result.KeepCallback = false;
- this.DispatchCommandResult(result);
- });
- }
- }
-
- void browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
- {
- //if (browser != null)
- //{
- // backButton.IsEnabled = browser.CanGoBack;
- // fwdButton.IsEnabled = browser.CanGoForward;
- //}
- string message = "{\"type\":\"loadstop\", \"url\":\"" + e.Uri.AbsoluteUri + "\"}";
- PluginResult result = new PluginResult(PluginResult.Status.OK, message);
- result.KeepCallback = true;
- this.DispatchCommandResult(result);
- }
-
- void browser_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e)
- {
- string message = "{\"type\":\"error\",\"url\":\"" + e.Uri.AbsoluteUri + "\"}";
- PluginResult result = new PluginResult(PluginResult.Status.ERROR, message);
- result.KeepCallback = true;
- this.DispatchCommandResult(result);
- }
-
- void browser_Navigating(object sender, NavigatingEventArgs e)
- {
- string message = "{\"type\":\"loadstart\",\"url\":\"" + e.Uri.AbsoluteUri + "\"}";
- PluginResult result = new PluginResult(PluginResult.Status.OK, message);
- result.KeepCallback = true;
- this.DispatchCommandResult(result);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/ec356291/templates/standalone/config.xml
----------------------------------------------------------------------
diff --git a/templates/standalone/config.xml b/templates/standalone/config.xml
index 2f63bca..64aef33 100644
--- a/templates/standalone/config.xml
+++ b/templates/standalone/config.xml
@@ -37,7 +37,6 @@
<plugin name="SplashScreen"/>
<plugin name="Battery"/>
<plugin name="Globalization"/>
- <plugin name="InAppBrowser"/>
</plugins>
[5/5] wp7 commit: removed dependencies for Battery status plugin
Posted by be...@apache.org.
removed dependencies for Battery status plugin
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp7/commit/86d27fc9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp7/tree/86d27fc9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp7/diff/86d27fc9
Branch: refs/heads/3.0.0
Commit: 86d27fc9730d055970c4528c6156eea0fbc2bf8c
Parents: ec35629
Author: Benn Mapes <be...@gmail.com>
Authored: Mon May 27 17:11:10 2013 -0700
Committer: Benn Mapes <be...@gmail.com>
Committed: Mon May 27 17:13:13 2013 -0700
----------------------------------------------------------------------
templates/standalone/CordovaAppProj.csproj | 1 -
templates/standalone/Plugins/Battery.cs | 79 -----------------------
templates/standalone/config.xml | 1 -
3 files changed, 0 insertions(+), 81 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/86d27fc9/templates/standalone/CordovaAppProj.csproj
----------------------------------------------------------------------
diff --git a/templates/standalone/CordovaAppProj.csproj b/templates/standalone/CordovaAppProj.csproj
index 2b43554..bcf300c 100644
--- a/templates/standalone/CordovaAppProj.csproj
+++ b/templates/standalone/CordovaAppProj.csproj
@@ -168,7 +168,6 @@
<ItemGroup>
<Compile Include="Plugins\AudioFormatsHelper.cs" />
<Compile Include="Plugins\AudioPlayer.cs" />
- <Compile Include="Plugins\Battery.cs" />
<Compile Include="Plugins\Camera.cs" />
<Compile Include="Plugins\Contacts.cs" />
<Compile Include="Plugins\DebugConsole.cs" />
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/86d27fc9/templates/standalone/Plugins/Battery.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/Plugins/Battery.cs b/templates/standalone/Plugins/Battery.cs
deleted file mode 100644
index 962959e..0000000
--- a/templates/standalone/Plugins/Battery.cs
+++ /dev/null
@@ -1,79 +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.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-
-using Microsoft.Phone.Info;
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
- /// <summary>
- /// Listens for changes to the state of the battery on the device.
- /// Currently only the "isPlugged" parameter available via native APIs.
- /// </summary>
- public class Battery : BaseCommand
- {
- private bool isPlugged = false;
- private EventHandler powerChanged;
-
- public Battery()
- {
- powerChanged = new EventHandler(DeviceStatus_PowerSourceChanged);
- isPlugged = DeviceStatus.PowerSource.ToString().CompareTo("External") == 0;
- }
-
- public void start(string options)
- {
- // Register power changed event handler
- DeviceStatus.PowerSourceChanged += powerChanged;
-
- PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
- result.KeepCallback = true;
- DispatchCommandResult(result);
- }
- public void stop(string options)
- {
- // Unregister power changed event handler
- DeviceStatus.PowerSourceChanged -= powerChanged;
- }
-
- private void DeviceStatus_PowerSourceChanged(object sender, EventArgs e)
- {
- isPlugged = DeviceStatus.PowerSource.ToString().CompareTo("External") == 0;
- PluginResult result = new PluginResult(PluginResult.Status.OK, GetCurrentBatteryStateFormatted());
- result.KeepCallback = true;
- DispatchCommandResult(result);
- }
-
- private string GetCurrentBatteryStateFormatted()
- {
- string batteryState = String.Format("\"level\":{0},\"isPlugged\":{1}",
- "null",
- isPlugged ? "true" : "false"
- );
- batteryState = "{" + batteryState + "}";
- return batteryState;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/86d27fc9/templates/standalone/config.xml
----------------------------------------------------------------------
diff --git a/templates/standalone/config.xml b/templates/standalone/config.xml
index 64aef33..56869c3 100644
--- a/templates/standalone/config.xml
+++ b/templates/standalone/config.xml
@@ -35,7 +35,6 @@
<plugin name="Media"/>
<plugin name="Capture"/>
<plugin name="SplashScreen"/>
- <plugin name="Battery"/>
<plugin name="Globalization"/>
</plugins>
[2/5] wp7 commit: removed notification plugin dependencies
Posted by be...@apache.org.
removed notification plugin dependencies
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp7/commit/4d05619d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp7/tree/4d05619d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp7/diff/4d05619d
Branch: refs/heads/3.0.0
Commit: 4d05619d3f63c9e2ded701abcb03434cbe4d0f0f
Parents: 640e505
Author: Benn Mapes <be...@gmail.com>
Authored: Fri May 24 17:49:45 2013 -0700
Committer: Benn Mapes <be...@gmail.com>
Committed: Mon May 27 17:12:48 2013 -0700
----------------------------------------------------------------------
templates/standalone/CordovaAppProj.csproj | 1 -
templates/standalone/Plugins/Notification.cs | 367 ---------------------
templates/standalone/config.xml | 1 -
3 files changed, 0 insertions(+), 369 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/4d05619d/templates/standalone/CordovaAppProj.csproj
----------------------------------------------------------------------
diff --git a/templates/standalone/CordovaAppProj.csproj b/templates/standalone/CordovaAppProj.csproj
index 3e0bc51..8d4c3e0 100644
--- a/templates/standalone/CordovaAppProj.csproj
+++ b/templates/standalone/CordovaAppProj.csproj
@@ -182,7 +182,6 @@
<Compile Include="Plugins\Media.cs" />
<Compile Include="Plugins\MimeTypeMapper.cs" />
<Compile Include="Plugins\NetworkStatus.cs" />
- <Compile Include="Plugins\Notification.cs" />
<Compile Include="Plugins\UI\AudioCaptureTask.cs" />
<Compile Include="Plugins\UI\AudioRecorder.xaml.cs" >
<DependentUpon>AudioRecorder.xaml</DependentUpon>
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/4d05619d/templates/standalone/Plugins/Notification.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/Plugins/Notification.cs b/templates/standalone/Plugins/Notification.cs
deleted file mode 100644
index 11f14bd..0000000
--- a/templates/standalone/Plugins/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-wp7/blob/4d05619d/templates/standalone/config.xml
----------------------------------------------------------------------
diff --git a/templates/standalone/config.xml b/templates/standalone/config.xml
index 715c7d0..2f63bca 100644
--- a/templates/standalone/config.xml
+++ b/templates/standalone/config.xml
@@ -32,7 +32,6 @@
<plugin name="File"/>
<plugin name="FileTransfer"/>
<plugin name="Geolocation"/>
- <plugin name="Notification"/>
<plugin name="Media"/>
<plugin name="Capture"/>
<plugin name="SplashScreen"/>