From 0b2f6e8f043517e544d9d883e48ca0e782bc786b Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 16 Mar 2018 23:24:52 +0100 Subject: [PATCH] list contact groups at the View screen --- .../activities/ViewContactActivity.kt | 18 +++++++++++++++ .../main/res/layout/activity_view_contact.xml | 22 ++++++++++++++++++- app/src/main/res/layout/item_view_group.xml | 14 ++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/layout/item_view_group.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt index ff483eb8..1bffbd05 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt @@ -19,6 +19,7 @@ import kotlinx.android.synthetic.main.activity_view_contact.* import kotlinx.android.synthetic.main.item_event.view.* import kotlinx.android.synthetic.main.item_view_address.view.* import kotlinx.android.synthetic.main.item_view_email.view.* +import kotlinx.android.synthetic.main.item_view_group.view.* import kotlinx.android.synthetic.main.item_view_phone_number.view.* class ViewContactActivity : ContactActivity() { @@ -119,6 +120,7 @@ class ViewContactActivity : ContactActivity() { contact_event_image.applyColorFilter(textColor) contact_source_image.applyColorFilter(textColor) contact_notes_image.applyColorFilter(textColor) + contact_groups_image.applyColorFilter(textColor) contact_send_sms.setOnClickListener { trySendSMS() } contact_start_call.setOnClickListener { tryStartCall(contact!!) } @@ -159,6 +161,7 @@ class ViewContactActivity : ContactActivity() { setupAddresses() setupEvents() setupNotes() + setupGroups() } private fun setupPhoneNumbers() { @@ -245,5 +248,20 @@ class ViewContactActivity : ContactActivity() { contact_notes.beVisibleIf(notes.isNotEmpty()) } + private fun setupGroups() { + contact_groups_holder.removeAllViews() + val groups = contact!!.groups + 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 + } + } + + contact_groups_image.beVisibleIf(groups.isNotEmpty()) + contact_groups_holder.beVisibleIf(groups.isNotEmpty()) + } + private fun getStarDrawable(on: Boolean) = resources.getDrawable(if (on) R.drawable.ic_star_on_big else R.drawable.ic_star_off_big) } diff --git a/app/src/main/res/layout/activity_view_contact.xml b/app/src/main/res/layout/activity_view_contact.xml index 3a8e9c31..4b081639 100644 --- a/app/src/main/res/layout/activity_view_contact.xml +++ b/app/src/main/res/layout/activity_view_contact.xml @@ -239,6 +239,26 @@ android:paddingTop="@dimen/normal_margin" android:textSize="@dimen/bigger_text_size"/> + + + + +