From 874056dfcacc63945e9510836d07a627a7babf1c Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 14 Mar 2019 22:35:00 +0100 Subject: [PATCH] show attendees selected from autocomplete differently --- .../calendar/pro/activities/EventActivity.kt | 28 ++++++++++++++----- app/src/main/res/layout/item_attendee.xml | 20 +++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt index 9efb38efc..34a1ee5e3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt @@ -1156,8 +1156,12 @@ class EventActivity : SimpleActivity() { private fun addAttendee(value: String? = null) { val attendeeHolder = layoutInflater.inflate(R.layout.item_attendee, event_attendees_holder, false) as RelativeLayout - mAttendeeViews.add(attendeeHolder.event_attendee) - attendeeHolder.event_attendee.onTextChangeListener { + val autoCompleteView = attendeeHolder.event_attendee + val selectedAttendeeHolder = attendeeHolder.event_contact_attendee + val selectedAttendeeName = selectedAttendeeHolder.event_contact_name + + mAttendeeViews.add(autoCompleteView) + autoCompleteView.onTextChangeListener { if (mWasContactsPermissionChecked && value == null) { checkNewAttendeeField(value) } else { @@ -1169,17 +1173,27 @@ class EventActivity : SimpleActivity() { } event_attendees_holder.addView(attendeeHolder) - attendeeHolder.event_attendee.setColors(config.textColor, getAdjustedPrimaryColor(), config.backgroundColor) + event_attendees_holder.onGlobalLayout { + selectedAttendeeHolder.layoutParams.height = autoCompleteView.height + } + + autoCompleteView.setColors(config.textColor, getAdjustedPrimaryColor(), config.backgroundColor) + selectedAttendeeName.setColors(config.textColor, getAdjustedPrimaryColor(), config.backgroundColor) if (value != null) { - attendeeHolder.event_attendee.setText(value) + autoCompleteView.setText(value) } val adapter = AutoCompleteTextViewAdapter(this, mAvailableContacts) - attendeeHolder.event_attendee.setAdapter(adapter) - attendeeHolder.event_attendee.setOnItemClickListener { parent, view, position, id -> - val currAttendees = (attendeeHolder.event_attendee.adapter as AutoCompleteTextViewAdapter).resultList + autoCompleteView.setAdapter(adapter) + autoCompleteView.setOnItemClickListener { parent, view, position, id -> + val currAttendees = (autoCompleteView.adapter as AutoCompleteTextViewAdapter).resultList val selectedAttendee = currAttendees[position] + + hideKeyboard(autoCompleteView) + autoCompleteView.beGone() + selectedAttendeeName.text = selectedAttendee.getPublicName() + selectedAttendeeHolder.beVisible() } } diff --git a/app/src/main/res/layout/item_attendee.xml b/app/src/main/res/layout/item_attendee.xml index 1b04b5433..b85562fab 100644 --- a/app/src/main/res/layout/item_attendee.xml +++ b/app/src/main/res/layout/item_attendee.xml @@ -1,6 +1,7 @@ + + + + +