From dfd1083e41fcf24683a95b292094b56371792584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 30 Nov 2022 10:41:43 +0100 Subject: [PATCH] [UI/Timetable] Show lesson replacing notes in all places. --- .../pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt | 7 +++++-- .../edziennik/ui/home/cards/HomeTimetableCard.kt | 2 ++ .../ui/widgets/timetable/WidgetTimetableProvider.kt | 5 ++++- .../edziennik/utils/models/ItemWidgetTimetableModel.java | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt index c63311e1..dc7144bc 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt @@ -61,6 +61,7 @@ class CounterActivity : AppCompatActivity(), CoroutineScope { it.type != Lesson.TYPE_SHIFTED_SOURCE }) } + lessonList.onEach { it.filterNotes() } } b.bellSync.setImageDrawable( @@ -101,13 +102,15 @@ class CounterActivity : AppCompatActivity(), CoroutineScope { when { actual != null -> { - b.lessonName.text = actual.displaySubjectName + b.lessonName.text = actual.getNoteSubstituteText(showNotes = true) + ?: actual.displaySubjectName val left = actual.displayEndTime!! - now b.timeLeft.text = timeLeft(left.toInt(), "\n", countInSeconds) } next != null -> { - b.lessonName.text = next.displaySubjectName + b.lessonName.text = next.getNoteSubstituteText(showNotes = true) + ?: next.displaySubjectName val till = next.displayStartTime!! - now b.timeLeft.text = timeTill(till.toInt(), "\n", countInSeconds) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeTimetableCard.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeTimetableCard.kt index f5523eec..39959121 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeTimetableCard.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeTimetableCard.kt @@ -232,6 +232,7 @@ class HomeTimetableCard( } lessons = lessons.filter { it.type != Lesson.TYPE_NO_LESSONS } + lessons.onEach { it.filterNotes() } b.timetableLayout.visibility = View.VISIBLE b.noTimetableLayout.visibility = View.GONE @@ -344,6 +345,7 @@ class HomeTimetableCard( private val LessonFull?.subjectSpannable: CharSequence get() = if (this == null) "?" else when { + hasReplacingNotes() -> getNoteSubstituteText(showNotes = true) ?: "?" isCancelled -> displaySubjectName?.asStrikethroughSpannable() ?: "?" isChange -> displaySubjectName?.asItalicSpannable() ?: "?" else -> displaySubjectName ?: "?" diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt index 2ac510f5..10df27c3 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt @@ -337,8 +337,11 @@ class WidgetTimetableProvider : AppWidgetProvider() { scrollPos = pos + 1 } + // remove notes from other profiles + lesson.filterNotes() // set the subject and classroom name - model.subjectName = lesson.displaySubjectName + model.subjectName = lesson.getNoteSubstituteText(showNotes = true) + ?: lesson.displaySubjectName model.classroomName = lesson.displayClassroom // set the bell sync to calculate progress in ListProvider diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java b/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java index 05c41e3b..964bee93 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java @@ -19,7 +19,7 @@ public class ItemWidgetTimetableModel { public Time endTime; public boolean lessonPassed; public boolean lessonCurrent; - public String subjectName = ""; + public CharSequence subjectName = ""; public String classroomName = ""; public boolean lessonChange = false; public boolean lessonChangeNoClassroom = false;