From 3f24c63fc537262fca0790aea2f4f53d21832871 Mon Sep 17 00:00:00 2001 From: macdonst Date: Mon, 13 Sep 2010 16:14:33 -0400 Subject: [PATCH] Changing navigator.contacts to navigator.service.contacts --- example/index.html | 2 +- framework/assets/js/contact.js | 3 ++- framework/assets/www/phonegap.js | 3 ++- .../src/com/phonegap/ContactAccessorSdk3_4.java | 16 ++++++++-------- .../src/com/phonegap/ContactAccessorSdk5.java | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/example/index.html b/example/index.html index dca39dd4..124e8101 100644 --- a/example/index.html +++ b/example/index.html @@ -105,7 +105,7 @@ var name = new ContactName(); name.givenName = ''; obj.name = name; - navigator.contacts.find(obj, count_contacts, fail); + navigator.service.contacts.find(obj, count_contacts, fail); } function count_contacts(contacts) diff --git a/framework/assets/js/contact.js b/framework/assets/js/contact.js index 05be9341..ac27140a 100644 --- a/framework/assets/js/contact.js +++ b/framework/assets/js/contact.js @@ -152,5 +152,6 @@ ContactError.TIMEOUT_ERROR = 6; ContactError.UNKNOWN_ERROR = 7; PhoneGap.addConstructor(function() { - if(typeof navigator.contacts == "undefined") navigator.contacts = new Contacts(); + if(typeof navigator.service == "undefined") navigator.service = new Object(); + if(typeof navigator.service.contacts == "undefined") navigator.service.contacts = new Contacts(); }); diff --git a/framework/assets/www/phonegap.js b/framework/assets/www/phonegap.js index 6cb55124..543c3627 100644 --- a/framework/assets/www/phonegap.js +++ b/framework/assets/www/phonegap.js @@ -1081,7 +1081,8 @@ ContactError.TIMEOUT_ERROR = 6; ContactError.UNKNOWN_ERROR = 7; PhoneGap.addConstructor(function() { - if(typeof navigator.contacts == "undefined") navigator.contacts = new Contacts(); + if(typeof navigator.service == "undefined") navigator.service = new Object(); + if(typeof navigator.service.contacts == "undefined") navigator.service.contacts = new Contacts(); }); com.phonegap.CryptoHandlerProxy = function() { this.className = "com.phonegap.CryptoHandler"; diff --git a/framework/src/com/phonegap/ContactAccessorSdk3_4.java b/framework/src/com/phonegap/ContactAccessorSdk3_4.java index a806edf3..ec4a4d40 100644 --- a/framework/src/com/phonegap/ContactAccessorSdk3_4.java +++ b/framework/src/com/phonegap/ContactAccessorSdk3_4.java @@ -159,22 +159,22 @@ public class ContactAccessorSdk3_4 extends ContactAccessor { // Code for backwards compatibility with the OLD Contacts API if (all) - mView.loadUrl("javascript:navigator.ContactManager.droidAddContact('" + name + "','" + phoneNumber + "','" + email +"')"); + mView.loadUrl("javascript:navigator.service.ContactManager.droidAddContact('" + name + "','" + phoneNumber + "','" + email +"')"); else - mView.loadUrl("javascript:navigator.contacts.droidFoundContact('" + name + "','" + phoneNumber + "','" + email +"')"); + mView.loadUrl("javascript:navigator.service.contacts.droidFoundContact('" + name + "','" + phoneNumber + "','" + email +"')"); } while (cur.moveToNext()); if (all) - mView.loadUrl("javascript:navigator.ContactManager.droidDone()"); + mView.loadUrl("javascript:navigator.service.ContactManager.droidDone()"); else - mView.loadUrl("javascript:navigator.contacts.droidDone();"); + mView.loadUrl("javascript:navigator.service.contacts.droidDone();"); } else { if(all) - mView.loadUrl("javascript:navigator.ContactManager.fail()"); + mView.loadUrl("javascript:navigator.service.ContactManager.fail()"); else - mView.loadUrl("javascript:navigator.contacts.fail('None found!')"); + mView.loadUrl("javascript:navigator.service.contacts.fail('None found!')"); } } @@ -197,10 +197,10 @@ public class ContactAccessorSdk3_4 extends ContactAccessor { if(data != null) { data.email = email; - mView.loadUrl("javascript:navigator.Contacts.droidFoundContact('" + data.name + "','" + data.phone + "','" + data.email +"')"); + mView.loadUrl("javascript:navigator.service.Contacts.droidFoundContact('" + data.name + "','" + data.phone + "','" + data.email +"')"); } } while (cur.moveToNext()); - mView.loadUrl("javascript:navigator.contacts.droidDoneContacts();"); + mView.loadUrl("javascript:navigator.service.contacts.droidDoneContacts();"); } } diff --git a/framework/src/com/phonegap/ContactAccessorSdk5.java b/framework/src/com/phonegap/ContactAccessorSdk5.java index a7d27d1e..e9353e76 100644 --- a/framework/src/com/phonegap/ContactAccessorSdk5.java +++ b/framework/src/com/phonegap/ContactAccessorSdk5.java @@ -98,11 +98,11 @@ public class ContactAccessorSdk5 extends ContactAccessor { emailAddress = "'" + emails.getString(emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA)).replace('\'', '`') + "'"; } emails.close(); - String contactAddJS = "javascript:navigator.contacts.droidFoundContact('" + contactName.replace('\'', '`') + "'," + phoneNumber + "," + emailAddress +")"; + String contactAddJS = "javascript:navigator.service.contacts.droidFoundContact('" + contactName.replace('\'', '`') + "'," + phoneNumber + "," + emailAddress +")"; mView.loadUrl(contactAddJS); } cursor.close(); - mView.loadUrl("javascript:navigator.contacts.droidDone();"); + mView.loadUrl("javascript:navigator.service.contacts.droidDone();"); } } \ No newline at end of file