forked from github/wulkanowy-mirror
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
a82e11d694 | |||
4dc5fc65ac | |||
7463cf6253 | |||
d799ec7ac9 | |||
254719f22f | |||
e1e276e1ea | |||
8cdd4311a9 | |||
b7f7b16aef |
@ -27,8 +27,8 @@ android {
|
|||||||
testApplicationId "io.github.tests.wulkanowy"
|
testApplicationId "io.github.tests.wulkanowy"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 34
|
targetSdkVersion 34
|
||||||
versionCode 152
|
versionCode 154
|
||||||
versionName "2.5.3"
|
versionName "2.5.5"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
resValue "string", "app_name", "Wulkanowy"
|
resValue "string", "app_name", "Wulkanowy"
|
||||||
@ -164,8 +164,8 @@ play {
|
|||||||
defaultToAppBundles = false
|
defaultToAppBundles = false
|
||||||
track = 'production'
|
track = 'production'
|
||||||
releaseStatus = ReleaseStatus.IN_PROGRESS
|
releaseStatus = ReleaseStatus.IN_PROGRESS
|
||||||
userFraction = 0.20d
|
userFraction = 0.99d
|
||||||
updatePriority = 3
|
updatePriority = 1
|
||||||
enabled.set(false)
|
enabled.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'io.github.wulkanowy:sdk:2.5.3'
|
implementation 'io.github.wulkanowy:sdk:2.5.5'
|
||||||
|
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ class WulkanowySdkFactory @Inject constructor(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
private val eduOneMutex = Mutex()
|
private val eduOneMutex = Mutex()
|
||||||
|
private val migrationFailedStudentIds = mutableSetOf<Long>()
|
||||||
|
|
||||||
private val sdk = Sdk().apply {
|
private val sdk = Sdk().apply {
|
||||||
androidVersion = android.os.Build.VERSION.RELEASE
|
androidVersion = android.os.Build.VERSION.RELEASE
|
||||||
@ -78,14 +79,24 @@ class WulkanowySdkFactory @Inject constructor(
|
|||||||
private suspend fun checkEduOneAndMigrateIfNecessary(student: Student): Boolean {
|
private suspend fun checkEduOneAndMigrateIfNecessary(student: Student): Boolean {
|
||||||
if (student.isEduOne != null) return student.isEduOne
|
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 {
|
eduOneMutex.withLock {
|
||||||
|
if (student.id in migrationFailedStudentIds) {
|
||||||
|
Timber.i("Migration eduOne: skipping because of previous failure")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
val studentFromDatabase = studentDb.loadById(student.id)
|
val studentFromDatabase = studentDb.loadById(student.id)
|
||||||
if (studentFromDatabase?.isEduOne != null) {
|
if (studentFromDatabase?.isEduOne != null) {
|
||||||
Timber.d("Migration eduOne: already done")
|
Timber.i("Migration eduOne: already done")
|
||||||
return studentFromDatabase.isEduOne
|
return studentFromDatabase.isEduOne
|
||||||
}
|
}
|
||||||
|
|
||||||
Timber.d("Migration eduOne: flag missing. Running migration...")
|
Timber.i("Migration eduOne: flag missing. Running migration...")
|
||||||
val initializedSdk = buildSdk(
|
val initializedSdk = buildSdk(
|
||||||
student = student,
|
student = student,
|
||||||
semester = null,
|
semester = null,
|
||||||
@ -96,11 +107,12 @@ class WulkanowySdkFactory @Inject constructor(
|
|||||||
.getOrNull()
|
.getOrNull()
|
||||||
|
|
||||||
if (newCurrentStudent == null) {
|
if (newCurrentStudent == null) {
|
||||||
Timber.d("Migration eduOne: failed, so skipping")
|
Timber.i("Migration eduOne: failed, so skipping")
|
||||||
|
migrationFailedStudentIds.add(student.id)
|
||||||
return false
|
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(
|
val studentIsEduOne = StudentIsEduOne(
|
||||||
id = student.id,
|
id = student.id,
|
||||||
|
@ -14,6 +14,6 @@ interface SemesterDao : BaseDao<Semester> {
|
|||||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||||
suspend fun insertSemesters(items: List<Semester>): List<Long>
|
suspend fun insertSemesters(items: List<Semester>): List<Long>
|
||||||
|
|
||||||
@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<Semester>
|
suspend fun loadAll(studentId: Int, classId: Int): List<Semester>
|
||||||
}
|
}
|
||||||
|
@ -47,11 +47,11 @@ abstract class StudentDao {
|
|||||||
abstract suspend fun loadAll(): List<Student>
|
abstract suspend fun loadAll(): List<Student>
|
||||||
|
|
||||||
@Transaction
|
@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<Student, List<Semester>>
|
abstract suspend fun loadStudentsWithSemesters(): Map<Student, List<Semester>>
|
||||||
|
|
||||||
@Transaction
|
@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<Student, List<Semester>>
|
abstract suspend fun loadStudentWithSemestersById(id: Long): Map<Student, List<Semester>>
|
||||||
|
|
||||||
@Query("UPDATE Students SET is_current = 1 WHERE id = :id")
|
@Query("UPDATE Students SET is_current = 1 WHERE id = :id")
|
||||||
|
@ -64,7 +64,10 @@ class SemesterRepository @Inject constructor(
|
|||||||
.getSemesters()
|
.getSemesters()
|
||||||
.mapToEntities(student.studentId)
|
.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)
|
val old = semesterDb.loadAll(student.studentId, student.classId)
|
||||||
semesterDb.removeOldAndSaveNew(
|
semesterDb.removeOldAndSaveNew(
|
||||||
|
@ -42,6 +42,7 @@ class StudentRepository @Inject constructor(
|
|||||||
): RegisterUser = wulkanowySdkFactory.create()
|
): RegisterUser = wulkanowySdkFactory.create()
|
||||||
.getStudentsFromHebe(token, pin, symbol, "")
|
.getStudentsFromHebe(token, pin, symbol, "")
|
||||||
.mapToPojo(null)
|
.mapToPojo(null)
|
||||||
|
.also { it.logErrors() }
|
||||||
|
|
||||||
suspend fun getUserSubjectsFromScrapper(
|
suspend fun getUserSubjectsFromScrapper(
|
||||||
email: String,
|
email: String,
|
||||||
@ -52,6 +53,7 @@ class StudentRepository @Inject constructor(
|
|||||||
): RegisterUser = wulkanowySdkFactory.create()
|
): RegisterUser = wulkanowySdkFactory.create()
|
||||||
.getUserSubjectsFromScrapper(email, password, scrapperBaseUrl, domainSuffix, symbol)
|
.getUserSubjectsFromScrapper(email, password, scrapperBaseUrl, domainSuffix, symbol)
|
||||||
.mapToPojo(password)
|
.mapToPojo(password)
|
||||||
|
.also { it.logErrors() }
|
||||||
|
|
||||||
suspend fun getStudentsHybrid(
|
suspend fun getStudentsHybrid(
|
||||||
email: String,
|
email: String,
|
||||||
@ -61,6 +63,7 @@ class StudentRepository @Inject constructor(
|
|||||||
): RegisterUser = wulkanowySdkFactory.create()
|
): RegisterUser = wulkanowySdkFactory.create()
|
||||||
.getStudentsHybrid(email, password, scrapperBaseUrl, "", symbol)
|
.getStudentsHybrid(email, password, scrapperBaseUrl, "", symbol)
|
||||||
.mapToPojo(password)
|
.mapToPojo(password)
|
||||||
|
.also { it.logErrors() }
|
||||||
|
|
||||||
suspend fun getSavedStudents(decryptPass: Boolean = true): List<StudentWithSemesters> {
|
suspend fun getSavedStudents(decryptPass: Boolean = true): List<StudentWithSemesters> {
|
||||||
return studentDb.loadStudentsWithSemesters().map { (student, semesters) ->
|
return studentDb.loadStudentsWithSemesters().map { (student, semesters) ->
|
||||||
@ -195,10 +198,10 @@ class StudentRepository @Inject constructor(
|
|||||||
.authorizePermission(pesel)
|
.authorizePermission(pesel)
|
||||||
|
|
||||||
suspend fun refreshStudentAfterAuthorize(student: Student, semester: Semester) {
|
suspend fun refreshStudentAfterAuthorize(student: Student, semester: Semester) {
|
||||||
val newCurrentApiStudent = wulkanowySdkFactory
|
val wulkanowySdk = wulkanowySdkFactory.create(student, semester)
|
||||||
.create(student, semester)
|
val newCurrentApiStudent = runCatching { wulkanowySdk.getCurrentStudent() }
|
||||||
.getCurrentStudent()
|
.onFailure { Timber.e(it, "Can't find student with id ${student.studentId}") }
|
||||||
?: return Timber.d("Can't find student with id ${student.studentId}")
|
.getOrNull() ?: return
|
||||||
|
|
||||||
val studentName = StudentName(
|
val studentName = StudentName(
|
||||||
studentName = "${newCurrentApiStudent.studentName} ${newCurrentApiStudent.studentSurname}"
|
studentName = "${newCurrentApiStudent.studentName} ${newCurrentApiStudent.studentSurname}"
|
||||||
@ -221,6 +224,18 @@ class StudentRepository @Inject constructor(
|
|||||||
appDatabase.clearAllTables()
|
appDatabase.clearAllTables()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun RegisterUser.logErrors() {
|
||||||
|
val symbolsErrors = symbols.filter { it.error != null }
|
||||||
|
.map { it.error }
|
||||||
|
val unitsErrors = symbols.flatMap { it.schools }
|
||||||
|
.filter { it.error != null }
|
||||||
|
.map { it.error }
|
||||||
|
|
||||||
|
(symbolsErrors + unitsErrors).forEach { error ->
|
||||||
|
Timber.e(error, "Error occurred while fetching students")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NoAuthorizationException : Exception()
|
class NoAuthorizationException : Exception()
|
||||||
|
@ -18,7 +18,7 @@ fun Semester.isCurrent(now: LocalDate = now()): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun List<Semester>.getCurrentOrLast(): Semester {
|
fun List<Semester>.getCurrentOrLast(): Semester {
|
||||||
if (isEmpty()) throw RuntimeException("Empty semester list")
|
if (isEmpty()) throw IllegalStateException("Empty semester list")
|
||||||
|
|
||||||
// when there is only one current semester
|
// when there is only one current semester
|
||||||
singleOrNull { it.isCurrent() }?.let { return it }
|
singleOrNull { it.isCurrent() }?.let { return it }
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
Wersja 2.5.3
|
Wersja 2.5.5
|
||||||
|
|
||||||
— naprawiliśmy wyświetlanie błędu "Brak uprawnień" po starcie aplikacji u użytkowników eduOne
|
— naprawiliśmy migrację informacji o tym, czy szkoła ucznia używa eduOne
|
||||||
— naprawiliśmy obsługę autoryzacji u użytkowników eduOne
|
— naprawiliśmy w końcu (teraz naprawdę mamy taką nadzieję) ten komunikat o braku uprawnień
|
||||||
— ukryliśmy numery lekcji i oceny klasy u użytkowników eduOne, bo VULCAN te funkcje usunął
|
|
||||||
— naprawiliśmy inne rzeczy u użytkowników eduOne (jak brak opisu oceny czy ładowanie danych na kilku ekranach)
|
|
||||||
|
|
||||||
Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases
|
Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases
|
||||||
|
Reference in New Issue
Block a user