From 209f98594f6f99145bdb7064c85e3976f5b0d983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Thu, 27 Feb 2020 22:32:02 +0100 Subject: [PATCH] [Widgets/Timetable] Show lessons date in unified timetable widget. --- .../timetable/WidgetTimetableFactory.java | 6 ++++- .../timetable/WidgetTimetableProvider.kt | 23 +++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableFactory.java b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableFactory.java index 6791369f..4d0b04f0 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableFactory.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableFactory.java @@ -35,6 +35,7 @@ import pl.szczodrzynski.edziennik.R; import pl.szczodrzynski.edziennik.utils.models.Date; import pl.szczodrzynski.edziennik.utils.models.ItemWidgetTimetableModel; import pl.szczodrzynski.edziennik.utils.models.Time; +import pl.szczodrzynski.edziennik.utils.models.Week; import static android.util.TypedValue.COMPLEX_UNIT_SP; @@ -153,7 +154,10 @@ public class WidgetTimetableFactory implements RemoteViewsService.RemoteViewsFac views.setViewVisibility(R.id.widgetTimetableProfileName, View.VISIBLE); views.setViewVisibility(R.id.widgetTimetableContent, View.GONE); - views.setTextViewText(R.id.widgetTimetableProfileName, lesson.separatorProfileName); + if (lesson.lessonDate == null) + views.setTextViewText(R.id.widgetTimetableProfileName, lesson.separatorProfileName); + else + views.setTextViewText(R.id.widgetTimetableProfileName, lesson.separatorProfileName+"\n"+Week.getFullDayName(lesson.lessonDate.getWeekDay())); views.setTextViewTextSize(R.id.widgetTimetableProfileName, COMPLEX_UNIT_SP, lesson.bigStyle ? 30 : 20); views.setTextColor(R.id.widgetTimetableProfileName, lesson.darkTheme ? 0xffffffff : 0xff000000); 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 1b494ece..b56e951b 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 @@ -204,16 +204,6 @@ class WidgetTimetableProvider : AppWidgetProvider() { for (profile in profileList) { - // add a profile separator with its name - if (unified) { - val separator = ItemWidgetTimetableModel() - separator.profileId = profile.id - separator.bigStyle = widgetConfig.bigStyle - separator.darkTheme = widgetConfig.darkTheme - separator.separatorProfileName = profile.name - models.add(separator) - } - // search for lessons to display val timetableDate = Date.getToday() var checkedDays = 0 @@ -244,6 +234,19 @@ class WidgetTimetableProvider : AppWidgetProvider() { checkedDays++ } + // add a profile separator with its name + if (unified) { + val separator = ItemWidgetTimetableModel() + separator.profileId = profile.id + separator.bigStyle = widgetConfig.bigStyle + separator.darkTheme = widgetConfig.darkTheme + separator.separatorProfileName = profile.name + if (lessons.isNotEmpty() && lessons[0].type != TYPE_NO_LESSONS) { + separator.lessonDate = timetableDate + } + models.add(separator) + } + // set the displayingDate to show in the header if (!unified) { if (lessons.isNotEmpty())