diff --git a/framework/assets/js/phonegap.js.base b/framework/assets/js/phonegap.js.base index af0fb556..c6215128 100755 --- a/framework/assets/js/phonegap.js.base +++ b/framework/assets/js/phonegap.js.base @@ -237,6 +237,28 @@ PhoneGap.stringify = function(args) { if ((type == "number") || (type == "boolean")) { s = s + args[i]; } + else if (args[i] instanceof Array) { + s = s + "[" + args[i] + "]"; + } + else if (args[i] instanceof Object) { + var start = true; + s = s + '{'; + for (var name in args[i]) { + if (!start) { + s = s + ','; + } + s = s + '"' + name + '":'; + var nameType = typeof args[i][name]; + if ((nameType == "number") || (nameType == "boolean")) { + s = s + args[i][name]; + } + else { + s = s + '"' + args[i][name] + '"'; + } + start=false; + } + s = s + '}'; + } else { s = s + '"' + args[i] + '"'; } diff --git a/framework/assets/www/phonegap.js b/framework/assets/www/phonegap.js index c8791cbe..a98a68c2 100644 --- a/framework/assets/www/phonegap.js +++ b/framework/assets/www/phonegap.js @@ -237,6 +237,28 @@ PhoneGap.stringify = function(args) { if ((type == "number") || (type == "boolean")) { s = s + args[i]; } + else if (args[i] instanceof Array) { + s = s + "[" + args[i] + "]"; + } + else if (args[i] instanceof Object) { + var start = true; + s = s + '{'; + for (var name in args[i]) { + if (!start) { + s = s + ','; + } + s = s + '"' + name + '":'; + var nameType = typeof args[i][name]; + if ((nameType == "number") || (nameType == "boolean")) { + s = s + args[i][name]; + } + else { + s = s + '"' + args[i][name] + '"'; + } + start=false; + } + s = s + '}'; + } else { s = s + '"' + args[i] + '"'; } diff --git a/framework/src/com/phonegap/ContactAccessorSdk3_4.java b/framework/src/com/phonegap/ContactAccessorSdk3_4.java index f84fc0b4..927003f4 100644 --- a/framework/src/com/phonegap/ContactAccessorSdk3_4.java +++ b/framework/src/com/phonegap/ContactAccessorSdk3_4.java @@ -62,6 +62,7 @@ public class ContactAccessorSdk3_4 extends ContactAccessor { @Override public void search(JSONArray filter, JSONObject options) { + Log.d(LOG_TAG, "in 1.5+ search"); String searchTerm = ""; int limit = Integer.MAX_VALUE; boolean multiple = true; @@ -98,7 +99,7 @@ public class ContactAccessorSdk3_4 extends ContactAccessor { contact.put("phoneNumbers", phoneQuery(cr, contactId)); } // email - contact.put("emails", emailQuery(cr, contactId)); + //contact.put("emails", emailQuery(cr, contactId)); // addresses contact.put("addresses", addressQuery(cr, contactId)); // organizations @@ -119,6 +120,9 @@ public class ContactAccessorSdk3_4 extends ContactAccessor { } contacts.put(contact); } + cur.close(); + Log.d(LOG_TAG, "returning contacts string to javascript"); + mView.loadUrl("javascript:navigator.service.contacts.droidDone('" + contacts.toString() + "');"); } private JSONArray imQuery(ContentResolver cr, String contactId) { diff --git a/framework/src/com/phonegap/ContactManager.java b/framework/src/com/phonegap/ContactManager.java index 1c752c05..2882cb60 100755 --- a/framework/src/com/phonegap/ContactManager.java +++ b/framework/src/com/phonegap/ContactManager.java @@ -2,7 +2,6 @@ package com.phonegap; import org.json.JSONArray; import org.json.JSONException; -import org.json.JSONObject; import com.phonegap.api.Plugin; import com.phonegap.api.PluginResult; @@ -10,9 +9,7 @@ import com.phonegap.api.PluginResult; import android.util.Log; import android.webkit.WebView; import android.content.Intent; -import android.net.Uri; -@SuppressWarnings("deprecation") public class ContactManager implements Plugin { private static ContactAccessor contactAccessor; @@ -20,9 +17,6 @@ public class ContactManager implements Plugin { DroidGap ctx; // DroidGap object private static final String LOG_TAG = "Contact Query"; - Uri mPeople = android.provider.Contacts.People.CONTENT_URI; - Uri mPhone = android.provider.Contacts.Phones.CONTENT_URI; - Uri mEmail = android.provider.Contacts.ContactMethods.CONTENT_URI; /** * Constructor. @@ -70,10 +64,18 @@ public class ContactManager implements Plugin { //} //else if (action.equals("search")) { if (action.equals("search")) { + Log.d(LOG_TAG, "*** Calling search of " + contactAccessor.getClass().getName()); + Log.d(LOG_TAG, "what is 0 " + args.get(0).getClass().toString()); + Log.d(LOG_TAG, "what is 0 " + args.get(0).toString()); + Log.d(LOG_TAG, "what is 1 " + args.get(1).getClass().toString()); + Log.d(LOG_TAG, "what is 1 " + args.get(1).toString()); + Log.d(LOG_TAG, "Fields = " + args.getJSONArray(0).toString()); + Log.d(LOG_TAG, "Options = " + args.getJSONObject(1).toString()); contactAccessor.search(args.getJSONArray(0), args.getJSONObject(1)); } return new PluginResult(status, result); } catch (JSONException e) { + Log.e(LOG_TAG, e.getMessage(), e); return new PluginResult(PluginResult.Status.JSON_EXCEPTION); } }