From 660278ce611eef8c835ac3d988931f8767a4ef9f Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 19 Mar 2019 23:26:59 +0100 Subject: [PATCH] show my attendance status in a special way --- .../calendar/pro/activities/EventActivity.kt | 19 +++++++++++++++++-- .../calendar/pro/helpers/Constants.kt | 1 + app/src/main/res/layout/item_attendee.xml | 13 +++++++++++++ 3 files changed, 31 insertions(+), 2 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 619075b48..87f3bbe3c 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 @@ -1160,9 +1160,15 @@ class EventActivity : SimpleActivity() { { it.status }) mAttendees.reverse() + val currentCalendar = calDAVHelper.getCalDAVCalendars("", true).firstOrNull { it.id == mEventCalendarId } + mAttendees.forEach { val attendee = it val deviceContact = mAvailableContacts.firstOrNull { it.email.isNotEmpty() && it.email == attendee.email && it.photoUri.isNotEmpty() } + if (attendee.email == currentCalendar?.accountName) { + attendee.name = ATTENDEE_ME + } + if (deviceContact != null) { attendee.photoUri = deviceContact.photoUri } @@ -1244,17 +1250,26 @@ class EventActivity : SimpleActivity() { val attendeeStatusBackground = resources.getDrawable(R.drawable.attendee_status_circular_background) (attendeeStatusBackground as LayerDrawable).findDrawableByLayerId(R.id.attendee_status_circular_background).applyColorFilter(config.backgroundColor) selectedAttendeeStatusImage.background = attendeeStatusBackground + val isMe = attendee.name == ATTENDEE_ME autoCompleteView.beGone() autoCompleteView.focusSearch(View.FOCUS_DOWN)?.requestFocus() - selectedAttendeeName.text = attendee.getPublicName() + selectedAttendeeName.text = if (isMe) getString(R.string.my_status) else attendee.getPublicName() selectedAttendeeHolder.beVisible() selectedAttendeeImage.beVisible() selectedAttendeeStatusImage.beVisibleIf(showAttendeeStatus) selectedAttendeeStatusImage.setImageDrawable(attendeeStatusImage) attendee.updateImage(applicationContext, selectedAttendeeImage, mAttendeePlaceholder) - selectedAttendeeDismiss.beVisible() + selectedAttendeeDismiss.beGoneIf(isMe) selectedAttendeeDismiss.tag = attendee.contactId + + selectedAttendeeHolder.event_contact_me_status.beVisibleIf(isMe) + selectedAttendeeHolder.event_contact_me_status.text = getString(when (attendee.status) { + CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED -> R.string.going + CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED -> R.string.not_going + CalendarContract.Attendees.ATTENDEE_STATUS_TENTATIVE -> R.string.maybe_going + else -> R.string.invited + }) } private fun checkNewAttendeeField() { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt index 4878387c7..7a969ed77 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt @@ -16,6 +16,7 @@ const val WEEK_START_DATE_TIME = "week_start_date_time" const val CALDAV = "Caldav" const val VIEW_TO_OPEN = "view_to_open" const val SHORTCUT_NEW_EVENT = "shortcut_new_event" +const val ATTENDEE_ME = "attendee_me" const val REGULAR_EVENT_TYPE_ID = 1L const val CHOPPED_LIST_DEFAULT_SIZE = 100 diff --git a/app/src/main/res/layout/item_attendee.xml b/app/src/main/res/layout/item_attendee.xml index 8be5afdfd..8c5bd897e 100644 --- a/app/src/main/res/layout/item_attendee.xml +++ b/app/src/main/res/layout/item_attendee.xml @@ -74,5 +74,18 @@ android:padding="@dimen/small_margin" android:src="@drawable/ic_cross_big"/> + +