Skip to content
This repository has been archived by the owner on Apr 18, 2019. It is now read-only.

Commit

Permalink
Merge pull request #22 from sgrebnov/master
Browse files Browse the repository at this point in the history
fixes CB-1663 WP7. Fix mobile-spec tests issues
  • Loading branch information
purplecabbage committed Oct 30, 2012
2 parents d805058 + 35a91b2 commit c7e56d7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 47 deletions.
7 changes: 5 additions & 2 deletions templates/standalone/cordovalib/Commands/AudioPlayer.cs
Expand Up @@ -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
Expand Down
80 changes: 40 additions & 40 deletions templates/standalone/cordovalib/Commands/Contacts.cs
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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."));
}
}

Expand Down Expand Up @@ -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(),
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions templates/standalone/cordovalib/Commands/File.cs
Expand Up @@ -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);
Expand Down

0 comments on commit c7e56d7

Please sign in to comment.