Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Jesse MacFadyen authored
7  templates/standalone/cordovalib/Commands/AudioPlayer.cs
@@ -622,8 +622,11 @@ private void InitializeXnaGameLoop()
622 622
         private void FinalizeXnaGameLoop()
623 623
         {
624 624
             // Timer to simulate the XNA game loop (Microphone is from XNA)
625  
-            this.dtXna.Stop();
626  
-            this.dtXna = null;
  625
+            if (this.dtXna != null)
  626
+            {
  627
+                this.dtXna.Stop();
  628
+                this.dtXna = null;
  629
+            }
627 630
         }
628 631
 
629 632
         #endregion
80  templates/standalone/cordovalib/Commands/Contacts.cs
@@ -12,24 +12,16 @@
12 12
 	limitations under the License.
13 13
 */
14 14
 
15  
-using System;
16  
-using System.Net;
17  
-using System.Windows;
18  
-using System.Windows.Controls;
19  
-using System.Windows.Documents;
20  
-using System.Windows.Ink;
21  
-using System.Windows.Input;
22  
-using System.Windows.Media;
23  
-using System.Windows.Media.Animation;
24  
-using System.Windows.Shapes;
25 15
 using Microsoft.Phone.Tasks;
26 16
 using Microsoft.Phone.UserData;
  17
+using System;
27 18
 using System.Collections;
28 19
 using System.Collections.Generic;
29  
-using System.Runtime.Serialization;
30  
-using DeviceContacts = Microsoft.Phone.UserData.Contacts;
31 20
 using System.Diagnostics;
32 21
 using System.Linq;
  22
+using System.Runtime.Serialization;
  23
+using System.Windows;
  24
+using DeviceContacts = Microsoft.Phone.UserData.Contacts;
33 25
 
34 26
 
35 27
 namespace WP7CordovaClassLib.Cordova.Commands
@@ -176,23 +168,6 @@ public Contacts()
176 168
 
177 169
         }
178 170
 
179  
-        private void saveContactTask_Completed(object sender, SaveContactResult e)
180  
-        {
181  
-            switch (e.TaskResult)
182  
-            {
183  
-                case TaskResult.OK:
184  
-                    // successful save
185  
-                    MessageBoxResult res = MessageBox.Show("contact saved", "Alert", MessageBoxButton.OK);
186  
-                    break;
187  
-                case TaskResult.Cancel:
188  
-                    // user cancelled
189  
-                    break;
190  
-                case TaskResult.None:
191  
-                    // no info about result is available
192  
-                    break;
193  
-            }
194  
-        }
195  
-
196 171
         // 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
197 172
         public void save(string jsonContact)
