mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2024-12-24 23:40:54 +01:00
allow changing the attendance status of myself
This commit is contained in:
parent
9ec52a4ab7
commit
389b50c553
@ -1235,16 +1235,6 @@ class EventActivity : SimpleActivity() {
|
||||
private fun addSelectedAttendee(attendee: Attendee, autoCompleteView: MyAutoCompleteTextView, selectedAttendeeHolder: RelativeLayout) {
|
||||
mSelectedContacts.add(attendee)
|
||||
|
||||
val showAttendeeStatus = attendee.status == CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED ||
|
||||
attendee.status == CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED ||
|
||||
attendee.status == CalendarContract.Attendees.ATTENDEE_STATUS_TENTATIVE
|
||||
|
||||
val attendeeStatusImage = resources.getDrawable(when (attendee.status) {
|
||||
CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED -> R.drawable.ic_check_green
|
||||
CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED -> R.drawable.ic_cross_red
|
||||
else -> R.drawable.ic_question_yellow
|
||||
})
|
||||
|
||||
val isMe = attendee.name == ATTENDEE_ME
|
||||
|
||||
autoCompleteView.beGone()
|
||||
@ -1257,8 +1247,8 @@ class EventActivity : SimpleActivity() {
|
||||
(attendeeStatusBackground as LayerDrawable).findDrawableByLayerId(R.id.attendee_status_circular_background).applyColorFilter(config.backgroundColor)
|
||||
event_contact_status_image.apply {
|
||||
background = attendeeStatusBackground
|
||||
setImageDrawable(attendeeStatusImage)
|
||||
beVisibleIf(showAttendeeStatus)
|
||||
setImageDrawable(getAttendeeStatusImage(attendee))
|
||||
beVisibleIf(attendee.showStatusImage())
|
||||
}
|
||||
|
||||
event_contact_image.apply {
|
||||
@ -1276,14 +1266,51 @@ class EventActivity : SimpleActivity() {
|
||||
(event_contact_name.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.START_OF, event_contact_me_status.id)
|
||||
}
|
||||
|
||||
if (isMe) {
|
||||
updateAttendeeMe(this, attendee)
|
||||
}
|
||||
|
||||
event_contact_me_status.apply {
|
||||
beVisibleIf(isMe)
|
||||
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
|
||||
})
|
||||
}
|
||||
|
||||
if (isMe) {
|
||||
event_contact_attendee.setOnClickListener {
|
||||
val items = arrayListOf(
|
||||
RadioItem(CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED, getString(R.string.going)),
|
||||
RadioItem(CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED, getString(R.string.not_going)),
|
||||
RadioItem(CalendarContract.Attendees.ATTENDEE_STATUS_TENTATIVE, getString(R.string.maybe_going))
|
||||
)
|
||||
|
||||
RadioGroupDialog(this@EventActivity, items, attendee.status) {
|
||||
attendee.status = it as Int
|
||||
updateAttendeeMe(this, attendee)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAttendeeStatusImage(attendee: Attendee): Drawable {
|
||||
return resources.getDrawable(when (attendee.status) {
|
||||
CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED -> R.drawable.ic_check_green
|
||||
CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED -> R.drawable.ic_cross_red
|
||||
else -> R.drawable.ic_question_yellow
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateAttendeeMe(holder: RelativeLayout, attendee: Attendee) {
|
||||
holder.apply {
|
||||
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
|
||||
})
|
||||
|
||||
event_contact_status_image.apply {
|
||||
beVisibleIf(attendee.showStatusImage())
|
||||
setImageDrawable(getAttendeeStatusImage(attendee))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.simplemobiletools.calendar.pro.models
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.provider.CalendarContract
|
||||
import android.widget.ImageView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
@ -28,4 +29,8 @@ data class Attendee(val contactId: Int, var name: String, val email: String, var
|
||||
.into(imageView)
|
||||
}
|
||||
}
|
||||
|
||||
fun showStatusImage() = status == CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED ||
|
||||
status == CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED ||
|
||||
status == CalendarContract.Attendees.ATTENDEE_STATUS_TENTATIVE
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
android:layout_height="@dimen/avatar_size"
|
||||
android:layout_alignTop="@+id/event_attendee"
|
||||
android:layout_alignBottom="@+id/event_attendee"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
|
Loading…
Reference in New Issue
Block a user