You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2016/12/08 00:56:36 UTC
[06/11] cordova-plugin-contacts git commit: CB-11206 (android) Fixed
custom IM protocol parsing close #128
CB-11206 (android) Fixed custom IM protocol parsing
close #128
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/7f662d6c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/7f662d6c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/7f662d6c
Branch: refs/heads/2.2.x
Commit: 7f662d6c67ac08a96adef633dd426cf998421296
Parents: 534d16c
Author: Alexander Sorokin <al...@akvelon.com>
Authored: Fri Oct 28 20:50:37 2016 +0300
Committer: Alexander Sorokin <al...@akvelon.com>
Committed: Fri Oct 28 20:50:37 2016 +0300
----------------------------------------------------------------------
src/android/ContactAccessorSdk5.java | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/7f662d6c/src/android/ContactAccessorSdk5.java
----------------------------------------------------------------------
diff --git a/src/android/ContactAccessorSdk5.java b/src/android/ContactAccessorSdk5.java
index 1ef0e6c..8f7135e 100644
--- a/src/android/ContactAccessorSdk5.java
+++ b/src/android/ContactAccessorSdk5.java
@@ -904,7 +904,15 @@ public class ContactAccessorSdk5 extends ContactAccessor {
im.put("id", cursor.getString(cursor.getColumnIndex(CommonDataKinds.Im._ID)));
im.put("pref", false); // Android does not store pref attribute
im.put("value", cursor.getString(cursor.getColumnIndex(CommonDataKinds.Im.DATA)));
- im.put("type", getImType(Integer.parseInt(cursor.getString(cursor.getColumnIndex(CommonDataKinds.Im.PROTOCOL)))));
+ String protocol = cursor.getString(cursor.getColumnIndex(CommonDataKinds.Im.PROTOCOL));
+ if (!isInteger(protocol) || Integer.parseInt(protocol) == CommonDataKinds.Im.PROTOCOL_CUSTOM) {
+ // the protocol is custom, get its name and put it into JSON
+ protocol = cursor.getString(cursor.getColumnIndex(CommonDataKinds.Im.CUSTOM_PROTOCOL));
+ im.put("type", protocol);
+ } else {
+ // (the protocol is one of the standard ones) look up its type and then put it into JSON
+ im.put("type", getImType(Integer.parseInt(protocol)));
+ }
} catch (JSONException e) {
LOG.e(LOG_TAG, e.getMessage(), e);
}
@@ -2290,4 +2298,19 @@ public class ContactAccessorSdk5 extends ContactAccessor {
return stringType;
}
+ /**
+ * checks if a String can be converted to an Integer
+ * @param str
+ * @return boolean
+ */
+ private static boolean isInteger(String str) {
+ try {
+ Integer.parseInt(str);
+ return true;
+ }
+ catch(Exception e) {
+ return false;
+ }
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org