198 173
         {
@@ -265,13 +240,28 @@ public void save(string jsonContact)
265 240
             #endregion
266 241
 
267 242
             #region contact.emails
  243
+
268 244
             if (contact.emails != null && contact.emails.Length > 0)
269 245
             {
  246
+
  247
+                // set up different email types if they are not explicitly defined
  248
+                foreach (string type in new string[] { "personal", "work", "other" })
  249
+                {
  250
+                    foreach (JSONContactField field in contact.emails)
  251
+                    {
  252
+                        if (field != null && String.IsNullOrEmpty(field.type))
  253
+                        {
  254
+                            field.type = type;
  255
+                            break;
  256
+                        }
  257
+                    }
  258
+                }
  259
+
270 260
                 foreach (JSONContactField field in contact.emails)
271 261
                 {
272 262
                     if (field != null)
273 263
                     {
274  
-                        if (field.type != null)
  264
+                        if (field.type != null && field.type != "other")
275 265
                         {
276 266
                             string fieldType = field.type.ToLower();
277 267
                             if (fieldType == "work")
@@ -334,25 +324,32 @@ public void save(string jsonContact)
334 324
             #endregion
335 325
 
336 326
 
337  
-            contactTask.Completed += new EventHandler<SaveContactResult>(contactTask_Completed);
  327
+            contactTask.Completed += new EventHandler<SaveContactResult>(ContactSaveTaskCompleted);
338 328
             contactTask.Show();
339  
-
340  
-            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new string[] { }));
341 329
         }
342 330
 
343  
-        void contactTask_Completed(object sender, SaveContactResult e)
  331
+        void ContactSaveTaskCompleted(object sender, SaveContactResult e)
344 332
         {
345 333
             SaveContactTask task = sender as SaveContactTask;
346 334
 
347 335
             if (e.TaskResult == TaskResult.OK)
348 336
             {
349  
-                DeviceContacts deviceContacts = new DeviceContacts();
350  
-                deviceContacts.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(postAdd_SearchCompleted);
351  
-                deviceContacts.SearchAsync(task.FirstName + " " + task.LastName, FilterKind.DisplayName, task);
  337
+
  338
+                Deployment.Current.Dispatcher.BeginInvoke(() =>
  339
+                {
  340
+                    DeviceContacts deviceContacts = new DeviceContacts();
  341
+                    deviceContacts.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(postAdd_SearchCompleted);
  342
+
  343
+                    string displayName = String.Format("{0}{2}{1}", task.FirstName, task.LastName, String.IsNullOrEmpty(task.FirstName) ? "" : " ");
  344
+
  345
+                    deviceContacts.SearchAsync(displayName, FilterKind.DisplayName, task);
  346
+                });
  347
+                
  348
+
352 349
             }
353 350
             else if (e.TaskResult == TaskResult.Cancel)
354 351
             {
355  
-
  352
+                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Operation cancelled."));
356 353
             }
357 354
         }
358 355
 
@@ -637,7 +634,9 @@ private string FormatJSONContact(Contact con, string[] fields)
637 634
                                       "\"addresses\":[{5}]," +
638 635
                                       "\"urls\":[{6}]," +
639 636
                                       "\"name\":{7}," +
640  
-                                      "\"note\":\"{8}\"";
  637
+                                      "\"note\":\"{8}\"," +
  638
+                                      "\"birthday\":\"{9}\"";
  639
+
641 640
 
642 641
             string jsonContact = String.Format(contactFormatStr,
643 642
                                                con.GetHashCode(),
@@ -648,7 +647,8 @@ private string FormatJSONContact(Contact con, string[] fields)
648 647
                                                FormatJSONAddresses(con),
649 648
                                                FormatJSONWebsites(con),
650 649
                                                FormatJSONName(con),
651  
-                                               con.Notes.FirstOrDefault());
  650
+                                               con.Notes.FirstOrDefault(),
  651
+                                               con.Birthdays.FirstOrDefault());
652 652
 
653 653
             //Debug.WriteLine("jsonContact = " + jsonContact);
654 654
             // JSON requires new line characters be escaped
10  templates/standalone/cordovalib/Commands/File.cs
@@ -1125,21 +1125,21 @@ private void removeDirRecursively(string fullPath)
1125 1125
                 {
1126 1126
                     if (isoFile.DirectoryExists(fullPath))
1127 1127
                     {
1128  
-                        string path = File.AddSlashToDirectory(fullPath);
1129  
-                        string[] files = isoFile.GetFileNames(path + "*");
  1128
+                        string tempPath = File.AddSlashToDirectory(fullPath);
  1129
+                        string[] files = isoFile.GetFileNames(tempPath + "*");
1130 1130
                         if (files.Length > 0)
1131 1131
                         {
1132 1132
                             foreach (string file in files)
1133 1133
                             {
1134  
-                                isoFile.DeleteFile(path + file);
  1134
+                                isoFile.DeleteFile(tempPath + file);
1135 1135
                             }
1136 1136
                         }
1137  
-                        string[] dirs = isoFile.GetDirectoryNames(path + "*");
  1137
+                        string[] dirs = isoFile.GetDirectoryNames(tempPath + "*");
1138 1138
                         if (dirs.Length > 0)
1139 1139
                         {
1140 1140
                             foreach (string dir in dirs)
1141 1141
                             {
1142  
-                                removeDirRecursively(path + dir + "/");
  1142
+                                removeDirRecursively(tempPath + dir);
1143 1143
                             }
1144 1144
                         }
1145 1145
                         isoFile.DeleteDirectory(fullPath);

0 notes on commit c7e56d7

Please sign in to comment.
Something went wrong with that request. Please try again.