Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #22 from sgrebnov/master

fixes CB-1663 WP7. Fix mobile-spec tests issues
  • Loading branch information...
commit c7e56d7d52f07a77cd778df5c5c6086730d119be 2 parents d805058 + 35a91b2
@purplecabbage purplecabbage authored
View
7 templates/standalone/cordovalib/Commands/AudioPlayer.cs
@@ -622,8 +622,11 @@ private void InitializeXnaGameLoop()
private void FinalizeXnaGameLoop()
{
// Timer to simulate the XNA game loop (Microphone is from XNA)
- this.dtXna.Stop();
- this.dtXna = null;
+ if (this.dtXna != null)
+ {
+ this.dtXna.Stop();
+ this.dtXna = null;
+ }
}
#endregion
View
80 templates/standalone/cordovalib/Commands/Contacts.cs
@@ -12,24 +12,16 @@
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.Tasks;
using Microsoft.Phone.UserData;
+using System;
using System.Collections;
using System.Collections.Generic;
-using System.Runtime.Serialization;
-using DeviceContacts = Microsoft.Phone.UserData.Contacts;
using System.Diagnostics;
using System.Linq;
+using System.Runtime.Serialization;
+using System.Windows;
+using DeviceContacts = Microsoft.Phone.UserData.Contacts;
namespace WP7CordovaClassLib.Cordova.Commands
@@ -176,23 +168,6 @@ public Contacts()
}
- private void saveContactTask_Completed(object sender, SaveContactResult e)
- {
- switch (e.TaskResult)
- {
- case TaskResult.OK:
- // successful save
- MessageBoxResult res = MessageBox.Show("contact saved", "Alert", MessageBoxButton.OK);
- break;
- case TaskResult.Cancel:
- // user cancelled
- break;
- case TaskResult.None:
- // no info about result is available
- break;
- }
- }
-
// refer here for contact properties we can access: http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.savecontacttask_members%28v=VS.92%29.aspx
public void save(string jsonContact)
{
@@ -265,13 +240,28 @@ public void save(string jsonContact)
#endregion
#region contact.emails
+
if (contact.emails != null && contact.emails.Length > 0)
{
+
+ // set up different email types if they are not explicitly defined
+ foreach (string type in new string[] { "personal", "work", "other" })
+ {
+ foreach (JSONContactField field in contact.emails)
+ {
+ if (field != null && String.IsNullOrEmpty(field.type))
+ {
+ field.type = type;
+ break;
+ }
+ }
+ }
+
foreach (JSONContactField field in contact.emails)
{
if (field != null)
{
- if (field.type != null)
+ if (field.type != null && field.type != "other")
{
string fieldType = field.type.ToLower();
if (fieldType == "work")
@@ -334,25 +324,32 @@ public void save(string jsonContact)
#endregion
- contactTask.Completed += new EventHandler<SaveContactResult>(contactTask_Completed);
+ contactTask.Completed += new EventHandler<SaveContactResult>(ContactSaveTaskCompleted);
contactTask.Show();
-
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new string[] { }));
}
- void contactTask_Completed(object sender, SaveContactResult e)
+ void ContactSaveTaskCompleted(object sender, SaveContactResult e)
{
SaveContactTask task = sender as SaveContactTask;
if (e.TaskResult == TaskResult.OK)
{
- DeviceContacts deviceContacts = new DeviceContacts();
- deviceContacts.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(postAdd_SearchCompleted);
- deviceContacts.SearchAsync(task.FirstName + " " + task.LastName, FilterKind.DisplayName, task);
+
+ Deployment.Current.Dispatcher.BeginInvoke(() =>
+ {
+ DeviceContacts deviceContacts = new DeviceContacts();
+ deviceContacts.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(postAdd_SearchCompleted);
+
+ string displayName = String.Format("{0}{2}{1}", task.FirstName, task.LastName, String.IsNullOrEmpty(task.FirstName) ? "" : " ");
+
+ deviceContacts.SearchAsync(displayName, FilterKind.DisplayName, task);
+ });
+
+
}
else if (e.TaskResult == TaskResult.Cancel)
{
-
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Operation cancelled."));
}
}
@@ -637,7 +634,9 @@ private string FormatJSONContact(Contact con, string[] fields)
"\"addresses\":[{5}]," +
"\"urls\":[{6}]," +
"\"name\":{7}," +
- "\"note\":\"{8}\"";
+ "\"note\":\"{8}\"," +
+ "\"birthday\":\"{9}\"";
+
string jsonContact = String.Format(contactFormatStr,
con.GetHashCode(),
@@ -648,7 +647,8 @@ private string FormatJSONContact(Contact con, string[] fields)
FormatJSONAddresses(con),
FormatJSONWebsites(con),
FormatJSONName(con),
- con.Notes.FirstOrDefault());
+ con.Notes.FirstOrDefault(),
+ con.Birthdays.FirstOrDefault());
//Debug.WriteLine("jsonContact = " + jsonContact);
// JSON requires new line characters be escaped
View
10 templates/standalone/cordovalib/Commands/File.cs
@@ -1125,21 +1125,21 @@ private void removeDirRecursively(string fullPath)
{
if (isoFile.DirectoryExists(fullPath))
{
- string path = File.AddSlashToDirectory(fullPath);
- string[] files = isoFile.GetFileNames(path + "*");
+ string tempPath = File.AddSlashToDirectory(fullPath);
+ string[] files = isoFile.GetFileNames(tempPath + "*");
if (files.Length > 0)
{
foreach (string file in files)
{
- isoFile.DeleteFile(path + file);
+ isoFile.DeleteFile(tempPath + file);
}
}
- string[] dirs = isoFile.GetDirectoryNames(path + "*");
+ string[] dirs = isoFile.GetDirectoryNames(tempPath + "*");
if (dirs.Length > 0)
{
foreach (string dir in dirs)
{
- removeDirRecursively(path + dir + "/");
+ removeDirRecursively(tempPath + dir);
}
}
isoFile.DeleteDirectory(fullPath);
Please sign in to comment.
Something went wrong with that request. Please try again.