show my attendance status in a special way

This commit is contained in:
tibbi 2019-03-19 23:26:59 +01:00
parent e79871daab
commit 660278ce61
3 changed files with 31 additions and 2 deletions

View File

@ -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() {

View File

@ -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

View File

@ -74,5 +74,18 @@
android:padding="@dimen/small_margin"
android:src="@drawable/ic_cross_big"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/event_contact_me_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/activity_margin"
android:ellipsize="end"
android:gravity="end"
android:lines="1"
android:textSize="@dimen/bigger_text_size"
tools:text="@string/invited"/>
</RelativeLayout>
</RelativeLayout>