diff --git a/app/build.gradle b/app/build.gradle index 68a195b9..ed452748 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -27,8 +27,8 @@ android { testApplicationId "io.github.tests.wulkanowy" minSdkVersion 21 targetSdkVersion 34 - versionCode 153 - versionName "2.5.4" + versionCode 154 + versionName "2.5.5" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" resValue "string", "app_name", "Wulkanowy" @@ -191,7 +191,7 @@ ext { } dependencies { - implementation 'io.github.wulkanowy:sdk:2.5.4' + implementation 'io.github.wulkanowy:sdk:2.5.5' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' diff --git a/app/src/main/java/io/github/wulkanowy/data/WulkanowySdkFactory.kt b/app/src/main/java/io/github/wulkanowy/data/WulkanowySdkFactory.kt index a4911f95..83268a0e 100644 --- a/app/src/main/java/io/github/wulkanowy/data/WulkanowySdkFactory.kt +++ b/app/src/main/java/io/github/wulkanowy/data/WulkanowySdkFactory.kt @@ -23,6 +23,7 @@ class WulkanowySdkFactory @Inject constructor( ) { private val eduOneMutex = Mutex() + private val migrationFailedStudentIds = mutableSetOf() private val sdk = Sdk().apply { androidVersion = android.os.Build.VERSION.RELEASE @@ -78,14 +79,24 @@ class WulkanowySdkFactory @Inject constructor( private suspend fun checkEduOneAndMigrateIfNecessary(student: Student): Boolean { if (student.isEduOne != null) return student.isEduOne + if (student.id in migrationFailedStudentIds) { + Timber.i("Migration eduOne: skipping because of previous failure") + return false + } + eduOneMutex.withLock { + if (student.id in migrationFailedStudentIds) { + Timber.i("Migration eduOne: skipping because of previous failure") + return false + } + val studentFromDatabase = studentDb.loadById(student.id) if (studentFromDatabase?.isEduOne != null) { - Timber.d("Migration eduOne: already done") + Timber.i("Migration eduOne: already done") return studentFromDatabase.isEduOne } - Timber.d("Migration eduOne: flag missing. Running migration...") + Timber.i("Migration eduOne: flag missing. Running migration...") val initializedSdk = buildSdk( student = student, semester = null, @@ -96,11 +107,12 @@ class WulkanowySdkFactory @Inject constructor( .getOrNull() if (newCurrentStudent == null) { - Timber.d("Migration eduOne: failed, so skipping") + Timber.i("Migration eduOne: failed, so skipping") + migrationFailedStudentIds.add(student.id) return false } - Timber.d("Migration eduOne: success. New isEduOne flag: ${newCurrentStudent.isEduOne}") + Timber.i("Migration eduOne: success. New isEduOne flag: ${newCurrentStudent.isEduOne}") val studentIsEduOne = StudentIsEduOne( id = student.id, diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt index 4d171907..bf9a34d0 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt @@ -14,6 +14,6 @@ interface SemesterDao : BaseDao { @Insert(onConflict = OnConflictStrategy.IGNORE) suspend fun insertSemesters(items: List): List - @Query("SELECT * FROM Semesters WHERE student_id = :studentId AND class_id = :classId") + @Query("SELECT * FROM Semesters WHERE (student_id = :studentId AND class_id = :classId) OR (student_id = :studentId AND class_id = 0)") suspend fun loadAll(studentId: Int, classId: Int): List } diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/StudentDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/StudentDao.kt index bfaecef6..5302b320 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/StudentDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/StudentDao.kt @@ -47,11 +47,11 @@ abstract class StudentDao { abstract suspend fun loadAll(): List @Transaction - @Query("SELECT * FROM Students JOIN Semesters ON Students.student_id = Semesters.student_id AND Students.class_id = Semesters.class_id") + @Query("SELECT * FROM Students JOIN Semesters ON (Students.student_id = Semesters.student_id AND Students.class_id = Semesters.class_id) OR (Students.student_id = Semesters.student_id AND Semesters.class_id = 0)") abstract suspend fun loadStudentsWithSemesters(): Map> @Transaction - @Query("SELECT * FROM Students JOIN Semesters ON Students.student_id = Semesters.student_id AND Students.class_id = Semesters.class_id WHERE Students.id = :id") + @Query("SELECT * FROM Students JOIN Semesters ON (Students.student_id = Semesters.student_id AND Students.class_id = Semesters.class_id) OR (Students.student_id = Semesters.student_id AND Semesters.class_id = 0) WHERE Students.id = :id") abstract suspend fun loadStudentWithSemestersById(id: Long): Map> @Query("UPDATE Students SET is_current = 1 WHERE id = :id") diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/SemesterRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/SemesterRepository.kt index da21f59a..92d44650 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/SemesterRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/SemesterRepository.kt @@ -64,7 +64,10 @@ class SemesterRepository @Inject constructor( .getSemesters() .mapToEntities(student.studentId) - if (new.isEmpty()) return Timber.i("Empty semester list!") + if (new.isEmpty()) { + Timber.i("Empty semester list from SDK!") + return + } val old = semesterDb.loadAll(student.studentId, student.classId) semesterDb.removeOldAndSaveNew( diff --git a/app/src/main/play/release-notes/pl-PL/default.txt b/app/src/main/play/release-notes/pl-PL/default.txt index d848d01c..9d72cb07 100644 --- a/app/src/main/play/release-notes/pl-PL/default.txt +++ b/app/src/main/play/release-notes/pl-PL/default.txt @@ -1,5 +1,6 @@ -Wersja 2.5.4 +Wersja 2.5.5 -— naprawiliśmy kolejnych kilka błędów związanych z obsługą dziennika eduOne (tak, nie umiemy za jednym razem) +— naprawiliśmy migrację informacji o tym, czy szkoła ucznia używa eduOne +— naprawiliśmy w końcu (teraz naprawdę mamy taką nadzieję) ten komunikat o braku uprawnień Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases