diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/event/AgendaEventRenderer.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/event/AgendaEventRenderer.kt index dafdb853..ac65fcef 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/event/AgendaEventRenderer.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/event/AgendaEventRenderer.kt @@ -6,8 +6,15 @@ package pl.szczodrzynski.edziennik.ui.modules.agenda.event import android.annotation.SuppressLint import android.view.View +import android.widget.FrameLayout +import android.widget.TextView import androidx.core.view.isVisible import com.github.tibolte.agendacalendarview.render.EventRenderer +import com.mikepenz.iconics.IconicsDrawable +import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial +import com.mikepenz.iconics.utils.colorInt +import com.mikepenz.iconics.utils.sizeDp +import com.mikepenz.iconics.view.IconicsTextView import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventBinding import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventCompactBinding @@ -22,14 +29,33 @@ class AgendaEventRenderer( @SuppressLint("SetTextI18n") override fun render(view: View, aEvent: AgendaEvent) { + if (isCompact) { + val b = AgendaWrappedEventCompactBinding.bind(view).item + bindView(aEvent, b.card, b.title, null, b.badgeBackground, b.badge) + } else { + val b = AgendaWrappedEventBinding.bind(view).item + bindView(aEvent, b.card, b.title, b.subtitle, b.badgeBackground, b.badge) + } + } + + private fun bindView( + aEvent: AgendaEvent, + card: FrameLayout, + title: IconicsTextView, + subtitle: TextView?, + badgeBackground: View, + badge: View + ) { val event = aEvent.event + val textColor = Colors.legibleTextColor(event.eventColor) + val timeText = if (event.time == null) - view.context.getString(R.string.agenda_event_all_day) + card.context.getString(R.string.agenda_event_all_day) else event.time!!.stringHM - val eventTitle = "${event.typeName ?: "wydarzenie"} - ${event.topic}" + var eventTitle = "${event.typeName ?: "wydarzenie"} - ${event.topic}" val eventSubtitle = listOfNotNull( timeText, @@ -38,36 +64,33 @@ class AgendaEventRenderer( event.teamName ).join(", ") - if (isCompact) { - val b = AgendaWrappedEventCompactBinding.bind(view).item - - b.card.foreground.setTintColor(event.eventColor) - b.card.background.setTintColor(event.eventColor) - b.title.text = eventTitle - b.title.setTextColor(Colors.legibleTextColor(event.eventColor)) - - b.badgeBackground.isVisible = aEvent.showItemBadge - b.badgeBackground.background.setTintColor( - android.R.attr.colorBackground.resolveAttr(view.context) - ) - b.badge.isVisible = aEvent.showItemBadge + if (event.addedManually) { + eventTitle = "{cmd-clipboard-edit-outline} $eventTitle" } - else { - val b = AgendaWrappedEventBinding.bind(view).item - b.card.foreground.setTintColor(event.eventColor) - b.card.background.setTintColor(event.eventColor) - b.title.text = eventTitle - b.title.setTextColor(Colors.legibleTextColor(event.eventColor)) - b.subtitle.text = eventSubtitle - b.subtitle.setTextColor(Colors.legibleTextColor(event.eventColor)) + card.foreground.setTintColor(event.eventColor) + card.background.setTintColor(event.eventColor) + title.text = eventTitle + title.setTextColor(textColor) + subtitle?.text = eventSubtitle + subtitle?.setTextColor(textColor) - b.badgeBackground.isVisible = aEvent.showItemBadge - b.badgeBackground.background.setTintColor( - android.R.attr.colorBackground.resolveAttr(view.context) - ) - b.badge.isVisible = aEvent.showItemBadge - } + title.setCompoundDrawables( + null, + null, + if (event.isDone) IconicsDrawable(card.context).apply { + icon = CommunityMaterial.Icon.cmd_check + colorInt = textColor + sizeDp = 24 + } else null, + null + ) + + badgeBackground.isVisible = aEvent.showItemBadge + badgeBackground.background.setTintColor( + android.R.attr.colorBackground.resolveAttr(card.context) + ) + badge.isVisible = aEvent.showItemBadge } override fun getEventLayout() = if (isCompact) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/lessonchanges/LessonChangesEventRenderer.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/lessonchanges/LessonChangesEventRenderer.kt index 8b8ff81b..2a904016 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/lessonchanges/LessonChangesEventRenderer.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/lessonchanges/LessonChangesEventRenderer.kt @@ -17,13 +17,14 @@ class LessonChangesEventRenderer : EventRenderer() { override fun render(view: View, event: LessonChangesEvent) { val b = AgendaWrappedCounterBinding.bind(view).item + val textColor = Colors.legibleTextColor(event.color) b.card.foreground.setTintColor(event.color) b.card.background.setTintColor(event.color) b.name.setText(R.string.agenda_lesson_changes) - b.name.setTextColor(Colors.legibleTextColor(event.color)) + b.name.setTextColor(textColor) b.count.text = event.count.toString() - b.count.setTextColor(b.name.currentTextColor) + b.count.setTextColor(textColor) b.badgeBackground.isVisible = event.showItemBadge b.badgeBackground.background.setTintColor( diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/teacherabsence/TeacherAbsenceEventRenderer.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/teacherabsence/TeacherAbsenceEventRenderer.kt index ec0a3915..12dd1947 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/teacherabsence/TeacherAbsenceEventRenderer.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/teacherabsence/TeacherAbsenceEventRenderer.kt @@ -16,13 +16,14 @@ class TeacherAbsenceEventRenderer : EventRenderer() { override fun render(view: View, event: TeacherAbsenceEvent) { val b = AgendaWrappedCounterBinding.bind(view).item + val textColor = Colors.legibleTextColor(event.color) b.card.foreground.setTintColor(event.color) b.card.background.setTintColor(event.color) b.name.setText(R.string.agenda_teacher_absence) - b.name.setTextColor(Colors.legibleTextColor(event.color)) + b.name.setTextColor(textColor) b.count.text = event.count.toString() - b.count.setTextColor(b.name.currentTextColor) + b.count.setTextColor(textColor) b.badgeBackground.isVisible = false b.badge.isVisible = false diff --git a/app/src/main/res/layout/agenda_event_compact_item.xml b/app/src/main/res/layout/agenda_event_compact_item.xml index df48e70c..b97ddfa3 100644 --- a/app/src/main/res/layout/agenda_event_compact_item.xml +++ b/app/src/main/res/layout/agenda_event_compact_item.xml @@ -25,7 +25,7 @@ android:orientation="vertical" android:padding="10dp"> - -