mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
Issue #174: contact attribs should return null instead of empty array
Currently the implementation will return an empty array for the following Contact attributes: phoneNumbers, emails, addresses, ims, organizations, addresses, websites and photos. With this fix these attributes will be null unless the lenght of the array is greater than 0.
This commit is contained in:
parent
e09c728fd0
commit
c093881f54
@ -425,13 +425,28 @@ public class ContactAccessorSdk5 extends ContactAccessor {
|
||||
JSONArray addresses, JSONArray phones, JSONArray emails,
|
||||
JSONArray ims, JSONArray websites, JSONArray photos) {
|
||||
try {
|
||||
contact.put("organizations", organizations);
|
||||
contact.put("addresses", addresses);
|
||||
contact.put("phoneNumbers", phones);
|
||||
contact.put("emails", emails);
|
||||
contact.put("ims", ims);
|
||||
contact.put("websites", websites);
|
||||
contact.put("photos", photos);
|
||||
// Only return the array if it has at least one entry
|
||||
if (organizations.length() > 0) {
|
||||
contact.put("organizations", organizations);
|
||||
}
|
||||
if (addresses.length() > 0) {
|
||||
contact.put("addresses", addresses);
|
||||
}
|
||||
if (phones.length() > 0) {
|
||||
contact.put("phoneNumbers", phones);
|
||||
}
|
||||
if (emails.length() > 0) {
|
||||
contact.put("emails", emails);
|
||||
}
|
||||
if (ims.length() > 0) {
|
||||
contact.put("ims", ims);
|
||||
}
|
||||
if (websites.length() > 0) {
|
||||
contact.put("websites", websites);
|
||||
}
|
||||
if (photos.length() > 0) {
|
||||
contact.put("photos", photos);
|
||||
}
|
||||
}
|
||||
catch (JSONException e) {
|
||||
Log.e(LOG_TAG,e.getMessage(),e);
|
||||
|
Loading…
Reference in New Issue
Block a user