From 0db6393bb05df423162f83937037f446c9afdb4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 30 Mar 2020 23:02:19 +0200 Subject: [PATCH] [Events] Add showing green check when event is done. Hide done events from homework current list. --- .../ui/dialogs/event/EventListAdapter.kt | 6 +++-- .../modules/homework/HomeworkListFragment.kt | 4 +-- app/src/main/res/layout/event_list_item.xml | 26 ++++++++++++++----- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventListAdapter.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventListAdapter.kt index 8f5ebaee..9c5fb456 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventListAdapter.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventListAdapter.kt @@ -6,7 +6,6 @@ package pl.szczodrzynski.edziennik.ui.dialogs.event import android.content.Context import android.view.LayoutInflater -import android.view.View import android.view.ViewGroup import android.widget.Toast import androidx.core.view.isVisible @@ -52,6 +51,7 @@ class EventListAdapter( b.simpleMode = simpleMode b.topic.text = event.topic + b.topic.maxLines = if (simpleMode) 2 else 3 b.details.text = mutableListOf( if (showWeekDay) Week.getFullDayName(event.date.weekDay) else null, @@ -79,11 +79,13 @@ class EventListAdapter( b.typeColor.background?.setTintColor(event.eventColor) b.typeColor.isVisible = showType - b.editButton.visibility = if (event.addedManually && !simpleMode) View.VISIBLE else View.GONE + b.editButton.isVisible = !simpleMode && event.addedManually && !event.isDone b.editButton.onClick { onEventEditClick?.invoke(event) } + b.isDone.isVisible = event.isDone + b.editButton.setOnLongClickListener { Toast.makeText(context, R.string.hint_edit_event, Toast.LENGTH_SHORT).show() true diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt index 2b84a596..38586593 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt @@ -49,8 +49,8 @@ class HomeworkListFragment : LazyFragment(), CoroutineScope { val today = Date.getToday() val filter = when(homeworkDate) { - HomeworkDate.CURRENT -> "eventDate >= '${today.stringY_m_d}'" - else -> "eventDate < '${today.stringY_m_d}'" + HomeworkDate.CURRENT -> "eventDate >= '${today.stringY_m_d}' AND eventIsDone = 0" + else -> "eventDate < '${today.stringY_m_d}' OR eventIsDone = 1" } val adapter = EventListAdapter( diff --git a/app/src/main/res/layout/event_list_item.xml b/app/src/main/res/layout/event_list_item.xml index f43a7637..62c0922e 100644 --- a/app/src/main/res/layout/event_list_item.xml +++ b/app/src/main/res/layout/event_list_item.xml @@ -4,7 +4,8 @@ --> + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> @@ -54,22 +55,35 @@ android:id="@+id/topic" android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_marginEnd="4dp" + android:layout_marginRight="4dp" android:layout_weight="1" - android:textAppearance="@style/NavView.TextView.Medium" - android:maxLines="@{simpleMode ? 2 : 3}" android:ellipsize="end" - tools:maxLines="3" + android:maxLines="3" + android:textAppearance="@style/NavView.TextView.Medium" tools:text="Rozdział II: Panowanie Piastów i Jagiellonów.Przeniesiony z 11 grudnia. Nie wiem co się dzieje w tym roku nie będzie już religii w szkołach podstawowych w Polsce i Europie zachodniej Afryki" /> + tools:visibility="gone" /> + +