list contact groups at the View screen

This commit is contained in:
tibbi 2018-03-16 23:24:52 +01:00
parent 20a333071e
commit 0b2f6e8f04
3 changed files with 53 additions and 1 deletions

View File

@ -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)
}

View File

@ -239,6 +239,26 @@
android:paddingTop="@dimen/normal_margin"
android:textSize="@dimen/bigger_text_size"/>
<ImageView
android:id="@+id/contact_groups_image"
android:layout_width="@dimen/contact_icons_size"
android:layout_height="@dimen/contact_icons_size"
android:layout_alignTop="@+id/contact_groups_holder"
android:paddingBottom="@dimen/small_margin"
android:paddingEnd="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:paddingTop="@dimen/medium_margin"
android:src="@drawable/ic_group"/>
<LinearLayout
android:id="@+id/contact_groups_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_notes"
android:layout_toRightOf="@+id/contact_name_image"
android:orientation="vertical"
android:paddingLeft="@dimen/small_margin"/>
<ImageView
android:id="@+id/contact_source_image"
android:layout_width="@dimen/contact_icons_size"
@ -254,7 +274,7 @@
android:id="@+id/contact_source"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_notes"
android:layout_below="@+id/contact_groups_holder"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/contact_name_image"
android:lines="1"

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<com.simplemobiletools.commons.views.MyTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contact_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"/>