From 70c2cb7dbf717c508bbec08b69931019b2430699 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Aug 2022 13:30:00 +0000 Subject: [PATCH 1/9] Bump desugar_jdk_libs from 1.1.6 to 1.1.8 (#1957) --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 5fb07377a..52ae02ddc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -188,7 +188,7 @@ ext { dependencies { implementation "io.github.wulkanowy:sdk:1.7.0" - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.6' + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8' implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines" From f68a8e4215e719ecdfedeb72553ce58df1fcfbf7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Aug 2022 13:30:28 +0000 Subject: [PATCH 2/9] Bump robolectric from 4.8.1 to 4.8.2 (#1956) --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 52ae02ddc..1dba83c5d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -263,7 +263,7 @@ dependencies { testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines" testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testImplementation 'org.robolectric:robolectric:4.8.1' + testImplementation 'org.robolectric:robolectric:4.8.2' testImplementation "androidx.test:runner:1.4.0" testImplementation "androidx.test.ext:junit:1.1.3" testImplementation "androidx.test:core:1.4.0" From 5c17c38d1d16214db4cc423ffe8556e7b7c64d8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Aug 2022 13:30:56 +0000 Subject: [PATCH 3/9] Bump mockk from 1.12.5 to 1.12.7 (#1955) --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 1dba83c5d..10648c15f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -181,7 +181,7 @@ ext { android_hilt = "1.0.0" room = "2.4.3" chucker = "3.5.2" - mockk = "1.12.5" + mockk = "1.12.7" coroutines = "1.6.4" } From 54372e0a55e8e903f868d4e47897e9c1a868b505 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Aug 2022 13:40:14 +0000 Subject: [PATCH 4/9] Bump kotlinx-serialization-json from 1.3.3 to 1.4.0 (#1950) --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 10648c15f..5977b347b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -190,7 +190,7 @@ dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8' - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3" + implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines" implementation "androidx.core:core-ktx:1.8.0" From f2cb3b4f9edd69a1936d3ccb52b3b8eab0e0e320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Tue, 30 Aug 2022 09:06:29 +0200 Subject: [PATCH 5/9] Change message draft key in shared preferences (#1959) --- .../github/wulkanowy/data/repositories/MessageRepository.kt | 4 ++-- app/src/main/res/values/preferences_keys.xml | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/MessageRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/MessageRepository.kt index 00cbffb84..5a43da4e2 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/MessageRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/MessageRepository.kt @@ -167,10 +167,10 @@ class MessageRepository @Inject constructor( } var draftMessage: MessageDraft? - get() = sharedPrefProvider.getString(context.getString(R.string.pref_key_message_send_draft)) + get() = sharedPrefProvider.getString(context.getString(R.string.pref_key_message_draft)) ?.let { json.decodeFromString(it) } set(value) = sharedPrefProvider.putString( - context.getString(R.string.pref_key_message_send_draft), + context.getString(R.string.pref_key_message_draft), value?.let { json.encodeToString(it) } ) } diff --git a/app/src/main/res/values/preferences_keys.xml b/app/src/main/res/values/preferences_keys.xml index f29080b33..80a71bc71 100644 --- a/app/src/main/res/values/preferences_keys.xml +++ b/app/src/main/res/values/preferences_keys.xml @@ -31,8 +31,7 @@ homework_fullscreen subjects_without_grades optional_arithmetic_average - message_send_is_draft - message_send_recipients + message_draft last_sync_date notifications_piggyback notifications_piggyback_cancel_original From 535206056d9b385a5cea1e15a53f0a1c7f37cb4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Tue, 30 Aug 2022 09:07:07 +0200 Subject: [PATCH 6/9] Fix selecting student mailbox based on studentName field (#1958) --- app/build.gradle | 2 +- .../wulkanowy/data/db/dao/MailboxDao.kt | 3 - .../data/repositories/MailboxRepository.kt | 11 +- .../repositories/MailboxRepositoryTest.kt | 132 ++++++++++++++++++ 4 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 app/src/test/java/io/github/wulkanowy/data/repositories/MailboxRepositoryTest.kt diff --git a/app/build.gradle b/app/build.gradle index 5977b347b..62eb8e315 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -186,7 +186,7 @@ ext { } dependencies { - implementation "io.github.wulkanowy:sdk:1.7.0" + implementation "io.github.wulkanowy:sdk:09e5215894" coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8' diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/MailboxDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/MailboxDao.kt index 8589db311..c44ecd0c2 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/MailboxDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/MailboxDao.kt @@ -11,7 +11,4 @@ interface MailboxDao : BaseDao { @Query("SELECT * FROM Mailboxes WHERE userLoginId = :userLoginId ") suspend fun loadAll(userLoginId: Int): List - - @Query("SELECT * FROM Mailboxes WHERE userLoginId = :userLoginId AND studentName = :studentName ") - suspend fun load(userLoginId: Int, studentName: String): Mailbox? } diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/MailboxRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/MailboxRepository.kt index 7f5974920..8c1097bdb 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/MailboxRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/MailboxRepository.kt @@ -32,17 +32,22 @@ class MailboxRepository @Inject constructor( suspend fun getMailbox(student: Student): Mailbox { val isExpired = refreshHelper.shouldBeRefreshed(getRefreshKey(cacheKey, student)) - val mailbox = mailboxDao.load(student.userLoginId, student.studentName) + val mailboxes = mailboxDao.loadAll(student.userLoginId) + val mailbox = mailboxes.filterByStudent(student) return if (isExpired || mailbox == null) { refreshMailboxes(student) - val newMailbox = mailboxDao.load(student.userLoginId, student.studentName) + val newMailbox = mailboxDao.loadAll(student.userLoginId).filterByStudent(student) requireNotNull(newMailbox) { - "Mailbox for ${student.userName} - ${student.studentName} not found!" + "Mailbox for ${student.userName} - ${student.studentName} not found! Saved mailboxes: $mailboxes" } newMailbox } else mailbox } + + private fun List.filterByStudent(student: Student): Mailbox? = find { + it.studentName.trim() == student.studentName.trim() + } } diff --git a/app/src/test/java/io/github/wulkanowy/data/repositories/MailboxRepositoryTest.kt b/app/src/test/java/io/github/wulkanowy/data/repositories/MailboxRepositoryTest.kt new file mode 100644 index 000000000..56e315638 --- /dev/null +++ b/app/src/test/java/io/github/wulkanowy/data/repositories/MailboxRepositoryTest.kt @@ -0,0 +1,132 @@ +package io.github.wulkanowy.data.repositories + +import io.github.wulkanowy.data.db.dao.MailboxDao +import io.github.wulkanowy.data.db.entities.Mailbox +import io.github.wulkanowy.data.db.entities.MailboxType +import io.github.wulkanowy.data.db.entities.Student +import io.github.wulkanowy.sdk.Sdk +import io.github.wulkanowy.utils.AutoRefreshHelper +import io.mockk.MockKAnnotations +import io.mockk.Runs +import io.mockk.coEvery +import io.mockk.impl.annotations.MockK +import io.mockk.impl.annotations.SpyK +import io.mockk.just +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.runTest +import org.junit.Assert.assertEquals +import org.junit.Before +import org.junit.Test +import java.time.Instant + +@OptIn(ExperimentalCoroutinesApi::class) +class MailboxRepositoryTest { + + @SpyK + private var sdk = Sdk() + + @MockK + private lateinit var mailboxDao: MailboxDao + + @MockK + private lateinit var refreshHelper: AutoRefreshHelper + + private lateinit var systemUnderTest: MailboxRepository + + @Before + fun setUp() { + MockKAnnotations.init(this) + + coEvery { refreshHelper.shouldBeRefreshed(any()) } returns false + coEvery { refreshHelper.updateLastRefreshTimestamp(any()) } just Runs + coEvery { mailboxDao.deleteAll(any()) } just Runs + coEvery { mailboxDao.insertAll(any()) } returns emptyList() + coEvery { mailboxDao.loadAll(any()) } returns emptyList() + coEvery { sdk.getMailboxes() } returns emptyList() + + systemUnderTest = MailboxRepository( + mailboxDao = mailboxDao, + sdk = sdk, + refreshHelper = refreshHelper, + ) + } + + @Test(expected = IllegalArgumentException::class) + fun `get mailbox that doesn't exist`() = runTest { + val student = getStudentEntity( + userName = "Stanisław Kowalski", + studentName = "Jan Kowalski", + ) + coEvery { sdk.getMailboxes() } returns emptyList() + + systemUnderTest.getMailbox(student) + } + + @Test + fun `get mailbox for user with additional spaces`() = runTest { + val student = getStudentEntity( + userName = " Stanisław Kowalski ", + studentName = " Jan Kowalski ", + ) + val expectedMailbox = getMailboxEntity("Jan Kowalski ") + coEvery { mailboxDao.loadAll(any()) } returns listOf( + expectedMailbox, + ) + + val selectedMailbox = systemUnderTest.getMailbox(student) + assertEquals(expectedMailbox, selectedMailbox) + } + + @Test(expected = IllegalArgumentException::class) + fun `get mailbox for student with strange name`() = runTest { + val student = getStudentEntity( + userName = "Stanisław Kowalski", + studentName = "J**** K*****", + ) + val expectedMailbox = getMailboxEntity("Jan Kowalski") + coEvery { mailboxDao.loadAll(any()) } returns listOf( + expectedMailbox, + ) + + systemUnderTest.getMailbox(student) + } + + private fun getMailboxEntity( + studentName: String, + ) = Mailbox( + globalKey = "", + fullName = "", + userName = "", + userLoginId = 123, + studentName = studentName, + schoolNameShort = "", + type = MailboxType.STUDENT, + ) + + private fun getStudentEntity( + studentName: String, + userName: String, + ) = Student( + scrapperBaseUrl = "http://fakelog.cf", + email = "jan@fakelog.cf", + certificateKey = "", + classId = 0, + className = "", + isCurrent = false, + isParent = false, + loginMode = Sdk.Mode.API.name, + loginType = Sdk.ScrapperLoginType.STANDARD.name, + mobileBaseUrl = "", + password = "", + privateKey = "", + registrationDate = Instant.now(), + schoolName = "", + schoolShortName = "test", + schoolSymbol = "", + studentId = 1, + studentName = studentName, + symbol = "", + userLoginId = 1, + userName = userName, + ) +} From eed091aad29b76ac3340e84ae90f4ffc01868491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Tue, 30 Aug 2022 09:07:24 +0200 Subject: [PATCH 7/9] Update row in mailboxes table on primary key conflict (#1954) --- app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt index 048e9e3cd..056a5cbd1 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt @@ -2,11 +2,12 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Delete import androidx.room.Insert +import androidx.room.OnConflictStrategy import androidx.room.Update interface BaseDao { - @Insert + @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertAll(items: List): List @Update From bf34cb0c1e483b0253e12359c97e332404385e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Tue, 30 Aug 2022 12:11:32 +0200 Subject: [PATCH 8/9] New Crowdin updates (#1953) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mikołaj Pich --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 62eb8e315..b70e77b73 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -186,7 +186,7 @@ ext { } dependencies { - implementation "io.github.wulkanowy:sdk:09e5215894" + implementation "io.github.wulkanowy:sdk:a1bf69486b" coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8' From d139bd5b14a3b068f217f4ec107b5484f5539856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Tue, 30 Aug 2022 13:34:10 +0200 Subject: [PATCH 9/9] Version 1.7.2 --- app/build.gradle | 8 ++++---- app/src/main/play/release-notes/pl-PL/default.txt | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b70e77b73..759199cad 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,8 +23,8 @@ android { testApplicationId "io.github.tests.wulkanowy" minSdkVersion 21 targetSdkVersion 32 - versionCode 110 - versionName "1.7.1" + versionCode 111 + versionName "1.7.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" resValue "string", "app_name", "Wulkanowy" @@ -161,7 +161,7 @@ play { defaultToAppBundles = false track = 'production' releaseStatus = com.github.triplet.gradle.androidpublisher.ReleaseStatus.IN_PROGRESS - userFraction = 0.95d + userFraction = 0.05d updatePriority = 5 enabled.set(false) } @@ -186,7 +186,7 @@ ext { } dependencies { - implementation "io.github.wulkanowy:sdk:a1bf69486b" + implementation "io.github.wulkanowy:sdk:1.7.2" coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8' 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 4b6dcaf28..69699208a 100644 --- a/app/src/main/play/release-notes/pl-PL/default.txt +++ b/app/src/main/play/release-notes/pl-PL/default.txt @@ -1,9 +1,5 @@ -Wersja 1.7.1 +Wersja 1.7.2 -- naprawiliśmy logowanie do aplikacji -- dodaliśmy wsparcie nowego modułu Wiadomości Plus -- dodaliśmy nową możliwość wsparcia naszego projektu przez opcjonalne reklamy -- dodaliśmy sortowanie po średniej -- naprawiliśmy też kilka usterek wpływających na komfort używania aplikacji +- naprawiliśmy kilka błędów w obsłudze nowego modułu wiadomości Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases