Revert "do not reduce text alpha of past events, keep it readable"
This reverts commit 5ce9971fb0
.
This commit is contained in:
parent
2e33b4f63f
commit
db4d27b0db
2 changed files with 14 additions and 7 deletions
|
@ -449,9 +449,10 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||
val dayColumn = dayColumns[dayOfWeek]
|
||||
(inflater.inflate(R.layout.week_event_marker, null, false) as TextView).apply {
|
||||
var backgroundColor = eventTypeColors.get(event.eventType, primaryColor)
|
||||
val textColor = backgroundColor.getContrastColor()
|
||||
var textColor = backgroundColor.getContrastColor()
|
||||
if (dimPastEvents && event.isPastEvent && !isPrintVersion) {
|
||||
backgroundColor = backgroundColor.adjustAlpha(LOW_ALPHA)
|
||||
textColor = textColor.adjustAlpha(LOW_ALPHA)
|
||||
}
|
||||
|
||||
background = ColorDrawable(backgroundColor)
|
||||
|
@ -555,9 +556,10 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||
private fun addAllDayEvent(event: Event) {
|
||||
(inflater.inflate(R.layout.week_all_day_event_marker, null, false) as TextView).apply {
|
||||
var backgroundColor = eventTypeColors.get(event.eventType, primaryColor)
|
||||
val textColor = backgroundColor.getContrastColor()
|
||||
var textColor = backgroundColor.getContrastColor()
|
||||
if (dimPastEvents && event.isPastEvent && !isPrintVersion) {
|
||||
backgroundColor = backgroundColor.adjustAlpha(LOW_ALPHA)
|
||||
textColor = textColor.adjustAlpha(LOW_ALPHA)
|
||||
}
|
||||
background = ColorDrawable(backgroundColor)
|
||||
|
||||
|
|
|
@ -275,16 +275,16 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
bgRectF.set(bgLeft, bgTop, bgRight, bgBottom)
|
||||
canvas.drawRoundRect(bgRectF, BG_CORNER_RADIUS, BG_CORNER_RADIUS, getEventBackgroundColor(event, startDayIndex, endDayIndex))
|
||||
|
||||
drawEventTitle(event, canvas, xPos, yPos + verticalOffset, bgRight - bgLeft - smallPadding)
|
||||
drawEventTitle(event, canvas, xPos, yPos + verticalOffset, bgRight - bgLeft - smallPadding, startDayIndex, endDayIndex)
|
||||
|
||||
for (i in 0 until Math.min(event.daysCnt, 7 - event.startDayIndex % 7)) {
|
||||
dayVerticalOffsets.put(event.startDayIndex + i, verticalOffset + eventTitleHeight + smallPadding * 2)
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawEventTitle(event: MonthViewEvent, canvas: Canvas, x: Float, y: Float, availableWidth: Float) {
|
||||
private fun drawEventTitle(event: MonthViewEvent, canvas: Canvas, x: Float, y: Float, availableWidth: Float, startDay: DayMonthly, endDay: DayMonthly) {
|
||||
val ellipsized = TextUtils.ellipsize(event.title, eventTitlePaint, availableWidth - smallPadding, TextUtils.TruncateAt.END)
|
||||
canvas.drawText(event.title, 0, ellipsized.length, x + smallPadding * 2, y, getEventTitlePaint(event))
|
||||
canvas.drawText(event.title, 0, ellipsized.length, x + smallPadding * 2, y, getEventTitlePaint(event, startDay, endDay))
|
||||
}
|
||||
|
||||
private fun getTextPaint(startDay: DayMonthly): Paint {
|
||||
|
@ -319,9 +319,14 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
return getColoredPaint(paintColor)
|
||||
}
|
||||
|
||||
private fun getEventTitlePaint(event: MonthViewEvent): Paint {
|
||||
private fun getEventTitlePaint(event: MonthViewEvent, startDay: DayMonthly, endDay: DayMonthly): Paint {
|
||||
var paintColor = event.color.getContrastColor()
|
||||
if ((!startDay.isThisMonth && !endDay.isThisMonth) || (dimPastEvents && event.isPastEvent && !isPrintVersion)) {
|
||||
paintColor = paintColor.adjustAlpha(MEDIUM_ALPHA)
|
||||
}
|
||||
|
||||
val curPaint = Paint(eventTitlePaint)
|
||||
curPaint.color = event.color.getContrastColor()
|
||||
curPaint.color = paintColor
|
||||
return curPaint
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue