some attendee related improvements
This commit is contained in:
parent
b26bd7a20e
commit
a5f5e4783e
|
@ -17,7 +17,6 @@ import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.widget.EditText
|
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
|
@ -35,6 +34,7 @@ import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
|
import com.simplemobiletools.commons.views.MyAutoCompleteTextView
|
||||||
import kotlinx.android.synthetic.main.activity_event.*
|
import kotlinx.android.synthetic.main.activity_event.*
|
||||||
import kotlinx.android.synthetic.main.activity_event.view.*
|
import kotlinx.android.synthetic.main.activity_event.view.*
|
||||||
import kotlinx.android.synthetic.main.item_attendee.view.*
|
import kotlinx.android.synthetic.main.item_attendee.view.*
|
||||||
|
@ -77,8 +77,9 @@ class EventActivity : SimpleActivity() {
|
||||||
private var mWasActivityInitialized = false
|
private var mWasActivityInitialized = false
|
||||||
private var mWasContactsPermissionChecked = false
|
private var mWasContactsPermissionChecked = false
|
||||||
private var mAttendees = ArrayList<Attendee>()
|
private var mAttendees = ArrayList<Attendee>()
|
||||||
private var mAttendeeViews = ArrayList<EditText>()
|
private var mAttendeeAutoCompleteViews = ArrayList<MyAutoCompleteTextView>()
|
||||||
private var mAvailableContacts = ArrayList<Attendee>()
|
private var mAvailableContacts = ArrayList<Attendee>()
|
||||||
|
private var mSelectedContacts = ArrayList<Attendee>()
|
||||||
|
|
||||||
private lateinit var mAttendeePlaceholder: Drawable
|
private lateinit var mAttendeePlaceholder: Drawable
|
||||||
private lateinit var mEventStartDateTime: DateTime
|
private lateinit var mEventStartDateTime: DateTime
|
||||||
|
@ -1169,7 +1170,7 @@ class EventActivity : SimpleActivity() {
|
||||||
val selectedAttendeeImage = attendeeHolder.event_contact_image
|
val selectedAttendeeImage = attendeeHolder.event_contact_image
|
||||||
val selectedAttendeeDismiss = attendeeHolder.event_contact_dismiss
|
val selectedAttendeeDismiss = attendeeHolder.event_contact_dismiss
|
||||||
|
|
||||||
mAttendeeViews.add(autoCompleteView)
|
mAttendeeAutoCompleteViews.add(autoCompleteView)
|
||||||
autoCompleteView.onTextChangeListener {
|
autoCompleteView.onTextChangeListener {
|
||||||
if (mWasContactsPermissionChecked && value == null) {
|
if (mWasContactsPermissionChecked && value == null) {
|
||||||
checkNewAttendeeField(value)
|
checkNewAttendeeField(value)
|
||||||
|
@ -1197,6 +1198,7 @@ class EventActivity : SimpleActivity() {
|
||||||
|
|
||||||
selectedAttendeeDismiss.setOnClickListener {
|
selectedAttendeeDismiss.setOnClickListener {
|
||||||
attendeeHolder.beGone()
|
attendeeHolder.beGone()
|
||||||
|
mSelectedContacts = mSelectedContacts.filter { it.contactId == selectedAttendeeDismiss.tag }.toMutableList() as ArrayList<Attendee>
|
||||||
}
|
}
|
||||||
|
|
||||||
val adapter = AutoCompleteTextViewAdapter(this, mAvailableContacts)
|
val adapter = AutoCompleteTextViewAdapter(this, mAvailableContacts)
|
||||||
|
@ -1205,6 +1207,7 @@ class EventActivity : SimpleActivity() {
|
||||||
autoCompleteView.setOnItemClickListener { parent, view, position, id ->
|
autoCompleteView.setOnItemClickListener { parent, view, position, id ->
|
||||||
val currAttendees = (autoCompleteView.adapter as AutoCompleteTextViewAdapter).resultList
|
val currAttendees = (autoCompleteView.adapter as AutoCompleteTextViewAdapter).resultList
|
||||||
val selectedAttendee = currAttendees[position]
|
val selectedAttendee = currAttendees[position]
|
||||||
|
mSelectedContacts.add(selectedAttendee)
|
||||||
|
|
||||||
autoCompleteView.beGone()
|
autoCompleteView.beGone()
|
||||||
autoCompleteView.focusSearch(View.FOCUS_DOWN)?.requestFocus()
|
autoCompleteView.focusSearch(View.FOCUS_DOWN)?.requestFocus()
|
||||||
|
@ -1213,21 +1216,28 @@ class EventActivity : SimpleActivity() {
|
||||||
selectedAttendeeImage.beVisible()
|
selectedAttendeeImage.beVisible()
|
||||||
selectedAttendee.updateImage(applicationContext, selectedAttendeeImage, mAttendeePlaceholder)
|
selectedAttendee.updateImage(applicationContext, selectedAttendeeImage, mAttendeePlaceholder)
|
||||||
selectedAttendeeDismiss.beVisible()
|
selectedAttendeeDismiss.beVisible()
|
||||||
|
selectedAttendeeDismiss.tag = selectedAttendee.contactId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkNewAttendeeField(value: String?) {
|
private fun checkNewAttendeeField(value: String?) {
|
||||||
if (value == null && mAttendeeViews.none { it.value.isEmpty() }) {
|
if (value == null && mAttendeeAutoCompleteViews.none { it.value.isEmpty() }) {
|
||||||
addAttendee()
|
addAttendee()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAllAttendees(): String {
|
private fun getAllAttendees(): String {
|
||||||
val attendeeEmails = mAttendeeViews.map { it.value }.filter { it.isNotEmpty() }.toMutableList() as ArrayList<String>
|
var attendees = ArrayList<Attendee>()
|
||||||
val attendees = ArrayList<Attendee>()
|
mSelectedContacts.forEach {
|
||||||
attendeeEmails.mapTo(attendees) {
|
it.status = CalendarContract.Attendees.ATTENDEE_STATUS_INVITED
|
||||||
|
attendees.add(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
val customEmails = mAttendeeAutoCompleteViews.filter { it.isVisible() }.map { it.value }.filter { it.isNotEmpty() }.toMutableList() as ArrayList<String>
|
||||||
|
customEmails.mapTo(attendees) {
|
||||||
Attendee(0, "", it, CalendarContract.Attendees.ATTENDEE_STATUS_INVITED, "")
|
Attendee(0, "", it, CalendarContract.Attendees.ATTENDEE_STATUS_INVITED, "")
|
||||||
}
|
}
|
||||||
|
attendees = attendees.distinctBy { it.email }.toMutableList() as ArrayList<Attendee>
|
||||||
return Gson().toJson(attendees)
|
return Gson().toJson(attendees)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
|
|
||||||
data class Attendee(val contactId: Int, var name: String, val email: String, val status: Int, var photoUri: String) {
|
data class Attendee(val contactId: Int, var name: String, val email: String, var status: Int, var photoUri: String) {
|
||||||
fun getPublicName() = if (name.isNotEmpty()) name else email
|
fun getPublicName() = if (name.isNotEmpty()) name else email
|
||||||
|
|
||||||
fun updateImage(context: Context, imageView: ImageView, placeholder: Drawable) {
|
fun updateImage(context: Context, imageView: ImageView, placeholder: Drawable) {
|
||||||
|
|
Loading…
Reference in New Issue