From 8afdf0430ee8e00d2c6ee643e5e38984c30fc5d9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 15 Sep 2019 21:11:11 +0200 Subject: [PATCH] show groups as the last field at contacts too --- .../pro/activities/ViewContactActivity.kt | 40 ++++++++++++------- .../main/res/layout/activity_view_contact.xml | 2 +- 2 files changed, 26 insertions(+), 16 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 4b4eb194..ecfe0498 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 @@ -208,14 +208,13 @@ class ViewContactActivity : ContactActivity() { setupAddresses() setupIMs() setupEvents() + setupWebsites() + setupGroups() + setupContactSources() setupNotes() setupOrganization() - setupWebsites() - setupContactSources() } } - - setupGroups() } private fun launchEditContact(contact: Contact) { @@ -522,18 +521,29 @@ class ViewContactActivity : ContactActivity() { private fun setupGroups() { contact_groups_holder.removeAllViews() - val groups = contact!!.groups - 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 - contact_groups_holder.addView(this) - contact_group.text = group.title - copyOnLongClick(group.title) - } + if (showFields and SHOW_GROUPS_FIELD != 0) { + var groups = contact!!.groups.toMutableSet() as LinkedHashSet + duplicateContacts.forEach { + groups.addAll(it.groups) + } + + groups = groups.sortedBy { it.title }.toMutableSet() as LinkedHashSet + + if (groups.isNotEmpty()) { + groups.forEach { + layoutInflater.inflate(R.layout.item_view_group, contact_groups_holder, false).apply { + val group = it + contact_groups_holder.addView(this) + contact_group.text = group.title + copyOnLongClick(group.title) + } + } + contact_groups_image.beVisible() + contact_groups_holder.beVisible() + } else { + contact_groups_image.beGone() + contact_groups_holder.beGone() } - contact_groups_image.beVisible() - contact_groups_holder.beVisible() } else { contact_groups_image.beGone() contact_groups_holder.beGone() diff --git a/app/src/main/res/layout/activity_view_contact.xml b/app/src/main/res/layout/activity_view_contact.xml index d12aa28c..81a0a1d6 100644 --- a/app/src/main/res/layout/activity_view_contact.xml +++ b/app/src/main/res/layout/activity_view_contact.xml @@ -374,7 +374,7 @@ android:id="@+id/contact_sources_holder" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_below="@+id/contact_websites_holder" + android:layout_below="@+id/contact_groups_holder" android:layout_toEndOf="@+id/contact_name_image" android:orientation="vertical" android:paddingStart="@dimen/small_margin"