Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
afc16e3d17 | |||
59f6f5c212 | |||
86f8763e69 | |||
157becb017 | |||
83ca9a7060 | |||
1033be4503 | |||
e67066f3ae | |||
bc22808b0e | |||
e05abb3539 | |||
6153c7b97d | |||
e574e5e2ec | |||
e6571a1dfc | |||
d566de0282 | |||
558db061f5 | |||
190f40ede8 |
@ -23,8 +23,8 @@ android {
|
|||||||
testApplicationId "io.github.tests.wulkanowy"
|
testApplicationId "io.github.tests.wulkanowy"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 32
|
targetSdkVersion 32
|
||||||
versionCode 111
|
versionCode 114
|
||||||
versionName "1.7.2"
|
versionName "1.7.5"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
resValue "string", "app_name", "Wulkanowy"
|
resValue "string", "app_name", "Wulkanowy"
|
||||||
@ -160,9 +160,9 @@ kapt {
|
|||||||
play {
|
play {
|
||||||
defaultToAppBundles = false
|
defaultToAppBundles = false
|
||||||
track = 'production'
|
track = 'production'
|
||||||
releaseStatus = com.github.triplet.gradle.androidpublisher.ReleaseStatus.IN_PROGRESS
|
// releaseStatus = com.github.triplet.gradle.androidpublisher.ReleaseStatus.IN_PROGRESS
|
||||||
userFraction = 0.05d
|
// userFraction = 0.05d
|
||||||
updatePriority = 5
|
updatePriority = 4
|
||||||
enabled.set(false)
|
enabled.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "io.github.wulkanowy:sdk:1.7.2"
|
implementation "io.github.wulkanowy:sdk:1.7.5"
|
||||||
|
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8'
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8'
|
||||||
|
|
||||||
|
@ -47,7 +47,39 @@ class MailboxRepository @Inject constructor(
|
|||||||
} else mailbox
|
} else mailbox
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun List<Mailbox>.filterByStudent(student: Student): Mailbox? = find {
|
private fun List<Mailbox>.filterByStudent(student: Student): Mailbox? {
|
||||||
it.studentName.trim() == student.studentName.trim()
|
val normalizedStudentName = student.studentName.normalizeStudentName()
|
||||||
|
|
||||||
|
return find {
|
||||||
|
it.studentName.normalizeStudentName() == normalizedStudentName
|
||||||
|
} ?: singleOrNull {
|
||||||
|
it.studentName.getFirstAndLastPart() == normalizedStudentName.getFirstAndLastPart()
|
||||||
|
} ?: singleOrNull {
|
||||||
|
it.studentName.getUnauthorizedVersion() == normalizedStudentName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String.normalizeStudentName(): String {
|
||||||
|
return trim().split(" ")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.joinToString(" ") { part ->
|
||||||
|
part.lowercase().replaceFirstChar { it.uppercase() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String.getFirstAndLastPart(): String {
|
||||||
|
val parts = normalizeStudentName().split(" ")
|
||||||
|
|
||||||
|
val endParts = parts.filterIndexed { i, _ ->
|
||||||
|
i == 0 || parts.size - 1 == i
|
||||||
|
}
|
||||||
|
return endParts.joinToString(" ")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String.getUnauthorizedVersion(): String {
|
||||||
|
return normalizeStudentName().split(" ")
|
||||||
|
.joinToString(" ") {
|
||||||
|
it.first() + "*".repeat(it.length - 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,10 @@ class MessageRepository @Inject constructor(
|
|||||||
},
|
},
|
||||||
query = { messagesDb.loadAll(mailbox.globalKey, folder.id) },
|
query = { messagesDb.loadAll(mailbox.globalKey, folder.id) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student).getMessages(Folder.valueOf(folder.name)).mapToEntities(mailbox)
|
sdk.init(student).getMessages(
|
||||||
|
folder = Folder.valueOf(folder.name),
|
||||||
|
mailboxKey = mailbox.globalKey,
|
||||||
|
).mapToEntities(mailbox)
|
||||||
},
|
},
|
||||||
saveFetchResult = { old, new ->
|
saveFetchResult = { old, new ->
|
||||||
messagesDb.deleteAll(old uniqueSubtract new)
|
messagesDb.deleteAll(old uniqueSubtract new)
|
||||||
@ -89,7 +92,7 @@ class MessageRepository @Inject constructor(
|
|||||||
},
|
},
|
||||||
query = { messagesDb.loadMessageWithAttachment(message.messageGlobalKey) },
|
query = { messagesDb.loadMessageWithAttachment(message.messageGlobalKey) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student).getMessageDetails(it!!.message.messageGlobalKey)
|
sdk.init(student).getMessageDetails(it!!.message.messageGlobalKey, markAsRead)
|
||||||
},
|
},
|
||||||
saveFetchResult = { old, new ->
|
saveFetchResult = { old, new ->
|
||||||
checkNotNull(old) { "Fetched message no longer exist!" }
|
checkNotNull(old) { "Fetched message no longer exist!" }
|
||||||
@ -98,7 +101,7 @@ class MessageRepository @Inject constructor(
|
|||||||
id = message.id
|
id = message.id
|
||||||
unread = !markAsRead
|
unread = !markAsRead
|
||||||
sender = new.sender
|
sender = new.sender
|
||||||
recipients = new.recipients.firstOrNull() ?: "Wielu adresoatów"
|
recipients = new.recipients.singleOrNull() ?: "Wielu adresatów"
|
||||||
content = content.ifBlank { new.content }
|
content = content.ifBlank { new.content }
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -8,7 +8,6 @@ import io.github.wulkanowy.data.db.entities.Student
|
|||||||
import io.github.wulkanowy.data.pojos.GroupNotificationData
|
import io.github.wulkanowy.data.pojos.GroupNotificationData
|
||||||
import io.github.wulkanowy.data.pojos.NotificationData
|
import io.github.wulkanowy.data.pojos.NotificationData
|
||||||
import io.github.wulkanowy.ui.modules.Destination
|
import io.github.wulkanowy.ui.modules.Destination
|
||||||
import io.github.wulkanowy.ui.modules.splash.SplashActivity
|
|
||||||
import io.github.wulkanowy.utils.descriptionRes
|
import io.github.wulkanowy.utils.descriptionRes
|
||||||
import io.github.wulkanowy.utils.getPlural
|
import io.github.wulkanowy.utils.getPlural
|
||||||
import io.github.wulkanowy.utils.toFormattedString
|
import io.github.wulkanowy.utils.toFormattedString
|
||||||
@ -22,8 +21,9 @@ class NewAttendanceNotification @Inject constructor(
|
|||||||
suspend fun notify(items: List<Attendance>, student: Student) {
|
suspend fun notify(items: List<Attendance>, student: Student) {
|
||||||
val lines = items.filterNot { it.presence || it.name == "UNKNOWN" }
|
val lines = items.filterNot { it.presence || it.name == "UNKNOWN" }
|
||||||
.map {
|
.map {
|
||||||
|
val lesson = it.subject.ifBlank { "Lekcja ${it.number}" }
|
||||||
val description = context.getString(it.descriptionRes)
|
val description = context.getString(it.descriptionRes)
|
||||||
"${it.date.toFormattedString("dd.MM")} - ${it.subject}: $description"
|
"${it.date.toFormattedString("dd.MM")} - $lesson: $description"
|
||||||
}
|
}
|
||||||
.ifEmpty { return }
|
.ifEmpty { return }
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package io.github.wulkanowy.ui.modules.grade.details
|
|||||||
import io.github.wulkanowy.data.*
|
import io.github.wulkanowy.data.*
|
||||||
import io.github.wulkanowy.data.db.entities.Grade
|
import io.github.wulkanowy.data.db.entities.Grade
|
||||||
import io.github.wulkanowy.data.enums.GradeExpandMode
|
import io.github.wulkanowy.data.enums.GradeExpandMode
|
||||||
import io.github.wulkanowy.data.enums.GradeSortingMode
|
|
||||||
import io.github.wulkanowy.data.enums.GradeSortingMode.*
|
import io.github.wulkanowy.data.enums.GradeSortingMode.*
|
||||||
import io.github.wulkanowy.data.repositories.GradeRepository
|
import io.github.wulkanowy.data.repositories.GradeRepository
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
@ -132,16 +131,17 @@ class GradeDetailsPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
.logResourceStatus("load grade details")
|
.logResourceStatus("load grade details")
|
||||||
.onResourceData {
|
.onResourceData {
|
||||||
|
val gradeItems = createGradeItems(it)
|
||||||
view?.run {
|
view?.run {
|
||||||
enableSwipe(true)
|
enableSwipe(true)
|
||||||
showProgress(false)
|
showProgress(false)
|
||||||
showErrorView(false)
|
showErrorView(false)
|
||||||
showContent(it.isNotEmpty())
|
showContent(gradeItems.isNotEmpty())
|
||||||
showEmpty(it.isEmpty())
|
showEmpty(gradeItems.isEmpty())
|
||||||
updateNewGradesAmount(it)
|
updateNewGradesAmount(it)
|
||||||
updateMarkAsDoneButton()
|
updateMarkAsDoneButton()
|
||||||
updateData(
|
updateData(
|
||||||
data = createGradeItems(it),
|
data = gradeItems,
|
||||||
expandMode = preferencesRepository.gradeExpandMode,
|
expandMode = preferencesRepository.gradeExpandMode,
|
||||||
preferencesRepository.gradeColorTheme
|
preferencesRepository.gradeColorTheme
|
||||||
)
|
)
|
||||||
|
@ -15,5 +15,8 @@ fun List<Semester>.getCurrentOrLast(): Semester {
|
|||||||
// when there is more than one current semester - find one with higher id
|
// when there is more than one current semester - find one with higher id
|
||||||
singleOrNull { semester -> semester.semesterId == maxByOrNull { it.semesterId }?.semesterId }?.let { return it }
|
singleOrNull { semester -> semester.semesterId == maxByOrNull { it.semesterId }?.semesterId }?.let { return it }
|
||||||
|
|
||||||
|
// when there is no active kindergarten semester - get one from last year
|
||||||
|
singleOrNull { semester -> semester.schoolYear == maxByOrNull { it.schoolYear }?.schoolYear }?.let { return it }
|
||||||
|
|
||||||
throw IllegalArgumentException("Duplicated last semester! Semesters: ${joinToString(separator = "\n")}")
|
throw IllegalArgumentException("Duplicated last semester! Semesters: ${joinToString(separator = "\n")}")
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
Wersja 1.7.2
|
Wersja 1.7.5
|
||||||
|
|
||||||
- naprawiliśmy kilka błędów w obsłudze nowego modułu wiadomości
|
- naprawiliśmy kilka błędów w obsłudze nowego modułu wiadomości
|
||||||
|
- naprawiliśmy wyświetlanie napisu "Brak ocen", jesli uczeń nie zdobył w danym semestrze jeszcze żadnych ocen
|
||||||
|
- naprawiliśmy logowanie do aplikacji rodzicom będącym jednocześnie nauczycielami
|
||||||
|
|
||||||
Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases
|
Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases
|
||||||
|
@ -77,20 +77,90 @@ class MailboxRepositoryTest {
|
|||||||
assertEquals(expectedMailbox, selectedMailbox)
|
assertEquals(expectedMailbox, selectedMailbox)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException::class)
|
@Test
|
||||||
fun `get mailbox for student with strange name`() = runTest {
|
fun `get mailbox for unique non-authorized student`() = runTest {
|
||||||
val student = getStudentEntity(
|
val student = getStudentEntity(
|
||||||
userName = "Stanisław Kowalski",
|
userName = "Stanisław Kowalski",
|
||||||
studentName = "J**** K*****",
|
studentName = "J** K*******",
|
||||||
)
|
)
|
||||||
val expectedMailbox = getMailboxEntity("Jan Kowalski")
|
val expectedMailbox = getMailboxEntity("Jan Kowalski")
|
||||||
coEvery { mailboxDao.loadAll(any()) } returns listOf(
|
coEvery { mailboxDao.loadAll(any()) } returns listOf(
|
||||||
expectedMailbox,
|
expectedMailbox,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assertEquals(expectedMailbox, systemUnderTest.getMailbox(student))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `get mailbox for unique non-authorized student but with spaces`() = runTest {
|
||||||
|
val student = getStudentEntity(
|
||||||
|
userName = "Stanisław Kowalski",
|
||||||
|
studentName = "J** K*******",
|
||||||
|
)
|
||||||
|
val expectedMailbox = getMailboxEntity("Jan Kowalski")
|
||||||
|
coEvery { mailboxDao.loadAll(any()) } returns listOf(
|
||||||
|
expectedMailbox,
|
||||||
|
)
|
||||||
|
|
||||||
|
assertEquals(expectedMailbox, systemUnderTest.getMailbox(student))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException::class)
|
||||||
|
fun `get mailbox for not-unique non-authorized student`() = runTest {
|
||||||
|
val student = getStudentEntity(
|
||||||
|
userName = "Stanisław Kowalski",
|
||||||
|
studentName = "J** K*******",
|
||||||
|
)
|
||||||
|
coEvery { mailboxDao.loadAll(any()) } returns listOf(
|
||||||
|
getMailboxEntity("Jan Kowalski"),
|
||||||
|
getMailboxEntity("Jan Kurowski"),
|
||||||
|
)
|
||||||
|
|
||||||
systemUnderTest.getMailbox(student)
|
systemUnderTest.getMailbox(student)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `get mailbox for student with uppercase name`() = runTest {
|
||||||
|
val student = getStudentEntity(
|
||||||
|
userName = "Mochoń Julia",
|
||||||
|
studentName = "KLAUDIA MOCHOŃ",
|
||||||
|
)
|
||||||
|
val expectedMailbox = getMailboxEntity("Klaudia Mochoń")
|
||||||
|
coEvery { mailboxDao.loadAll(any()) } returns listOf(
|
||||||
|
expectedMailbox,
|
||||||
|
)
|
||||||
|
|
||||||
|
assertEquals(expectedMailbox, systemUnderTest.getMailbox(student))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `get mailbox for student with second name`() = runTest {
|
||||||
|
val student = getStudentEntity(
|
||||||
|
userName = "Fistaszek Karolina",
|
||||||
|
studentName = "Julia Fistaszek",
|
||||||
|
)
|
||||||
|
val expectedMailbox = getMailboxEntity("Julia Maria Fistaszek")
|
||||||
|
coEvery { mailboxDao.loadAll(any()) } returns listOf(
|
||||||
|
expectedMailbox,
|
||||||
|
)
|
||||||
|
|
||||||
|
assertEquals(expectedMailbox, systemUnderTest.getMailbox(student))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `get mailbox for student with second name and uppercase`() = runTest {
|
||||||
|
val student = getStudentEntity(
|
||||||
|
userName = "BEDNAREK KAMIL",
|
||||||
|
studentName = "ALEKSANDRA BEDNAREK",
|
||||||
|
)
|
||||||
|
val expectedMailbox = getMailboxEntity("Aleksandra Anna Bednarek")
|
||||||
|
coEvery { mailboxDao.loadAll(any()) } returns listOf(
|
||||||
|
expectedMailbox,
|
||||||
|
)
|
||||||
|
|
||||||
|
assertEquals(expectedMailbox, systemUnderTest.getMailbox(student))
|
||||||
|
}
|
||||||
|
|
||||||
private fun getMailboxEntity(
|
private fun getMailboxEntity(
|
||||||
studentName: String,
|
studentName: String,
|
||||||
) = Mailbox(
|
) = Mailbox(
|
||||||
|
@ -141,7 +141,7 @@ class MessageRepositoryTest {
|
|||||||
messageDb.loadMessageWithAttachment("v4")
|
messageDb.loadMessageWithAttachment("v4")
|
||||||
} returnsMany listOf(flowOf(mWa), flowOf(mWaWithContent))
|
} returnsMany listOf(flowOf(mWa), flowOf(mWaWithContent))
|
||||||
coEvery {
|
coEvery {
|
||||||
sdk.getMessageDetails("v4")
|
sdk.getMessageDetails("v4", any())
|
||||||
} returns mockk {
|
} returns mockk {
|
||||||
every { sender } returns ""
|
every { sender } returns ""
|
||||||
every { recipients } returns listOf("")
|
every { recipients } returns listOf("")
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
|
import io.github.wulkanowy.data.db.entities.Semester
|
||||||
|
import io.github.wulkanowy.getSemesterEntity
|
||||||
|
import org.junit.Test
|
||||||
|
import java.time.LocalDate
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
class SemesterExtensionKtTest {
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException::class)
|
||||||
|
fun `get current semester when current is doubled`() {
|
||||||
|
val semesters = listOf(
|
||||||
|
getSemesterEntity(1, 1, LocalDate.now(), LocalDate.now()),
|
||||||
|
getSemesterEntity(1, 1, LocalDate.now(), LocalDate.now())
|
||||||
|
)
|
||||||
|
|
||||||
|
semesters.getCurrentOrLast()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = RuntimeException::class)
|
||||||
|
fun `get current semester when there is empty list`() {
|
||||||
|
val semesters = listOf<Semester>()
|
||||||
|
|
||||||
|
semesters.getCurrentOrLast()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `get current kindergarten semester when there is no any current`() {
|
||||||
|
val semesters = listOf(
|
||||||
|
createSemesterEntity(
|
||||||
|
kindergartenDiaryId = 281,
|
||||||
|
schoolYear = 2020,
|
||||||
|
semesterId = 0,
|
||||||
|
start = LocalDate.of(2020, 9, 1),
|
||||||
|
end = LocalDate.of(2021, 8, 31),
|
||||||
|
),
|
||||||
|
createSemesterEntity(
|
||||||
|
kindergartenDiaryId = 342,
|
||||||
|
schoolYear = 2021,
|
||||||
|
semesterId = 0,
|
||||||
|
start = LocalDate.of(2021, 9, 1),
|
||||||
|
end = LocalDate.of(2022, 8, 31),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
val res = semesters.getCurrentOrLast()
|
||||||
|
|
||||||
|
assertEquals(2021, res.schoolYear)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createSemesterEntity(
|
||||||
|
diaryId: Int = 0,
|
||||||
|
kindergartenDiaryId: Int = 0,
|
||||||
|
semesterId: Int = 0,
|
||||||
|
schoolYear: Int = 0,
|
||||||
|
start: LocalDate = LocalDate.now(),
|
||||||
|
end: LocalDate = LocalDate.now().plusMonths(6),
|
||||||
|
) = Semester(
|
||||||
|
studentId = 1,
|
||||||
|
diaryId = diaryId,
|
||||||
|
kindergartenDiaryId = kindergartenDiaryId,
|
||||||
|
semesterId = semesterId,
|
||||||
|
diaryName = "$semesterId",
|
||||||
|
schoolYear = schoolYear,
|
||||||
|
classId = 0,
|
||||||
|
semesterName = semesterId,
|
||||||
|
unitId = 1,
|
||||||
|
start = start,
|
||||||
|
end = end
|
||||||
|
)
|
||||||
|
}
|
Reference in New Issue
Block a user