diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/DataNotifications.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/DataNotifications.kt index 18583986..d416e858 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/DataNotifications.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/DataNotifications.kt @@ -45,6 +45,10 @@ class DataNotifications(val data: Data) { return@run } + val today = Date.getToday() + val todayValue = today.value + profile.currentSemester = profile.dateToSemester(today) + for (lesson in app.db.timetableDao().getNotNotifiedNow(profileId)) { val text = app.getString(R.string.notification_lesson_change_format, lesson.getDisplayChangeType(app), if (lesson.displayDate == null) "" else lesson.displayDate!!.formattedString, lesson.changeSubjectName) data.notifications += Notification( @@ -90,10 +94,6 @@ class DataNotifications(val data: Data) { ).addExtra("eventId", event.id).addExtra("eventDate", event.eventDate.value.toLong()) } - val today = Date.getToday() - val todayValue = today.value - profile.currentSemester = profile.dateToSemester(today) - for (grade in app.db.gradeDao().getNotNotifiedNow(profileId)) { val gradeName = when (grade.type) { TYPE_SEMESTER1_PROPOSED, TYPE_SEMESTER2_PROPOSED -> app.getString(R.string.grade_semester_proposed_format_2, grade.name) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Regexes.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Regexes.kt index 4c5ebbee..4e5a5ce1 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Regexes.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Regexes.kt @@ -141,6 +141,9 @@ object Regexes { val EDUDZIENNIK_EVENT_ID by lazy { """/KlassEvent/([\w-_]+?)/""".toRegex() } + val EDUDZIENNIK_NOTE_ID by lazy { + """/RegistryNotes/([\w-_]+?)/""".toRegex() + } val EDUDZIENNIK_SCHOOL_DETAIL_ID by lazy { """ Unit) { data.startProgress(R.string.edziennik_progress_endpoint_events) EdudziennikWebEvents(data, onSuccess) } + ENDPOINT_EDUDZIENNIK_WEB_NOTES -> { + data.startProgress(R.string.edziennik_progress_endpoint_notices) + EdudziennikWebNotes(data, onSuccess) + } ENDPOINT_EDUDZIENNIK_WEB_LUCKY_NUMBER -> { data.startProgress(R.string.edziennik_progress_endpoint_lucky_number) EdudziennikWebLuckyNumber(data, onSuccess) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebNotes.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebNotes.kt new file mode 100644 index 00000000..213dd2d2 --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebNotes.kt @@ -0,0 +1,65 @@ +/* + * Copyright (c) Kacper Ziubryniewicz 2020-1-1 + */ + +package pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.data.web + +import org.jsoup.Jsoup +import pl.szczodrzynski.edziennik.crc32 +import pl.szczodrzynski.edziennik.data.api.Regexes.EDUDZIENNIK_NOTE_ID +import pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.DataEdudziennik +import pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.ENDPOINT_EDUDZIENNIK_WEB_NOTES +import pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.data.EdudziennikWeb +import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS +import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata +import pl.szczodrzynski.edziennik.data.db.modules.notices.Notice +import pl.szczodrzynski.edziennik.get +import pl.szczodrzynski.edziennik.utils.models.Date + +class EdudziennikWebNotes(override val data: DataEdudziennik, + val onSuccess: () -> Unit) : EdudziennikWeb(data) { + companion object { + const val TAG = "EdudziennikWebNotes" + } + + init { data.profile?.also { profile -> + webGet(TAG, data.classStudentEndpoint + "RegistryNotesStudent", xhr = true) { text -> + val doc = Jsoup.parseBodyFragment("