@@ -10,14 +10,14 @@ import android.view.View
1010import com.simplemobiletools.calendar.pro.R
1111import com.simplemobiletools.calendar.pro.extensions.config
1212import com.simplemobiletools.calendar.pro.extensions.seconds
13- import com.simplemobiletools.calendar.pro.helpers.*
13+ import com.simplemobiletools.calendar.pro.helpers.COLUMN_COUNT
14+ import com.simplemobiletools.calendar.pro.helpers.Formatter
15+ import com.simplemobiletools.calendar.pro.helpers.ROW_COUNT
16+ import com.simplemobiletools.calendar.pro.helpers.isWeekend
1417import com.simplemobiletools.calendar.pro.models.DayMonthly
1518import com.simplemobiletools.calendar.pro.models.Event
1619import com.simplemobiletools.calendar.pro.models.MonthViewEvent
17- import com.simplemobiletools.commons.extensions.adjustAlpha
18- import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
19- import com.simplemobiletools.commons.extensions.getContrastColor
20- import com.simplemobiletools.commons.extensions.moveLastItemToFront
20+ import com.simplemobiletools.commons.extensions.*
2121import com.simplemobiletools.commons.helpers.HIGHER_ALPHA
2222import com.simplemobiletools.commons.helpers.LOWER_ALPHA
2323import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
@@ -121,15 +121,18 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
121121 val daysCnt = getEventLastingDaysCount(event)
122122 val validDayEvent = isDayValid(event, day.code)
123123 if ((lastEvent == null || lastEvent.startDayIndex + daysCnt <= day.indexOnMonthView) && ! validDayEvent) {
124- val monthViewEvent = MonthViewEvent (event.id!! , event.title, event.startTS, event.endTS, event.color, day.indexOnMonthView,
125- daysCnt, day.indexOnMonthView, event.getIsAllDay(), event.isPastEvent, event.isTask(), event.isTaskCompleted())
124+ val monthViewEvent = MonthViewEvent (
125+ event.id!! , event.title, event.startTS, event.endTS, event.color, day.indexOnMonthView,
126+ daysCnt, day.indexOnMonthView, event.getIsAllDay(), event.isPastEvent, event.isTask(), event.isTaskCompleted()
127+ )
126128 allEvents.add(monthViewEvent)
127129 }
128130 }
129131 }
130132
131- allEvents = allEvents.asSequence().sortedWith(compareBy({ - it.daysCnt }, { ! it.isAllDay }, { it.startTS }, { it.endTS }, { it.startDayIndex }, { it.title }))
132- .toMutableList() as ArrayList <MonthViewEvent >
133+ allEvents =
134+ allEvents.asSequence().sortedWith(compareBy({ - it.daysCnt }, { ! it.isAllDay }, { it.startTS }, { it.endTS }, { it.startDayIndex }, { it.title }))
135+ .toMutableList() as ArrayList <MonthViewEvent >
133136 }
134137
135138 override fun onDraw (canvas : Canvas ) {
@@ -172,7 +175,12 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
172175 if (isMonthDayView && day.dayEvents.isNotEmpty()) {
173176 getCirclePaint(day).getTextBounds(dayNumber, 0 , dayNumber.length, dayTextRect)
174177 val height = dayTextRect.height() * 1.25f
175- canvas.drawCircle(xPosCenter, yPos + height + textPaint.textSize / 2 , textPaint.textSize * 0.2f , getDayEventColor(day.dayEvents.first()))
178+ canvas.drawCircle(
179+ xPosCenter,
180+ yPos + height + textPaint.textSize / 2 ,
181+ textPaint.textSize * 0.2f ,
182+ getDayEventColor(day.dayEvents.first())
183+ )
176184 }
177185
178186 canvas.drawText(dayNumber, xPosCenter, yPos + textPaint.textSize, textPaint)
@@ -279,16 +287,26 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
279287 bgRectF.set(bgLeft, bgTop, bgRight, bgBottom)
280288 canvas.drawRoundRect(bgRectF, BG_CORNER_RADIUS , BG_CORNER_RADIUS , getEventBackgroundColor(event, startDayIndex, endDayIndex))
281289
282- drawEventTitle(event, canvas, xPos, yPos + verticalOffset, bgRight - bgLeft - smallPadding, startDayIndex, endDayIndex)
290+ val specificEventTitlePaint = getEventTitlePaint(event, startDayIndex, endDayIndex)
291+ var taskIconWidth = 0
292+ if (event.isTask) {
293+ val taskIcon = resources.getColoredDrawableWithColor(R .drawable.ic_task_vector, specificEventTitlePaint.color).mutate()
294+ val taskIconY = yPos.toInt() + verticalOffset - eventTitleHeight + smallPadding * 2
295+ taskIcon.setBounds(xPos.toInt() + smallPadding * 2 , taskIconY, xPos.toInt() + eventTitleHeight + smallPadding * 2 , taskIconY + eventTitleHeight)
296+ taskIcon.draw(canvas)
297+ taskIconWidth + = eventTitleHeight + smallPadding
298+ }
299+
300+ drawEventTitle(event, canvas, xPos + taskIconWidth, yPos + verticalOffset, bgRight - bgLeft - smallPadding - taskIconWidth, specificEventTitlePaint)
283301
284302 for (i in 0 until Math .min(event.daysCnt, 7 - event.startDayIndex % 7 )) {
285303 dayVerticalOffsets.put(event.startDayIndex + i, verticalOffset + eventTitleHeight + smallPadding * 2 )
286304 }
287305 }
288306
289- private fun drawEventTitle (event : MonthViewEvent , canvas : Canvas , x : Float , y : Float , availableWidth : Float , startDay : DayMonthly , endDay : DayMonthly ) {
307+ private fun drawEventTitle (event : MonthViewEvent , canvas : Canvas , x : Float , y : Float , availableWidth : Float , paint : Paint ) {
290308 val ellipsized = TextUtils .ellipsize(event.title, eventTitlePaint, availableWidth - smallPadding, TextUtils .TruncateAt .END )
291- canvas.drawText(event.title, 0 , ellipsized.length, x + smallPadding * 2 , y, getEventTitlePaint(event, startDay, endDay) )
309+ canvas.drawText(event.title, 0 , ellipsized.length, x + smallPadding * 2 , y, paint )
292310 }
293311
294312 private fun getTextPaint (startDay : DayMonthly ): Paint {
0 commit comments