mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
Hide event colors setting when there are no colors available
This commit is contained in:
@@ -835,8 +835,7 @@ class EventActivity : SimpleActivity() {
|
|||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val eventType = eventsHelper.getEventTypeWithCalDAVCalendarId(calendarId = mEventCalendarId)!!
|
val eventType = eventsHelper.getEventTypeWithCalDAVCalendarId(calendarId = mEventCalendarId)!!
|
||||||
val eventColorsMap = calDAVHelper.getAvailableCalDAVCalendarColors(eventType, Colors.TYPE_EVENT)
|
val eventColors = getEventColors(eventType)
|
||||||
val eventColors = eventColorsMap.keys.toIntArray()
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val currentColor = if (mEventColor == 0) {
|
val currentColor = if (mEventColor == 0) {
|
||||||
eventType.color
|
eventType.color
|
||||||
@@ -964,9 +963,6 @@ class EventActivity : SimpleActivity() {
|
|||||||
event_caldav_calendar_image.beVisible()
|
event_caldav_calendar_image.beVisible()
|
||||||
event_caldav_calendar_holder.beVisible()
|
event_caldav_calendar_holder.beVisible()
|
||||||
event_caldav_calendar_divider.beVisible()
|
event_caldav_calendar_divider.beVisible()
|
||||||
event_caldav_color_image.beVisible()
|
|
||||||
event_caldav_color_holder.beVisible()
|
|
||||||
event_caldav_color_divider.beVisible()
|
|
||||||
|
|
||||||
val calendars = calDAVHelper.getCalDAVCalendars("", true).filter {
|
val calendars = calDAVHelper.getCalDAVCalendars("", true).filter {
|
||||||
it.canWrite() && config.getSyncedCalendarIdsAsList().contains(it.id)
|
it.canWrite() && config.getSyncedCalendarIdsAsList().contains(it.id)
|
||||||
@@ -1005,9 +1001,6 @@ class EventActivity : SimpleActivity() {
|
|||||||
event_type_holder.beVisibleIf(currentCalendar == null)
|
event_type_holder.beVisibleIf(currentCalendar == null)
|
||||||
event_caldav_calendar_divider.beVisibleIf(currentCalendar == null)
|
event_caldav_calendar_divider.beVisibleIf(currentCalendar == null)
|
||||||
event_caldav_calendar_email.beGoneIf(currentCalendar == null)
|
event_caldav_calendar_email.beGoneIf(currentCalendar == null)
|
||||||
event_caldav_color_image.beGoneIf(currentCalendar == null)
|
|
||||||
event_caldav_color_holder.beGoneIf(currentCalendar == null)
|
|
||||||
event_caldav_color_divider.beGoneIf(currentCalendar == null)
|
|
||||||
|
|
||||||
if (currentCalendar == null) {
|
if (currentCalendar == null) {
|
||||||
mEventCalendarId = STORED_LOCALLY_ONLY
|
mEventCalendarId = STORED_LOCALLY_ONLY
|
||||||
@@ -1020,11 +1013,20 @@ class EventActivity : SimpleActivity() {
|
|||||||
event_caldav_calendar_holder.apply {
|
event_caldav_calendar_holder.apply {
|
||||||
setPadding(paddingLeft, mediumMargin, paddingRight, mediumMargin)
|
setPadding(paddingLeft, mediumMargin, paddingRight, mediumMargin)
|
||||||
}
|
}
|
||||||
|
event_caldav_color_image.beGone()
|
||||||
|
event_caldav_color_holder.beGone()
|
||||||
|
event_caldav_color_divider.beGone()
|
||||||
} else {
|
} else {
|
||||||
event_caldav_calendar_email.text = currentCalendar.accountName
|
event_caldav_calendar_email.text = currentCalendar.accountName
|
||||||
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val calendarColor = eventsHelper.getEventTypeWithCalDAVCalendarId(currentCalendar.id)?.color ?: currentCalendar.color
|
val eventType = eventsHelper.getEventTypeWithCalDAVCalendarId(currentCalendar.id)
|
||||||
|
val calendarColor = eventType?.color ?: currentCalendar.color
|
||||||
|
val canCustomizeColors = if (eventType != null) {
|
||||||
|
getEventColors(eventType).isNotEmpty()
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
event_caldav_calendar_name.apply {
|
event_caldav_calendar_name.apply {
|
||||||
@@ -1035,11 +1037,17 @@ class EventActivity : SimpleActivity() {
|
|||||||
event_caldav_calendar_holder.apply {
|
event_caldav_calendar_holder.apply {
|
||||||
setPadding(paddingLeft, 0, paddingRight, 0)
|
setPadding(paddingLeft, 0, paddingRight, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event_caldav_color_image.beVisibleIf(canCustomizeColors)
|
||||||
|
event_caldav_color_holder.beVisibleIf(canCustomizeColors)
|
||||||
|
event_caldav_color_divider.beVisibleIf(canCustomizeColors)
|
||||||
|
if (canCustomizeColors) {
|
||||||
updateEventColorInfo(calendarColor)
|
updateEventColorInfo(calendarColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateEventColorInfo(defaultColor: Int) {
|
private fun updateEventColorInfo(defaultColor: Int) {
|
||||||
val eventColor = if (mEventColor == 0) {
|
val eventColor = if (mEventColor == 0) {
|
||||||
@@ -1050,6 +1058,10 @@ class EventActivity : SimpleActivity() {
|
|||||||
event_caldav_color.setFillWithStroke(eventColor, getProperBackgroundColor())
|
event_caldav_color.setFillWithStroke(eventColor, getProperBackgroundColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getEventColors(eventType: EventType): IntArray {
|
||||||
|
return calDAVHelper.getAvailableCalDAVCalendarColors(eventType, Colors.TYPE_EVENT).keys.toIntArray()
|
||||||
|
}
|
||||||
|
|
||||||
private fun resetTime() {
|
private fun resetTime() {
|
||||||
if (mEventEndDateTime.isBefore(mEventStartDateTime) &&
|
if (mEventEndDateTime.isBefore(mEventStartDateTime) &&
|
||||||
mEventStartDateTime.dayOfMonth() == mEventEndDateTime.dayOfMonth() &&
|
mEventStartDateTime.dayOfMonth() == mEventEndDateTime.dayOfMonth() &&
|
||||||
|
Reference in New Issue
Block a user