diff --git a/library/src/androidTest/java/com/alexstyl/contactstore/ContactStoreInsertContactTest.kt b/library/src/androidTest/java/com/alexstyl/contactstore/ContactStoreInsertContactTest.kt index 86cfcc99..e4ff0e65 100644 --- a/library/src/androidTest/java/com/alexstyl/contactstore/ContactStoreInsertContactTest.kt +++ b/library/src/androidTest/java/com/alexstyl/contactstore/ContactStoreInsertContactTest.kt @@ -131,7 +131,6 @@ class ContactStoreInsertContactTest : ContactStoreTestBase() { val actual = store.fetchContacts(columnsToFetch = listOf(Events)).first() val expected = contact( - displayName = "", columns = listOf(Events), events = listOf( LabeledValue( @@ -226,7 +225,6 @@ class ContactStoreInsertContactTest : ContactStoreTestBase() { val actual = store.fetchContacts(columnsToFetch = listOf(WebAddresses)).first() val expected = contact( - displayName = "", columns = listOf(WebAddresses), webAddresses = listOf( LabeledValue( diff --git a/library/src/androidTest/java/com/alexstyl/contactstore/ContactStoreTestBase.kt b/library/src/androidTest/java/com/alexstyl/contactstore/ContactStoreTestBase.kt index 6acac00a..bd0629be 100644 --- a/library/src/androidTest/java/com/alexstyl/contactstore/ContactStoreTestBase.kt +++ b/library/src/androidTest/java/com/alexstyl/contactstore/ContactStoreTestBase.kt @@ -58,7 +58,7 @@ abstract class ContactStoreTestBase { protected open val context: Application = ApplicationProvider.getApplicationContext() protected fun contact( - displayName: String = "", + displayName: String? = null, firstName: String? = null, lastName: String? = null, organization: String? = null, diff --git a/library/src/androidTest/java/com/alexstyl/contactstore/EqualContentsContactMatcher.kt b/library/src/androidTest/java/com/alexstyl/contactstore/EqualContentsContactMatcher.kt index 8a551ef1..8a40ca76 100644 --- a/library/src/androidTest/java/com/alexstyl/contactstore/EqualContentsContactMatcher.kt +++ b/library/src/androidTest/java/com/alexstyl/contactstore/EqualContentsContactMatcher.kt @@ -1,6 +1,5 @@ package com.alexstyl.contactstore -import com.alexstyl.contactstore.ContactColumn.Companion.standardColumns import com.alexstyl.contactstore.ContactColumn.Events import com.alexstyl.contactstore.ContactColumn.Image import com.alexstyl.contactstore.ContactColumn.Mails diff --git a/library/src/main/java/com/alexstyl/contactstore/ContactQueries.kt b/library/src/main/java/com/alexstyl/contactstore/ContactQueries.kt index 66cf9aa2..b8f1ed00 100644 --- a/library/src/main/java/com/alexstyl/contactstore/ContactQueries.kt +++ b/library/src/main/java/com/alexstyl/contactstore/ContactQueries.kt @@ -57,9 +57,7 @@ internal class ContactQueries( if (columnsToFetch.isEmpty()) { contacts } else { - // TODO forward contacts instead of just the ids and keep displayname + stars - val contactIds = contacts.map { it.contactId } - fetchAdditionalColumns(contactIds, columnsToFetch) + fetchAdditionalColumns(contacts, columnsToFetch) } } } @@ -198,10 +196,11 @@ internal class ContactQueries( } private fun fetchAdditionalColumns( - forContactIds: List, + forContacts: List, columnsToFetch: List ): List { - return forContactIds.map { contactId -> + return forContacts.map { contact -> + val contactId = contact.contactId var firstName: String? = null var middleName: String? = null var lastName: String? = null @@ -222,8 +221,6 @@ internal class ContactQueries( var organization: String? = null var jobTitle: String? = null var note: Note? = null - var displayName: String? = null - var isStarred = false val groupIds = mutableListOf() val linkedAccountValues = mutableListOf() @@ -232,8 +229,6 @@ internal class ContactQueries( selection = buildColumnsToFetchSelection(contactId, columnsToFetch), selectionArgs = buildSelectionArgs(columnsToFetch) ).iterate { row -> - displayName = row[Data.DISPLAY_NAME] - isStarred = row[Data.STARRED].toInt() == 1 when (row[Contacts.Data.MIMETYPE]) { NicknameColumns.CONTENT_ITEM_TYPE -> { @@ -372,8 +367,8 @@ internal class ContactQueries( PartialContact( contactId = contactId, columns = columnsToFetch, - isStarred = isStarred, - displayName = displayName.orEmpty(), + isStarred = contact.isStarred, + displayName = contact.displayName, firstName = firstName, lastName = lastName, imageData = imageData,