From faa77ee5fb9395648dad9dc3a656ce9587b6fa1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Fri, 28 Feb 2020 17:11:41 +0100 Subject: [PATCH] [Widgets/Timetable] Show crossed out classroom in lesson change if no new classroom specified. --- .../edziennik/ui/widgets/LessonDialogActivity.kt | 3 ++- .../ui/widgets/timetable/WidgetTimetableFactory.java | 9 ++++++++- .../ui/widgets/timetable/WidgetTimetableProvider.kt | 7 ++++--- .../edziennik/utils/models/ItemWidgetTimetableModel.java | 1 + 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/LessonDialogActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/LessonDialogActivity.kt index 1767c206..7a8f78ac 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/LessonDialogActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/LessonDialogActivity.kt @@ -47,6 +47,7 @@ class LessonDialogActivity : AppCompatActivity(), CoroutineScope { val i = Intent(app, MainActivity::class.java) .putExtra("fragmentId", MainActivity.DRAWER_ITEM_TIMETABLE) .putExtra("profileId", profileId) + .putExtra("timetableDate", extras.getString("timetableDate", null)) .addFlags(FLAG_ACTIVITY_REORDER_TO_FRONT or FLAG_ACTIVITY_NEW_TASK) app.startActivity(i) finish() @@ -74,4 +75,4 @@ class LessonDialogActivity : AppCompatActivity(), CoroutineScope { } } } -} \ No newline at end of file +} 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 4d0b04f0..6f81bf2c 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 @@ -164,6 +164,8 @@ public class WidgetTimetableFactory implements RemoteViewsService.RemoteViewsFac Intent intent = new Intent(); intent.putExtra("profileId", lesson.profileId); intent.putExtra("separatorItem", true); + if (lesson.lessonDate != null) + intent.putExtra("timetableDate", lesson.lessonDate.getStringY_m_d()); views.setOnClickFillInIntent(R.id.widgetTimetableRoot, intent); return views; @@ -298,7 +300,12 @@ public class WidgetTimetableFactory implements RemoteViewsService.RemoteViewsFac views.setViewVisibility(R.id.widgetTimetableOldSubjectName, View.GONE); if (lesson.lessonChange) { views.setTextViewText(R.id.widgetTimetableSubjectName, Html.fromHtml(""+lesson.subjectName+"")); - views.setTextViewText(R.id.widgetTimetableClassroomName, Html.fromHtml(""+lesson.classroomName+"")); + if (lesson.lessonChangeNoClassroom) { + views.setTextViewText(R.id.widgetTimetableClassroomName, Html.fromHtml(""+lesson.classroomName+"")); + } + else { + views.setTextViewText(R.id.widgetTimetableClassroomName, Html.fromHtml("" + lesson.classroomName + "")); + } } else if (lesson.lessonCancelled) { views.setTextViewText(R.id.widgetTimetableSubjectName, Html.fromHtml(""+lesson.subjectName+"")); 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 b56e951b..17ea9633 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 @@ -324,13 +324,14 @@ class WidgetTimetableProvider : AppWidgetProvider() { // make the model aware of the lesson type when (lesson.type) { - Lesson.TYPE_CANCELLED -> { + Lesson.TYPE_CANCELLED, + Lesson.TYPE_SHIFTED_SOURCE -> { model.lessonCancelled = true } Lesson.TYPE_CHANGE, - Lesson.TYPE_SHIFTED_SOURCE, - Lesson.TYPE_SHIFTED_TARGET -> { + Lesson.TYPE_SHIFTED_TARGET -> { model.lessonChange = true + model.lessonChangeNoClassroom = lesson.classroom.isNullOrBlank() } } 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 d45f1f35..05c41e3b 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 @@ -22,6 +22,7 @@ public class ItemWidgetTimetableModel { public String subjectName = ""; public String classroomName = ""; public boolean lessonChange = false; + public boolean lessonChangeNoClassroom = false; public String newSubjectName = null; public String newClassroomName = null; public boolean lessonCancelled = false;