color the event markers at monthly view if all events are 1 event type
This commit is contained in:
parent
30d593649a
commit
13932d46f2
|
@ -58,7 +58,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
||||||
setupLabels()
|
setupLabels()
|
||||||
mCalendar = MonthlyCalendarImpl(this, context)
|
mCalendar = MonthlyCalendarImpl(this, context)
|
||||||
|
|
||||||
val padding = resources.getDimension(R.dimen.activity_margin).toInt()
|
val padding = mRes.getDimension(R.dimen.activity_margin).toInt()
|
||||||
view.calendar_holder.setPadding(padding, padding, padding, padding)
|
view.calendar_holder.setPadding(padding, padding, padding, padding)
|
||||||
|
|
||||||
return view
|
return view
|
||||||
|
@ -175,14 +175,6 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
val weakerText = mTextColor.adjustAlpha(MEDIUM_ALPHA)
|
val weakerText = mTextColor.adjustAlpha(MEDIUM_ALPHA)
|
||||||
val todayCircle = resources.getDrawable(R.drawable.circle_empty)
|
|
||||||
todayCircle.setColorFilter(weakerText, PorterDuff.Mode.SRC_IN)
|
|
||||||
|
|
||||||
val eventDot = resources.getDrawable(R.drawable.monthly_day_dot)
|
|
||||||
eventDot.setColorFilter(weakerText, PorterDuff.Mode.SRC_IN)
|
|
||||||
|
|
||||||
val todayWithEvent = resources.getDrawable(R.drawable.monthly_day_with_event_today)
|
|
||||||
todayWithEvent.setColorFilter(weakerText, PorterDuff.Mode.SRC_IN)
|
|
||||||
|
|
||||||
for (i in 0..len - 1) {
|
for (i in 0..len - 1) {
|
||||||
val day = days[i]
|
val day = days[i]
|
||||||
|
@ -200,11 +192,17 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
||||||
background = if (!day.isThisMonth) {
|
background = if (!day.isThisMonth) {
|
||||||
null
|
null
|
||||||
} else if (day.isToday && day.hasEvent) {
|
} else if (day.isToday && day.hasEvent) {
|
||||||
todayWithEvent
|
val drawable = mRes.getDrawable(R.drawable.monthly_day_with_event_today).mutate()
|
||||||
|
drawable.setColorFilter(getDayDotColor(day, weakerText), PorterDuff.Mode.SRC_IN)
|
||||||
|
drawable
|
||||||
} else if (day.isToday) {
|
} else if (day.isToday) {
|
||||||
|
val todayCircle = mRes.getDrawable(R.drawable.circle_empty)
|
||||||
|
todayCircle.setColorFilter(weakerText, PorterDuff.Mode.SRC_IN)
|
||||||
todayCircle
|
todayCircle
|
||||||
} else if (day.hasEvent) {
|
} else if (day.hasEvent) {
|
||||||
eventDot
|
val drawable = mRes.getDrawable(R.drawable.monthly_day_dot).mutate()
|
||||||
|
drawable.setColorFilter(getDayDotColor(day, weakerText), PorterDuff.Mode.SRC_IN)
|
||||||
|
drawable
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
@ -212,6 +210,14 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getDayDotColor(day: Day, defaultColor: Int): Int {
|
||||||
|
val colors = day.eventColors.distinct()
|
||||||
|
return if (colors.size == 1)
|
||||||
|
colors[0]
|
||||||
|
else
|
||||||
|
defaultColor
|
||||||
|
}
|
||||||
|
|
||||||
private fun openDay(code: String) {
|
private fun openDay(code: String) {
|
||||||
if (code.isEmpty())
|
if (code.isEmpty())
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue