do not mess with the phone numbers if they arent shown anyway

This commit is contained in:
tibbi 2019-09-15 12:04:38 +02:00
parent f9bd62b2a7
commit 72ccd10aa1
1 changed files with 33 additions and 28 deletions

View File

@ -200,10 +200,10 @@ class ViewContactActivity : ContactActivity() {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
setupFavorite() setupFavorite()
setupNames() setupNames()
setupContactSources()
getDuplicateContacts { getDuplicateContacts {
setupPhoneNumbers() setupPhoneNumbers()
setupContactSources()
} }
setupEmails() setupEmails()
@ -280,42 +280,47 @@ class ViewContactActivity : ContactActivity() {
} }
private fun setupPhoneNumbers() { private fun setupPhoneNumbers() {
var phoneNumbers = contact!!.phoneNumbers.toMutableSet() as LinkedHashSet<PhoneNumber> if (showFields and SHOW_PHONE_NUMBERS_FIELD != 0) {
duplicateContacts.forEach { var phoneNumbers = contact!!.phoneNumbers.toMutableSet() as LinkedHashSet<PhoneNumber>
phoneNumbers.addAll(it.phoneNumbers) duplicateContacts.forEach {
} phoneNumbers.addAll(it.phoneNumbers)
phoneNumbers = phoneNumbers.distinctBy {
if (it.normalizedNumber != null && it.normalizedNumber!!.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
it.normalizedNumber?.substring(it.normalizedNumber!!.length - COMPARABLE_PHONE_NUMBER_LENGTH)
} else {
it.normalizedNumber
} }
}.toMutableSet() as LinkedHashSet<PhoneNumber>
contact_numbers_holder.removeAllViews() phoneNumbers = phoneNumbers.distinctBy {
if (phoneNumbers.isNotEmpty() && showFields and SHOW_PHONE_NUMBERS_FIELD != 0) { if (it.normalizedNumber != null && it.normalizedNumber!!.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
phoneNumbers.forEach { it.normalizedNumber?.substring(it.normalizedNumber!!.length - COMPARABLE_PHONE_NUMBER_LENGTH)
layoutInflater.inflate(R.layout.item_view_phone_number, contact_numbers_holder, false).apply { } else {
val phoneNumber = it it.normalizedNumber
contact_numbers_holder.addView(this) }
contact_number.text = phoneNumber.value }.toMutableSet() as LinkedHashSet<PhoneNumber>
contact_number_type.text = getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label)
copyOnLongClick(phoneNumber.value)
setOnClickListener { contact_numbers_holder.removeAllViews()
if (config.showCallConfirmation) { if (phoneNumbers.isNotEmpty()) {
CallConfirmationDialog(this@ViewContactActivity, phoneNumber.value) { phoneNumbers.forEach {
layoutInflater.inflate(R.layout.item_view_phone_number, contact_numbers_holder, false).apply {
val phoneNumber = it
contact_numbers_holder.addView(this)
contact_number.text = phoneNumber.value
contact_number_type.text = getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label)
copyOnLongClick(phoneNumber.value)
setOnClickListener {
if (config.showCallConfirmation) {
CallConfirmationDialog(this@ViewContactActivity, phoneNumber.value) {
startCallIntent(phoneNumber.value)
}
} else {
startCallIntent(phoneNumber.value) startCallIntent(phoneNumber.value)
} }
} else {
startCallIntent(phoneNumber.value)
} }
} }
} }
contact_numbers_image.beVisible()
contact_numbers_holder.beVisible()
} else {
contact_numbers_image.beGone()
contact_numbers_holder.beGone()
} }
contact_numbers_image.beVisible()
contact_numbers_holder.beVisible()
} else { } else {
contact_numbers_image.beGone() contact_numbers_image.beGone()
contact_numbers_holder.beGone() contact_numbers_holder.beGone()