diff --git a/app/src/main/assets/pl-changelog.html b/app/src/main/assets/pl-changelog.html index 840467ee..a7bfcaa6 100644 --- a/app/src/main/assets/pl-changelog.html +++ b/app/src/main/assets/pl-changelog.html @@ -1,23 +1,8 @@ -

Wersja 4.11, 2021-11-01

+

Wersja 4.11.2, 2022-02-05



Dzięki za korzystanie ze Szkolnego!
-© [Kuba Szczodrzyński](@kuba2k2), [Kacper Ziubryniewicz](@kapi2289) 2021 +© [Kuba Szczodrzyński](@kuba2k2), [Kacper Ziubryniewicz](@kapi2289) 2022 diff --git a/app/src/main/cpp/szkolny-signing.cpp b/app/src/main/cpp/szkolny-signing.cpp index 7e03e898..88369629 100644 --- a/app/src/main/cpp/szkolny-signing.cpp +++ b/app/src/main/cpp/szkolny-signing.cpp @@ -9,7 +9,7 @@ /*secret password - removed for source code publication*/ static toys AES_IV[16] = { - 0x17, 0xf8, 0xac, 0xf6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + 0x66, 0xae, 0x85, 0x2a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char *agony(unsigned int laugh, unsigned char *box, unsigned char *heat); diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusData.kt index 877d803b..db72ddcc 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusData.kt @@ -182,10 +182,6 @@ class LibrusData(val data: DataLibrus, val onSuccess: () -> Unit) { data.startProgress(R.string.edziennik_progress_endpoint_pt_meetings) LibrusApiPtMeetings(data, lastSync, onSuccess) } - ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES -> { - data.startProgress(R.string.edziennik_progress_endpoint_teacher_free_day_types) - LibrusApiTeacherFreeDayTypes(data, lastSync, onSuccess) - } ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS -> { data.startProgress(R.string.edziennik_progress_endpoint_teacher_free_days) LibrusApiTeacherFreeDays(data, lastSync, onSuccess) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTeacherFreeDayTypes.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTeacherFreeDayTypes.kt deleted file mode 100644 index c87e71d8..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTeacherFreeDayTypes.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) Kacper Ziubryniewicz 2019-10-19 - */ - -package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.api - -import pl.szczodrzynski.edziennik.* -import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus -import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES -import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi -import pl.szczodrzynski.edziennik.data.db.entity.TeacherAbsenceType -import pl.szczodrzynski.edziennik.ext.* - -class LibrusApiTeacherFreeDayTypes(override val data: DataLibrus, - override val lastSync: Long?, - val onSuccess: (endpointId: Int) -> Unit -) : LibrusApi(data, lastSync) { - companion object { - const val TAG = "LibrusApiTeacherFreeDayTypes" - } - - init { - apiGet(TAG, "TeacherFreeDays/Types") { json -> - val teacherAbsenceTypes = json.getJsonArray("Types")?.asJsonObjectList() - - teacherAbsenceTypes?.forEach { teacherAbsenceType -> - val id = teacherAbsenceType.getLong("Id") ?: return@forEach - val name = teacherAbsenceType.getString("Name") ?: return@forEach - - val teacherAbsenceTypeObject = TeacherAbsenceType( - profileId, - id, - name - ) - - data.teacherAbsenceTypes.put(id, teacherAbsenceTypeObject) - } - - data.setSyncNext(ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES, 7 * DAY) - onSuccess(ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES) - } - } -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTeacherFreeDays.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTeacherFreeDays.kt index 54a3fb36..09ed5416 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTeacherFreeDays.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTeacherFreeDays.kt @@ -36,8 +36,6 @@ class LibrusApiTeacherFreeDays(override val data: DataLibrus, val id = teacherAbsence.getLong("Id") ?: return@forEach val teacherId = teacherAbsence.getJsonObject("Teacher")?.getLong("Id") ?: return@forEach - val type = teacherAbsence.getJsonObject("Type").getLong("Id") ?: return@forEach - val name = data.teacherAbsenceTypes.singleOrNull { it.id == type }?.name val dateFrom = Date.fromY_m_d(teacherAbsence.getString("DateFrom")) val dateTo = Date.fromY_m_d(teacherAbsence.getString("DateTo")) val timeFrom = teacherAbsence.getString("TimeFrom")?.let { Time.fromH_m_s(it) } @@ -46,8 +44,8 @@ class LibrusApiTeacherFreeDays(override val data: DataLibrus, val teacherAbsenceObject = TeacherAbsence( profileId = profileId, id = id, - type = type, - name = name, + type = -1L, + name = null, dateFrom = dateFrom, dateTo = dateTo, timeFrom = timeFrom, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/DataMobidziennik.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/DataMobidziennik.kt index 3553d72d..cee3cda5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/DataMobidziennik.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/DataMobidziennik.kt @@ -7,10 +7,12 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik import android.util.LongSparseArray import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_MOBIDZIENNIK_WEB +import pl.szczodrzynski.edziennik.data.api.Regexes import pl.szczodrzynski.edziennik.data.api.models.Data import pl.szczodrzynski.edziennik.data.db.entity.LoginStore import pl.szczodrzynski.edziennik.data.db.entity.Profile import pl.szczodrzynski.edziennik.ext.currentTimeUnix +import pl.szczodrzynski.edziennik.ext.get import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time @@ -35,6 +37,31 @@ class DataMobidziennik(app: App, profile: Profile?, loginStore: LoginStore) : Da override fun generateUserCode() = "$loginServerName:$loginUsername:$studentId" + fun parseDateTime(dateStr: String): Pair { + // pt, 4 lut, 09:11 + val dateParts = dateStr.split(',', ' ').filter { it.isNotEmpty() } + // [pt], [4], [lut], [09:11] + val date = Date.getToday() + date.day = dateParts[1].toIntOrNull() ?: 1 + date.month = when (dateParts[2]) { + "sty" -> 1 + "lut" -> 2 + "mar" -> 3 + "kwi" -> 4 + "maj" -> 5 + "cze" -> 6 + "lip" -> 7 + "sie" -> 8 + "wrz" -> 9 + "paź" -> 10 + "lis" -> 11 + "gru" -> 12 + else -> 1 + } + val time = Time.fromH_m(dateParts[3]) + return date to time + } + val teachersMap = LongSparseArray() val subjectsMap = LongSparseArray() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebMessagesInbox.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebMessagesInbox.kt index ed9c2ae1..b3819784 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebMessagesInbox.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebMessagesInbox.kt @@ -36,6 +36,10 @@ class MobidziennikWebMessagesInbox(override val data: DataMobidziennik, val doc = Jsoup.parse(text) + val today = Date.getToday() + var currentYear = today.year + var currentMonth = today.month + val list = doc.getElementsByClass("spis").first()?.getElementsByClass("podswietl") list?.forEach { item -> val id = item.attr("rel").toLongOrNull() ?: return@forEach @@ -47,15 +51,20 @@ class MobidziennikWebMessagesInbox(override val data: DataMobidziennik, } val subject = subjectEl?.ownText() ?: "" - val addedDateEl = item.select("td:eq(1) small").first() - val addedDate = Date.fromIsoHm(addedDateEl?.text()) + val addedDateEl = item.select("td:eq(4)").first() + val (date, time) = data.parseDateTime(addedDateEl?.text()?.trim() ?: "") + if (date.month > currentMonth) { + currentYear-- + } + currentMonth = date.month + date.year = currentYear - val senderEl = item.select("td:eq(2)").first() + val senderEl = item.select("td:eq(3)").first() val senderName = senderEl?.ownText().fixName() val senderId = data.teacherList.singleOrNull { it.fullNameLastFirst == senderName }?.id data.messageRecipientIgnoreList.add(MessageRecipient(profileId, -1, id)) - val isRead = item.select("td:eq(3) span").first()?.hasClass("wiadomosc_przeczytana") == true + val isRead = item.select("td:eq(5) span").first()?.hasClass("wiadomosc_przeczytana") == true val message = Message( profileId = profileId, @@ -64,7 +73,7 @@ class MobidziennikWebMessagesInbox(override val data: DataMobidziennik, subject = subject, body = null, senderId = senderId, - addedDate = addedDate + addedDate = date.combineWith(time) ) if (hasAttachments) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebMessagesSent.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebMessagesSent.kt index c6508a26..7f249cf6 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebMessagesSent.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebMessagesSent.kt @@ -40,23 +40,29 @@ class MobidziennikWebMessagesSent(override val data: DataMobidziennik, val doc = Jsoup.parse(text) + val today = Date.getToday() + var currentYear = today.year + var currentMonth = today.month + val list = doc.getElementsByClass("spis").first()?.getElementsByClass("podswietl") list?.forEach { item -> val id = item.attr("rel").toLongOrNull() ?: return@forEach val subjectEl = item.select("td:eq(0)").first() - var hasAttachments = false - if (subjectEl?.getElementsByTag("a")?.size ?: 0 > 0) { - hasAttachments = true - } val subject = subjectEl?.ownText() ?: "" - val readByString = item.select("td:eq(2)").first()?.text() ?: "" + val attachmentsEl = item.select("td:eq(1)").first() + var hasAttachments = false + if (attachmentsEl?.getElementsByTag("a")?.size ?: 0 > 0) { + hasAttachments = true + } + + val readByString = item.select("td:eq(4)").first()?.text() ?: "" val (readBy, sentTo) = Regexes.MOBIDZIENNIK_MESSAGE_SENT_READ_BY.find(readByString).let { (it?.get(1)?.toIntOrNull() ?: 0) to (it?.get(2)?.toIntOrNull() ?: 0) } - val recipientEl = item.select("td:eq(1) a span").first() + val recipientEl = item.select("td:eq(2) a span").first() val recipientNames = recipientEl?.ownText()?.split(", ") val readState = when (readBy) { 0 -> 0 @@ -69,8 +75,13 @@ class MobidziennikWebMessagesSent(override val data: DataMobidziennik, data.messageRecipientIgnoreList.add(MessageRecipient(profileId, recipientId, -1, readState, id)) } - val addedDateEl = item.select("td:eq(3) small").first() - val addedDate = Date.fromIsoHm(addedDateEl?.text()) + val addedDateEl = item.select("td:eq(3)").first() + val (date, time) = data.parseDateTime(addedDateEl?.text()?.trim() ?: "") + if (date.month > currentMonth) { + currentYear-- + } + currentMonth = date.month + date.year = currentYear val message = Message( profileId = profileId, @@ -79,7 +90,7 @@ class MobidziennikWebMessagesSent(override val data: DataMobidziennik, subject = subject, body = null, senderId = null, - addedDate = addedDate + addedDate = date.combineWith(time) ) if (hasAttachments) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt index b28a93fd..dcbea186 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt @@ -46,6 +46,6 @@ object Signing { /*fun provideKey(param1: String, param2: Long): ByteArray {*/ fun pleaseStopRightNow(param1: String, param2: Long): ByteArray { - return "$param1.MTIzNDU2Nzg5MDlc1YQl9S===.$param2".sha256() + return "$param1.MTIzNDU2Nzg5MDMIlcxGrq===.$param2".sha256() } } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 0aaaf661..92471e03 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -857,7 +857,7 @@ Open-Source-Lizenzen Datenschutzrichtlinie E-Klassenbuch - © Kuba Szczodrzyński && Kacper Ziubryniewicz\nSeptember 2018 - Oktober 2021 + © Kuba Szczodrzyński && Kacper Ziubryniewicz\nSeptember 2018 - 2022 Klicken Sie hier, um nach Aktualisierungen zu suchen Aktualisierung Version diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index a06f8ed8..97eaeac1 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -348,7 +348,7 @@ information Added %1$s by %2$s%3$s Added %1$s by you%3$s - Adde %1$s%3$s + Added %1$s%3$s {cmd-share-variant} %1$s by %2$s%3$s {cmd-share-variant} %1$s by you%3$s Removing event… @@ -859,7 +859,7 @@ Open-source licenses Privacy policy E-register - © Kuba Szczodrzyński && Kacper Ziubryniewicz\nSeptember 2018 - October 2021 + © Kuba Szczodrzyński && Kacper Ziubryniewicz\nSeptember 2018 - 2022 Click to check for updates Update Version diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6df291f7..ba7f7458 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -926,7 +926,7 @@ Licencje open-source Polityka prywatności E-dziennik - © Kuba Szczodrzyński && Kacper Ziubryniewicz\nwrzesień 2018 - październik 2021 + © Kuba Szczodrzyński && Kacper Ziubryniewicz\nwrzesień 2018 - 2022 Kliknij, aby sprawdzić aktualizacje Aktualizacja Wersja diff --git a/build.gradle b/build.gradle index 536aae8b..668185ea 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ buildscript { kotlin_version = '1.5.30' release = [ - versionName: "4.11", - versionCode: 4110099 + versionName: "4.11.2", + versionCode: 4110299 ] setup = [