show all contact sources of a given contact at View screen

This commit is contained in:
tibbi 2019-09-09 15:19:07 +02:00
parent fd00506c4e
commit c1db2701d8
2 changed files with 14 additions and 3 deletions

View File

@ -113,6 +113,17 @@ class ViewContactActivity : ContactActivity() {
if (contactId != 0 && !wasLookupKeyUsed) {
contact = ContactsHelper(this).getContactWithId(contactId, intent.getBooleanExtra(IS_PRIVATE, false))
if (contact != null) {
ContactsHelper(this).getContacts { contacts ->
contacts.forEach {
if (it.id != contact!!.id && it.getHashToCompare() == contact!!.getHashToCompare()) {
addContactSource(it.source)
}
}
}
}
if (contact == null) {
if (!wasEditLaunched) {
toast(R.string.unknown_error_occurred)
@ -201,7 +212,7 @@ class ViewContactActivity : ContactActivity() {
setupOrganization()
setupWebsites()
setupGroups()
setupContactSource(contact!!.source)
addContactSource(contact!!.source)
}
private fun editContact() {
@ -469,7 +480,7 @@ class ViewContactActivity : ContactActivity() {
}
}
private fun setupContactSource(source: String) {
private fun addContactSource(source: String) {
if (showFields and SHOW_CONTACT_SOURCE_FIELD != 0) {
layoutInflater.inflate(R.layout.item_view_contact_source, contact_sources_holder, false).apply {
getPublicContactSource(source) {

View File

@ -112,7 +112,7 @@ data class Contact(var id: Int, var prefix: String, var firstName: String, var m
emails.mapTo(newEmails) { Email(it.value, 0, "") }
return copy(id = 0, prefix = "", firstName = getNameToDisplay().toLowerCase(), middleName = "", surname = "", suffix = "", nickname = "", photoUri = "",
phoneNumbers = ArrayList(), events = ArrayList(), addresses = ArrayList(), emails = newEmails, starred = 0, contactId = 0,
phoneNumbers = ArrayList(), events = ArrayList(), source = "", addresses = ArrayList(), emails = newEmails, starred = 0, contactId = 0,
thumbnailUri = "", notes = "", groups = ArrayList(), websites = ArrayList(), organization = Organization("", ""), IMs = ArrayList()).toString()
}