From 554097fc7d0fee6f5611f1f3e8aeb564d45f047a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 25 Sep 2019 21:40:03 +0200 Subject: [PATCH 1/8] [API/Librus] Fix r() IndexOutOfBounds. Fix Descriptive grades NPE. --- .../pl/szczodrzynski/edziennik/api/Librus.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java b/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java index 908c845b..ca231ebf 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java @@ -435,6 +435,10 @@ public class Librus implements EdziennikInterface { callback.onProgress(PROGRESS_STEP); index++; } + if (index > targetEndpoints.size()) { + finish(); + return; + } d(TAG, "Called r("+type+", "+endpoint+"). Getting "+targetEndpoints.get(index)); switch (targetEndpoints.get(index)) { case "Me": @@ -2409,7 +2413,15 @@ public class Librus implements EdziennikInterface { long teacherId = grade.get("AddedBy").getAsJsonObject().get("Id").getAsLong(); int semester = grade.get("Semester").getAsInt(); long subjectId = grade.get("Subject").getAsJsonObject().get("Id").getAsLong(); - String description = grade.get("Map").getAsString(); + JsonElement map = grade.get("Map"); + JsonElement realGrade = grade.get("RealGradeValue"); + String description = ""; + if (map != null) { + description = map.getAsString(); + } + else if (realGrade != null) { + description = realGrade.getAsString(); + } long categoryId = -1; JsonElement skillEl = grade.get("Skill"); From 37e57d2f733002d97431fcc82b2baa886cdfaa3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 25 Sep 2019 21:48:28 +0200 Subject: [PATCH 2/8] [API/Librus] Fix timetable with no HourFrom and HourTo. --- .../szczodrzynski/edziennik/api/Librus.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java b/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java index ca231ebf..d431dae2 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java @@ -1671,11 +1671,32 @@ public class Librus implements EdziennikInterface { continue; } + Time startTime = null; + Time endTime = null; + try { + startTime = Time.fromH_m(lesson.get(substitution && !cancelled ? "OrgHourFrom" : "HourFrom").getAsString()); + endTime = Time.fromH_m(lesson.get(substitution && !cancelled ? "OrgHourTo" : "HourTo").getAsString()); + } + catch (Exception ignore) { + try { + JsonElement lessonNo; + if (!((lessonNo = lesson.get("LessonNo")) instanceof JsonNull)) { + Pair timePair = lessonRanges.get(strToInt(lessonNo.getAsString())); + if (timePair != null) { + startTime = timePair.first; + endTime = timePair.second; + } + } + } + catch (Exception ignore2) { } + } + + Lesson lessonObject = new Lesson( profileId, lesson.get("DayNo").getAsInt() - 1, - Time.fromH_m(lesson.get(substitution && !cancelled ? "OrgHourFrom" : "HourFrom").getAsString()), - Time.fromH_m(lesson.get(substitution && !cancelled ? "OrgHourTo" : "HourTo").getAsString()) + startTime, + endTime ); JsonElement subject; @@ -1720,7 +1741,7 @@ public class Librus implements EdziennikInterface { r("finish", "Substitutions"); return; } - + JsonArray substitutions = data.get("Substitutions").getAsJsonArray(); try { List ignoreList = new ArrayList<>(); From 33ca55401baa5e4e22242cd5d9b3205b9d4d4d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 25 Sep 2019 22:23:47 +0200 Subject: [PATCH 3/8] [API/Vulcan] Swap grade category and description. --- app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java index 32705060..4911935b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java @@ -1240,9 +1240,9 @@ public class Vulcan implements EdziennikInterface { Grade gradeObject = new Grade( profileId, id, - finalDescription, - color, category, + color, + finalDescription, finalName, finalValue, weight, From 9cc4da5fe9b71d33d506127139017fc3506ecac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 25 Sep 2019 22:26:28 +0200 Subject: [PATCH 4/8] [API/Vulcan] Temporarily try to fix attendances not syncing. --- app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java index 4911935b..60117879 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java @@ -1459,7 +1459,7 @@ public class Vulcan implements EdziennikInterface { private void getAttendances() { callback.onActionStarted(R.string.sync_action_syncing_attendances); JsonObject json = new JsonObject(); - json.addProperty("DataPoczatkowa", profile.getEmpty() ? getCurrentSemesterStartDate().getStringY_m_d() : oneMonthBack.getStringY_m_d()); + json.addProperty("DataPoczatkowa", true ? getCurrentSemesterStartDate().getStringY_m_d() : oneMonthBack.getStringY_m_d()); json.addProperty("DataKoncowa", getCurrentSemesterEndDate().getStringY_m_d()); json.addProperty("IdOddzial", studentClassId); json.addProperty("IdUczen", studentId); From 1bdafd489ceaf29ebf8c5ea9fa4c07b02482a4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 25 Sep 2019 22:37:44 +0200 Subject: [PATCH 5/8] [API/Vulcan] Add marking message as read in the e-register. --- .../main/java/pl/szczodrzynski/edziennik/api/Vulcan.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java index 60117879..7a3deede 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java @@ -1632,6 +1632,15 @@ public class Vulcan implements EdziennikInterface { recipient.fullName = profile.getStudentNameLong(); } if (!message.seen) { + studentId = profile.getStudentData("studentId", -1); + studentLoginId = profile.getStudentData("studentLoginId", -1); + JsonObject json = new JsonObject(); + json.addProperty("WiadomoscId", message.id); + json.addProperty("FolderWiadomosci", "Odebrane"); + json.addProperty("Status", "Widoczna"); + json.addProperty("LoginId", studentLoginId); + json.addProperty("IdUczen", studentId); + apiRequest(schoolSymbol+"/ZmienStatusWiadomosci", json, result -> { }); app.db.metadataDao().setSeen(profile.getId(), message, true); if (message.type != TYPE_SENT) { app.db.messageRecipientDao().add(new MessageRecipient(profile.getId(), -1, -1, System.currentTimeMillis(), message.id)); From 8a30c6c7ce872946e9e12751175cf854c7737663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Thu, 26 Sep 2019 18:48:45 +0200 Subject: [PATCH 6/8] [API/Vulcan] Fix messages mark-as-read. Fix sent messages & attendances sync. --- .../pl/szczodrzynski/edziennik/api/Vulcan.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java index 7a3deede..f3a84477 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java @@ -113,6 +113,7 @@ public class Vulcan implements EdziennikInterface { private static final String ENDPOINT_ATTENDANCES = "mobile-api/Uczen.v3.Uczen/Frekwencje"; private static final String ENDPOINT_MESSAGES_RECEIVED = "mobile-api/Uczen.v3.Uczen/WiadomosciOdebrane"; private static final String ENDPOINT_MESSAGES_SENT = "mobile-api/Uczen.v3.Uczen/WiadomosciWyslane"; + private static final String ENDPOINT_MESSAGES_CHANGE_STATUS = "mobile-api/Uczen.v3.Uczen/ZmienStatusWiadomosci"; private static final String ENDPOINT_PUSH = "mobile-api/Uczen.v3.Uczen/UstawPushToken"; private static final String userAgent = "MobileUserAgent"; @@ -427,8 +428,10 @@ public class Vulcan implements EdziennikInterface { app.db.noticeDao().clearForSemester(profileId, studentSemesterNumber); app.db.noticeDao().addAll(noticeList); } - if (attendanceList.size() > 0) + if (attendanceList.size() > 0) { + app.db.attendanceDao().clearAfterDate(profileId, getCurrentSemesterStartDate()); app.db.attendanceDao().addAll(attendanceList); + } if (messageList.size() > 0) app.db.messageDao().addAllIgnore(messageList); if (messageRecipientList.size() > 0) @@ -1506,8 +1509,8 @@ public class Vulcan implements EdziennikInterface { private void getMessagesInbox() { callback.onActionStarted(R.string.sync_action_syncing_messages_inbox); JsonObject json = new JsonObject(); - json.addProperty("DataPoczatkowa", profile.getEmpty() ? getCurrentSemesterStartDate().getInUnix() : oneMonthBack.getInUnix()); - json.addProperty("DataKoncowa", Date.getToday().getInUnix()); + json.addProperty("DataPoczatkowa", true ? getCurrentSemesterStartDate().getInUnix() : oneMonthBack.getInUnix()); + json.addProperty("DataKoncowa", getCurrentSemesterEndDate().getInUnix()); json.addProperty("LoginId", studentLoginId); json.addProperty("IdUczen", studentId); apiRequest(schoolSymbol+"/"+ENDPOINT_MESSAGES_RECEIVED, json, result -> { @@ -1557,8 +1560,8 @@ public class Vulcan implements EdziennikInterface { } callback.onActionStarted(R.string.sync_action_syncing_messages_outbox); JsonObject json = new JsonObject(); - json.addProperty("DataPoczatkowa", profile.getEmpty() ? getCurrentSemesterStartDate().getInUnix() : oneMonthBack.getInUnix()); - json.addProperty("DataKoncowa", Date.getToday().getInUnix()); + json.addProperty("DataPoczatkowa", true ? getCurrentSemesterStartDate().getInUnix() : oneMonthBack.getInUnix()); + json.addProperty("DataKoncowa", getCurrentSemesterEndDate().getInUnix()); json.addProperty("LoginId", studentLoginId); json.addProperty("IdUczen", studentId); apiRequest(schoolSymbol+"/"+ENDPOINT_MESSAGES_SENT, json, result -> { @@ -1640,7 +1643,7 @@ public class Vulcan implements EdziennikInterface { json.addProperty("Status", "Widoczna"); json.addProperty("LoginId", studentLoginId); json.addProperty("IdUczen", studentId); - apiRequest(schoolSymbol+"/ZmienStatusWiadomosci", json, result -> { }); + apiRequest(schoolSymbol+"/"+ENDPOINT_MESSAGES_CHANGE_STATUS, json, result -> { }); app.db.metadataDao().setSeen(profile.getId(), message, true); if (message.type != TYPE_SENT) { app.db.messageRecipientDao().add(new MessageRecipient(profile.getId(), -1, -1, System.currentTimeMillis(), message.id)); From 773b590d79fd304008fe7629873af54fa4ae4bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Thu, 26 Sep 2019 20:25:57 +0200 Subject: [PATCH 7/8] [API/Vulcan] Fix for null OddzialKod in students list. --- app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java index f3a84477..6e76974e 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java @@ -745,7 +745,7 @@ public class Vulcan implements EdziennikInterface { studentLoginId = account.get("UzytkownikLoginId").getAsInt(); studentClassId = account.get("IdOddzial").getAsInt(); studentSemesterId = account.get("IdOkresKlasyfikacyjny").getAsInt(); - String studentClassName = account.get("OddzialKod").getAsString(); + String studentClassName = account.get("OkresPoziom").getAsInt()+account.get("OddzialSymbol").getAsString(); targetProfile.putStudentData("userName", account.get("UzytkownikNazwa").getAsString()); targetProfile.putStudentData("schoolName", schoolName); targetProfile.putStudentData("schoolSymbol", schoolSymbol); From 518a8ea542dc2c9355192a5d7acfecacb07b1c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Thu, 26 Sep 2019 22:26:34 +0200 Subject: [PATCH 8/8] [3.0.3] Update build.gradle and changelog --- app/src/main/assets/pl-changelog.html | 8 ++++++++ build.gradle | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/assets/pl-changelog.html b/app/src/main/assets/pl-changelog.html index 5ef7daa1..88a90ec4 100644 --- a/app/src/main/assets/pl-changelog.html +++ b/app/src/main/assets/pl-changelog.html @@ -31,6 +31,14 @@ +

Wersja 3.0.3, 2019-09-26

+
    +
  • Librus: poprawka kilku błędów synchronizacji.
  • +
  • Vulcan: prawidłowe oznaczanie wiadomości jako przeczytana.
  • +
  • Vulcan: poprawiona synchronizacja wiadomości i frekwencji.
  • +
  • Vulcan: poprawka błędów logowania.
  • +
+

Wersja 3.0.2, 2019-09-24

  • Librus: pobieranie Bieżących ocen opisowych.
  • diff --git a/build.gradle b/build.gradle index 1aa9b1f4..aadf871a 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ buildscript { kotlin_version = '1.3.50' release = [ - versionName: "3.0.2", - versionCode: 3000299 + versionName: "3.0.3", + versionCode: 3000399 ] setup = [