Calendar
Calendar copied to clipboard
text vs background color regression on 1.2.0
Checklist
- [x] I can reproduce the bug with the latest version given here.
- [x] I made sure that there are no existing issues - open or closed - to which I could contribute my information.
- [x] I made sure that there are no existing discussions - open or closed - to which I could contribute my information.
- [x] I have read the FAQs inside the app (Menu -> About -> FAQs) and my problem isn't listed.
- [x] I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
- [x] This issue contains only one bug.
- [x] I have read and understood the contribution guidelines.
Affected app version
1.2.0
Affected Android/Custom ROM version
Android 11
Affected device model
Oneplus
How did you install the app?
F-Droid / IzzyOnDroid
Which calendar service or provider do you use, if any?
No response
Which sync adapter app do you use for calendar synchronization, if any?
CalDAV sync
Steps to reproduce the bug
On monthly (and weekly?) views, on gray event colors
- In 1.1.0 the text color is light and easy to read.
- In 1.2.0, the text color is dark and hard to read
Expected behavior
Text color remains light on darker backgrounds
Actual behavior
Text color is dark on dark backgrounds
Screenshots/Screen recordings
It seems the darker text on gray is okay when it's in current month, but if it's faded out like in previous or next month it's too hard to read.
Additional information
No response
Caused by https://github.com/FossifyOrg/Calendar/commit/aff984bd2d56eb9b334f677c768ad5b7dd8d6753
Related:
- https://github.com/FossifyOrg/Calendar/issues/188
- https://github.com/FossifyOrg/Calendar/pull/448
I'll use this revert for now
commit b5695edad9d560e55a77f8fed3164f66dc69b587
Author: me <>
Date: Sat Mar 29 05:31:25 2025 +0000
Revert "Disable CalDAV event color modification"
This reverts commit aff984bd2d56eb9b334f677c768ad5b7dd8d6753
diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt
index 473793473..9e060318d 100644
--- a/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt
+++ b/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt
@@ -4,6 +4,8 @@ import android.annotation.SuppressLint
import android.content.ContentUris
import android.content.ContentValues
import android.content.Context
+import android.graphics.Color
+import android.provider.CalendarContract
import android.provider.CalendarContract.Attendees
import android.provider.CalendarContract.Calendars
import android.provider.CalendarContract.Colors
@@ -40,6 +42,7 @@ import org.fossify.commons.helpers.PERMISSION_WRITE_CALENDAR
import org.joda.time.DateTimeZone
import org.joda.time.format.DateTimeFormat
import kotlin.math.max
+import kotlin.math.min
@SuppressLint("MissingPermission")
class CalDAVHelper(val context: Context) {
@@ -147,6 +150,15 @@ class CalDAVHelper(val context: Context) {
return colors[eventType.color]
}
+ // darkens the given color to ensure that white text is clearly visible on top of it
+ private fun getDisplayColorFromColor(color: Int): Int {
+ val hsv = FloatArray(3)
+ Color.colorToHSV(color, hsv)
+ hsv[1] = min(hsv[1] * SATURATION_ADJUST, 1.0f)
+ hsv[2] = hsv[2] * INTENSITY_ADJUST
+ return Color.HSVToColor(hsv)
+ }
+
@SuppressLint("MissingPermission")
fun getAvailableCalDAVCalendarColors(
eventType: EventType,
@@ -161,7 +173,12 @@ class CalDAVHelper(val context: Context) {
context.queryCursor(uri, projection, selection, selectionArgs) { cursor ->
val colorKey = cursor.getStringValue(Colors.COLOR_KEY)
val color = cursor.getIntValue(Colors.COLOR)
- colors[color] = colorKey
+ val displayColor = if (colorType == Colors.TYPE_CALENDAR) {
+ color
+ } else {
+ getDisplayColorFromColor(color)
+ }
+ colors[displayColor] = colorKey
}
return colors.toSortedMap(HsvColorComparator())
}
@@ -241,7 +258,12 @@ class CalDAVHelper(val context: Context) {
val attendees = getCalDAVEventAttendees(id, calendar)
val availability = cursor.getIntValue(Events.AVAILABILITY)
val status = cursor.getIntValue(Events.STATUS)
- val color = cursor.getIntValueOrNull(Events.EVENT_COLOR) ?: 0
+ val color = cursor.getIntValueOrNull(Events.EVENT_COLOR)
+ val displayColor = if (color != null) {
+ getDisplayColorFromColor(color)
+ } else {
+ 0
+ }
if (endTS == 0L) {
val duration = cursor.getStringValue(Events.DURATION) ?: ""
@@ -281,7 +303,7 @@ class CalDAVHelper(val context: Context) {
eventType = eventTypeId,
source = source,
availability = availability,
- color = color,
+ color = displayColor,
status = status
)
@@ -679,4 +701,9 @@ class CalDAVHelper(val context: Context) {
private fun refreshCalDAVCalendar(event: Event) {
context.refreshCalDAVCalendars(event.getCalDAVCalendarId().toString(), false)
}
+
+ companion object {
+ private const val INTENSITY_ADJUST = 0.8f
+ private const val SATURATION_ADJUST = 1.3f
+ }
}
Is this related? This popup is from tapping the + button on the widget
See https://github.com/FossifyOrg/General-Discussion/issues/279