You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2016/08/22 20:10:11 UTC
cordova-plugin-contacts git commit: Plugin uses Android Log class and
not Cordova LOG class
Repository: cordova-plugin-contacts
Updated Branches:
refs/heads/master bc7845b43 -> 533d0d8d1
Plugin uses Android Log class and not Cordova LOG class
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/533d0d8d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/533d0d8d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/533d0d8d
Branch: refs/heads/master
Commit: 533d0d8d18ee1ed7f7efdc67d9ca8ab4eeeb8c97
Parents: bc7845b
Author: Simon MacDonald <si...@gmail.com>
Authored: Mon Aug 22 16:08:27 2016 -0400
Committer: Simon MacDonald <si...@gmail.com>
Committed: Mon Aug 22 16:09:52 2016 -0400
----------------------------------------------------------------------
src/android/ContactAccessor.java | 16 +++---
src/android/ContactAccessorSdk5.java | 86 +++++++++++++++----------------
src/android/ContactManager.java | 6 +--
3 files changed, 53 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/533d0d8d/src/android/ContactAccessor.java
----------------------------------------------------------------------
diff --git a/src/android/ContactAccessor.java b/src/android/ContactAccessor.java
index 2b73d43..462090b 100644
--- a/src/android/ContactAccessor.java
+++ b/src/android/ContactAccessor.java
@@ -20,8 +20,8 @@ import java.util.HashMap;
import android.Manifest;
import android.content.pm.PackageManager;
-import android.util.Log;
import org.apache.cordova.CordovaInterface;
+import org.apache.cordova.LOG;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -112,7 +112,7 @@ public abstract class ContactAccessor {
}
}
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
return map;
}
@@ -132,13 +132,13 @@ public abstract class ContactAccessor {
if (obj != null) {
value = obj.getString(property);
if (value.equals("null")) {
- Log.d(LOG_TAG, property + " is string called 'null'");
+ LOG.d(LOG_TAG, property + " is string called 'null'");
value = null;
}
}
}
catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get = " + e.getMessage());
+ LOG.d(LOG_TAG, "Could not get = " + e.getMessage());
}
return value;
}
@@ -159,10 +159,10 @@ public abstract class ContactAccessor {
* @throws JSONException
*/
public abstract JSONObject getContactById(String id) throws JSONException;
-
+
/**
* Handles searching through SDK-specific contacts API.
- * @param desiredFields fields that will filled. All fields will be filled if null
+ * @param desiredFields fields that will filled. All fields will be filled if null
* @throws JSONException
*/
public abstract JSONObject getContactById(String id, JSONArray desiredFields) throws JSONException;
@@ -171,9 +171,9 @@ public abstract class ContactAccessor {
* Handles removing a contact from the database.
*/
public abstract boolean remove(String id);
-
+
/**
- * A class that represents the where clause to be used in the database query
+ * A class that represents the where clause to be used in the database query
*/
class WhereOptions {
private String where;
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/533d0d8d/src/android/ContactAccessorSdk5.java
----------------------------------------------------------------------
diff --git a/src/android/ContactAccessorSdk5.java b/src/android/ContactAccessorSdk5.java
index 5d052fb..35d7d88 100644
--- a/src/android/ContactAccessorSdk5.java
+++ b/src/android/ContactAccessorSdk5.java
@@ -35,6 +35,7 @@ import java.util.Map;
import java.util.Set;
import org.apache.cordova.CordovaInterface;
+import org.apache.cordova.LOG;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -54,7 +55,6 @@ import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.text.TextUtils;
-import android.util.Log;
/**
* An implementation of {@link ContactAccessor} that uses current Contacts API.
@@ -165,7 +165,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
} catch (JSONException e) {
// Multiple was not specified so we assume the default is true.
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
try {
@@ -464,7 +464,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
// Set the old contact ID
@@ -556,7 +556,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
contact.put("photos", photos);
}
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
return contact;
}
@@ -636,7 +636,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}else if(!("%".equals(searchTerm))){
String key;
try {
- //Log.d(LOG_TAG, "How many fields do we have = " + fields.length());
+ //LOG.d(LOG_TAG, "How many fields do we have = " + fields.length());
for (int i = 0; i < fields.length(); i++) {
key = fields.getString(i);
@@ -708,7 +708,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
}
@@ -780,7 +780,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
organization.put("name", cursor.getString(cursor.getColumnIndex(CommonDataKinds.Organization.COMPANY)));
organization.put("title", cursor.getString(cursor.getColumnIndex(CommonDataKinds.Organization.TITLE)));
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
return organization;
}
@@ -803,7 +803,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
address.put("postalCode", cursor.getString(cursor.getColumnIndex(CommonDataKinds.StructuredPostal.POSTCODE)));
address.put("country", cursor.getString(cursor.getColumnIndex(CommonDataKinds.StructuredPostal.COUNTRY)));
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
return address;
}
@@ -850,7 +850,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
contactName.put("honorificSuffix", honorificSuffix);
contactName.put("formatted", formatted);
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
return contactName;
}
@@ -868,9 +868,9 @@ public class ContactAccessorSdk5 extends ContactAccessor {
phoneNumber.put("value", cursor.getString(cursor.getColumnIndex(CommonDataKinds.Phone.NUMBER)));
phoneNumber.put("type", getPhoneType(cursor.getInt(cursor.getColumnIndex(CommonDataKinds.Phone.TYPE))));
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
} catch (Exception excp) {
- Log.e(LOG_TAG, excp.getMessage(), excp);
+ LOG.e(LOG_TAG, excp.getMessage(), excp);
}
return phoneNumber;
}
@@ -888,7 +888,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
email.put("value", cursor.getString(cursor.getColumnIndex(CommonDataKinds.Email.DATA)));
email.put("type", getContactType(cursor.getInt(cursor.getColumnIndex(CommonDataKinds.Email.TYPE))));
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
return email;
}
@@ -906,7 +906,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
im.put("value", cursor.getString(cursor.getColumnIndex(CommonDataKinds.Im.DATA)));
im.put("type", getImType(Integer.parseInt(cursor.getString(cursor.getColumnIndex(CommonDataKinds.Im.PROTOCOL)))));
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
return im;
}
@@ -924,7 +924,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
website.put("value", cursor.getString(cursor.getColumnIndex(CommonDataKinds.Website.URL)));
website.put("type", getContactType(cursor.getInt(cursor.getColumnIndex(CommonDataKinds.Website.TYPE))));
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
return website;
}
@@ -954,9 +954,9 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
photoCursor.close();
} catch (JSONException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
} catch (SQLiteException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
} finally {
if(photoCursor != null && !photoCursor.isClosed()) {
photoCursor.close();
@@ -1080,7 +1080,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
ops.add(builder.build());
}
} catch (JSONException e1) {
- Log.d(LOG_TAG, "Could not get name");
+ LOG.d(LOG_TAG, "Could not get name");
}
// Modify phone numbers
@@ -1126,7 +1126,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get phone numbers");
+ LOG.d(LOG_TAG, "Could not get phone numbers");
}
// Modify emails
@@ -1181,7 +1181,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get emails");
+ LOG.d(LOG_TAG, "Could not get emails");
}
// Modify addresses
@@ -1237,7 +1237,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get addresses");
+ LOG.d(LOG_TAG, "Could not get addresses");
}
// Modify organizations
@@ -1287,7 +1287,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get organizations");
+ LOG.d(LOG_TAG, "Could not get organizations");
}
// Modify IMs
@@ -1333,7 +1333,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get emails");
+ LOG.d(LOG_TAG, "Could not get emails");
}
// Modify note
@@ -1363,7 +1363,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
if (websites != null) {
// Delete all the websites
if (websites.length() == 0) {
- Log.d(LOG_TAG, "This means we should be deleting all the phone numbers.");
+ LOG.d(LOG_TAG, "This means we should be deleting all the phone numbers.");
ops.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI)
.withSelection(ContactsContract.Data.RAW_CONTACT_ID + "=? AND " +
ContactsContract.Data.MIMETYPE + "=?",
@@ -1400,7 +1400,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get websites");
+ LOG.d(LOG_TAG, "Could not get websites");
}
// Modify birthday
@@ -1460,7 +1460,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get photos");
+ LOG.d(LOG_TAG, "Could not get photos");
}
boolean retVal = true;
@@ -1469,12 +1469,10 @@ public class ContactAccessorSdk5 extends ContactAccessor {
try {
mApp.getActivity().getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
} catch (RemoteException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
- Log.e(LOG_TAG, Log.getStackTraceString(e), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
retVal = false;
} catch (OperationApplicationException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
- Log.e(LOG_TAG, Log.getStackTraceString(e), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
retVal = false;
}
@@ -1628,9 +1626,9 @@ public class ContactAccessorSdk5 extends ContactAccessor {
in.close();
buffer.flush();
} catch (FileNotFoundException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
} catch (IOException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
return buffer.toByteArray();
}
@@ -1692,7 +1690,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
.withValue(CommonDataKinds.StructuredName.SUFFIX, getJsonString(name, "honorificSuffix"))
.build());
} else {
- Log.d(LOG_TAG, "Both \"name\" and \"displayName\" properties are empty");
+ LOG.d(LOG_TAG, "Both \"name\" and \"displayName\" properties are empty");
}
//Add phone numbers
@@ -1708,7 +1706,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get phone numbers");
+ LOG.d(LOG_TAG, "Could not get phone numbers");
}
// Add emails
@@ -1722,7 +1720,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get emails");
+ LOG.d(LOG_TAG, "Could not get emails");
}
// Add addresses
@@ -1736,7 +1734,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get addresses");
+ LOG.d(LOG_TAG, "Could not get addresses");
}
// Add organizations
@@ -1750,7 +1748,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get organizations");
+ LOG.d(LOG_TAG, "Could not get organizations");
}
// Add IMs
@@ -1764,7 +1762,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get emails");
+ LOG.d(LOG_TAG, "Could not get emails");
}
// Add note
@@ -1798,7 +1796,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get websites");
+ LOG.d(LOG_TAG, "Could not get websites");
}
// Add birthday
@@ -1823,7 +1821,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
}
} catch (JSONException e) {
- Log.d(LOG_TAG, "Could not get photos");
+ LOG.d(LOG_TAG, "Could not get photos");
}
String newId = null;
@@ -1834,9 +1832,9 @@ public class ContactAccessorSdk5 extends ContactAccessor {
newId = cpResults[0].uri.getLastPathSegment();
}
} catch (RemoteException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
} catch (OperationApplicationException e) {
- Log.e(LOG_TAG, e.getMessage(), e);
+ LOG.e(LOG_TAG, e.getMessage(), e);
}
return newId;
}
@@ -1859,7 +1857,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
result = mApp.getActivity().getContentResolver().delete(uri, null, null);
} else {
- Log.d(LOG_TAG, "Could not find contact with ID");
+ LOG.d(LOG_TAG, "Could not find contact with ID");
}
return (result > 0) ? true : false;
@@ -1876,7 +1874,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
Long timestamp = contact.getLong("birthday");
return new Date(timestamp);
} catch (JSONException e) {
- Log.e(LOG_TAG, "Could not get birthday from JSON object", e);
+ LOG.e(LOG_TAG, "Could not get birthday from JSON object", e);
return null;
}
}
@@ -1893,7 +1891,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
try {
return Date.valueOf(c.getString(colBirthday));
} catch (IllegalArgumentException e) {
- Log.e(LOG_TAG, "Failed to get birthday for contact from cursor", e);
+ LOG.e(LOG_TAG, "Failed to get birthday for contact from cursor", e);
return null;
}
}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/533d0d8d/src/android/ContactManager.java
----------------------------------------------------------------------
diff --git a/src/android/ContactManager.java b/src/android/ContactManager.java
index 268b8ea..4a111e1 100644
--- a/src/android/ContactManager.java
+++ b/src/android/ContactManager.java
@@ -21,6 +21,7 @@ package org.apache.cordova.contacts;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaActivity;
import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.LOG;
import org.apache.cordova.PermissionHelper;
import org.apache.cordova.PluginResult;
import org.json.JSONArray;
@@ -36,7 +37,6 @@ import android.os.Build;
import android.os.Bundle;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.RawContacts;
-import android.util.Log;
import java.lang.reflect.Method;
@@ -188,7 +188,7 @@ public class ContactManager extends CordovaPlugin {
try {
res = contactAccessor.getContactById(id);
} catch (JSONException e) {
- Log.e(LOG_TAG, "JSON fail.", e);
+ LOG.e(LOG_TAG, "JSON fail.", e);
}
}
if (res != null) {
@@ -255,7 +255,7 @@ public class ContactManager extends CordovaPlugin {
this.callbackContext.success(contact);
return;
} catch (JSONException e) {
- Log.e(LOG_TAG, "JSON fail.", e);
+ LOG.e(LOG_TAG, "JSON fail.", e);
}
} else if (resultCode == Activity.RESULT_CANCELED) {
callbackContext.error(OPERATION_CANCELLED_ERROR);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org