add myself as an event attendee if there is any other attendee

This commit is contained in:
tibbi
2019-03-20 18:20:02 +01:00
parent b76512edf9
commit 673b97110e
2 changed files with 12 additions and 4 deletions

View File

@ -253,7 +253,7 @@ class EventActivity : SimpleActivity() {
putInt(REPEAT_RULE, mRepeatRule) putInt(REPEAT_RULE, mRepeatRule)
putLong(REPEAT_LIMIT, mRepeatLimit) putLong(REPEAT_LIMIT, mRepeatLimit)
putString(ATTENDEES, getAllAttendees()) putString(ATTENDEES, getAllAttendees(false))
putLong(EVENT_TYPE_ID, mEventTypeId) putLong(EVENT_TYPE_ID, mEventTypeId)
putInt(EVENT_CALENDAR_ID, mEventCalendarId) putInt(EVENT_CALENDAR_ID, mEventCalendarId)
@ -921,7 +921,7 @@ class EventActivity : SimpleActivity() {
flags = mEvent.flags.addBitIf(event_all_day.isChecked, FLAG_ALL_DAY) flags = mEvent.flags.addBitIf(event_all_day.isChecked, FLAG_ALL_DAY)
repeatLimit = if (repeatInterval == 0) 0 else mRepeatLimit repeatLimit = if (repeatInterval == 0) 0 else mRepeatLimit
repeatRule = mRepeatRule repeatRule = mRepeatRule
attendees = if (mEventCalendarId == STORED_LOCALLY_ONLY) "" else getAllAttendees() attendees = if (mEventCalendarId == STORED_LOCALLY_ONLY) "" else getAllAttendees(true)
eventType = newEventType eventType = newEventType
lastUpdated = System.currentTimeMillis() lastUpdated = System.currentTimeMillis()
source = newSource source = newSource
@ -1329,7 +1329,7 @@ class EventActivity : SimpleActivity() {
} }
} }
private fun getAllAttendees(): String { private fun getAllAttendees(isSavingEvent: Boolean): String {
var attendees = ArrayList<Attendee>() var attendees = ArrayList<Attendee>()
mSelectedContacts.forEach { mSelectedContacts.forEach {
attendees.add(it) attendees.add(it)
@ -1340,6 +1340,15 @@ class EventActivity : SimpleActivity() {
Attendee(0, "", it, CalendarContract.Attendees.ATTENDEE_STATUS_INVITED, "", false) Attendee(0, "", it, CalendarContract.Attendees.ATTENDEE_STATUS_INVITED, "", false)
} }
attendees = attendees.distinctBy { it.email }.toMutableList() as ArrayList<Attendee> attendees = attendees.distinctBy { it.email }.toMutableList() as ArrayList<Attendee>
if (mEvent.id == null && isSavingEvent && attendees.isNotEmpty()) {
val currentCalendar = calDAVHelper.getCalDAVCalendars("", true).firstOrNull { it.id == mEventCalendarId }
mAvailableContacts.firstOrNull { it.email == currentCalendar?.accountName }?.apply {
status = CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED
attendees.add(this)
}
}
return Gson().toJson(attendees) return Gson().toJson(attendees)
} }

View File

@ -16,7 +16,6 @@ const val WEEK_START_DATE_TIME = "week_start_date_time"
const val CALDAV = "Caldav" const val CALDAV = "Caldav"
const val VIEW_TO_OPEN = "view_to_open" const val VIEW_TO_OPEN = "view_to_open"
const val SHORTCUT_NEW_EVENT = "shortcut_new_event" const val SHORTCUT_NEW_EVENT = "shortcut_new_event"
const val ATTENDEE_ME = "attendee_me"
const val REGULAR_EVENT_TYPE_ID = 1L const val REGULAR_EVENT_TYPE_ID = 1L
const val CHOPPED_LIST_DEFAULT_SIZE = 100 const val CHOPPED_LIST_DEFAULT_SIZE = 100