change the way contact sources are added, to allow multiple ones

This commit is contained in:
tibbi 2019-09-09 13:41:13 +02:00
parent e3712ca223
commit fd00506c4e
3 changed files with 33 additions and 21 deletions

View File

@ -19,6 +19,7 @@ import com.simplemobiletools.contacts.pro.helpers.*
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_contact_source.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_im.view.*
@ -200,7 +201,7 @@ class ViewContactActivity : ContactActivity() {
setupOrganization()
setupWebsites()
setupGroups()
setupContactSource()
setupContactSource(contact!!.source)
}
private fun editContact() {
@ -468,17 +469,21 @@ class ViewContactActivity : ContactActivity() {
}
}
private fun setupContactSource() {
private fun setupContactSource(source: String) {
if (showFields and SHOW_CONTACT_SOURCE_FIELD != 0) {
getPublicContactSource(contact!!.source) {
contact_source.text = it
contact_source.copyOnLongClick(it)
layoutInflater.inflate(R.layout.item_view_contact_source, contact_sources_holder, false).apply {
getPublicContactSource(source) {
contact_source.text = it
contact_source.copyOnLongClick(it)
contact_sources_holder.addView(this)
}
}
contact_source_image.beVisible()
contact_source.beVisible()
contact_sources_holder.beVisible()
} else {
contact_source_image.beGone()
contact_source.beGone()
contact_sources_holder.beGone()
}
}

View File

@ -389,28 +389,20 @@
android:id="@+id/contact_source_image"
android:layout_width="@dimen/contact_icons_size"
android:layout_height="@dimen/contact_icons_size"
android:layout_alignTop="@+id/contact_source"
android:layout_alignTop="@+id/contact_sources_holder"
android:paddingTop="@dimen/medium_margin"
android:paddingEnd="@dimen/small_margin"
android:paddingBottom="@dimen/small_margin"
android:src="@drawable/ic_account_box_vector"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_source"
<LinearLayout
android:id="@+id/contact_sources_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_groups_holder"
android:layout_centerVertical="true"
android:layout_below="@+id/contact_websites_holder"
android:layout_toEndOf="@+id/contact_name_image"
android:background="?attr/selectableItemBackground"
android:lines="1"
android:maxLines="1"
android:paddingStart="@dimen/small_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingBottom="@dimen/normal_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"
tools:text="hello@simplemobiletools.com"/>
android:orientation="vertical"
android:paddingStart="@dimen/small_margin"/>
</RelativeLayout>
</ScrollView>

View File

@ -0,0 +1,15 @@
<?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_source"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:paddingTop="@dimen/normal_margin"
android:paddingBottom="@dimen/normal_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"/>