Commit cc49b6a4 authored by Ricki Hirner's avatar Ricki Hirner 🐑

remove empty string values from ContentValues before processing data rows

parent fb144332
Pipeline #9545572 passed with stage
in 9 minutes and 29 seconds
...@@ -119,6 +119,14 @@ open class AndroidContact( ...@@ -119,6 +119,14 @@ open class AndroidContact(
val subValues = e.subValues val subValues = e.subValues
for (subValue in subValues) { for (subValue in subValues) {
val values = subValue.values val values = subValue.values
// remove empty values
val it = values.keySet().iterator()
while (it.hasNext()) {
val obj = values[it.next()]
if (obj is String && obj.isEmpty())
it.remove()
}
val mimeType = values.getAsString(ContactsContract.RawContactsEntity.MIMETYPE) val mimeType = values.getAsString(ContactsContract.RawContactsEntity.MIMETYPE)
when (mimeType) { when (mimeType) {
...@@ -297,27 +305,20 @@ open class AndroidContact( ...@@ -297,27 +305,20 @@ open class AndroidContact(
val company = row.getAsString(Organization.COMPANY) val company = row.getAsString(Organization.COMPANY)
val department = row.getAsString(Organization.DEPARTMENT) val department = row.getAsString(Organization.DEPARTMENT)
val title = row.getAsString(Organization.TITLE) if (company != null || department != null) {
val role = row.getAsString(Organization.JOB_DESCRIPTION)
if (!company.isNullOrEmpty() || !department.isNullOrEmpty()) {
val org = ezvcard.property.Organization() val org = ezvcard.property.Organization()
if (!company.isNullOrEmpty()) company?.let { org.values += it }
org.values += company department?.let { org.values += it }
if (!department.isNullOrEmpty())
org.values += department
contact.organization = org contact.organization = org
} }
if (!title.isNullOrEmpty()) row.getAsString(Organization.TITLE)?.let { contact.jobTitle = it }
contact.jobTitle = title row.getAsString(Organization.JOB_DESCRIPTION)?.let { contact.jobDescription = it }
if (!role.isNullOrEmpty())
contact.jobDescription = role
} }
protected fun populateIMPP(row: ContentValues) { protected fun populateIMPP(row: ContentValues) {
val handle = row.getAsString(Im.DATA) val handle = row.getAsString(Im.DATA)
if (handle.isNullOrEmpty()) { if (handle == null) {
Constants.log.warning("Ignoring instant messenger record without handle") Constants.log.warning("Ignoring instant messenger record without handle")
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment