mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-02-22 22:44:45 +01:00
[Agenda] Add unread badges to events and groups.
This commit is contained in:
parent
777ae945e0
commit
f5ceaa9afe
@ -92,6 +92,10 @@ class EventDetailsDialog(
|
||||
b.eventShared = eventShared
|
||||
b.eventOwn = eventOwn
|
||||
|
||||
if (!event.seen) {
|
||||
app.eventManager.markAsSeen(event)
|
||||
}
|
||||
|
||||
val bullet = " • "
|
||||
val colorSecondary = android.R.attr.textColorSecondary.resolveAttr(activity)
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
package pl.szczodrzynski.edziennik.ui.modules.agenda
|
||||
|
||||
import android.util.SparseIntArray
|
||||
import android.widget.AbsListView
|
||||
import android.widget.AbsListView.OnScrollListener
|
||||
import androidx.core.util.forEach
|
||||
import androidx.core.util.set
|
||||
import androidx.core.view.isVisible
|
||||
@ -14,9 +16,7 @@ import com.github.tibolte.agendacalendarview.agenda.AgendaAdapter
|
||||
import com.github.tibolte.agendacalendarview.models.BaseCalendarEvent
|
||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent
|
||||
import com.github.tibolte.agendacalendarview.models.IDayItem
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.*
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.MainActivity
|
||||
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
@ -40,16 +40,67 @@ class AgendaFragmentDefault(
|
||||
private val activity: MainActivity,
|
||||
private val app: App,
|
||||
private val b: FragmentAgendaDefaultBinding
|
||||
) {
|
||||
) : OnScrollListener, CoroutineScope {
|
||||
companion object {
|
||||
var selectedDate: Date = Date.getToday()
|
||||
}
|
||||
|
||||
override val coroutineContext = Job() + Dispatchers.Main
|
||||
|
||||
private val unreadDates = mutableSetOf<Int>()
|
||||
private val events = mutableListOf<CalendarEvent>()
|
||||
private var isInitialized = false
|
||||
private val profileConfig by lazy { app.config.forProfile().ui }
|
||||
|
||||
private val listView
|
||||
get() = b.agendaDefaultView.agendaView.agendaListView
|
||||
private val adapter
|
||||
get() = listView.adapter as? AgendaAdapter
|
||||
private val manager
|
||||
get() = CalendarManager.getInstance()
|
||||
|
||||
// TODO: 2021-04-11 find a way to attach the OnScrollListener automatically
|
||||
// then set this to IDLE by default
|
||||
// the FAB also needs the original listener, though
|
||||
private var scrollState = OnScrollListener.SCROLL_STATE_TOUCH_SCROLL
|
||||
private var updatePending = false
|
||||
private var notifyPending = false
|
||||
override fun onScrollStateChanged(view: AbsListView?, newScrollState: Int) {
|
||||
scrollState = newScrollState
|
||||
if (updatePending) updateData()
|
||||
if (notifyPending) notifyDataSetChanged()
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the data as needing update, either after 1 second (when
|
||||
* not scrolling) or 1 second after scrolling stops.
|
||||
*/
|
||||
private fun updateData() = launch {
|
||||
if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
|
||||
updatePending = false
|
||||
delay(1000)
|
||||
notifyDataSetChanged()
|
||||
} else updatePending = true
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the adapter about changes, either instantly or after
|
||||
* scrolling stops.
|
||||
*/
|
||||
private fun notifyDataSetChanged() {
|
||||
if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
|
||||
notifyPending = false
|
||||
adapter?.notifyDataSetChanged()
|
||||
} else notifyPending = true
|
||||
}
|
||||
|
||||
override fun onScroll(
|
||||
view: AbsListView?,
|
||||
firstVisibleItem: Int,
|
||||
visibleItemCount: Int,
|
||||
totalItemCount: Int
|
||||
) = Unit
|
||||
|
||||
suspend fun initView(fragment: AgendaFragment) {
|
||||
isInitialized = false
|
||||
|
||||
@ -95,9 +146,22 @@ class AgendaFragmentDefault(
|
||||
app.profileId,
|
||||
date
|
||||
)
|
||||
is AgendaEventGroup -> DayDialog(activity, app.profileId, date)
|
||||
is BaseCalendarEvent -> if (event.isPlaceHolder)
|
||||
DayDialog(activity, app.profileId, date)
|
||||
}
|
||||
|
||||
if (event is BaseEvent && event.showItemBadge) {
|
||||
val unreadCount = manager.events.count {
|
||||
it.instanceDay.equals(event.instanceDay) && it.showBadge
|
||||
}
|
||||
// only clicked event is unread, remove the day badge
|
||||
if (unreadCount == 1 && event.showBadge) {
|
||||
event.dayReference.showBadge = false
|
||||
unreadDates.remove(date.value)
|
||||
}
|
||||
setAsRead(event)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onScrollToDate(calendar: Calendar) {
|
||||
@ -105,6 +169,7 @@ class AgendaFragmentDefault(
|
||||
|
||||
// Mark as read scrolled date
|
||||
if (selectedDate.value in unreadDates) {
|
||||
setAsRead(calendar)
|
||||
activity.launch(Dispatchers.Default) {
|
||||
app.db.eventDao().setSeenByDate(app.profileId, selectedDate, true)
|
||||
}
|
||||
@ -123,20 +188,45 @@ class AgendaFragmentDefault(
|
||||
}
|
||||
|
||||
private fun updateView() {
|
||||
val manager = CalendarManager.getInstance()
|
||||
manager.events.clear()
|
||||
manager.loadEvents(events, BaseCalendarEvent())
|
||||
|
||||
val adapter = b.agendaDefaultView.agendaView.agendaListView.adapter as? AgendaAdapter
|
||||
adapter?.updateEvents(manager.events)
|
||||
b.agendaDefaultView.agendaView.agendaListView.scrollToCurrentDate(selectedDate.asCalendar)
|
||||
listView.scrollToCurrentDate(selectedDate.asCalendar)
|
||||
}
|
||||
|
||||
private fun setAsRead(date: Calendar) {
|
||||
// get all events matching the date
|
||||
val events = manager.events.filter {
|
||||
if (it.instanceDay.equals(date) && it.showBadge && it is AgendaEvent) {
|
||||
// hide the day badge for the date
|
||||
it.dayReference.showBadge = false
|
||||
return@filter true
|
||||
}
|
||||
false
|
||||
}
|
||||
// set this date's events as read
|
||||
setAsRead(*events.toTypedArray())
|
||||
}
|
||||
|
||||
private fun setAsRead(vararg event: CalendarEvent) {
|
||||
// hide per-event badges
|
||||
for (e in event) {
|
||||
events.firstOrNull {
|
||||
it == e
|
||||
}?.showBadge = false
|
||||
e.showBadge = false
|
||||
}
|
||||
|
||||
listView.setOnScrollListener(this)
|
||||
updateData()
|
||||
}
|
||||
|
||||
private fun addEvents(
|
||||
events: MutableList<CalendarEvent>,
|
||||
eventList: List<EventFull>
|
||||
) {
|
||||
events.removeAll { it is AgendaEvent }
|
||||
events.removeAll { it is AgendaEvent || it is AgendaEventGroup }
|
||||
|
||||
if (!profileConfig.agendaGroupByType) {
|
||||
events += eventList.map {
|
||||
@ -155,14 +245,14 @@ class AgendaFragmentDefault(
|
||||
if (!event.seen)
|
||||
unreadDates.add(event.date.value)
|
||||
events += AgendaEvent(event)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
events.add(0, AgendaEventGroup(
|
||||
profileId = event.profileId,
|
||||
date = event.date,
|
||||
typeName = event.typeName ?: "-",
|
||||
typeColor = event.typeColor ?: event.eventColor,
|
||||
eventCount = list.size
|
||||
count = list.size,
|
||||
showBadge = list.any { !it.seen }
|
||||
))
|
||||
}
|
||||
}
|
||||
@ -179,7 +269,8 @@ class AgendaFragmentDefault(
|
||||
LessonChangesEvent(
|
||||
app.profileId,
|
||||
date = date ?: return@mapNotNull null,
|
||||
changeCount = changes.size
|
||||
count = changes.size,
|
||||
showBadge = changes.any { !it.seen }
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -200,7 +291,7 @@ class AgendaFragmentDefault(
|
||||
events += TeacherAbsenceEvent(
|
||||
app.profileId,
|
||||
date = Date.fromValue(dateInt),
|
||||
absenceCount = count
|
||||
count = count
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ open class BaseEvent(
|
||||
private val id: Long,
|
||||
private val time: Calendar,
|
||||
private val color: Int,
|
||||
private val showBadge: Boolean
|
||||
private var showBadge: Boolean,
|
||||
var showItemBadge: Boolean = showBadge
|
||||
) : CalendarEvent {
|
||||
|
||||
override fun copy() = BaseEvent(id, time, color, showBadge)
|
||||
@ -36,6 +37,12 @@ open class BaseEvent(
|
||||
weekReference = value
|
||||
}
|
||||
|
||||
override fun getShowBadge() = showBadge
|
||||
override fun setShowBadge(value: Boolean) {
|
||||
showBadge = value
|
||||
showItemBadge = value
|
||||
}
|
||||
|
||||
override fun getId() = id
|
||||
override fun getStartTime() = time
|
||||
override fun getEndTime() = time
|
||||
@ -44,7 +51,6 @@ open class BaseEvent(
|
||||
override fun getLocation() = ""
|
||||
override fun getColor() = color
|
||||
override fun getTextColor() = 0
|
||||
override fun getShowBadge() = showBadge
|
||||
override fun isPlaceholder() = false
|
||||
override fun isAllDay() = false
|
||||
|
||||
@ -55,7 +61,6 @@ open class BaseEvent(
|
||||
override fun setDescription(value: String) = Unit
|
||||
override fun setLocation(value: String) = Unit
|
||||
override fun setTextColor(value: Int) = Unit
|
||||
override fun setShowBadge(value: Boolean) = Unit
|
||||
override fun setPlaceholder(value: Boolean) = Unit
|
||||
override fun setAllDay(value: Boolean) = Unit
|
||||
}
|
||||
|
@ -8,12 +8,13 @@ import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
import pl.szczodrzynski.edziennik.ui.modules.agenda.BaseEvent
|
||||
|
||||
class AgendaEvent(
|
||||
val event: EventFull
|
||||
val event: EventFull,
|
||||
showBadge: Boolean = !event.seen
|
||||
) : BaseEvent(
|
||||
id = event.id,
|
||||
time = event.startTimeCalendar,
|
||||
color = event.eventColor,
|
||||
showBadge = !event.seen
|
||||
showBadge = showBadge
|
||||
) {
|
||||
override fun copy() = AgendaEvent(event)
|
||||
override fun copy() = AgendaEvent(event, showBadge)
|
||||
}
|
||||
|
@ -12,12 +12,13 @@ class AgendaEventGroup(
|
||||
val date: Date,
|
||||
val typeName: String,
|
||||
val typeColor: Int,
|
||||
val eventCount: Int
|
||||
val count: Int,
|
||||
showBadge: Boolean
|
||||
) : BaseEvent(
|
||||
id = date.value.toLong(),
|
||||
time = date.asCalendar,
|
||||
color = typeColor,
|
||||
showBadge = false
|
||||
showBadge = showBadge
|
||||
) {
|
||||
override fun copy() = AgendaEventGroup(profileId, date, typeName, typeColor, eventCount)
|
||||
override fun copy() = AgendaEventGroup(profileId, date, typeName, typeColor, count, showBadge)
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
package pl.szczodrzynski.edziennik.ui.modules.agenda.event
|
||||
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import com.github.tibolte.agendacalendarview.render.EventRenderer
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedGroupBinding
|
||||
@ -17,13 +18,14 @@ class AgendaEventGroupRenderer : EventRenderer<AgendaEventGroup>() {
|
||||
override fun render(view: View, event: AgendaEventGroup) {
|
||||
val b = AgendaWrappedGroupBinding.bind(view).item
|
||||
|
||||
b.foreground.foreground.setTintColor(event.typeColor)
|
||||
b.background.background.setTintColor(event.typeColor)
|
||||
b.name.background.setTintColor(event.typeColor)
|
||||
b.card.foreground.setTintColor(event.color)
|
||||
b.card.background.setTintColor(event.color)
|
||||
b.name.text = event.typeName
|
||||
b.name.setTextColor(Colors.legibleTextColor(event.typeColor))
|
||||
b.count.text = event.eventCount.toString()
|
||||
b.name.setTextColor(Colors.legibleTextColor(event.color))
|
||||
b.count.text = event.count.toString()
|
||||
b.count.background.setTintColor(android.R.attr.colorBackground.resolveAttr(view.context))
|
||||
|
||||
b.badge.isVisible = event.showItemBadge
|
||||
}
|
||||
|
||||
override fun getEventLayout(): Int = R.layout.agenda_wrapped_group
|
||||
|
@ -6,36 +6,72 @@ package pl.szczodrzynski.edziennik.ui.modules.agenda.event
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import com.github.tibolte.agendacalendarview.render.EventRenderer
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventBinding
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventCompactBinding
|
||||
import pl.szczodrzynski.edziennik.join
|
||||
import pl.szczodrzynski.edziennik.resolveAttr
|
||||
import pl.szczodrzynski.edziennik.setTintColor
|
||||
import pl.szczodrzynski.edziennik.utils.Colors
|
||||
|
||||
class AgendaEventRenderer(
|
||||
private val isCompact: Boolean
|
||||
val isCompact: Boolean
|
||||
) : EventRenderer<AgendaEvent>() {
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun render(view: View, aEvent: AgendaEvent) {
|
||||
val b = AgendaWrappedEventBinding.bind(view).item
|
||||
val event = aEvent.event
|
||||
|
||||
b.isCompact = isCompact
|
||||
val timeText = if (event.time == null)
|
||||
view.context.getString(R.string.agenda_event_all_day)
|
||||
else
|
||||
event.time!!.stringHM
|
||||
|
||||
b.card.setCardBackgroundColor(event.eventColor)
|
||||
b.eventTitle.setTextColor(Colors.legibleTextColor(event.eventColor))
|
||||
b.eventSubtitle.setTextColor(Colors.legibleTextColor(event.eventColor))
|
||||
val eventTitle = "${event.typeName ?: "wydarzenie"} - ${event.topic}"
|
||||
|
||||
b.eventTitle.text = "${event.typeName ?: "wydarzenie"} - ${event.topic}"
|
||||
b.eventSubtitle.text =
|
||||
(if (event.time == null)
|
||||
view.context.getString(R.string.agenda_event_all_day)
|
||||
else
|
||||
event.time!!.stringHM) +
|
||||
(event.subjectLongName?.let { ", $it" } ?: "") +
|
||||
(event.teacherName?.let { ", $it" } ?: "") +
|
||||
(event.teamName?.let { ", $it" } ?: "")
|
||||
val eventSubtitle = listOfNotNull(
|
||||
timeText,
|
||||
event.subjectLongName,
|
||||
event.teacherName,
|
||||
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
|
||||
}
|
||||
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))
|
||||
|
||||
b.badgeBackground.isVisible = aEvent.showItemBadge
|
||||
b.badgeBackground.background.setTintColor(
|
||||
android.R.attr.colorBackground.resolveAttr(view.context)
|
||||
)
|
||||
b.badge.isVisible = aEvent.showItemBadge
|
||||
}
|
||||
}
|
||||
|
||||
override fun getEventLayout(): Int = R.layout.agenda_wrapped_event
|
||||
override fun getEventLayout() = if (isCompact)
|
||||
R.layout.agenda_wrapped_event_compact
|
||||
else
|
||||
R.layout.agenda_wrapped_event
|
||||
}
|
||||
|
@ -10,12 +10,16 @@ import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
class LessonChangesEvent(
|
||||
val profileId: Int,
|
||||
val date: Date,
|
||||
val changeCount: Int
|
||||
val count: Int,
|
||||
showBadge: Boolean
|
||||
) : BaseEvent(
|
||||
id = date.value.toLong(),
|
||||
time = date.asCalendar,
|
||||
color = 0xff78909c.toInt(),
|
||||
showBadge = false
|
||||
showBadge = false,
|
||||
showItemBadge = showBadge
|
||||
) {
|
||||
override fun copy() = LessonChangesEvent(profileId, date, changeCount)
|
||||
override fun copy() = LessonChangesEvent(profileId, date, count, showItemBadge)
|
||||
|
||||
override fun getShowBadge() = false
|
||||
}
|
||||
|
@ -5,17 +5,32 @@
|
||||
package pl.szczodrzynski.edziennik.ui.modules.agenda.lessonchanges
|
||||
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import com.github.tibolte.agendacalendarview.render.EventRenderer
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedLessonChangesBinding
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedCounterBinding
|
||||
import pl.szczodrzynski.edziennik.resolveAttr
|
||||
import pl.szczodrzynski.edziennik.setTintColor
|
||||
import pl.szczodrzynski.edziennik.utils.Colors
|
||||
|
||||
class LessonChangesEventRenderer : EventRenderer<LessonChangesEvent>() {
|
||||
|
||||
override fun render(view: View, event: LessonChangesEvent) {
|
||||
val b = AgendaWrappedLessonChangesBinding.bind(view).item
|
||||
val b = AgendaWrappedCounterBinding.bind(view).item
|
||||
|
||||
b.lessonChangeCount.text = event.changeCount.toString()
|
||||
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.count.text = event.count.toString()
|
||||
b.count.setTextColor(b.name.currentTextColor)
|
||||
|
||||
b.badgeBackground.isVisible = event.showItemBadge
|
||||
b.badgeBackground.background.setTintColor(
|
||||
android.R.attr.colorBackground.resolveAttr(view.context)
|
||||
)
|
||||
b.badge.isVisible = event.showItemBadge
|
||||
}
|
||||
|
||||
override fun getEventLayout(): Int = R.layout.agenda_wrapped_lesson_changes
|
||||
override fun getEventLayout(): Int = R.layout.agenda_wrapped_counter
|
||||
}
|
||||
|
@ -10,12 +10,12 @@ import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
class TeacherAbsenceEvent(
|
||||
val profileId: Int,
|
||||
val date: Date,
|
||||
val absenceCount: Int
|
||||
val count: Int
|
||||
) : BaseEvent(
|
||||
id = date.value.toLong(),
|
||||
time = date.asCalendar,
|
||||
color = 0xffff1744.toInt(),
|
||||
showBadge = false
|
||||
) {
|
||||
override fun copy() = TeacherAbsenceEvent(profileId, date, absenceCount)
|
||||
override fun copy() = TeacherAbsenceEvent(profileId, date, count)
|
||||
}
|
||||
|
@ -5,17 +5,28 @@
|
||||
package pl.szczodrzynski.edziennik.ui.modules.agenda.teacherabsence
|
||||
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import com.github.tibolte.agendacalendarview.render.EventRenderer
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedTeacherAbsenceBinding
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedCounterBinding
|
||||
import pl.szczodrzynski.edziennik.setTintColor
|
||||
import pl.szczodrzynski.edziennik.utils.Colors
|
||||
|
||||
class TeacherAbsenceEventRenderer : EventRenderer<TeacherAbsenceEvent>() {
|
||||
|
||||
override fun render(view: View, event: TeacherAbsenceEvent) {
|
||||
val b = AgendaWrappedTeacherAbsenceBinding.bind(view).item
|
||||
val b = AgendaWrappedCounterBinding.bind(view).item
|
||||
|
||||
b.teacherAbsenceCount.text = event.absenceCount.toString()
|
||||
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.count.text = event.count.toString()
|
||||
b.count.setTextColor(b.name.currentTextColor)
|
||||
|
||||
b.badgeBackground.isVisible = false
|
||||
b.badge.isVisible = false
|
||||
}
|
||||
|
||||
override fun getEventLayout(): Int = R.layout.agenda_wrapped_teacher_absence
|
||||
override fun getEventLayout(): Int = R.layout.agenda_wrapped_counter
|
||||
}
|
||||
|
61
app/src/main/res/layout/agenda_counter_item.xml
Normal file
61
app/src/main/res/layout/agenda_counter_item.xml
Normal file
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (c) Kuba Szczodrzyński 2021-4-11.
|
||||
-->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_rounded_8dp"
|
||||
android:foreground="@drawable/bg_rounded_8dp_outline"
|
||||
tools:backgroundTint="#ff1744"
|
||||
tools:foregroundTint="#ff1744">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="10dp"
|
||||
android:textAppearance="@style/NavView.TextView.Medium"
|
||||
tools:text="@string/agenda_lesson_changes"
|
||||
tools:textColor="@color/md_white_1000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginVertical="2dp"
|
||||
android:gravity="center"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:textSize="20sp"
|
||||
tools:text="3"
|
||||
tools:textColor="@color/md_white_1000" />
|
||||
|
||||
<View
|
||||
android:id="@+id/badgeBackground"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/bg_rounded_8dp"
|
||||
android:layout_marginRight="-24dp"
|
||||
android:layout_marginEnd="-24dp"
|
||||
android:layout_marginTop="-24dp"
|
||||
tools:backgroundTint="?android:colorBackground"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/badge"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@drawable/unread_red_circle" />
|
||||
</FrameLayout>
|
57
app/src/main/res/layout/agenda_event_compact_item.xml
Normal file
57
app/src/main/res/layout/agenda_event_compact_item.xml
Normal file
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (c) Kuba Szczodrzyński 2021-4-8.
|
||||
-->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_rounded_8dp"
|
||||
android:foreground="@drawable/bg_rounded_8dp_outline"
|
||||
tools:backgroundTint="@color/blue_selected"
|
||||
tools:foregroundTint="@color/blue_selected">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textSize="16sp"
|
||||
tools:text="sprawdzian - Język polski"
|
||||
tools:textColor="@color/md_white_1000" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/badgeBackground"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="-24dp"
|
||||
android:layout_marginEnd="-24dp"
|
||||
android:layout_marginRight="-24dp"
|
||||
android:background="@drawable/bg_rounded_8dp"
|
||||
tools:backgroundTint="?android:colorBackground" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/badge"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@drawable/unread_red_circle" />
|
||||
</FrameLayout>
|
@ -3,50 +3,64 @@
|
||||
~ Copyright (c) Kuba Szczodrzyński 2021-4-8.
|
||||
-->
|
||||
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_rounded_8dp"
|
||||
android:foreground="@drawable/bg_rounded_8dp_outline"
|
||||
tools:backgroundTint="@color/blue_selected"
|
||||
tools:foregroundTint="@color/blue_selected">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="android.view.View" />
|
||||
|
||||
<variable
|
||||
name="isCompact"
|
||||
type="boolean" />
|
||||
</data>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/card"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="5dp"
|
||||
tools:cardBackgroundColor="@color/blue_selected">
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/eventTitle"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="@{isCompact ? 2 : 3}"
|
||||
android:maxLines="3"
|
||||
android:textSize="16sp"
|
||||
tools:text="sprawdzian - Język polski" />
|
||||
tools:text="sprawdzian - Język polski"
|
||||
tools:textColor="@color/md_white_1000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/eventSubtitle"
|
||||
android:id="@+id/subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:textColor="@color/calendar_text_default"
|
||||
android:textSize="12sp"
|
||||
android:visibility="@{isCompact ? View.GONE : View.VISIBLE}"
|
||||
tools:text="9:05, biologia, Jan Kowalski, 7a" />
|
||||
tools:text="9:05, biologia, Jan Kowalski, 7a"
|
||||
tools:textColor="@color/md_white_1000" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</layout>
|
||||
|
||||
<View
|
||||
android:id="@+id/badgeBackground"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="-24dp"
|
||||
android:layout_marginEnd="-24dp"
|
||||
android:layout_marginRight="-24dp"
|
||||
android:background="@drawable/bg_rounded_8dp"
|
||||
tools:backgroundTint="?android:colorBackground" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/badge"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@drawable/unread_red_circle" />
|
||||
</FrameLayout>
|
||||
|
@ -5,33 +5,29 @@
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/foreground"
|
||||
android:id="@+id/card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_rounded_8dp"
|
||||
android:foreground="@drawable/bg_rounded_8dp_outline"
|
||||
tools:backgroundTint="@color/blue_selected"
|
||||
tools:foregroundTint="@color/blue_selected">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_rounded_8dp"
|
||||
android:orientation="horizontal"
|
||||
tools:backgroundTint="@color/blue_selected"
|
||||
tools:ignore="UselessParent">
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_rounded_8dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:padding="10dp"
|
||||
android:textAppearance="@style/NavView.TextView.Medium"
|
||||
tools:backgroundTint="@color/blue_selected"
|
||||
tools:text="informacja"
|
||||
tools:textColor="@color/md_white_1000" />
|
||||
|
||||
@ -43,7 +39,6 @@
|
||||
android:layout_marginRight="-1dp"
|
||||
android:background="@drawable/bg_rounded_8dp"
|
||||
android:gravity="center"
|
||||
android:paddingVertical="10dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingEnd="18dp"
|
||||
@ -52,4 +47,12 @@
|
||||
tools:backgroundTint="?android:colorBackground"
|
||||
tools:text="3" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/badge"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_margin="6dp"
|
||||
android:background="@drawable/unread_red_circle" />
|
||||
</FrameLayout>
|
||||
|
@ -1,4 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (c) Kuba Szczodrzyński 2021-4-11.
|
||||
-->
|
||||
|
||||
<com.github.tibolte.agendacalendarview.agenda.AgendaEventView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -7,7 +11,7 @@
|
||||
|
||||
<include
|
||||
android:id="@+id/item"
|
||||
layout="@layout/agenda_lesson_changes_item"
|
||||
layout="@layout/agenda_counter_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
@ -1,4 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (c) Kuba Szczodrzyński 2021-4-11.
|
||||
-->
|
||||
|
||||
<com.github.tibolte.agendacalendarview.agenda.AgendaEventView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -7,7 +11,7 @@
|
||||
|
||||
<include
|
||||
android:id="@+id/item"
|
||||
layout="@layout/agenda_teacher_absence_item"
|
||||
layout="@layout/agenda_event_compact_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
Loading…
x
Reference in New Issue
Block a user