diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/AutoCompleteTextViewAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/AutoCompleteTextViewAdapter.kt index f71e9d78f..ac6aabdcd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/AutoCompleteTextViewAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/AutoCompleteTextViewAdapter.kt @@ -9,19 +9,21 @@ import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.activities.SimpleActivity import com.simplemobiletools.calendar.pro.models.Attendee import com.simplemobiletools.commons.extensions.normalizeString -import kotlinx.android.synthetic.main.item_autocomplete_email.view.* +import kotlinx.android.synthetic.main.item_autocomplete_email_name.view.* class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: ArrayList) : ArrayAdapter(activity, 0, contacts) { private var resultList = ArrayList() override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val contact = resultList[position] var listItem = convertView if (listItem == null) { - listItem = LayoutInflater.from(activity).inflate(R.layout.item_autocomplete_email, parent, false) + val layout = if (contact.name.isNotEmpty()) R.layout.item_autocomplete_email_name else R.layout.item_autocomplete_email + listItem = LayoutInflater.from(activity).inflate(layout, parent, false) } - val contact = resultList[position] - listItem!!.item_autocomplete.text = contact.email + listItem!!.item_autocomplete_name?.text = contact.name + listItem.item_autocomplete_email.text = contact.email return listItem } @@ -59,7 +61,7 @@ class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: Ar } } - override fun convertResultToString(resultValue: Any?) = (resultValue as? Attendee)?.email + override fun convertResultToString(resultValue: Any?) = (resultValue as? Attendee)?.getPublicName() } override fun getItem(index: Int) = resultList[index] diff --git a/app/src/main/res/layout/item_autocomplete_email.xml b/app/src/main/res/layout/item_autocomplete_email.xml index ce4b4edf9..bc48edf72 100644 --- a/app/src/main/res/layout/item_autocomplete_email.xml +++ b/app/src/main/res/layout/item_autocomplete_email.xml @@ -1,6 +1,7 @@ + android:textSize="@dimen/bigger_text_size" + tools:text="hello@simplemobiletools.com"/> diff --git a/app/src/main/res/layout/item_autocomplete_email_name.xml b/app/src/main/res/layout/item_autocomplete_email_name.xml new file mode 100644 index 000000000..d99035825 --- /dev/null +++ b/app/src/main/res/layout/item_autocomplete_email_name.xml @@ -0,0 +1,39 @@ + + + + + + + +