[Widgets/Timetable] Show lessons date in unified timetable widget.

This commit is contained in:
Kuba Szczodrzyński 2020-02-27 22:32:02 +01:00
parent 54121c99a3
commit 209f98594f
2 changed files with 18 additions and 11 deletions

View File

@ -35,6 +35,7 @@ import pl.szczodrzynski.edziennik.R;
import pl.szczodrzynski.edziennik.utils.models.Date; import pl.szczodrzynski.edziennik.utils.models.Date;
import pl.szczodrzynski.edziennik.utils.models.ItemWidgetTimetableModel; import pl.szczodrzynski.edziennik.utils.models.ItemWidgetTimetableModel;
import pl.szczodrzynski.edziennik.utils.models.Time; import pl.szczodrzynski.edziennik.utils.models.Time;
import pl.szczodrzynski.edziennik.utils.models.Week;
import static android.util.TypedValue.COMPLEX_UNIT_SP; 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.widgetTimetableProfileName, View.VISIBLE);
views.setViewVisibility(R.id.widgetTimetableContent, View.GONE); 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.setTextViewTextSize(R.id.widgetTimetableProfileName, COMPLEX_UNIT_SP, lesson.bigStyle ? 30 : 20);
views.setTextColor(R.id.widgetTimetableProfileName, lesson.darkTheme ? 0xffffffff : 0xff000000); views.setTextColor(R.id.widgetTimetableProfileName, lesson.darkTheme ? 0xffffffff : 0xff000000);

View File

@ -204,16 +204,6 @@ class WidgetTimetableProvider : AppWidgetProvider() {
for (profile in profileList) { 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 // search for lessons to display
val timetableDate = Date.getToday() val timetableDate = Date.getToday()
var checkedDays = 0 var checkedDays = 0
@ -244,6 +234,19 @@ class WidgetTimetableProvider : AppWidgetProvider() {
checkedDays++ 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 // set the displayingDate to show in the header
if (!unified) { if (!unified) {
if (lessons.isNotEmpty()) if (lessons.isNotEmpty())