From 72ccd10aa14ba6c3dba39f363e24a49498c8974a Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 15 Sep 2019 12:04:38 +0200 Subject: [PATCH] do not mess with the phone numbers if they arent shown anyway --- .../pro/activities/ViewContactActivity.kt | 61 ++++++++++--------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt index 8b80415b..bd9d9a06 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt @@ -200,10 +200,10 @@ class ViewContactActivity : ContactActivity() { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) setupFavorite() setupNames() - setupContactSources() getDuplicateContacts { setupPhoneNumbers() + setupContactSources() } setupEmails() @@ -280,42 +280,47 @@ class ViewContactActivity : ContactActivity() { } private fun setupPhoneNumbers() { - var phoneNumbers = contact!!.phoneNumbers.toMutableSet() as LinkedHashSet - 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 + if (showFields and SHOW_PHONE_NUMBERS_FIELD != 0) { + var phoneNumbers = contact!!.phoneNumbers.toMutableSet() as LinkedHashSet + duplicateContacts.forEach { + phoneNumbers.addAll(it.phoneNumbers) } - }.toMutableSet() as LinkedHashSet - contact_numbers_holder.removeAllViews() - if (phoneNumbers.isNotEmpty() && showFields and SHOW_PHONE_NUMBERS_FIELD != 0) { - 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) + 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 - setOnClickListener { - if (config.showCallConfirmation) { - CallConfirmationDialog(this@ViewContactActivity, phoneNumber.value) { + contact_numbers_holder.removeAllViews() + if (phoneNumbers.isNotEmpty()) { + 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) } - } 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 { contact_numbers_image.beGone() contact_numbers_holder.beGone()