properly fill all required fields at Sharing from View screen

This commit is contained in:
tibbi 2019-09-15 23:39:09 +02:00
parent cf2b6b6d5e
commit 209dbc799b
1 changed files with 118 additions and 142 deletions

View File

@ -284,8 +284,6 @@ class ViewContactActivity : ContactActivity() {
}
private fun setupPhoneNumbers() {
contact_numbers_holder.removeAllViews()
if (showFields and SHOW_PHONE_NUMBERS_FIELD != 0) {
var phoneNumbers = contact!!.phoneNumbers.toMutableSet() as LinkedHashSet<PhoneNumber>
duplicateContacts.forEach {
phoneNumbers.addAll(it.phoneNumbers)
@ -301,7 +299,9 @@ class ViewContactActivity : ContactActivity() {
phoneNumbers = phoneNumbers.sortedBy { it.type }.toMutableSet() as LinkedHashSet<PhoneNumber>
fullContact!!.phoneNumbers = phoneNumbers.toMutableList() as ArrayList<PhoneNumber>
if (phoneNumbers.isNotEmpty()) {
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
@ -327,10 +327,6 @@ class ViewContactActivity : ContactActivity() {
contact_numbers_image.beGone()
contact_numbers_holder.beGone()
}
} else {
contact_numbers_image.beGone()
contact_numbers_holder.beGone()
}
}
// a contact cannot have different emails per contact source. Such contacts are handled as separate ones, not duplicates of each other
@ -360,8 +356,6 @@ class ViewContactActivity : ContactActivity() {
}
private fun setupAddresses() {
contact_addresses_holder.removeAllViews()
if (showFields and SHOW_ADDRESSES_FIELD != 0) {
var addresses = contact!!.addresses.toMutableSet() as LinkedHashSet<Address>
duplicateContacts.forEach {
addresses.addAll(it.addresses)
@ -369,7 +363,9 @@ class ViewContactActivity : ContactActivity() {
addresses = addresses.sortedBy { it.type }.toMutableSet() as LinkedHashSet<Address>
fullContact!!.addresses = addresses.toMutableList() as ArrayList<Address>
if (addresses.isNotEmpty()) {
contact_addresses_holder.removeAllViews()
if (addresses.isNotEmpty() && showFields and SHOW_ADDRESSES_FIELD != 0) {
addresses.forEach {
layoutInflater.inflate(R.layout.item_view_address, contact_addresses_holder, false).apply {
val address = it
@ -389,15 +385,9 @@ class ViewContactActivity : ContactActivity() {
contact_addresses_image.beGone()
contact_addresses_holder.beGone()
}
} else {
contact_addresses_image.beGone()
contact_addresses_holder.beGone()
}
}
private fun setupIMs() {
contact_ims_holder.removeAllViews()
if (showFields and SHOW_IMS_FIELD != 0) {
var IMs = contact!!.IMs.toMutableSet() as LinkedHashSet<IM>
duplicateContacts.forEach {
IMs.addAll(it.IMs)
@ -405,7 +395,9 @@ class ViewContactActivity : ContactActivity() {
IMs = IMs.sortedBy { it.type }.toMutableSet() as LinkedHashSet<IM>
fullContact!!.IMs = IMs.toMutableList() as ArrayList<IM>
if (IMs.isNotEmpty()) {
contact_ims_holder.removeAllViews()
if (IMs.isNotEmpty() && showFields and SHOW_IMS_FIELD != 0) {
IMs.forEach {
layoutInflater.inflate(R.layout.item_view_im, contact_ims_holder, false).apply {
val IM = it
@ -421,15 +413,9 @@ class ViewContactActivity : ContactActivity() {
contact_ims_image.beGone()
contact_ims_holder.beGone()
}
} else {
contact_ims_image.beGone()
contact_ims_holder.beGone()
}
}
private fun setupEvents() {
contact_events_holder.removeAllViews()
if (showFields and SHOW_EVENTS_FIELD != 0) {
var events = contact!!.events.toMutableSet() as LinkedHashSet<Event>
duplicateContacts.forEach {
events.addAll(it.events)
@ -437,7 +423,9 @@ class ViewContactActivity : ContactActivity() {
events = events.sortedBy { it.type }.toMutableSet() as LinkedHashSet<Event>
fullContact!!.events = events.toMutableList() as ArrayList<Event>
if (events.isNotEmpty()) {
contact_events_holder.removeAllViews()
if (events.isNotEmpty() && showFields and SHOW_EVENTS_FIELD != 0) {
events.forEach {
layoutInflater.inflate(R.layout.item_view_event, contact_events_holder, false).apply {
contact_events_holder.addView(this)
@ -452,10 +440,6 @@ class ViewContactActivity : ContactActivity() {
contact_events_image.beGone()
contact_events_holder.beGone()
}
} else {
contact_events_image.beGone()
contact_events_holder.beGone()
}
}
private fun setupNotes() {
@ -493,8 +477,6 @@ class ViewContactActivity : ContactActivity() {
}
private fun setupWebsites() {
contact_websites_holder.removeAllViews()
if (showFields and SHOW_WEBSITES_FIELD != 0) {
var websites = contact!!.websites.toMutableSet() as LinkedHashSet<String>
duplicateContacts.forEach {
websites.addAll(it.websites)
@ -502,7 +484,9 @@ class ViewContactActivity : ContactActivity() {
websites = websites.sorted().toMutableSet() as LinkedHashSet<String>
fullContact!!.websites = websites.toMutableList() as ArrayList<String>
if (websites.isNotEmpty()) {
contact_websites_holder.removeAllViews()
if (websites.isNotEmpty() && showFields and SHOW_WEBSITES_FIELD != 0) {
websites.forEach {
val url = it
layoutInflater.inflate(R.layout.item_website, contact_websites_holder, false).apply {
@ -521,15 +505,9 @@ class ViewContactActivity : ContactActivity() {
contact_websites_image.beGone()
contact_websites_holder.beGone()
}
} else {
contact_websites_image.beGone()
contact_websites_holder.beGone()
}
}
private fun setupGroups() {
contact_groups_holder.removeAllViews()
if (showFields and SHOW_GROUPS_FIELD != 0) {
var groups = contact!!.groups.toMutableSet() as LinkedHashSet<Group>
duplicateContacts.forEach {
groups.addAll(it.groups)
@ -537,7 +515,9 @@ class ViewContactActivity : ContactActivity() {
groups = groups.sortedBy { it.title }.toMutableSet() as LinkedHashSet<Group>
fullContact!!.groups = groups.toMutableList() as ArrayList<Group>
if (groups.isNotEmpty()) {
contact_groups_holder.removeAllViews()
if (groups.isNotEmpty() && showFields and SHOW_GROUPS_FIELD != 0) {
groups.forEach {
layoutInflater.inflate(R.layout.item_view_group, contact_groups_holder, false).apply {
val group = it
@ -552,10 +532,6 @@ class ViewContactActivity : ContactActivity() {
contact_groups_image.beGone()
contact_groups_holder.beGone()
}
} else {
contact_groups_image.beGone()
contact_groups_holder.beGone()
}
}
private fun setupContactSources() {