Check event color change on back press

This commit is contained in:
Naveen 2023-04-08 17:41:35 +05:30
parent b2c21c6564
commit 06a6e3a3f7
2 changed files with 10 additions and 3 deletions

View File

@ -76,6 +76,7 @@ class EventActivity : SimpleActivity() {
private var mOriginalStartTS = 0L private var mOriginalStartTS = 0L
private var mOriginalEndTS = 0L private var mOriginalEndTS = 0L
private var mIsNewEvent = true private var mIsNewEvent = true
private var mEventColor = 0
private lateinit var mEventStartDateTime: DateTime private lateinit var mEventStartDateTime: DateTime
private lateinit var mEventEndDateTime: DateTime private lateinit var mEventEndDateTime: DateTime
@ -164,6 +165,7 @@ class EventActivity : SimpleActivity() {
putString(ATTENDEES, getAllAttendees(false)) putString(ATTENDEES, getAllAttendees(false))
putInt(AVAILABILITY, mAvailability) putInt(AVAILABILITY, mAvailability)
putInt(EVENT_COLOR, mEventColor)
putLong(EVENT_TYPE_ID, mEventTypeId) putLong(EVENT_TYPE_ID, mEventTypeId)
putInt(EVENT_CALENDAR_ID, mEventCalendarId) putInt(EVENT_CALENDAR_ID, mEventCalendarId)
@ -196,6 +198,7 @@ class EventActivity : SimpleActivity() {
mReminder3Type = getInt(REMINDER_3_TYPE) mReminder3Type = getInt(REMINDER_3_TYPE)
mAvailability = getInt(AVAILABILITY) mAvailability = getInt(AVAILABILITY)
mEventColor = getInt(EVENT_COLOR)
mRepeatInterval = getInt(REPEAT_INTERVAL) mRepeatInterval = getInt(REPEAT_INTERVAL)
mRepeatRule = getInt(REPEAT_RULE) mRepeatRule = getInt(REPEAT_RULE)
@ -429,6 +432,7 @@ class EventActivity : SimpleActivity() {
mEventTypeId != mEvent.eventType || mEventTypeId != mEvent.eventType ||
mWasCalendarChanged || mWasCalendarChanged ||
mIsAllDayEvent != mEvent.getIsAllDay() || mIsAllDayEvent != mEvent.getIsAllDay() ||
mEventColor != mEvent.color ||
hasTimeChanged hasTimeChanged
) { ) {
return true return true
@ -488,6 +492,7 @@ class EventActivity : SimpleActivity() {
mEventTypeId = mEvent.eventType mEventTypeId = mEvent.eventType
mEventCalendarId = mEvent.getCalDAVCalendarId() mEventCalendarId = mEvent.getCalDAVCalendarId()
mAvailability = mEvent.availability mAvailability = mEvent.availability
mEventColor = mEvent.color
val token = object : TypeToken<List<Attendee>>() {}.type val token = object : TypeToken<List<Attendee>>() {}.type
mAttendees = Gson().fromJson<ArrayList<Attendee>>(mEvent.attendees, token) ?: ArrayList() mAttendees = Gson().fromJson<ArrayList<Attendee>>(mEvent.attendees, token) ?: ArrayList()
@ -831,7 +836,7 @@ class EventActivity : SimpleActivity() {
val eventType = eventsHelper.getEventTypeWithCalDAVCalendarId(calendarId = mEventCalendarId)!! val eventType = eventsHelper.getEventTypeWithCalDAVCalendarId(calendarId = mEventCalendarId)!!
runOnUiThread { runOnUiThread {
SelectEventColorDialog(activity = this, eventType = eventType, selectedColor = mEvent.color) { color -> SelectEventColorDialog(activity = this, eventType = eventType, selectedColor = mEvent.color) { color ->
mEvent.color = color mEventColor = color
updateEventColorInfo(eventType.color) updateEventColorInfo(eventType.color)
} }
} }
@ -1029,10 +1034,10 @@ class EventActivity : SimpleActivity() {
} }
private fun updateEventColorInfo(defaultColor: Int) { private fun updateEventColorInfo(defaultColor: Int) {
val eventColor = if (mEvent.color == 0) { val eventColor = if (mEventColor == 0) {
defaultColor defaultColor
} else { } else {
mEvent.color mEventColor
} }
event_caldav_color.setFillWithStroke(eventColor, getProperBackgroundColor()) event_caldav_color.setFillWithStroke(eventColor, getProperBackgroundColor())
} }
@ -1225,6 +1230,7 @@ class EventActivity : SimpleActivity() {
source = newSource source = newSource
location = event_location.value location = event_location.value
availability = mAvailability availability = mAvailability
color = mEventColor
} }
// recreate the event if it was moved in a different CalDAV calendar // recreate the event if it was moved in a different CalDAV calendar

View File

@ -255,6 +255,7 @@ const val AVAILABILITY = "AVAILABILITY"
const val EVENT_TYPE_ID = "EVENT_TYPE_ID" const val EVENT_TYPE_ID = "EVENT_TYPE_ID"
const val EVENT_CALENDAR_ID = "EVENT_CALENDAR_ID" const val EVENT_CALENDAR_ID = "EVENT_CALENDAR_ID"
const val IS_NEW_EVENT = "IS_NEW_EVENT" const val IS_NEW_EVENT = "IS_NEW_EVENT"
const val EVENT_COLOR = "EVENT_COLOR"
// actions // actions
const val ACTION_MARK_COMPLETED = "ACTION_MARK_COMPLETED" const val ACTION_MARK_COMPLETED = "ACTION_MARK_COMPLETED"