Compare commits
172 Commits
Author | SHA1 | Date | |
---|---|---|---|
3eae3a7667 | |||
b613b84469 | |||
2776d019b9 | |||
729e72cddb | |||
ec101c1f52 | |||
cfec79405f | |||
7d8be1b9fc | |||
c781159e75 | |||
90a5b9e20f | |||
3cf6c295b0 | |||
e757585bd3 | |||
736d16a7ab | |||
6f4a8d5534 | |||
b5e17c4ff7 | |||
cc01525f16 | |||
c2ec05662b | |||
b99ba48d2c | |||
2d4a1bff83 | |||
cd853e4d57 | |||
8183d7d5a0 | |||
3f199cb610 | |||
22f72981cb | |||
bce92b7347 | |||
ed5166333a | |||
a05f1f70f7 | |||
e58a60410c | |||
fc91936884 | |||
88043569ac | |||
10add8a70e | |||
098af9884a | |||
554c1b1261 | |||
496695162d | |||
dc59f4ffa3 | |||
e0f4cad7fb | |||
a51a54dc7a | |||
7cdac6ede1 | |||
9dfb282e88 | |||
725668f855 | |||
e58c155961 | |||
05a5047a70 | |||
1fe464a289 | |||
497acf9d68 | |||
976eb5a772 | |||
9ececeb4e9 | |||
096fe359e7 | |||
a98e8398fd | |||
d8c4926a97 | |||
17c139b559 | |||
ddbcc7a04c | |||
9f9eb60280 | |||
f893170dec | |||
cff08d6322 | |||
9dee7f01f6 | |||
8324a9cac3 | |||
5316e3e1bf | |||
81e80181f2 | |||
6ee38e9259 | |||
40df80371c | |||
a3596c35b8 | |||
66b7ea4cb4 | |||
770749e158 | |||
0aa83b020e | |||
4d1218d1d3 | |||
0ea6cbc8ed | |||
eb31f9578f | |||
f69d50d2c1 | |||
8a424ee6a4 | |||
7dfa48bbe3 | |||
d811cdb919 | |||
e2f2e21081 | |||
c812310497 | |||
7f6475cf35 | |||
a2a7d2ebb2 | |||
a5bc45c5da | |||
5646befbd7 | |||
75f496b5d2 | |||
23d989d22a | |||
9e013f7cd9 | |||
c63a7c03f1 | |||
5ceee84f0e | |||
7f4539fd27 | |||
71ebf1260b | |||
784ee58384 | |||
eceef3f582 | |||
0d950fbd86 | |||
003d63b516 | |||
b4c0440a8e | |||
137c305295 | |||
2c40c221c3 | |||
e82ac78d4a | |||
59d46ce956 | |||
17caa8ecbd | |||
e9540b4012 | |||
643ad60455 | |||
01f892ce5c | |||
f61b6a5e78 | |||
650cf7484e | |||
037cbb0b19 | |||
e49835e89e | |||
c64be2fab0 | |||
ce9cb35172 | |||
7fa9219c7b | |||
1fe1618220 | |||
d9bab2af78 | |||
06b6d88dd1 | |||
3bf27baed5 | |||
6802d74002 | |||
3fd2683df7 | |||
b708c70ea2 | |||
aba08e6aa9 | |||
124b6dfd79 | |||
1dbaa8bfdc | |||
25ac171298 | |||
387ff1cba7 | |||
eef3464d0b | |||
61297a01c7 | |||
762d4b1393 | |||
2e86b67eec | |||
6071b7571b | |||
fcea2218b5 | |||
a4a191700e | |||
3d76d41b55 | |||
0e1c20a952 | |||
5d14ee7f4e | |||
83527d91f3 | |||
9d62410530 | |||
5dffbdadfa | |||
516922d5aa | |||
9098e74065 | |||
2f5577cc54 | |||
3272c38356 | |||
bcd305bef3 | |||
fc5ad16cb7 | |||
c8332a0642 | |||
3212efe21e | |||
693ce8217d | |||
2cdd322ed4 | |||
c04b3e40d2 | |||
d1d665bbdf | |||
d70568c446 | |||
1d8378e136 | |||
4a2bf539f0 | |||
4d085f8266 | |||
fca69e7234 | |||
711de0f77f | |||
58d5196ac9 | |||
26a95ecb99 | |||
1835446468 | |||
4d3b16ec80 | |||
95b4d53fac | |||
0fa197d520 | |||
646b4a149d | |||
afd0c8513a | |||
c4a3da93ca | |||
ff2aa6f195 | |||
1d8d71709f | |||
aabd7345c1 | |||
09d16cf6d8 | |||
81d8f7ea48 | |||
05a804832b | |||
db02f0c1e1 | |||
0a40237809 | |||
017d46e5db | |||
8478b8b7ed | |||
8cc69728aa | |||
c82e6ae95b | |||
50a177d18c | |||
a77b3d4cd7 | |||
aff56a8311 | |||
5238e4d187 | |||
10f9812495 | |||
ab1de323d4 |
4
.github/workflows/deploy-store.yml
vendored
4
.github/workflows/deploy-store.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
environment: google-play
|
environment: google-play
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: 17
|
java-version: 17
|
||||||
@ -49,7 +49,7 @@ jobs:
|
|||||||
environment: app-gallery
|
environment: app-gallery
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: 17
|
java-version: 17
|
||||||
|
4
.github/workflows/deploy-test.yml
vendored
4
.github/workflows/deploy-test.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
environment: app-center
|
environment: app-center
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: 17
|
java-version: 17
|
||||||
@ -89,7 +89,7 @@ jobs:
|
|||||||
if: github.event_name != 'pull_request_target'
|
if: github.event_name != 'pull_request_target'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: 17
|
java-version: 17
|
||||||
|
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
- uses: fkirc/skip-duplicate-actions@master
|
- uses: fkirc/skip-duplicate-actions@master
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: gradle/wrapper-validation-action@v1
|
- uses: gradle/wrapper-validation-action@v1
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: 17
|
java-version: 17
|
||||||
@ -45,7 +45,7 @@ jobs:
|
|||||||
- uses: fkirc/skip-duplicate-actions@master
|
- uses: fkirc/skip-duplicate-actions@master
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: gradle/wrapper-validation-action@v1
|
- uses: gradle/wrapper-validation-action@v1
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: 17
|
java-version: 17
|
||||||
@ -71,7 +71,7 @@ jobs:
|
|||||||
- uses: fkirc/skip-duplicate-actions@master
|
- uses: fkirc/skip-duplicate-actions@master
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: gradle/wrapper-validation-action@v1
|
- uses: gradle/wrapper-validation-action@v1
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: 17
|
java-version: 17
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -65,6 +65,8 @@ captures/
|
|||||||
.idea/uiDesigner.xml
|
.idea/uiDesigner.xml
|
||||||
.idea/runConfigurations.xml
|
.idea/runConfigurations.xml
|
||||||
.idea/discord.xml
|
.idea/discord.xml
|
||||||
|
.idea/migrations.xml
|
||||||
|
.idea/androidTestResultsUserPreferences.xml
|
||||||
|
|
||||||
# Keystore files
|
# Keystore files
|
||||||
*.jks
|
*.jks
|
||||||
|
@ -20,19 +20,18 @@ apply from: 'hooks.gradle'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'io.github.wulkanowy'
|
namespace 'io.github.wulkanowy'
|
||||||
compileSdk 33
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "io.github.wulkanowy"
|
applicationId "io.github.wulkanowy"
|
||||||
testApplicationId "io.github.tests.wulkanowy"
|
testApplicationId "io.github.tests.wulkanowy"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 33
|
targetSdkVersion 34
|
||||||
versionCode 131
|
versionCode 148
|
||||||
versionName "2.1.0"
|
versionName "2.4.2"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
resValue "string", "app_name", "Wulkanowy"
|
resValue "string", "app_name", "Wulkanowy"
|
||||||
|
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
firebase_enabled: project.hasProperty("enableFirebase"),
|
firebase_enabled: project.hasProperty("enableFirebase"),
|
||||||
admob_project_id: ""
|
admob_project_id: ""
|
||||||
@ -69,6 +68,7 @@ android {
|
|||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
signingConfig signingConfigs.release
|
signingConfig signingConfigs.release
|
||||||
buildConfigField "String", "MESSAGES_BASE_URL", "\"https://messages.wulkanowy.net.pl\""
|
buildConfigField "String", "MESSAGES_BASE_URL", "\"https://messages.wulkanowy.net.pl\""
|
||||||
|
buildConfigField "String", "SCHOOLS_BASE_URL", '"https://schools.wulkanowy.net.pl"'
|
||||||
}
|
}
|
||||||
debug {
|
debug {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
@ -78,6 +78,7 @@ android {
|
|||||||
versionNameSuffix "-dev"
|
versionNameSuffix "-dev"
|
||||||
ext.enableCrashlytics = project.hasProperty("enableFirebase")
|
ext.enableCrashlytics = project.hasProperty("enableFirebase")
|
||||||
buildConfigField "String", "MESSAGES_BASE_URL", "\"https://messages.wulkanowy.net.pl\""
|
buildConfigField "String", "MESSAGES_BASE_URL", "\"https://messages.wulkanowy.net.pl\""
|
||||||
|
buildConfigField "String", "SCHOOLS_BASE_URL", '"https://schools.wulkanowy.net.pl"'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +113,7 @@ android {
|
|||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding true
|
viewBinding true
|
||||||
|
buildConfig true
|
||||||
}
|
}
|
||||||
|
|
||||||
bundle {
|
bundle {
|
||||||
@ -140,7 +142,9 @@ android {
|
|||||||
packagingOptions {
|
packagingOptions {
|
||||||
resources {
|
resources {
|
||||||
excludes += ['META-INF/library_release.kotlin_module',
|
excludes += ['META-INF/library_release.kotlin_module',
|
||||||
'META-INF/library-core_release.kotlin_module']
|
'META-INF/library-core_release.kotlin_module',
|
||||||
|
'META-INF/LICENSE.md',
|
||||||
|
'META-INF/LICENSE-notice.md']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,8 +164,8 @@ play {
|
|||||||
defaultToAppBundles = false
|
defaultToAppBundles = false
|
||||||
track = 'production'
|
track = 'production'
|
||||||
releaseStatus = ReleaseStatus.IN_PROGRESS
|
releaseStatus = ReleaseStatus.IN_PROGRESS
|
||||||
userFraction = 0.25d
|
userFraction = 0.99d
|
||||||
updatePriority = 3
|
updatePriority = 2
|
||||||
enabled.set(false)
|
enabled.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,44 +186,44 @@ huaweiPublish {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
work_manager = "2.8.1"
|
work_manager = "2.9.0"
|
||||||
android_hilt = "1.0.0"
|
android_hilt = "1.1.0"
|
||||||
room = "2.5.2"
|
room = "2.6.1"
|
||||||
chucker = "3.5.2"
|
chucker = "4.0.0"
|
||||||
mockk = "1.13.7"
|
mockk = "1.13.9"
|
||||||
coroutines = "1.7.3"
|
coroutines = "1.8.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'io.github.wulkanowy:sdk:2.1.0'
|
implementation 'io.github.wulkanowy:sdk:2.4.1'
|
||||||
|
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
|
||||||
|
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"
|
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines"
|
||||||
|
|
||||||
implementation "androidx.core:core-ktx:1.10.1"
|
implementation 'androidx.core:core-ktx:1.12.0'
|
||||||
implementation 'androidx.core:core-splashscreen:1.0.1'
|
implementation 'androidx.core:core-splashscreen:1.0.1'
|
||||||
implementation "androidx.activity:activity-ktx:1.7.2"
|
implementation "androidx.activity:activity-ktx:1.8.2"
|
||||||
implementation "androidx.appcompat:appcompat:1.6.1"
|
implementation "androidx.appcompat:appcompat:1.6.1"
|
||||||
implementation "androidx.fragment:fragment-ktx:1.6.1"
|
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
||||||
implementation "androidx.annotation:annotation:1.6.0"
|
implementation "androidx.annotation:annotation:1.7.1"
|
||||||
|
|
||||||
implementation "androidx.preference:preference-ktx:1.2.1"
|
implementation "androidx.preference:preference-ktx:1.2.1"
|
||||||
implementation "androidx.recyclerview:recyclerview:1.3.1"
|
implementation "androidx.recyclerview:recyclerview:1.3.2"
|
||||||
implementation "androidx.viewpager2:viewpager2:1.1.0-beta02"
|
implementation "androidx.viewpager2:viewpager2:1.1.0-beta02"
|
||||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
||||||
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
|
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
|
||||||
implementation "androidx.coordinatorlayout:coordinatorlayout:1.2.0"
|
implementation "androidx.coordinatorlayout:coordinatorlayout:1.2.0"
|
||||||
implementation "com.google.android.material:material:1.9.0"
|
implementation "com.google.android.material:material:1.10.0"
|
||||||
implementation "com.github.wulkanowy:material-chips-input:2.3.1"
|
implementation "com.github.wulkanowy:material-chips-input:2.3.1"
|
||||||
implementation "com.github.PhilJay:MPAndroidChart:v3.1.0"
|
implementation "com.github.PhilJay:MPAndroidChart:v3.1.0"
|
||||||
implementation 'com.github.lopspower:CircularImageView:4.3.0'
|
implementation 'com.github.lopspower:CircularImageView:4.3.0'
|
||||||
|
|
||||||
implementation "androidx.work:work-runtime-ktx:$work_manager"
|
implementation "androidx.work:work-runtime:$work_manager"
|
||||||
playImplementation "androidx.work:work-gcm:$work_manager"
|
playImplementation "androidx.work:work-gcm:$work_manager"
|
||||||
|
|
||||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.1"
|
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.7.0"
|
||||||
|
|
||||||
implementation "androidx.room:room-runtime:$room"
|
implementation "androidx.room:room-runtime:$room"
|
||||||
implementation "androidx.room:room-ktx:$room"
|
implementation "androidx.room:room-ktx:$room"
|
||||||
@ -235,33 +239,37 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||||
implementation "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0"
|
implementation "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0"
|
||||||
implementation "com.squareup.okhttp3:logging-interceptor:4.11.0"
|
implementation "com.squareup.okhttp3:logging-interceptor:4.12.0"
|
||||||
|
implementation "com.squareup.okhttp3:okhttp-urlconnection:4.12.0"
|
||||||
|
|
||||||
implementation "com.jakewharton.timber:timber:5.0.1"
|
implementation "com.jakewharton.timber:timber:5.0.1"
|
||||||
implementation "at.favre.lib:slf4j-timber:1.0.1"
|
implementation 'com.github.Faierbel:slf4j-timber:2.0'
|
||||||
implementation 'com.github.bastienpaulfr:Treessence:1.0.5'
|
implementation 'com.github.bastienpaulfr:Treessence:1.1.2'
|
||||||
implementation "com.mikepenz:aboutlibraries-core:$about_libraries"
|
implementation "com.mikepenz:aboutlibraries-core:$about_libraries"
|
||||||
implementation "io.coil-kt:coil:2.4.0"
|
implementation 'io.coil-kt:coil:2.5.0'
|
||||||
implementation "io.github.wulkanowy:AppKillerManager:3.0.1"
|
implementation "io.github.wulkanowy:AppKillerManager:3.0.1"
|
||||||
implementation 'me.xdrop:fuzzywuzzy:1.4.0'
|
implementation 'me.xdrop:fuzzywuzzy:1.4.0'
|
||||||
implementation 'com.fredporciuncula:flow-preferences:1.9.1'
|
implementation 'com.fredporciuncula:flow-preferences:1.9.1'
|
||||||
implementation 'org.apache.commons:commons-text:1.10.0'
|
implementation 'org.apache.commons:commons-text:1.11.0'
|
||||||
|
|
||||||
playImplementation platform('com.google.firebase:firebase-bom:32.2.2')
|
playImplementation platform('com.google.firebase:firebase-bom:32.7.2')
|
||||||
playImplementation 'com.google.firebase:firebase-analytics-ktx'
|
playImplementation 'com.google.firebase:firebase-analytics'
|
||||||
playImplementation 'com.google.firebase:firebase-messaging:'
|
playImplementation 'com.google.firebase:firebase-messaging'
|
||||||
playImplementation 'com.google.firebase:firebase-crashlytics:'
|
playImplementation 'com.google.firebase:firebase-crashlytics:'
|
||||||
playImplementation 'com.google.firebase:firebase-config-ktx'
|
playImplementation 'com.google.firebase:firebase-config'
|
||||||
playImplementation 'com.google.android.play:core:1.10.3'
|
|
||||||
playImplementation 'com.google.android.play:core-ktx:1.8.1'
|
|
||||||
playImplementation 'com.google.android.gms:play-services-ads:22.2.0'
|
|
||||||
|
|
||||||
hmsImplementation 'com.huawei.hms:hianalytics:6.10.0.303'
|
playImplementation 'com.google.android.gms:play-services-ads:22.6.0'
|
||||||
hmsImplementation 'com.huawei.agconnect:agconnect-crash:1.9.1.300'
|
playImplementation "com.google.android.play:integrity:1.3.0"
|
||||||
|
playImplementation 'com.google.android.play:app-update-ktx:2.1.0'
|
||||||
|
playImplementation 'com.google.android.play:review-ktx:2.0.1'
|
||||||
|
playImplementation "com.google.android.ump:user-messaging-platform:2.1.0"
|
||||||
|
|
||||||
releaseImplementation "com.github.ChuckerTeam.Chucker:library-no-op:$chucker"
|
hmsImplementation 'com.huawei.hms:hianalytics:6.12.0.301'
|
||||||
|
hmsImplementation 'com.huawei.agconnect:agconnect-crash:1.9.1.303'
|
||||||
|
|
||||||
debugImplementation "com.github.ChuckerTeam.Chucker:library:$chucker"
|
releaseImplementation "com.github.chuckerteam.chucker:library-no-op:$chucker"
|
||||||
|
|
||||||
|
debugImplementation "com.github.chuckerteam.chucker:library:$chucker"
|
||||||
debugImplementation 'com.github.amitshekhariitbhu.Android-Debug-Database:debug-db:1.0.6'
|
debugImplementation 'com.github.amitshekhariitbhu.Android-Debug-Database:debug-db:1.0.6'
|
||||||
debugImplementation 'com.github.haroldadmin:WhatTheStack:1.0.0-alpha04'
|
debugImplementation 'com.github.haroldadmin:WhatTheStack:1.0.0-alpha04'
|
||||||
|
|
||||||
@ -270,7 +278,7 @@ dependencies {
|
|||||||
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines"
|
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines"
|
||||||
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
|
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
|
||||||
|
|
||||||
testImplementation 'org.robolectric:robolectric:4.10.3'
|
testImplementation 'org.robolectric:robolectric:4.11.1'
|
||||||
testImplementation "androidx.test:runner:1.5.2"
|
testImplementation "androidx.test:runner:1.5.2"
|
||||||
testImplementation "androidx.test.ext:junit:1.1.5"
|
testImplementation "androidx.test.ext:junit:1.1.5"
|
||||||
testImplementation "androidx.test:core:1.5.0"
|
testImplementation "androidx.test:core:1.5.0"
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
apply plugin: "jacoco"
|
apply plugin: "jacoco"
|
||||||
|
|
||||||
jacoco {
|
jacoco {
|
||||||
toolVersion "0.8.7"
|
toolVersion "0.8.11"
|
||||||
reportsDirectory.set(file("$buildDir/reports"))
|
reportsDirectory.set(file("$buildDir/reports"))
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(Test) {
|
tasks.withType(Test).configureEach {
|
||||||
jacoco.includeNoLocationClasses = true
|
jacoco.includeNoLocationClasses = true
|
||||||
jacoco.excludes = ['jdk.internal.*']
|
jacoco.excludes = ['jdk.internal.*']
|
||||||
}
|
}
|
||||||
|
|
||||||
task jacocoTestReport(type: JacocoReport) {
|
tasks.register('jacocoTestReport', JacocoReport) {
|
||||||
|
|
||||||
group = "Reporting"
|
group = "Reporting"
|
||||||
description = "Generate Jacoco coverage reports"
|
description = "Generate Jacoco coverage reports"
|
||||||
|
2451
app/schemas/io.github.wulkanowy.data.db.AppDatabase/58.json
Normal file
2451
app/schemas/io.github.wulkanowy.data.db.AppDatabase/58.json
Normal file
File diff suppressed because it is too large
Load Diff
2501
app/schemas/io.github.wulkanowy.data.db.AppDatabase/59.json
Normal file
2501
app/schemas/io.github.wulkanowy.data.db.AppDatabase/59.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -14,34 +14,37 @@ import kotlin.test.assertFailsWith
|
|||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class ScramblerTest {
|
class ScramblerTest {
|
||||||
|
|
||||||
|
private val scrambler = Scrambler(ApplicationProvider.getApplicationContext())
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun encryptDecryptTest() {
|
fun encryptDecryptTest() {
|
||||||
assertEquals("TEST", decrypt(encrypt("TEST",
|
assertEquals(
|
||||||
ApplicationProvider.getApplicationContext())))
|
"TEST", scrambler.decrypt(scrambler.encrypt("TEST"))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun emptyTextEncryptTest() {
|
fun emptyTextEncryptTest() {
|
||||||
assertFailsWith<ScramblerException> {
|
assertFailsWith<ScramblerException> {
|
||||||
decrypt("")
|
scrambler.decrypt("")
|
||||||
}
|
}
|
||||||
|
|
||||||
assertFailsWith<ScramblerException> {
|
assertFailsWith<ScramblerException> {
|
||||||
encrypt("", ApplicationProvider.getApplicationContext())
|
scrambler.encrypt("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SdkSuppress(minSdkVersion = 18)
|
@SdkSuppress(minSdkVersion = 18)
|
||||||
fun emptyKeyStoreTest() {
|
fun emptyKeyStoreTest() {
|
||||||
val text = encrypt("test", ApplicationProvider.getApplicationContext())
|
val text = scrambler.encrypt("test")
|
||||||
|
|
||||||
val keyStore = KeyStore.getInstance("AndroidKeyStore")
|
val keyStore = KeyStore.getInstance("AndroidKeyStore")
|
||||||
keyStore.load(null)
|
keyStore.load(null)
|
||||||
keyStore.deleteEntry("wulkanowy_password")
|
keyStore.deleteEntry("wulkanowy_password")
|
||||||
|
|
||||||
assertFailsWith<ScramblerException> {
|
assertFailsWith<ScramblerException> {
|
||||||
decrypt(text)
|
scrambler.decrypt(text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import android.view.View
|
|||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@ -13,9 +14,11 @@ class AdsHelper @Inject constructor(
|
|||||||
private val preferencesRepository: PreferencesRepository
|
private val preferencesRepository: PreferencesRepository
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
val isMobileAdsSdkInitialized = MutableStateFlow(false)
|
||||||
|
val canShowAd = false
|
||||||
|
|
||||||
fun initialize() {
|
fun initialize() {
|
||||||
preferencesRepository.isAdsEnabled = false
|
preferencesRepository.isAdsEnabled = false
|
||||||
preferencesRepository.isAgreeToProcessData = false
|
|
||||||
preferencesRepository.selectedDashboardTiles -= DashboardItem.Tile.ADS
|
preferencesRepository.selectedDashboardTiles -= DashboardItem.Tile.ADS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class InAppUpdateHelper @Inject constructor() {
|
||||||
|
|
||||||
|
lateinit var messageContainer: View
|
||||||
|
|
||||||
|
fun checkAndInstallUpdates() {}
|
||||||
|
|
||||||
|
fun onResume() {}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class IntegrityHelper @Inject constructor() {
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
|
fun getIntegrityToken(requestId: String): String? = null
|
||||||
|
}
|
@ -1,17 +0,0 @@
|
|||||||
package io.github.wulkanowy.utils
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.view.View
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
|
||||||
class UpdateHelper @Inject constructor() {
|
|
||||||
|
|
||||||
lateinit var messageContainer: View
|
|
||||||
|
|
||||||
fun checkAndInstallUpdates(activity: Activity) {}
|
|
||||||
|
|
||||||
fun onActivityResult(requestCode: Int, resultCode: Int) {}
|
|
||||||
|
|
||||||
fun onResume(activity: Activity) {}
|
|
||||||
}
|
|
@ -5,6 +5,7 @@ import android.view.View
|
|||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@ -12,10 +13,11 @@ class AdsHelper @Inject constructor(
|
|||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
private val preferencesRepository: PreferencesRepository
|
private val preferencesRepository: PreferencesRepository
|
||||||
) {
|
) {
|
||||||
|
val isMobileAdsSdkInitialized = MutableStateFlow(false)
|
||||||
|
val canShowAd = false
|
||||||
|
|
||||||
fun initialize() {
|
fun initialize() {
|
||||||
preferencesRepository.isAdsEnabled = false
|
preferencesRepository.isAdsEnabled = false
|
||||||
preferencesRepository.isAgreeToProcessData = false
|
|
||||||
preferencesRepository.selectedDashboardTiles -= DashboardItem.Tile.ADS
|
preferencesRepository.selectedDashboardTiles -= DashboardItem.Tile.ADS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ package io.github.wulkanowy.utils
|
|||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.huawei.agconnect.crash.AGConnectCrash
|
import com.huawei.agconnect.crash.AGConnectCrash
|
||||||
import fr.bipi.tressence.base.FormatterPriorityTree
|
import fr.bipi.treessence.base.FormatterPriorityTree
|
||||||
import fr.bipi.tressence.common.StackTraceRecorder
|
import fr.bipi.treessence.common.StackTraceRecorder
|
||||||
|
|
||||||
class CrashLogTree : FormatterPriorityTree(Log.VERBOSE) {
|
class CrashLogTree : FormatterPriorityTree(Log.VERBOSE) {
|
||||||
|
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class InAppUpdateHelper @Inject constructor() {
|
||||||
|
|
||||||
|
lateinit var messageContainer: View
|
||||||
|
|
||||||
|
fun checkAndInstallUpdates() {}
|
||||||
|
|
||||||
|
fun onResume() {}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class IntegrityHelper @Inject constructor() {
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
|
fun getIntegrityToken(requestId: String): String? = null
|
||||||
|
}
|
@ -1,17 +0,0 @@
|
|||||||
package io.github.wulkanowy.utils
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.view.View
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
|
||||||
class UpdateHelper @Inject constructor() {
|
|
||||||
|
|
||||||
lateinit var messageContainer: View
|
|
||||||
|
|
||||||
fun checkAndInstallUpdates(activity: Activity) {}
|
|
||||||
|
|
||||||
fun onActivityResult(requestCode: Int, resultCode: Int) {}
|
|
||||||
|
|
||||||
fun onResume(activity: Activity) {}
|
|
||||||
}
|
|
@ -44,6 +44,7 @@
|
|||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:supportsRtl="false"
|
android:supportsRtl="false"
|
||||||
android:theme="@style/WulkanowyTheme"
|
android:theme="@style/WulkanowyTheme"
|
||||||
|
android:resizeableActivity="true"
|
||||||
tools:ignore="DataExtractionRules,UnusedAttribute">
|
tools:ignore="DataExtractionRules,UnusedAttribute">
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.modules.splash.SplashActivity"
|
android:name=".ui.modules.splash.SplashActivity"
|
||||||
|
@ -1,24 +1,29 @@
|
|||||||
package io.github.wulkanowy
|
package io.github.wulkanowy
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.util.Log.*
|
import android.util.Log.DEBUG
|
||||||
|
import android.util.Log.INFO
|
||||||
|
import android.util.Log.VERBOSE
|
||||||
import androidx.hilt.work.HiltWorkerFactory
|
import androidx.hilt.work.HiltWorkerFactory
|
||||||
import androidx.work.Configuration
|
import androidx.work.Configuration
|
||||||
import com.yariksoffice.lingver.Lingver
|
import com.yariksoffice.lingver.Lingver
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
import fr.bipi.tressence.file.FileLoggerTree
|
import fr.bipi.treessence.file.FileLoggerTree
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
import io.github.wulkanowy.ui.base.ThemeManager
|
import io.github.wulkanowy.ui.base.ThemeManager
|
||||||
import io.github.wulkanowy.utils.*
|
import io.github.wulkanowy.utils.ActivityLifecycleLogger
|
||||||
|
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||||
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
|
import io.github.wulkanowy.utils.CrashLogExceptionTree
|
||||||
|
import io.github.wulkanowy.utils.CrashLogTree
|
||||||
|
import io.github.wulkanowy.utils.DebugLogTree
|
||||||
|
import io.github.wulkanowy.utils.RemoteConfigHelper
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltAndroidApp
|
@HiltAndroidApp
|
||||||
class WulkanowyApp : Application(), Configuration.Provider {
|
class WulkanowyApp : Application(), Configuration.Provider {
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var workerFactory: HiltWorkerFactory
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var themeManager: ThemeManager
|
lateinit var themeManager: ThemeManager
|
||||||
|
|
||||||
@ -32,16 +37,21 @@ class WulkanowyApp : Application(), Configuration.Provider {
|
|||||||
lateinit var analyticsHelper: AnalyticsHelper
|
lateinit var analyticsHelper: AnalyticsHelper
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var adsHelper: AdsHelper
|
lateinit var remoteConfigHelper: RemoteConfigHelper
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var remoteConfigHelper: RemoteConfigHelper
|
lateinit var workerFactory: HiltWorkerFactory
|
||||||
|
|
||||||
|
override val workManagerConfiguration: Configuration
|
||||||
|
get() = Configuration.Builder()
|
||||||
|
.setWorkerFactory(workerFactory)
|
||||||
|
.setMinimumLoggingLevel(if (appInfo.isDebug) VERBOSE else INFO)
|
||||||
|
.build()
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
initializeAppLanguage()
|
initializeAppLanguage()
|
||||||
themeManager.applyDefaultTheme()
|
themeManager.applyDefaultTheme()
|
||||||
adsHelper.initialize()
|
|
||||||
remoteConfigHelper.initialize()
|
remoteConfigHelper.initialize()
|
||||||
initLogging()
|
initLogging()
|
||||||
}
|
}
|
||||||
@ -74,9 +84,4 @@ class WulkanowyApp : Application(), Configuration.Provider {
|
|||||||
analyticsHelper.logEvent("language", "startup" to preferencesRepository.appLanguage)
|
analyticsHelper.logEvent("language", "startup" to preferencesRepository.appLanguage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getWorkManagerConfiguration() = Configuration.Builder()
|
|
||||||
.setWorkerFactory(workerFactory)
|
|
||||||
.setMinimumLoggingLevel(if (appInfo.isDebug) VERBOSE else INFO)
|
|
||||||
.build()
|
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,14 @@ import dagger.hilt.InstallIn
|
|||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
import io.github.wulkanowy.data.api.AdminMessageService
|
import io.github.wulkanowy.data.api.AdminMessageService
|
||||||
|
import io.github.wulkanowy.data.api.SchoolsService
|
||||||
import io.github.wulkanowy.data.db.AppDatabase
|
import io.github.wulkanowy.data.db.AppDatabase
|
||||||
import io.github.wulkanowy.data.db.SharedPrefProvider
|
import io.github.wulkanowy.data.db.SharedPrefProvider
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
import io.github.wulkanowy.sdk.Sdk
|
import io.github.wulkanowy.sdk.Sdk
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import io.github.wulkanowy.utils.RemoteConfigHelper
|
import io.github.wulkanowy.utils.RemoteConfigHelper
|
||||||
|
import io.github.wulkanowy.utils.WebkitCookieManagerProxy
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import okhttp3.MediaType.Companion.toMediaType
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
@ -42,6 +44,7 @@ internal class DataModule {
|
|||||||
buildTag = android.os.Build.MODEL
|
buildTag = android.os.Build.MODEL
|
||||||
userAgentTemplate = remoteConfig.userAgentTemplate
|
userAgentTemplate = remoteConfig.userAgentTemplate
|
||||||
setSimpleHttpLogger { Timber.d(it) }
|
setSimpleHttpLogger { Timber.d(it) }
|
||||||
|
setAdditionalCookieManager(WebkitCookieManagerProxy())
|
||||||
|
|
||||||
// for debug only
|
// for debug only
|
||||||
addInterceptor(chuckerInterceptor, network = true)
|
addInterceptor(chuckerInterceptor, network = true)
|
||||||
@ -82,19 +85,29 @@ internal class DataModule {
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
fun provideRetrofit(
|
fun provideAdminMessageService(
|
||||||
okHttpClient: OkHttpClient,
|
okHttpClient: OkHttpClient,
|
||||||
json: Json,
|
json: Json,
|
||||||
appInfo: AppInfo
|
appInfo: AppInfo
|
||||||
): Retrofit = Retrofit.Builder()
|
): AdminMessageService = Retrofit.Builder()
|
||||||
.baseUrl(appInfo.messagesBaseUrl)
|
.baseUrl(appInfo.messagesBaseUrl)
|
||||||
.client(okHttpClient)
|
.client(okHttpClient)
|
||||||
.addConverterFactory(json.asConverterFactory("application/json".toMediaType()))
|
.addConverterFactory(json.asConverterFactory("application/json".toMediaType()))
|
||||||
.build()
|
.build()
|
||||||
|
.create()
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
fun provideAdminMessageService(retrofit: Retrofit): AdminMessageService = retrofit.create()
|
fun provideSchoolsService(
|
||||||
|
okHttpClient: OkHttpClient,
|
||||||
|
json: Json,
|
||||||
|
appInfo: AppInfo,
|
||||||
|
): SchoolsService = Retrofit.Builder()
|
||||||
|
.baseUrl(appInfo.schoolsBaseUrl)
|
||||||
|
.client(okHttpClient)
|
||||||
|
.addConverterFactory(json.asConverterFactory("application/json".toMediaType()))
|
||||||
|
.build()
|
||||||
|
.create()
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
@ -240,4 +253,8 @@ internal class DataModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
fun provideAdminMessageDao(database: AppDatabase) = database.adminMessagesDao
|
fun provideAdminMessageDao(database: AppDatabase) = database.adminMessagesDao
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
fun provideGradeDescriptiveDao(database: AppDatabase) = database.gradeDescriptiveDao
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
package io.github.wulkanowy.data
|
package io.github.wulkanowy.data
|
||||||
|
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.catch
|
||||||
|
import kotlinx.coroutines.flow.collect
|
||||||
|
import kotlinx.coroutines.flow.emitAll
|
||||||
|
import kotlinx.coroutines.flow.filter
|
||||||
|
import kotlinx.coroutines.flow.first
|
||||||
|
import kotlinx.coroutines.flow.flow
|
||||||
|
import kotlinx.coroutines.flow.flowOf
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
import kotlinx.coroutines.flow.takeWhile
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -20,8 +30,15 @@ val <T> Resource<T>.dataOrNull: T?
|
|||||||
get() = when (this) {
|
get() = when (this) {
|
||||||
is Resource.Success -> this.data
|
is Resource.Success -> this.data
|
||||||
is Resource.Intermediate -> this.data
|
is Resource.Intermediate -> this.data
|
||||||
is Resource.Loading -> null
|
else -> null
|
||||||
is Resource.Error -> null
|
}
|
||||||
|
|
||||||
|
val <T> Resource<T>.dataOrThrow: T
|
||||||
|
get() = when (this) {
|
||||||
|
is Resource.Success -> this.data
|
||||||
|
is Resource.Intermediate -> this.data
|
||||||
|
is Resource.Loading -> throw IllegalStateException("Resource is in loading state")
|
||||||
|
is Resource.Error -> throw this.error
|
||||||
}
|
}
|
||||||
|
|
||||||
val <T> Resource<T>.errorOrNull: Throwable?
|
val <T> Resource<T>.errorOrNull: Throwable?
|
||||||
@ -131,7 +148,7 @@ inline fun <ResultType, RequestType> networkBoundResource(
|
|||||||
query().map { Resource.Success(filterResult(it)) }
|
query().map { Resource.Success(filterResult(it)) }
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
onFetchFailed(throwable)
|
onFetchFailed(throwable)
|
||||||
query().map { Resource.Error(throwable) }
|
flowOf(Resource.Error(throwable))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
query().map { Resource.Success(filterResult(it)) }
|
query().map { Resource.Success(filterResult(it)) }
|
||||||
@ -165,7 +182,7 @@ inline fun <ResultType, RequestType, T> networkBoundResource(
|
|||||||
query().map { Resource.Success(mapResult(it)) }
|
query().map { Resource.Success(mapResult(it)) }
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
onFetchFailed(throwable)
|
onFetchFailed(throwable)
|
||||||
query().map { Resource.Error(throwable) }
|
flowOf(Resource.Error(throwable))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
query().map { Resource.Success(mapResult(it)) }
|
query().map { Resource.Success(mapResult(it)) }
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package io.github.wulkanowy.data.api
|
||||||
|
|
||||||
|
import io.github.wulkanowy.data.pojos.IntegrityRequest
|
||||||
|
import io.github.wulkanowy.data.pojos.LoginEvent
|
||||||
|
import retrofit2.http.Body
|
||||||
|
import retrofit2.http.POST
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
interface SchoolsService {
|
||||||
|
|
||||||
|
@POST("/log/loginEvent")
|
||||||
|
suspend fun logLoginEvent(@Body request: IntegrityRequest<LoginEvent>)
|
||||||
|
}
|
@ -1,11 +1,126 @@
|
|||||||
package io.github.wulkanowy.data.db
|
package io.github.wulkanowy.data.db
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.room.*
|
import androidx.room.AutoMigration
|
||||||
|
import androidx.room.Database
|
||||||
|
import androidx.room.Room
|
||||||
|
import androidx.room.RoomDatabase
|
||||||
import androidx.room.RoomDatabase.JournalMode.TRUNCATE
|
import androidx.room.RoomDatabase.JournalMode.TRUNCATE
|
||||||
import io.github.wulkanowy.data.db.dao.*
|
import androidx.room.TypeConverters
|
||||||
import io.github.wulkanowy.data.db.entities.*
|
import io.github.wulkanowy.data.db.dao.AdminMessageDao
|
||||||
import io.github.wulkanowy.data.db.migrations.*
|
import io.github.wulkanowy.data.db.dao.AttendanceDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.AttendanceSummaryDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.CompletedLessonsDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.ConferenceDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.ExamDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.GradeDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.GradeDescriptiveDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.GradePartialStatisticsDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.GradePointsStatisticsDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.GradeSemesterStatisticsDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.GradeSummaryDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.HomeworkDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.LuckyNumberDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.MailboxDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.MessageAttachmentDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.MessagesDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.MobileDeviceDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.NoteDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.NotificationDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.RecipientDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.SchoolAnnouncementDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.SchoolDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.SemesterDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.StudentDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.StudentInfoDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.SubjectDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.TeacherDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.TimetableAdditionalDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.TimetableDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.TimetableHeaderDao
|
||||||
|
import io.github.wulkanowy.data.db.entities.AdminMessage
|
||||||
|
import io.github.wulkanowy.data.db.entities.Attendance
|
||||||
|
import io.github.wulkanowy.data.db.entities.AttendanceSummary
|
||||||
|
import io.github.wulkanowy.data.db.entities.CompletedLesson
|
||||||
|
import io.github.wulkanowy.data.db.entities.Conference
|
||||||
|
import io.github.wulkanowy.data.db.entities.Exam
|
||||||
|
import io.github.wulkanowy.data.db.entities.Grade
|
||||||
|
import io.github.wulkanowy.data.db.entities.GradeDescriptive
|
||||||
|
import io.github.wulkanowy.data.db.entities.GradePartialStatistics
|
||||||
|
import io.github.wulkanowy.data.db.entities.GradePointsStatistics
|
||||||
|
import io.github.wulkanowy.data.db.entities.GradeSemesterStatistics
|
||||||
|
import io.github.wulkanowy.data.db.entities.GradeSummary
|
||||||
|
import io.github.wulkanowy.data.db.entities.Homework
|
||||||
|
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
||||||
|
import io.github.wulkanowy.data.db.entities.Mailbox
|
||||||
|
import io.github.wulkanowy.data.db.entities.Message
|
||||||
|
import io.github.wulkanowy.data.db.entities.MessageAttachment
|
||||||
|
import io.github.wulkanowy.data.db.entities.MobileDevice
|
||||||
|
import io.github.wulkanowy.data.db.entities.Note
|
||||||
|
import io.github.wulkanowy.data.db.entities.Notification
|
||||||
|
import io.github.wulkanowy.data.db.entities.Recipient
|
||||||
|
import io.github.wulkanowy.data.db.entities.School
|
||||||
|
import io.github.wulkanowy.data.db.entities.SchoolAnnouncement
|
||||||
|
import io.github.wulkanowy.data.db.entities.Semester
|
||||||
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
|
import io.github.wulkanowy.data.db.entities.StudentInfo
|
||||||
|
import io.github.wulkanowy.data.db.entities.Subject
|
||||||
|
import io.github.wulkanowy.data.db.entities.Teacher
|
||||||
|
import io.github.wulkanowy.data.db.entities.Timetable
|
||||||
|
import io.github.wulkanowy.data.db.entities.TimetableAdditional
|
||||||
|
import io.github.wulkanowy.data.db.entities.TimetableHeader
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration10
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration11
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration12
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration13
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration14
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration15
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration16
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration17
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration18
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration19
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration2
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration20
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration21
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration22
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration23
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration24
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration25
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration26
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration27
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration28
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration29
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration3
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration30
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration31
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration32
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration33
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration34
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration35
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration36
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration37
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration38
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration39
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration4
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration40
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration41
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration42
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration43
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration44
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration46
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration49
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration5
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration50
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration51
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration53
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration54
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration55
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration57
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration58
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration6
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration7
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration8
|
||||||
|
import io.github.wulkanowy.data.db.migrations.Migration9
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@ -41,7 +156,8 @@ import javax.inject.Singleton
|
|||||||
TimetableHeader::class,
|
TimetableHeader::class,
|
||||||
SchoolAnnouncement::class,
|
SchoolAnnouncement::class,
|
||||||
Notification::class,
|
Notification::class,
|
||||||
AdminMessage::class
|
AdminMessage::class,
|
||||||
|
GradeDescriptive::class,
|
||||||
],
|
],
|
||||||
autoMigrations = [
|
autoMigrations = [
|
||||||
AutoMigration(from = 44, to = 45),
|
AutoMigration(from = 44, to = 45),
|
||||||
@ -51,6 +167,8 @@ import javax.inject.Singleton
|
|||||||
AutoMigration(from = 54, to = 55, spec = Migration55::class),
|
AutoMigration(from = 54, to = 55, spec = Migration55::class),
|
||||||
AutoMigration(from = 55, to = 56),
|
AutoMigration(from = 55, to = 56),
|
||||||
AutoMigration(from = 56, to = 57, spec = Migration57::class),
|
AutoMigration(from = 56, to = 57, spec = Migration57::class),
|
||||||
|
AutoMigration(from = 57, to = 58, spec = Migration58::class),
|
||||||
|
AutoMigration(from = 58, to = 59),
|
||||||
],
|
],
|
||||||
version = AppDatabase.VERSION_SCHEMA,
|
version = AppDatabase.VERSION_SCHEMA,
|
||||||
exportSchema = true
|
exportSchema = true
|
||||||
@ -59,7 +177,7 @@ import javax.inject.Singleton
|
|||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val VERSION_SCHEMA = 57
|
const val VERSION_SCHEMA = 59
|
||||||
|
|
||||||
fun getMigrations(sharedPrefProvider: SharedPrefProvider, appInfo: AppInfo) = arrayOf(
|
fun getMigrations(sharedPrefProvider: SharedPrefProvider, appInfo: AppInfo) = arrayOf(
|
||||||
Migration2(),
|
Migration2(),
|
||||||
@ -184,4 +302,6 @@ abstract class AppDatabase : RoomDatabase() {
|
|||||||
abstract val notificationDao: NotificationDao
|
abstract val notificationDao: NotificationDao
|
||||||
|
|
||||||
abstract val adminMessagesDao: AdminMessageDao
|
abstract val adminMessagesDao: AdminMessageDao
|
||||||
|
|
||||||
|
abstract val gradeDescriptiveDao: GradeDescriptiveDao
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package io.github.wulkanowy.data.db.dao
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Query
|
||||||
|
import io.github.wulkanowy.data.db.entities.GradeDescriptive
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Dao
|
||||||
|
interface GradeDescriptiveDao : BaseDao<GradeDescriptive> {
|
||||||
|
|
||||||
|
@Query("SELECT * FROM GradesDescriptive WHERE semester_id = :semesterId AND student_id = :studentId")
|
||||||
|
fun loadAll(semesterId: Int, studentId: Int): Flow<List<GradeDescriptive>>
|
||||||
|
}
|
@ -1,10 +1,16 @@
|
|||||||
package io.github.wulkanowy.data.db.dao
|
package io.github.wulkanowy.data.db.dao
|
||||||
|
|
||||||
import androidx.room.*
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Delete
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.OnConflictStrategy
|
||||||
|
import androidx.room.Query
|
||||||
|
import androidx.room.Transaction
|
||||||
|
import androidx.room.Update
|
||||||
|
import io.github.wulkanowy.data.db.entities.Semester
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import io.github.wulkanowy.data.db.entities.StudentName
|
import io.github.wulkanowy.data.db.entities.StudentName
|
||||||
import io.github.wulkanowy.data.db.entities.StudentNickAndAvatar
|
import io.github.wulkanowy.data.db.entities.StudentNickAndAvatar
|
||||||
import io.github.wulkanowy.data.db.entities.StudentWithSemesters
|
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@ -33,12 +39,12 @@ abstract class StudentDao {
|
|||||||
abstract suspend fun loadAll(): List<Student>
|
abstract suspend fun loadAll(): List<Student>
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
@Query("SELECT * FROM Students")
|
@Query("SELECT * FROM Students JOIN Semesters ON Students.student_id = Semesters.student_id AND Students.class_id = Semesters.class_id")
|
||||||
abstract suspend fun loadStudentsWithSemesters(): List<StudentWithSemesters>
|
abstract suspend fun loadStudentsWithSemesters(): Map<Student, List<Semester>>
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
@Query("SELECT * FROM Students WHERE id = :id")
|
@Query("SELECT * FROM Students JOIN Semesters ON Students.student_id = Semesters.student_id AND Students.class_id = Semesters.class_id WHERE Students.id = :id")
|
||||||
abstract suspend fun loadStudentWithSemestersById(id: Long): StudentWithSemesters?
|
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")
|
||||||
abstract suspend fun updateCurrent(id: Long)
|
abstract suspend fun updateCurrent(id: Long)
|
||||||
@ -46,6 +52,9 @@ abstract class StudentDao {
|
|||||||
@Query("UPDATE Students SET is_current = 0")
|
@Query("UPDATE Students SET is_current = 0")
|
||||||
abstract suspend fun resetCurrent()
|
abstract suspend fun resetCurrent()
|
||||||
|
|
||||||
|
@Query("DELETE FROM Students WHERE email = :email AND user_name = :userName")
|
||||||
|
abstract suspend fun deleteByEmailAndUserName(email: String, userName: String)
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
open suspend fun switchCurrent(id: Long) {
|
open suspend fun switchCurrent(id: Long) {
|
||||||
resetCurrent()
|
resetCurrent()
|
||||||
|
@ -37,6 +37,9 @@ data class AdminMessage(
|
|||||||
@ColumnInfo(name = "types", defaultValue = "[]")
|
@ColumnInfo(name = "types", defaultValue = "[]")
|
||||||
val types: List<MessageType> = emptyList(),
|
val types: List<MessageType> = emptyList(),
|
||||||
|
|
||||||
@ColumnInfo(name = "is_dismissible")
|
@ColumnInfo(name = "is_ok_visible", defaultValue = "0")
|
||||||
val isDismissible: Boolean = false
|
val isOkVisible: Boolean = false,
|
||||||
|
|
||||||
|
@ColumnInfo(name = "is_x_visible", defaultValue = "0")
|
||||||
|
val isXVisible: Boolean = false
|
||||||
)
|
)
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package io.github.wulkanowy.data.db.entities
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
@Entity(tableName = "GradesDescriptive")
|
||||||
|
data class GradeDescriptive(
|
||||||
|
|
||||||
|
@ColumnInfo(name = "semester_id")
|
||||||
|
val semesterId: Int,
|
||||||
|
|
||||||
|
@ColumnInfo(name = "student_id")
|
||||||
|
val studentId: Int,
|
||||||
|
|
||||||
|
val subject: String,
|
||||||
|
|
||||||
|
val description: String,
|
||||||
|
) : Serializable {
|
||||||
|
|
||||||
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
var id: Long = 0
|
||||||
|
|
||||||
|
@ColumnInfo(name = "is_notified")
|
||||||
|
var isNotified: Boolean = true
|
||||||
|
}
|
@ -1,13 +1,8 @@
|
|||||||
package io.github.wulkanowy.data.db.entities
|
package io.github.wulkanowy.data.db.entities
|
||||||
|
|
||||||
import androidx.room.Embedded
|
|
||||||
import androidx.room.Relation
|
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
data class StudentWithSemesters(
|
data class StudentWithSemesters(
|
||||||
@Embedded
|
|
||||||
val student: Student,
|
val student: Student,
|
||||||
|
|
||||||
@Relation(parentColumn = "student_id", entityColumn = "student_id")
|
|
||||||
val semesters: List<Semester>
|
val semesters: List<Semester>
|
||||||
) : Serializable
|
) : Serializable
|
||||||
|
@ -5,7 +5,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration10 : Migration(9, 10) {
|
class Migration10 : Migration(9, 10) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Grades_Summary RENAME TO GradesSummary")
|
db.execSQL("ALTER TABLE Grades_Summary RENAME TO GradesSummary")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration11 : Migration(10, 11) {
|
class Migration11 : Migration(10, 11) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS Grades_temp (
|
CREATE TABLE IF NOT EXISTS Grades_temp (
|
||||||
id INTEGER PRIMARY KEY NOT NULL,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
is_read INTEGER NOT NULL,
|
is_read INTEGER NOT NULL,
|
||||||
@ -26,9 +27,10 @@ class Migration11 : Migration(10, 11) {
|
|||||||
date INTEGER NOT NULL,
|
date INTEGER NOT NULL,
|
||||||
teacher TEXT NOT NULL
|
teacher TEXT NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
database.execSQL("INSERT INTO Grades_temp SELECT * FROM Grades")
|
)
|
||||||
database.execSQL("DROP TABLE Grades")
|
db.execSQL("INSERT INTO Grades_temp SELECT * FROM Grades")
|
||||||
database.execSQL("ALTER TABLE Grades_temp RENAME TO Grades")
|
db.execSQL("DROP TABLE Grades")
|
||||||
|
db.execSQL("ALTER TABLE Grades_temp RENAME TO Grades")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,17 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration12 : Migration(11, 12) {
|
class Migration12 : Migration(11, 12) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
createTempStudentsTable(database)
|
createTempStudentsTable(db)
|
||||||
replaceStudentTable(database)
|
replaceStudentTable(db)
|
||||||
updateStudentsWithClassId(database, getStudentsIds(database))
|
updateStudentsWithClassId(db, getStudentsIds(db))
|
||||||
removeStudentsWithNoClassId(database)
|
removeStudentsWithNoClassId(db)
|
||||||
ensureThereIsOnlyOneCurrentStudent(database)
|
ensureThereIsOnlyOneCurrentStudent(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createTempStudentsTable(database: SupportSQLiteDatabase) {
|
private fun createTempStudentsTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS Students_tmp (
|
CREATE TABLE IF NOT EXISTS Students_tmp (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
endpoint TEXT NOT NULL,
|
endpoint TEXT NOT NULL,
|
||||||
@ -30,15 +31,16 @@ class Migration12 : Migration(11, 12) {
|
|||||||
registration_date INTEGER NOT NULL,
|
registration_date INTEGER NOT NULL,
|
||||||
class_id INTEGER NOT NULL
|
class_id INTEGER NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
database.execSQL("CREATE UNIQUE INDEX index_Students_email_symbol_student_id_school_id_class_id ON Students_tmp (email, symbol, student_id, school_id, class_id)")
|
)
|
||||||
|
db.execSQL("CREATE UNIQUE INDEX index_Students_email_symbol_student_id_school_id_class_id ON Students_tmp (email, symbol, student_id, school_id, class_id)")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun replaceStudentTable(database: SupportSQLiteDatabase) {
|
private fun replaceStudentTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN class_id INTEGER DEFAULT 0 NOT NULL")
|
db.execSQL("ALTER TABLE Students ADD COLUMN class_id INTEGER DEFAULT 0 NOT NULL")
|
||||||
database.execSQL("INSERT INTO Students_tmp SELECT * FROM Students")
|
db.execSQL("INSERT INTO Students_tmp SELECT * FROM Students")
|
||||||
database.execSQL("DROP TABLE Students")
|
db.execSQL("DROP TABLE Students")
|
||||||
database.execSQL("ALTER TABLE Students_tmp RENAME TO Students")
|
db.execSQL("ALTER TABLE Students_tmp RENAME TO Students")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getStudentsIds(database: SupportSQLiteDatabase): List<Int> {
|
private fun getStudentsIds(database: SupportSQLiteDatabase): List<Int> {
|
||||||
@ -54,18 +56,18 @@ class Migration12 : Migration(11, 12) {
|
|||||||
return students
|
return students
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateStudentsWithClassId(database: SupportSQLiteDatabase, students: List<Int>) {
|
private fun updateStudentsWithClassId(db: SupportSQLiteDatabase, students: List<Int>) {
|
||||||
students.forEach {
|
students.forEach {
|
||||||
database.execSQL("UPDATE Students SET class_id = IFNULL((SELECT class_id FROM Semesters WHERE student_id = $it), 0) WHERE student_id = $it")
|
db.execSQL("UPDATE Students SET class_id = IFNULL((SELECT class_id FROM Semesters WHERE student_id = $it), 0) WHERE student_id = $it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun removeStudentsWithNoClassId(database: SupportSQLiteDatabase) {
|
private fun removeStudentsWithNoClassId(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DELETE FROM Students WHERE class_id = 0")
|
db.execSQL("DELETE FROM Students WHERE class_id = 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ensureThereIsOnlyOneCurrentStudent(database: SupportSQLiteDatabase) {
|
private fun ensureThereIsOnlyOneCurrentStudent(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("UPDATE Students SET is_current = 0")
|
db.execSQL("UPDATE Students SET is_current = 0")
|
||||||
database.execSQL("UPDATE Students SET is_current = 1 WHERE id = (SELECT MAX(id) FROM Students)")
|
db.execSQL("UPDATE Students SET is_current = 1 WHERE id = (SELECT MAX(id) FROM Students)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,27 +5,30 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration13 : Migration(12, 13) {
|
class Migration13 : Migration(12, 13) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
addClassNameToStudents(database, getStudentsIds(database))
|
addClassNameToStudents(db, getStudentsIds(db))
|
||||||
updateSemestersTable(database)
|
updateSemestersTable(db)
|
||||||
markAtLeastAndOnlyOneSemesterAtCurrent(database, getStudentsAndClassIds(database))
|
markAtLeastAndOnlyOneSemesterAtCurrent(db, getStudentsAndClassIds(db))
|
||||||
clearMessagesTable(database)
|
clearMessagesTable(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addClassNameToStudents(database: SupportSQLiteDatabase, students: List<Pair<Int, String>>) {
|
private fun addClassNameToStudents(
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN class_name TEXT DEFAULT \"\" NOT NULL")
|
db: SupportSQLiteDatabase,
|
||||||
|
students: List<Pair<Int, String>>
|
||||||
|
) {
|
||||||
|
db.execSQL("ALTER TABLE Students ADD COLUMN class_name TEXT DEFAULT \"\" NOT NULL")
|
||||||
|
|
||||||
students.forEach { (id, name) ->
|
students.forEach { (id, name) ->
|
||||||
val schoolName = name.substringAfter(" - ")
|
val schoolName = name.substringAfter(" - ")
|
||||||
val className = name.substringBefore(" - ", "").replace("Klasa ", "")
|
val className = name.substringBefore(" - ", "").replace("Klasa ", "")
|
||||||
database.execSQL("UPDATE Students SET class_name = '$className' WHERE id = '$id'")
|
db.execSQL("UPDATE Students SET class_name = '$className' WHERE id = '$id'")
|
||||||
database.execSQL("UPDATE Students SET school_name = '$schoolName' WHERE id = '$id'")
|
db.execSQL("UPDATE Students SET school_name = '$schoolName' WHERE id = '$id'")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getStudentsIds(database: SupportSQLiteDatabase): MutableList<Pair<Int, String>> {
|
private fun getStudentsIds(db: SupportSQLiteDatabase): MutableList<Pair<Int, String>> {
|
||||||
val students = mutableListOf<Pair<Int, String>>()
|
val students = mutableListOf<Pair<Int, String>>()
|
||||||
database.query("SELECT id, school_name FROM Students").use {
|
db.query("SELECT id, school_name FROM Students").use {
|
||||||
if (it.moveToFirst()) {
|
if (it.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
students.add(it.getInt(0) to it.getString(1))
|
students.add(it.getInt(0) to it.getString(1))
|
||||||
@ -36,15 +39,15 @@ class Migration13 : Migration(12, 13) {
|
|||||||
return students
|
return students
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSemestersTable(database: SupportSQLiteDatabase) {
|
private fun updateSemestersTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Semesters ADD COLUMN school_year INTEGER DEFAULT 1970 NOT NULL")
|
db.execSQL("ALTER TABLE Semesters ADD COLUMN school_year INTEGER DEFAULT 1970 NOT NULL")
|
||||||
database.execSQL("ALTER TABLE Semesters ADD COLUMN start INTEGER DEFAULT 0 NOT NULL")
|
db.execSQL("ALTER TABLE Semesters ADD COLUMN start INTEGER DEFAULT 0 NOT NULL")
|
||||||
database.execSQL("ALTER TABLE Semesters ADD COLUMN `end` INTEGER DEFAULT 0 NOT NULL")
|
db.execSQL("ALTER TABLE Semesters ADD COLUMN `end` INTEGER DEFAULT 0 NOT NULL")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getStudentsAndClassIds(database: SupportSQLiteDatabase): List<Pair<Int, Int>> {
|
private fun getStudentsAndClassIds(db: SupportSQLiteDatabase): List<Pair<Int, Int>> {
|
||||||
val students = mutableListOf<Pair<Int, Int>>()
|
val students = mutableListOf<Pair<Int, Int>>()
|
||||||
database.query("SELECT student_id, class_id FROM Students").use {
|
db.query("SELECT student_id, class_id FROM Students").use {
|
||||||
if (it.moveToFirst()) {
|
if (it.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
students.add(it.getInt(0) to it.getInt(1))
|
students.add(it.getInt(0) to it.getInt(1))
|
||||||
@ -55,14 +58,17 @@ class Migration13 : Migration(12, 13) {
|
|||||||
return students
|
return students
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun markAtLeastAndOnlyOneSemesterAtCurrent(database: SupportSQLiteDatabase, students: List<Pair<Int, Int>>) {
|
private fun markAtLeastAndOnlyOneSemesterAtCurrent(
|
||||||
|
db: SupportSQLiteDatabase,
|
||||||
|
students: List<Pair<Int, Int>>
|
||||||
|
) {
|
||||||
students.forEach { (studentId, classId) ->
|
students.forEach { (studentId, classId) ->
|
||||||
database.execSQL("UPDATE Semesters SET is_current = 0 WHERE student_id = '$studentId' AND class_id = '$classId'")
|
db.execSQL("UPDATE Semesters SET is_current = 0 WHERE student_id = '$studentId' AND class_id = '$classId'")
|
||||||
database.execSQL("UPDATE Semesters SET is_current = 1 WHERE id = (SELECT id FROM Semesters WHERE student_id = '$studentId' AND class_id = '$classId' ORDER BY semester_id DESC)")
|
db.execSQL("UPDATE Semesters SET is_current = 1 WHERE id = (SELECT id FROM Semesters WHERE student_id = '$studentId' AND class_id = '$classId' ORDER BY semester_id DESC)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clearMessagesTable(database: SupportSQLiteDatabase) {
|
private fun clearMessagesTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DELETE FROM Messages")
|
db.execSQL("DELETE FROM Messages")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,10 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration14 : Migration(13, 14) {
|
class Migration14 : Migration(13, 14) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS GradesSummary")
|
db.execSQL("DROP TABLE IF EXISTS GradesSummary")
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS GradesSummary (
|
CREATE TABLE IF NOT EXISTS GradesSummary (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
semester_id INTEGER NOT NULL,
|
semester_id INTEGER NOT NULL,
|
||||||
|
@ -5,8 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration15 : Migration(14, 15) {
|
class Migration15 : Migration(14, 15) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS MobileDevices (
|
CREATE TABLE IF NOT EXISTS MobileDevices (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
@ -14,6 +15,7 @@ class Migration15 : Migration(14, 15) {
|
|||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
date INTEGER NOT NULL
|
date INTEGER NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration16 : Migration(15, 16) {
|
class Migration16 : Migration(15, 16) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS Teachers (
|
CREATE TABLE IF NOT EXISTS Teachers (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
@ -15,6 +16,7 @@ class Migration16 : Migration(15, 16) {
|
|||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
short_name TEXT NOT NULL
|
short_name TEXT NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,14 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration17 : Migration(16, 17) {
|
class Migration17 : Migration(16, 17) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
createGradesPointsStatisticsTable(database)
|
createGradesPointsStatisticsTable(db)
|
||||||
truncateSemestersTable(database)
|
truncateSemestersTable(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createGradesPointsStatisticsTable(database: SupportSQLiteDatabase) {
|
private fun createGradesPointsStatisticsTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS GradesPointsStatistics(
|
CREATE TABLE IF NOT EXISTS GradesPointsStatistics(
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
@ -20,10 +21,11 @@ class Migration17 : Migration(16, 17) {
|
|||||||
others REAL NOT NULL,
|
others REAL NOT NULL,
|
||||||
student REAL NOT NULL
|
student REAL NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun truncateSemestersTable(database: SupportSQLiteDatabase) {
|
private fun truncateSemestersTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DELETE FROM Semesters")
|
db.execSQL("DELETE FROM Semesters")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration18 : Migration(17, 18) {
|
class Migration18 : Migration(17, 18) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS School (
|
CREATE TABLE IF NOT EXISTS School (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
|
@ -6,16 +6,17 @@ import io.github.wulkanowy.data.db.SharedPrefProvider
|
|||||||
|
|
||||||
class Migration19(private val sharedPrefProvider: SharedPrefProvider) : Migration(18, 19) {
|
class Migration19(private val sharedPrefProvider: SharedPrefProvider) : Migration(18, 19) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
migrateMessages(database)
|
migrateMessages(db)
|
||||||
migrateGrades(database)
|
migrateGrades(db)
|
||||||
migrateStudents(database)
|
migrateStudents(db)
|
||||||
migrateSharedPreferences()
|
migrateSharedPreferences()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateMessages(database: SupportSQLiteDatabase) {
|
private fun migrateMessages(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE Messages")
|
db.execSQL("DROP TABLE Messages")
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS Messages (
|
CREATE TABLE IF NOT EXISTS Messages (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
is_notified INTEGER NOT NULL,
|
is_notified INTEGER NOT NULL,
|
||||||
@ -34,12 +35,14 @@ class Migration19(private val sharedPrefProvider: SharedPrefProvider) : Migratio
|
|||||||
read_by INTEGER NOT NULL,
|
read_by INTEGER NOT NULL,
|
||||||
removed INTEGER NOT NULL
|
removed INTEGER NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateGrades(database: SupportSQLiteDatabase) {
|
private fun migrateGrades(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE Grades")
|
db.execSQL("DROP TABLE Grades")
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS Grades (
|
CREATE TABLE IF NOT EXISTS Grades (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
is_read INTEGER NOT NULL,
|
is_read INTEGER NOT NULL,
|
||||||
@ -59,11 +62,13 @@ class Migration19(private val sharedPrefProvider: SharedPrefProvider) : Migratio
|
|||||||
date INTEGER NOT NULL,
|
date INTEGER NOT NULL,
|
||||||
teacher TEXT NOT NULL
|
teacher TEXT NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateStudents(database: SupportSQLiteDatabase) {
|
private fun migrateStudents(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS Students_tmp (
|
CREATE TABLE IF NOT EXISTS Students_tmp (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
scrapper_base_url TEXT NOT NULL,
|
scrapper_base_url TEXT NOT NULL,
|
||||||
@ -86,26 +91,29 @@ class Migration19(private val sharedPrefProvider: SharedPrefProvider) : Migratio
|
|||||||
is_current INTEGER NOT NULL,
|
is_current INTEGER NOT NULL,
|
||||||
registration_date INTEGER NOT NULL
|
registration_date INTEGER NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN scrapperBaseUrl TEXT NOT NULL DEFAULT \"\";")
|
db.execSQL("ALTER TABLE Students ADD COLUMN scrapperBaseUrl TEXT NOT NULL DEFAULT \"\";")
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN apiBaseUrl TEXT NOT NULL DEFAULT \"\";")
|
db.execSQL("ALTER TABLE Students ADD COLUMN apiBaseUrl TEXT NOT NULL DEFAULT \"\";")
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN is_parent INT NOT NULL DEFAULT 0;")
|
db.execSQL("ALTER TABLE Students ADD COLUMN is_parent INT NOT NULL DEFAULT 0;")
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN loginMode TEXT NOT NULL DEFAULT \"\";")
|
db.execSQL("ALTER TABLE Students ADD COLUMN loginMode TEXT NOT NULL DEFAULT \"\";")
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN certificateKey TEXT NOT NULL DEFAULT \"\";")
|
db.execSQL("ALTER TABLE Students ADD COLUMN certificateKey TEXT NOT NULL DEFAULT \"\";")
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN privateKey TEXT NOT NULL DEFAULT \"\";")
|
db.execSQL("ALTER TABLE Students ADD COLUMN privateKey TEXT NOT NULL DEFAULT \"\";")
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN user_login_id INTEGER NOT NULL DEFAULT 0;")
|
db.execSQL("ALTER TABLE Students ADD COLUMN user_login_id INTEGER NOT NULL DEFAULT 0;")
|
||||||
|
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
INSERT INTO Students_tmp(
|
INSERT INTO Students_tmp(
|
||||||
id, scrapper_base_url, mobile_base_url, is_parent, login_type, login_mode, certificate_key, private_key, email, password, symbol, student_id, user_login_id, student_name, school_id, school_name, school_id, school_name, class_name, class_id, is_current, registration_date)
|
id, scrapper_base_url, mobile_base_url, is_parent, login_type, login_mode, certificate_key, private_key, email, password, symbol, student_id, user_login_id, student_name, school_id, school_name, school_id, school_name, class_name, class_id, is_current, registration_date)
|
||||||
SELECT
|
SELECT
|
||||||
id, endpoint, apiBaseUrl, is_parent, loginType, "SCRAPPER", certificateKey, privateKey, email, password, symbol, student_id, user_login_id, student_name, school_id, school_name, school_id, school_name, class_name, class_id, is_current, registration_date
|
id, endpoint, apiBaseUrl, is_parent, loginType, "SCRAPPER", certificateKey, privateKey, email, password, symbol, student_id, user_login_id, student_name, school_id, school_name, school_id, school_name, class_name, class_id, is_current, registration_date
|
||||||
FROM Students
|
FROM Students
|
||||||
""")
|
"""
|
||||||
database.execSQL("DROP TABLE Students")
|
)
|
||||||
database.execSQL("ALTER TABLE Students_tmp RENAME TO Students")
|
db.execSQL("DROP TABLE Students")
|
||||||
database.execSQL("CREATE UNIQUE INDEX index_Students_email_symbol_student_id_school_id_class_id ON Students (email, symbol, student_id, school_id, class_id)")
|
db.execSQL("ALTER TABLE Students_tmp RENAME TO Students")
|
||||||
|
db.execSQL("CREATE UNIQUE INDEX index_Students_email_symbol_student_id_school_id_class_id ON Students (email, symbol, student_id, school_id, class_id)")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateSharedPreferences() {
|
private fun migrateSharedPreferences() {
|
||||||
|
@ -5,14 +5,16 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration2 : Migration(1, 2) {
|
class Migration2 : Migration(1, 2) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS LuckyNumbers (
|
CREATE TABLE IF NOT EXISTS LuckyNumbers (
|
||||||
id INTEGER PRIMARY KEY NOT NULL,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
is_notified INTEGER NOT NULL,
|
is_notified INTEGER NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
date INTEGER NOT NULL,
|
date INTEGER NOT NULL,
|
||||||
lucky_number INTEGER NOT NULL)
|
lucky_number INTEGER NOT NULL)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,15 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration20 : Migration(19, 20) {
|
class Migration20 : Migration(19, 20) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
migrateTimetable(database)
|
migrateTimetable(db)
|
||||||
truncateSubjects(database)
|
truncateSubjects(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateTimetable(database: SupportSQLiteDatabase) {
|
private fun migrateTimetable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE Timetable")
|
db.execSQL("DROP TABLE Timetable")
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS `Timetable` (
|
CREATE TABLE IF NOT EXISTS `Timetable` (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
`student_id` INTEGER NOT NULL,
|
`student_id` INTEGER NOT NULL,
|
||||||
@ -33,10 +34,11 @@ class Migration20 : Migration(19, 20) {
|
|||||||
`changes` INTEGER NOT NULL,
|
`changes` INTEGER NOT NULL,
|
||||||
`canceled` INTEGER NOT NULL
|
`canceled` INTEGER NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun truncateSubjects(database: SupportSQLiteDatabase) {
|
private fun truncateSubjects(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DELETE FROM Subjects")
|
db.execSQL("DELETE FROM Subjects")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration21 : Migration(20, 21) {
|
class Migration21 : Migration(20, 21) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Attendance ADD COLUMN excusable INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE Attendance ADD COLUMN excusable INTEGER NOT NULL DEFAULT 0")
|
||||||
database.execSQL("ALTER TABLE Attendance ADD COLUMN time_id INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE Attendance ADD COLUMN time_id INTEGER NOT NULL DEFAULT 0")
|
||||||
database.execSQL("ALTER TABLE Attendance ADD COLUMN excuse_status TEXT DEFAULT NULL")
|
db.execSQL("ALTER TABLE Attendance ADD COLUMN excuse_status TEXT DEFAULT NULL")
|
||||||
|
|
||||||
database.execSQL("DELETE FROM Semesters")
|
db.execSQL("DELETE FROM Semesters")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration22 : Migration(21, 22) {
|
class Migration22 : Migration(21, 22) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN school_short TEXT NOT NULL DEFAULT ''")
|
db.execSQL("ALTER TABLE Students ADD COLUMN school_short TEXT NOT NULL DEFAULT ''")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration23 : Migration(22, 23) {
|
class Migration23 : Migration(22, 23) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Notes ADD COLUMN teacher_symbol TEXT NOT NULL DEFAULT ''")
|
db.execSQL("ALTER TABLE Notes ADD COLUMN teacher_symbol TEXT NOT NULL DEFAULT ''")
|
||||||
database.execSQL("ALTER TABLE Notes ADD COLUMN category_type INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE Notes ADD COLUMN category_type INTEGER NOT NULL DEFAULT 0")
|
||||||
database.execSQL("ALTER TABLE Notes ADD COLUMN is_points_show INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE Notes ADD COLUMN is_points_show INTEGER NOT NULL DEFAULT 0")
|
||||||
database.execSQL("ALTER TABLE Notes ADD COLUMN points INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE Notes ADD COLUMN points INTEGER NOT NULL DEFAULT 0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,10 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration24 : Migration(23, 24) {
|
class Migration24 : Migration(23, 24) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Messages ADD COLUMN has_attachments INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE Messages ADD COLUMN has_attachments INTEGER NOT NULL DEFAULT 0")
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS MessageAttachments (
|
CREATE TABLE IF NOT EXISTS MessageAttachments (
|
||||||
real_id INTEGER NOT NULL,
|
real_id INTEGER NOT NULL,
|
||||||
message_id INTEGER NOT NULL,
|
message_id INTEGER NOT NULL,
|
||||||
@ -16,6 +17,7 @@ class Migration24 : Migration(23, 24) {
|
|||||||
filename TEXT NOT NULL,
|
filename TEXT NOT NULL,
|
||||||
PRIMARY KEY(real_id)
|
PRIMARY KEY(real_id)
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration25 : Migration(24, 25) {
|
class Migration25 : Migration(24, 25) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Homework ADD COLUMN is_done INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE Homework ADD COLUMN is_done INTEGER NOT NULL DEFAULT 0")
|
||||||
database.execSQL("ALTER TABLE Homework ADD COLUMN attachments TEXT NOT NULL DEFAULT \"[]\"")
|
db.execSQL("ALTER TABLE Homework ADD COLUMN attachments TEXT NOT NULL DEFAULT \"[]\"")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration26 : Migration(25, 26) {
|
class Migration26 : Migration(25, 26) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE GradesSummary ADD COLUMN is_predicted_grade_notified INTEGER NOT NULL DEFAULT 1")
|
db.execSQL("ALTER TABLE GradesSummary ADD COLUMN is_predicted_grade_notified INTEGER NOT NULL DEFAULT 1")
|
||||||
database.execSQL("ALTER TABLE GradesSummary ADD COLUMN is_final_grade_notified INTEGER NOT NULL DEFAULT 1")
|
db.execSQL("ALTER TABLE GradesSummary ADD COLUMN is_final_grade_notified INTEGER NOT NULL DEFAULT 1")
|
||||||
database.execSQL("ALTER TABLE GradesSummary ADD COLUMN predicted_grade_last_change INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE GradesSummary ADD COLUMN predicted_grade_last_change INTEGER NOT NULL DEFAULT 0")
|
||||||
database.execSQL("ALTER TABLE GradesSummary ADD COLUMN final_grade_last_change INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE GradesSummary ADD COLUMN final_grade_last_change INTEGER NOT NULL DEFAULT 0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,24 +5,25 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration27 : Migration(26, 27) {
|
class Migration27 : Migration(26, 27) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN user_name TEXT NOT NULL DEFAULT \"\"")
|
db.execSQL("ALTER TABLE Students ADD COLUMN user_name TEXT NOT NULL DEFAULT \"\"")
|
||||||
|
|
||||||
val students = getStudentsIdsAndNames(database)
|
val students = getStudentsIdsAndNames(db)
|
||||||
val units = getReportingUnits(database)
|
val units = getReportingUnits(db)
|
||||||
|
|
||||||
students.forEach { (id, userLoginId, studentName) ->
|
students.forEach { (id, userLoginId, studentName) ->
|
||||||
val userNameFromUnits = units.singleOrNull { (senderId, _) -> senderId == userLoginId }?.second
|
val userNameFromUnits =
|
||||||
|
units.singleOrNull { (senderId, _) -> senderId == userLoginId }?.second
|
||||||
val normalizedStudentName = studentName.split(" ").asReversed().joinToString(" ")
|
val normalizedStudentName = studentName.split(" ").asReversed().joinToString(" ")
|
||||||
|
|
||||||
val userName = userNameFromUnits ?: normalizedStudentName
|
val userName = userNameFromUnits ?: normalizedStudentName
|
||||||
database.execSQL("UPDATE Students SET user_name = '$userName' WHERE id = '$id'")
|
db.execSQL("UPDATE Students SET user_name = '$userName' WHERE id = '$id'")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getStudentsIdsAndNames(database: SupportSQLiteDatabase): MutableList<Triple<Long, Int, String>> {
|
private fun getStudentsIdsAndNames(db: SupportSQLiteDatabase): MutableList<Triple<Long, Int, String>> {
|
||||||
val students = mutableListOf<Triple<Long, Int, String>>()
|
val students = mutableListOf<Triple<Long, Int, String>>()
|
||||||
database.query("SELECT id, user_login_id, student_name FROM Students").use {
|
db.query("SELECT id, user_login_id, student_name FROM Students").use {
|
||||||
if (it.moveToFirst()) {
|
if (it.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
students.add(Triple(it.getLong(0), it.getInt(1), it.getString(2)))
|
students.add(Triple(it.getLong(0), it.getInt(1), it.getString(2)))
|
||||||
@ -33,9 +34,9 @@ class Migration27 : Migration(26, 27) {
|
|||||||
return students
|
return students
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getReportingUnits(database: SupportSQLiteDatabase): MutableList<Pair<Int, String>> {
|
private fun getReportingUnits(db: SupportSQLiteDatabase): MutableList<Pair<Int, String>> {
|
||||||
val units = mutableListOf<Pair<Int, String>>()
|
val units = mutableListOf<Pair<Int, String>>()
|
||||||
database.query("SELECT sender_id, sender_name FROM ReportingUnits").use {
|
db.query("SELECT sender_id, sender_name FROM ReportingUnits").use {
|
||||||
if (it.moveToFirst()) {
|
if (it.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
units.add(it.getInt(0) to it.getString(1))
|
units.add(it.getInt(0) to it.getString(1))
|
||||||
|
@ -5,8 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration28 : Migration(27, 28) {
|
class Migration28 : Migration(27, 28) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS Conferences (
|
CREATE TABLE IF NOT EXISTS Conferences (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
|
@ -5,9 +5,10 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration29 : Migration(28, 29) {
|
class Migration29 : Migration(28, 29) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS GradesStatistics")
|
db.execSQL("DROP TABLE IF EXISTS GradesStatistics")
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS GradeSemesterStatistics (
|
CREATE TABLE IF NOT EXISTS GradeSemesterStatistics (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
@ -16,8 +17,10 @@ class Migration29 : Migration(28, 29) {
|
|||||||
amounts TEXT NOT NULL,
|
amounts TEXT NOT NULL,
|
||||||
student_grade INTEGER NOT NULL
|
student_grade INTEGER NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
database.execSQL("""
|
)
|
||||||
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS GradePartialStatistics (
|
CREATE TABLE IF NOT EXISTS GradePartialStatistics (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
|
@ -5,8 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration3 : Migration(2, 3) {
|
class Migration3 : Migration(2, 3) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS CompletedLesson (
|
CREATE TABLE IF NOT EXISTS CompletedLesson (
|
||||||
id INTEGER PRIMARY KEY NOT NULL,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
|
@ -5,8 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration30 : Migration(29, 30) {
|
class Migration30 : Migration(29, 30) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE TimetableAdditional (
|
CREATE TABLE TimetableAdditional (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
@ -16,6 +17,7 @@ class Migration30 : Migration(29, 30) {
|
|||||||
date INTEGER NOT NULL,
|
date INTEGER NOT NULL,
|
||||||
subject TEXT NOT NULL
|
subject TEXT NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration31 : Migration(30, 31) {
|
class Migration31 : Migration(30, 31) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""CREATE TABLE IF NOT EXISTS StudentInfo (
|
"""CREATE TABLE IF NOT EXISTS StudentInfo (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
|
@ -5,8 +5,8 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration32 : Migration(31, 32) {
|
class Migration32 : Migration(31, 32) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN nick TEXT NOT NULL DEFAULT \"\"")
|
db.execSQL("ALTER TABLE Students ADD COLUMN nick TEXT NOT NULL DEFAULT \"\"")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,10 +5,10 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration33 : Migration(32, 33) {
|
class Migration33 : Migration(32, 33) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS StudentInfo")
|
db.execSQL("DROP TABLE IF EXISTS StudentInfo")
|
||||||
|
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""CREATE TABLE IF NOT EXISTS StudentInfo (
|
"""CREATE TABLE IF NOT EXISTS StudentInfo (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
|
@ -5,9 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration34 : Migration(33, 34) {
|
class Migration34 : Migration(33, 34) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DELETE FROM ReportingUnits")
|
db.execSQL("DELETE FROM ReportingUnits")
|
||||||
database.execSQL("DELETE FROM Recipients")
|
db.execSQL("DELETE FROM Recipients")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@ import io.github.wulkanowy.utils.AppInfo
|
|||||||
|
|
||||||
class Migration35(private val appInfo: AppInfo) : Migration(34, 35) {
|
class Migration35(private val appInfo: AppInfo) : Migration(34, 35) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN `avatar_color` INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE Students ADD COLUMN `avatar_color` INTEGER NOT NULL DEFAULT 0")
|
||||||
|
|
||||||
database.query("SELECT * FROM Students").use {
|
db.query("SELECT * FROM Students").use {
|
||||||
while (it.moveToNext()) {
|
while (it.moveToNext()) {
|
||||||
val studentId = it.getLongOrNull(0)
|
val studentId = it.getLongOrNull(0)
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""
|
"""
|
||||||
UPDATE Students
|
UPDATE Students
|
||||||
SET avatar_color = ${appInfo.defaultColorsForAvatar.random()}
|
SET avatar_color = ${appInfo.defaultColorsForAvatar.random()}
|
||||||
|
@ -5,8 +5,8 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration36 : Migration(35, 36) {
|
class Migration36 : Migration(35, 36) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Exams ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
db.execSQL("ALTER TABLE Exams ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
||||||
database.execSQL("ALTER TABLE Homework ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
db.execSQL("ALTER TABLE Homework ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration37 : Migration(36, 37) {
|
class Migration37 : Migration(36, 37) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS TimetableHeaders (
|
CREATE TABLE IF NOT EXISTS TimetableHeaders (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
|
@ -5,8 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration38 : Migration(37, 38) {
|
class Migration38 : Migration(37, 38) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS `SchoolAnnouncements` (
|
CREATE TABLE IF NOT EXISTS `SchoolAnnouncements` (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
`student_id` INTEGER NOT NULL,
|
`student_id` INTEGER NOT NULL,
|
||||||
@ -14,6 +15,7 @@ class Migration38 : Migration(37, 38) {
|
|||||||
`subject` TEXT NOT NULL,
|
`subject` TEXT NOT NULL,
|
||||||
`content` TEXT NOT NULL
|
`content` TEXT NOT NULL
|
||||||
)
|
)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration39 : Migration(38, 39) {
|
class Migration39 : Migration(38, 39) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Conferences ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
db.execSQL("ALTER TABLE Conferences ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
||||||
database.execSQL("ALTER TABLE SchoolAnnouncements ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
db.execSQL("ALTER TABLE SchoolAnnouncements ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,9 +5,10 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration4 : Migration(3, 4) {
|
class Migration4 : Migration(3, 4) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS Messages")
|
db.execSQL("DROP TABLE IF EXISTS Messages")
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS Messages (
|
CREATE TABLE IF NOT EXISTS Messages (
|
||||||
id INTEGER PRIMARY KEY NOT NULL,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
is_notified INTEGER NOT NULL,
|
is_notified INTEGER NOT NULL,
|
||||||
|
@ -5,8 +5,8 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration40 : Migration(39, 40) {
|
class Migration40 : Migration(39, 40) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS `Notifications` (
|
CREATE TABLE IF NOT EXISTS `Notifications` (
|
||||||
`student_id` INTEGER NOT NULL,
|
`student_id` INTEGER NOT NULL,
|
||||||
|
@ -7,9 +7,9 @@ import io.github.wulkanowy.data.enums.GradeExpandMode
|
|||||||
|
|
||||||
class Migration41(private val sharedPrefProvider: SharedPrefProvider) : Migration(40, 41) {
|
class Migration41(private val sharedPrefProvider: SharedPrefProvider) : Migration(40, 41) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
migrateSharedPreferences()
|
migrateSharedPreferences()
|
||||||
database.execSQL("ALTER TABLE Homework ADD COLUMN is_added_by_user INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE Homework ADD COLUMN is_added_by_user INTEGER NOT NULL DEFAULT 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateSharedPreferences() {
|
private fun migrateSharedPreferences() {
|
||||||
|
@ -5,8 +5,8 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration42 : Migration(41, 42) {
|
class Migration42 : Migration(41, 42) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""CREATE TABLE IF NOT EXISTS `AdminMessages` (
|
"""CREATE TABLE IF NOT EXISTS `AdminMessages` (
|
||||||
`id` INTEGER NOT NULL,
|
`id` INTEGER NOT NULL,
|
||||||
`title` TEXT NOT NULL,
|
`title` TEXT NOT NULL,
|
||||||
|
@ -5,8 +5,8 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration43 : Migration(42, 43) {
|
class Migration43 : Migration(42, 43) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Timetable ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
db.execSQL("ALTER TABLE Timetable ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
||||||
database.execSQL("ALTER TABLE Attendance ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
db.execSQL("ALTER TABLE Attendance ADD COLUMN is_notified INTEGER NOT NULL DEFAULT 1")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration44 : Migration(43, 44) {
|
class Migration44 : Migration(43, 44) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE AdminMessages ADD COLUMN is_dismissible INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE AdminMessages ADD COLUMN is_dismissible INTEGER NOT NULL DEFAULT 0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,65 +8,65 @@ import java.time.ZoneOffset
|
|||||||
|
|
||||||
class Migration46 : Migration(45, 46) {
|
class Migration46 : Migration(45, 46) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
migrateConferences(database)
|
migrateConferences(db)
|
||||||
migrateMessages(database)
|
migrateMessages(db)
|
||||||
migrateMobileDevices(database)
|
migrateMobileDevices(db)
|
||||||
migrateNotifications(database)
|
migrateNotifications(db)
|
||||||
migrateTimetable(database)
|
migrateTimetable(db)
|
||||||
migrateTimetableAdditional(database)
|
migrateTimetableAdditional(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateConferences(database: SupportSQLiteDatabase) {
|
private fun migrateConferences(db: SupportSQLiteDatabase) {
|
||||||
database.query("SELECT * FROM Conferences").use {
|
db.query("SELECT * FROM Conferences").use {
|
||||||
while (it.moveToNext()) {
|
while (it.moveToNext()) {
|
||||||
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
||||||
val timestampLocal = it.getLong(it.getColumnIndexOrThrow("date"))
|
val timestampLocal = it.getLong(it.getColumnIndexOrThrow("date"))
|
||||||
val timestampUtc = timestampLocal.timestampLocalToUTC()
|
val timestampUtc = timestampLocal.timestampLocalToUTC()
|
||||||
|
|
||||||
database.execSQL("UPDATE Conferences SET date = $timestampUtc WHERE id = $id")
|
db.execSQL("UPDATE Conferences SET date = $timestampUtc WHERE id = $id")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateMessages(database: SupportSQLiteDatabase) {
|
private fun migrateMessages(db: SupportSQLiteDatabase) {
|
||||||
database.query("SELECT * FROM Messages").use {
|
db.query("SELECT * FROM Messages").use {
|
||||||
while (it.moveToNext()) {
|
while (it.moveToNext()) {
|
||||||
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
||||||
val timestampLocal = it.getLong(it.getColumnIndexOrThrow("date"))
|
val timestampLocal = it.getLong(it.getColumnIndexOrThrow("date"))
|
||||||
val timestampUtc = timestampLocal.timestampLocalToUTC()
|
val timestampUtc = timestampLocal.timestampLocalToUTC()
|
||||||
|
|
||||||
database.execSQL("UPDATE Messages SET date = $timestampUtc WHERE id = $id")
|
db.execSQL("UPDATE Messages SET date = $timestampUtc WHERE id = $id")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateMobileDevices(database: SupportSQLiteDatabase) {
|
private fun migrateMobileDevices(db: SupportSQLiteDatabase) {
|
||||||
database.query("SELECT * FROM MobileDevices").use {
|
db.query("SELECT * FROM MobileDevices").use {
|
||||||
while (it.moveToNext()) {
|
while (it.moveToNext()) {
|
||||||
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
||||||
val timestampLocal = it.getLong(it.getColumnIndexOrThrow("date"))
|
val timestampLocal = it.getLong(it.getColumnIndexOrThrow("date"))
|
||||||
val timestampUtc = timestampLocal.timestampLocalToUTC()
|
val timestampUtc = timestampLocal.timestampLocalToUTC()
|
||||||
|
|
||||||
database.execSQL("UPDATE MobileDevices SET date = $timestampUtc WHERE id = $id")
|
db.execSQL("UPDATE MobileDevices SET date = $timestampUtc WHERE id = $id")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateNotifications(database: SupportSQLiteDatabase) {
|
private fun migrateNotifications(db: SupportSQLiteDatabase) {
|
||||||
database.query("SELECT * FROM Notifications").use {
|
db.query("SELECT * FROM Notifications").use {
|
||||||
while (it.moveToNext()) {
|
while (it.moveToNext()) {
|
||||||
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
||||||
val timestampLocal = it.getLong(it.getColumnIndexOrThrow("date"))
|
val timestampLocal = it.getLong(it.getColumnIndexOrThrow("date"))
|
||||||
val timestampUtc = timestampLocal.timestampLocalToUTC()
|
val timestampUtc = timestampLocal.timestampLocalToUTC()
|
||||||
|
|
||||||
database.execSQL("UPDATE Notifications SET date = $timestampUtc WHERE id = $id")
|
db.execSQL("UPDATE Notifications SET date = $timestampUtc WHERE id = $id")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateTimetable(database: SupportSQLiteDatabase) {
|
private fun migrateTimetable(db: SupportSQLiteDatabase) {
|
||||||
database.query("SELECT * FROM Timetable").use {
|
db.query("SELECT * FROM Timetable").use {
|
||||||
while (it.moveToNext()) {
|
while (it.moveToNext()) {
|
||||||
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
||||||
val timestampLocalStart = it.getLong(it.getColumnIndexOrThrow("start"))
|
val timestampLocalStart = it.getLong(it.getColumnIndexOrThrow("start"))
|
||||||
@ -74,13 +74,13 @@ class Migration46 : Migration(45, 46) {
|
|||||||
val timestampUtcStart = timestampLocalStart.timestampLocalToUTC()
|
val timestampUtcStart = timestampLocalStart.timestampLocalToUTC()
|
||||||
val timestampUtcEnd = timestampLocalEnd.timestampLocalToUTC()
|
val timestampUtcEnd = timestampLocalEnd.timestampLocalToUTC()
|
||||||
|
|
||||||
database.execSQL("UPDATE Timetable SET start = $timestampUtcStart, end = $timestampUtcEnd WHERE id = $id")
|
db.execSQL("UPDATE Timetable SET start = $timestampUtcStart, end = $timestampUtcEnd WHERE id = $id")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateTimetableAdditional(database: SupportSQLiteDatabase) {
|
private fun migrateTimetableAdditional(db: SupportSQLiteDatabase) {
|
||||||
database.query("SELECT * FROM TimetableAdditional").use {
|
db.query("SELECT * FROM TimetableAdditional").use {
|
||||||
while (it.moveToNext()) {
|
while (it.moveToNext()) {
|
||||||
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
val id = it.getLong(it.getColumnIndexOrThrow("id"))
|
||||||
val timestampLocalStart = it.getLong(it.getColumnIndexOrThrow("start"))
|
val timestampLocalStart = it.getLong(it.getColumnIndexOrThrow("start"))
|
||||||
@ -88,7 +88,7 @@ class Migration46 : Migration(45, 46) {
|
|||||||
val timestampUtcStart = timestampLocalStart.timestampLocalToUTC()
|
val timestampUtcStart = timestampLocalStart.timestampLocalToUTC()
|
||||||
val timestampUtcEnd = timestampLocalEnd.timestampLocalToUTC()
|
val timestampUtcEnd = timestampLocalEnd.timestampLocalToUTC()
|
||||||
|
|
||||||
database.execSQL("UPDATE TimetableAdditional SET start = $timestampUtcStart, end = $timestampUtcEnd WHERE id = $id")
|
db.execSQL("UPDATE TimetableAdditional SET start = $timestampUtcStart, end = $timestampUtcEnd WHERE id = $id")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration49 : Migration(48, 49) {
|
class Migration49 : Migration(48, 49) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS SchoolAnnouncements")
|
db.execSQL("DROP TABLE IF EXISTS SchoolAnnouncements")
|
||||||
|
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS `SchoolAnnouncements` (
|
CREATE TABLE IF NOT EXISTS `SchoolAnnouncements` (
|
||||||
`user_login_id` INTEGER NOT NULL,
|
`user_login_id` INTEGER NOT NULL,
|
||||||
|
@ -7,11 +7,16 @@ import java.time.ZoneOffset
|
|||||||
|
|
||||||
class Migration5 : Migration(4, 5) {
|
class Migration5 : Migration(4, 5) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Students ADD COLUMN registration_date INTEGER DEFAULT 0 NOT NULL")
|
db.execSQL("ALTER TABLE Students ADD COLUMN registration_date INTEGER DEFAULT 0 NOT NULL")
|
||||||
database.execSQL("UPDATE Students SET registration_date = '${now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli()}'")
|
db.execSQL(
|
||||||
database.execSQL("DROP TABLE IF EXISTS Notes")
|
"UPDATE Students SET registration_date = '${
|
||||||
database.execSQL("""
|
now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli()
|
||||||
|
}'"
|
||||||
|
)
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS Notes")
|
||||||
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS Notes (
|
CREATE TABLE IF NOT EXISTS Notes (
|
||||||
id INTEGER PRIMARY KEY NOT NULL,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
is_read INTEGER NOT NULL,
|
is_read INTEGER NOT NULL,
|
||||||
@ -21,6 +26,7 @@ class Migration5 : Migration(4, 5) {
|
|||||||
teacher TEXT NOT NULL,
|
teacher TEXT NOT NULL,
|
||||||
category TEXT NOT NULL,
|
category TEXT NOT NULL,
|
||||||
content TEXT NOT NULL)
|
content TEXT NOT NULL)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration50 : Migration(49, 50) {
|
class Migration50 : Migration(49, 50) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS MobileDevices")
|
db.execSQL("DROP TABLE IF EXISTS MobileDevices")
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS `MobileDevices` (
|
CREATE TABLE IF NOT EXISTS `MobileDevices` (
|
||||||
`user_login_id` INTEGER NOT NULL,
|
`user_login_id` INTEGER NOT NULL,
|
||||||
|
@ -5,17 +5,17 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration51 : Migration(50, 51) {
|
class Migration51 : Migration(50, 51) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
createMailboxTable(database)
|
createMailboxTable(db)
|
||||||
recreateMessagesTable(database)
|
recreateMessagesTable(db)
|
||||||
recreateMessageAttachmentsTable(database)
|
recreateMessageAttachmentsTable(db)
|
||||||
recreateRecipientsTable(database)
|
recreateRecipientsTable(db)
|
||||||
deleteReportingUnitTable(database)
|
deleteReportingUnitTable(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createMailboxTable(database: SupportSQLiteDatabase) {
|
private fun createMailboxTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS Mailboxes")
|
db.execSQL("DROP TABLE IF EXISTS Mailboxes")
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS `Mailboxes` (
|
CREATE TABLE IF NOT EXISTS `Mailboxes` (
|
||||||
`globalKey` TEXT NOT NULL,
|
`globalKey` TEXT NOT NULL,
|
||||||
@ -30,9 +30,9 @@ class Migration51 : Migration(50, 51) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun recreateMessagesTable(database: SupportSQLiteDatabase) {
|
private fun recreateMessagesTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS Messages")
|
db.execSQL("DROP TABLE IF EXISTS Messages")
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS `Messages` (
|
CREATE TABLE IF NOT EXISTS `Messages` (
|
||||||
`message_global_key` TEXT NOT NULL,
|
`message_global_key` TEXT NOT NULL,
|
||||||
@ -52,9 +52,9 @@ class Migration51 : Migration(50, 51) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun recreateMessageAttachmentsTable(database: SupportSQLiteDatabase) {
|
private fun recreateMessageAttachmentsTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS MessageAttachments")
|
db.execSQL("DROP TABLE IF EXISTS MessageAttachments")
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS `MessageAttachments` (
|
CREATE TABLE IF NOT EXISTS `MessageAttachments` (
|
||||||
`real_id` INTEGER NOT NULL,
|
`real_id` INTEGER NOT NULL,
|
||||||
@ -66,9 +66,9 @@ class Migration51 : Migration(50, 51) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun recreateRecipientsTable(database: SupportSQLiteDatabase) {
|
private fun recreateRecipientsTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS Recipients")
|
db.execSQL("DROP TABLE IF EXISTS Recipients")
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS `Recipients` (
|
CREATE TABLE IF NOT EXISTS `Recipients` (
|
||||||
`mailboxGlobalKey` TEXT NOT NULL,
|
`mailboxGlobalKey` TEXT NOT NULL,
|
||||||
@ -82,7 +82,7 @@ class Migration51 : Migration(50, 51) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteReportingUnitTable(database: SupportSQLiteDatabase) {
|
private fun deleteReportingUnitTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS ReportingUnits")
|
db.execSQL("DROP TABLE IF EXISTS ReportingUnits")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,14 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration53 : Migration(52, 53) {
|
class Migration53 : Migration(52, 53) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
createMailboxTable(database)
|
createMailboxTable(db)
|
||||||
recreateMessagesTable(database)
|
recreateMessagesTable(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createMailboxTable(database: SupportSQLiteDatabase) {
|
private fun createMailboxTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS Mailboxes")
|
db.execSQL("DROP TABLE IF EXISTS Mailboxes")
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS `Mailboxes` (
|
CREATE TABLE IF NOT EXISTS `Mailboxes` (
|
||||||
`globalKey` TEXT NOT NULL,
|
`globalKey` TEXT NOT NULL,
|
||||||
@ -29,9 +29,9 @@ class Migration53 : Migration(52, 53) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun recreateMessagesTable(database: SupportSQLiteDatabase) {
|
private fun recreateMessagesTable(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS Messages")
|
db.execSQL("DROP TABLE IF EXISTS Messages")
|
||||||
database.execSQL(
|
db.execSQL(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS `Messages` (
|
CREATE TABLE IF NOT EXISTS `Messages` (
|
||||||
`email` TEXT NOT NULL,
|
`email` TEXT NOT NULL,
|
||||||
|
@ -5,22 +5,24 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration54 : Migration(53, 54) {
|
class Migration54 : Migration(53, 54) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
migrateResman(database)
|
migrateResman(db)
|
||||||
removeTomaszowMazowieckiStudents(database)
|
removeTomaszowMazowieckiStudents(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateResman(database: SupportSQLiteDatabase) {
|
private fun migrateResman(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
UPDATE Students SET
|
UPDATE Students SET
|
||||||
scrapper_base_url = 'https://vulcan.net.pl',
|
scrapper_base_url = 'https://vulcan.net.pl',
|
||||||
login_type = 'ADFSLightScoped',
|
login_type = 'ADFSLightScoped',
|
||||||
symbol = 'rzeszowprojekt'
|
symbol = 'rzeszowprojekt'
|
||||||
WHERE scrapper_base_url = 'https://resman.pl'
|
WHERE scrapper_base_url = 'https://resman.pl'
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun removeTomaszowMazowieckiStudents(database: SupportSQLiteDatabase) {
|
private fun removeTomaszowMazowieckiStudents(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DELETE FROM Students WHERE symbol = 'tomaszowmazowiecki'")
|
db.execSQL("DELETE FROM Students WHERE symbol = 'tomaszowmazowiecki'")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package io.github.wulkanowy.data.db.migrations
|
||||||
|
|
||||||
|
import androidx.room.DeleteColumn
|
||||||
|
import androidx.room.migration.AutoMigrationSpec
|
||||||
|
|
||||||
|
@DeleteColumn(
|
||||||
|
tableName = "AdminMessages",
|
||||||
|
columnName = "is_dismissible",
|
||||||
|
)
|
||||||
|
class Migration58 : AutoMigrationSpec
|
@ -5,8 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration6 : Migration(5, 6) {
|
class Migration6 : Migration(5, 6) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS ReportingUnits (
|
CREATE TABLE IF NOT EXISTS ReportingUnits (
|
||||||
id INTEGER PRIMARY KEY NOT NULL,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
@ -15,9 +16,11 @@ class Migration6 : Migration(5, 6) {
|
|||||||
sender_id INTEGER NOT NULL,
|
sender_id INTEGER NOT NULL,
|
||||||
sender_name TEXT NOT NULL,
|
sender_name TEXT NOT NULL,
|
||||||
roles TEXT NOT NULL)
|
roles TEXT NOT NULL)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS Recipients (
|
CREATE TABLE IF NOT EXISTS Recipients (
|
||||||
id INTEGER PRIMARY KEY NOT NULL,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
@ -28,10 +31,11 @@ class Migration6 : Migration(5, 6) {
|
|||||||
unit_id INTEGER NOT NULL,
|
unit_id INTEGER NOT NULL,
|
||||||
role INTEGER NOT NULL,
|
role INTEGER NOT NULL,
|
||||||
hash TEXT NOT NULL)
|
hash TEXT NOT NULL)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
database.execSQL("DELETE FROM Semesters WHERE 1")
|
db.execSQL("DELETE FROM Semesters WHERE 1")
|
||||||
database.execSQL("ALTER TABLE Semesters ADD COLUMN class_id INTEGER DEFAULT 0 NOT NULL")
|
db.execSQL("ALTER TABLE Semesters ADD COLUMN class_id INTEGER DEFAULT 0 NOT NULL")
|
||||||
database.execSQL("ALTER TABLE Semesters ADD COLUMN unit_id INTEGER DEFAULT 0 NOT NULL")
|
db.execSQL("ALTER TABLE Semesters ADD COLUMN unit_id INTEGER DEFAULT 0 NOT NULL")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration7 : Migration(6, 7) {
|
class Migration7 : Migration(6, 7) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS GradesStatistics (
|
CREATE TABLE IF NOT EXISTS GradesStatistics (
|
||||||
id INTEGER PRIMARY KEY NOT NULL,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
@ -15,6 +16,7 @@ class Migration7 : Migration(6, 7) {
|
|||||||
grade INTEGER NOT NULL,
|
grade INTEGER NOT NULL,
|
||||||
amount INTEGER NOT NULL,
|
amount INTEGER NOT NULL,
|
||||||
is_semester INTEGER NOT NULL)
|
is_semester INTEGER NOT NULL)
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration8 : Migration(7, 8) {
|
class Migration8 : Migration(7, 8) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE Timetable ADD COLUMN subjectOld TEXT DEFAULT \"\" NOT NULL")
|
db.execSQL("ALTER TABLE Timetable ADD COLUMN subjectOld TEXT DEFAULT \"\" NOT NULL")
|
||||||
database.execSQL("ALTER TABLE Timetable ADD COLUMN roomOld TEXT DEFAULT \"\" NOT NULL")
|
db.execSQL("ALTER TABLE Timetable ADD COLUMN roomOld TEXT DEFAULT \"\" NOT NULL")
|
||||||
database.execSQL("ALTER TABLE Timetable ADD COLUMN teacherOld TEXT DEFAULT \"\" NOT NULL")
|
db.execSQL("ALTER TABLE Timetable ADD COLUMN teacherOld TEXT DEFAULT \"\" NOT NULL")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,10 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
|
|
||||||
class Migration9 : Migration(8, 9) {
|
class Migration9 : Migration(8, 9) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(db: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS Messages")
|
db.execSQL("DROP TABLE IF EXISTS Messages")
|
||||||
database.execSQL("""
|
db.execSQL(
|
||||||
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS Messages (
|
CREATE TABLE IF NOT EXISTS Messages (
|
||||||
id INTEGER PRIMARY KEY NOT NULL,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
student_id INTEGER NOT NULL,
|
student_id INTEGER NOT NULL,
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package io.github.wulkanowy.data.mappers
|
package io.github.wulkanowy.data.mappers
|
||||||
|
|
||||||
import io.github.wulkanowy.data.db.entities.Grade
|
import io.github.wulkanowy.data.db.entities.Grade
|
||||||
|
import io.github.wulkanowy.data.db.entities.GradeDescriptive
|
||||||
import io.github.wulkanowy.data.db.entities.GradeSummary
|
import io.github.wulkanowy.data.db.entities.GradeSummary
|
||||||
import io.github.wulkanowy.data.db.entities.Semester
|
import io.github.wulkanowy.data.db.entities.Semester
|
||||||
import io.github.wulkanowy.sdk.pojo.GradeSummary as SdkGradeSummary
|
|
||||||
import io.github.wulkanowy.sdk.pojo.Grade as SdkGrade
|
import io.github.wulkanowy.sdk.pojo.Grade as SdkGrade
|
||||||
|
import io.github.wulkanowy.sdk.pojo.GradeDescriptive as SdkGradeDescriptive
|
||||||
|
import io.github.wulkanowy.sdk.pojo.GradeSummary as SdkGradeSummary
|
||||||
|
|
||||||
fun List<SdkGrade>.mapToEntities(semester: Semester) = map {
|
fun List<SdkGrade>.mapToEntities(semester: Semester) = map {
|
||||||
Grade(
|
Grade(
|
||||||
@ -40,3 +42,15 @@ fun List<SdkGradeSummary>.mapToEntities(semester: Semester) = map {
|
|||||||
average = it.average
|
average = it.average
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmName("mapGradeDescriptiveToEntities")
|
||||||
|
fun List<SdkGradeDescriptive>.mapToEntities(semester: Semester) = map {
|
||||||
|
GradeDescriptive(
|
||||||
|
semesterId = semester.semesterId,
|
||||||
|
studentId = semester.studentId,
|
||||||
|
subject = it.subject,
|
||||||
|
description = it.description
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package io.github.wulkanowy.data.pojos
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class LoginEvent(
|
||||||
|
val uuid: String,
|
||||||
|
val schoolName: String,
|
||||||
|
val schoolShort: String,
|
||||||
|
val schoolAddress: String,
|
||||||
|
val scraperBaseUrl: String,
|
||||||
|
val symbol: String,
|
||||||
|
val schoolId: String,
|
||||||
|
val loginType: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class IntegrityRequest<T>(
|
||||||
|
val tokenString: String,
|
||||||
|
val data: T,
|
||||||
|
)
|
@ -9,7 +9,13 @@ import io.github.wulkanowy.data.mappers.mapToEntities
|
|||||||
import io.github.wulkanowy.data.networkBoundResource
|
import io.github.wulkanowy.data.networkBoundResource
|
||||||
import io.github.wulkanowy.sdk.Sdk
|
import io.github.wulkanowy.sdk.Sdk
|
||||||
import io.github.wulkanowy.sdk.pojo.Absent
|
import io.github.wulkanowy.sdk.pojo.Absent
|
||||||
import io.github.wulkanowy.utils.*
|
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||||
|
import io.github.wulkanowy.utils.getRefreshKey
|
||||||
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.monday
|
||||||
|
import io.github.wulkanowy.utils.sunday
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
|
import io.github.wulkanowy.utils.uniqueSubtract
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
@ -58,7 +64,7 @@ class AttendanceRepository @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getAttendance(start.monday, end.sunday)
|
.getAttendance(start.monday, end.sunday)
|
||||||
.mapToEntities(semester, lessons)
|
.mapToEntities(semester, lessons)
|
||||||
},
|
},
|
||||||
@ -97,7 +103,7 @@ class AttendanceRepository @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.excuseForAbsence(items, reason)
|
.excuseForAbsence(items, reason)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import io.github.wulkanowy.sdk.Sdk
|
|||||||
import io.github.wulkanowy.utils.AutoRefreshHelper
|
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||||
import io.github.wulkanowy.utils.getRefreshKey
|
import io.github.wulkanowy.utils.getRefreshKey
|
||||||
import io.github.wulkanowy.utils.init
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
import io.github.wulkanowy.utils.uniqueSubtract
|
import io.github.wulkanowy.utils.uniqueSubtract
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -40,7 +41,7 @@ class AttendanceSummaryRepository @Inject constructor(
|
|||||||
query = { attendanceDb.loadAll(semester.diaryId, semester.studentId, subjectId) },
|
query = { attendanceDb.loadAll(semester.diaryId, semester.studentId, subjectId) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getAttendanceSummary(subjectId)
|
.getAttendanceSummary(subjectId)
|
||||||
.mapToEntities(semester, subjectId)
|
.mapToEntities(semester, subjectId)
|
||||||
},
|
},
|
||||||
|
@ -48,7 +48,7 @@ class CompletedLessonsRepository @Inject constructor(
|
|||||||
},
|
},
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getCompletedLessons(start.monday, end.sunday)
|
.getCompletedLessons(start.monday, end.sunday)
|
||||||
.mapToEntities(semester)
|
.mapToEntities(semester)
|
||||||
},
|
},
|
||||||
|
@ -10,6 +10,7 @@ import io.github.wulkanowy.sdk.Sdk
|
|||||||
import io.github.wulkanowy.utils.AutoRefreshHelper
|
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||||
import io.github.wulkanowy.utils.getRefreshKey
|
import io.github.wulkanowy.utils.getRefreshKey
|
||||||
import io.github.wulkanowy.utils.init
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
import io.github.wulkanowy.utils.uniqueSubtract
|
import io.github.wulkanowy.utils.uniqueSubtract
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
@ -46,7 +47,7 @@ class ConferenceRepository @Inject constructor(
|
|||||||
},
|
},
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getConferences()
|
.getConferences()
|
||||||
.mapToEntities(semester)
|
.mapToEntities(semester)
|
||||||
.filter { it.date >= startDate }
|
.filter { it.date >= startDate }
|
||||||
|
@ -7,7 +7,13 @@ import io.github.wulkanowy.data.db.entities.Student
|
|||||||
import io.github.wulkanowy.data.mappers.mapToEntities
|
import io.github.wulkanowy.data.mappers.mapToEntities
|
||||||
import io.github.wulkanowy.data.networkBoundResource
|
import io.github.wulkanowy.data.networkBoundResource
|
||||||
import io.github.wulkanowy.sdk.Sdk
|
import io.github.wulkanowy.sdk.Sdk
|
||||||
import io.github.wulkanowy.utils.*
|
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||||
|
import io.github.wulkanowy.utils.endExamsDay
|
||||||
|
import io.github.wulkanowy.utils.getRefreshKey
|
||||||
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.startExamsDay
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
|
import io.github.wulkanowy.utils.uniqueSubtract
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
@ -51,7 +57,7 @@ class ExamRepository @Inject constructor(
|
|||||||
},
|
},
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getExams(start.startExamsDay, start.endExamsDay)
|
.getExams(start.startExamsDay, start.endExamsDay)
|
||||||
.mapToEntities(semester)
|
.mapToEntities(semester)
|
||||||
},
|
},
|
||||||
@ -67,14 +73,16 @@ class ExamRepository @Inject constructor(
|
|||||||
filterResult = { it.filter { item -> item.date in start..end } }
|
filterResult = { it.filter { item -> item.date in start..end } }
|
||||||
)
|
)
|
||||||
|
|
||||||
fun getExamsFromDatabase(semester: Semester, start: LocalDate): Flow<List<Exam>> {
|
fun getExamsFromDatabase(
|
||||||
return examDb.loadAll(
|
semester: Semester,
|
||||||
|
start: LocalDate,
|
||||||
|
end: LocalDate
|
||||||
|
): Flow<List<Exam>> = examDb.loadAll(
|
||||||
diaryId = semester.diaryId,
|
diaryId = semester.diaryId,
|
||||||
studentId = semester.studentId,
|
studentId = semester.studentId,
|
||||||
from = start.startExamsDay,
|
from = start,
|
||||||
end = start.endExamsDay
|
end = end,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun updateExam(exam: List<Exam>) = examDb.updateAll(exam)
|
suspend fun updateExam(exam: List<Exam>) = examDb.updateAll(exam)
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,22 @@
|
|||||||
package io.github.wulkanowy.data.repositories
|
package io.github.wulkanowy.data.repositories
|
||||||
|
|
||||||
import io.github.wulkanowy.data.db.dao.GradeDao
|
import io.github.wulkanowy.data.db.dao.GradeDao
|
||||||
|
import io.github.wulkanowy.data.db.dao.GradeDescriptiveDao
|
||||||
import io.github.wulkanowy.data.db.dao.GradeSummaryDao
|
import io.github.wulkanowy.data.db.dao.GradeSummaryDao
|
||||||
import io.github.wulkanowy.data.db.entities.Grade
|
import io.github.wulkanowy.data.db.entities.Grade
|
||||||
|
import io.github.wulkanowy.data.db.entities.GradeDescriptive
|
||||||
import io.github.wulkanowy.data.db.entities.GradeSummary
|
import io.github.wulkanowy.data.db.entities.GradeSummary
|
||||||
import io.github.wulkanowy.data.db.entities.Semester
|
import io.github.wulkanowy.data.db.entities.Semester
|
||||||
import io.github.wulkanowy.data.db.entities.Student
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
import io.github.wulkanowy.data.mappers.mapToEntities
|
import io.github.wulkanowy.data.mappers.mapToEntities
|
||||||
import io.github.wulkanowy.data.networkBoundResource
|
import io.github.wulkanowy.data.networkBoundResource
|
||||||
import io.github.wulkanowy.sdk.Sdk
|
import io.github.wulkanowy.sdk.Sdk
|
||||||
import io.github.wulkanowy.utils.*
|
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||||
|
import io.github.wulkanowy.utils.getRefreshKey
|
||||||
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
|
import io.github.wulkanowy.utils.toLocalDate
|
||||||
|
import io.github.wulkanowy.utils.uniqueSubtract
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
@ -22,14 +29,13 @@ import javax.inject.Singleton
|
|||||||
class GradeRepository @Inject constructor(
|
class GradeRepository @Inject constructor(
|
||||||
private val gradeDb: GradeDao,
|
private val gradeDb: GradeDao,
|
||||||
private val gradeSummaryDb: GradeSummaryDao,
|
private val gradeSummaryDb: GradeSummaryDao,
|
||||||
|
private val gradeDescriptiveDb: GradeDescriptiveDao,
|
||||||
private val sdk: Sdk,
|
private val sdk: Sdk,
|
||||||
private val refreshHelper: AutoRefreshHelper,
|
private val refreshHelper: AutoRefreshHelper,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val saveFetchResultMutex = Mutex()
|
private val saveFetchResultMutex = Mutex()
|
||||||
|
|
||||||
private val cacheKey = "grade"
|
|
||||||
|
|
||||||
fun getGrades(
|
fun getGrades(
|
||||||
student: Student,
|
student: Student,
|
||||||
semester: Semester,
|
semester: Semester,
|
||||||
@ -41,30 +47,52 @@ class GradeRepository @Inject constructor(
|
|||||||
//When details is empty and summary is not, app will not use summary cache - edge case
|
//When details is empty and summary is not, app will not use summary cache - edge case
|
||||||
it.first.isEmpty()
|
it.first.isEmpty()
|
||||||
},
|
},
|
||||||
shouldFetch = { (details, summaries) ->
|
shouldFetch = { (details, summaries, descriptive) ->
|
||||||
val isExpired = refreshHelper.shouldBeRefreshed(getRefreshKey(cacheKey, semester))
|
val isExpired =
|
||||||
details.isEmpty() || summaries.isEmpty() || forceRefresh || isExpired
|
refreshHelper.shouldBeRefreshed(getRefreshKey(GRADE_CACHE_KEY, semester))
|
||||||
|
details.isEmpty() || (summaries.isEmpty() && descriptive.isEmpty()) || forceRefresh || isExpired
|
||||||
},
|
},
|
||||||
query = {
|
query = {
|
||||||
val detailsFlow = gradeDb.loadAll(semester.semesterId, semester.studentId)
|
val detailsFlow = gradeDb.loadAll(semester.semesterId, semester.studentId)
|
||||||
val summaryFlow = gradeSummaryDb.loadAll(semester.semesterId, semester.studentId)
|
val summaryFlow = gradeSummaryDb.loadAll(semester.semesterId, semester.studentId)
|
||||||
detailsFlow.combine(summaryFlow) { details, summaries -> details to summaries }
|
val descriptiveFlow =
|
||||||
|
gradeDescriptiveDb.loadAll(semester.semesterId, semester.studentId)
|
||||||
|
|
||||||
|
combine(detailsFlow, summaryFlow, descriptiveFlow) { details, summaries, descriptive ->
|
||||||
|
Triple(details, summaries, descriptive)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fetch = {
|
fetch = {
|
||||||
val (details, summary) = sdk.init(student)
|
val (details, summary, descriptive) = sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getGrades(semester.semesterId)
|
.getGrades(semester.semesterId)
|
||||||
|
|
||||||
details.mapToEntities(semester) to summary.mapToEntities(semester)
|
Triple(
|
||||||
|
details.mapToEntities(semester),
|
||||||
|
summary.mapToEntities(semester),
|
||||||
|
descriptive.mapToEntities(semester)
|
||||||
|
)
|
||||||
},
|
},
|
||||||
saveFetchResult = { (oldDetails, oldSummary), (newDetails, newSummary) ->
|
saveFetchResult = { (oldDetails, oldSummary, oldDescriptive), (newDetails, newSummary, newDescriptive) ->
|
||||||
refreshGradeDetails(student, oldDetails, newDetails, notify)
|
refreshGradeDetails(student, oldDetails, newDetails, notify)
|
||||||
refreshGradeSummaries(oldSummary, newSummary, notify)
|
refreshGradeSummaries(oldSummary, newSummary, notify)
|
||||||
|
refreshGradeDescriptions(oldDescriptive, newDescriptive, notify)
|
||||||
|
|
||||||
refreshHelper.updateLastRefreshTimestamp(getRefreshKey(cacheKey, semester))
|
refreshHelper.updateLastRefreshTimestamp(getRefreshKey(GRADE_CACHE_KEY, semester))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private suspend fun refreshGradeDescriptions(
|
||||||
|
old: List<GradeDescriptive>,
|
||||||
|
new: List<GradeDescriptive>,
|
||||||
|
notify: Boolean
|
||||||
|
) {
|
||||||
|
gradeDescriptiveDb.deleteAll(old uniqueSubtract new)
|
||||||
|
gradeDescriptiveDb.insertAll((new uniqueSubtract old).onEach {
|
||||||
|
if (notify) it.isNotified = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun refreshGradeDetails(
|
private suspend fun refreshGradeDetails(
|
||||||
student: Student,
|
student: Student,
|
||||||
oldGrades: List<Grade>,
|
oldGrades: List<Grade>,
|
||||||
@ -132,6 +160,10 @@ class GradeRepository @Inject constructor(
|
|||||||
return gradeSummaryDb.loadAll(semester.semesterId, semester.studentId)
|
return gradeSummaryDb.loadAll(semester.semesterId, semester.studentId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getGradesDescriptiveFromDatabase(semester: Semester): Flow<List<GradeDescriptive>> {
|
||||||
|
return gradeDescriptiveDb.loadAll(semester.semesterId, semester.studentId)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun updateGrade(grade: Grade) {
|
suspend fun updateGrade(grade: Grade) {
|
||||||
return gradeDb.updateAll(listOf(grade))
|
return gradeDb.updateAll(listOf(grade))
|
||||||
}
|
}
|
||||||
@ -143,4 +175,13 @@ class GradeRepository @Inject constructor(
|
|||||||
suspend fun updateGradesSummary(gradesSummary: List<GradeSummary>) {
|
suspend fun updateGradesSummary(gradesSummary: List<GradeSummary>) {
|
||||||
return gradeSummaryDb.updateAll(gradesSummary)
|
return gradeSummaryDb.updateAll(gradesSummary)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun updateGradesDescriptive(gradesDescriptive: List<GradeDescriptive>) {
|
||||||
|
return gradeDescriptiveDb.updateAll(gradesDescriptive)
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
|
||||||
|
private const val GRADE_CACHE_KEY = "grade"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import io.github.wulkanowy.sdk.Sdk
|
|||||||
import io.github.wulkanowy.utils.AutoRefreshHelper
|
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||||
import io.github.wulkanowy.utils.getRefreshKey
|
import io.github.wulkanowy.utils.getRefreshKey
|
||||||
import io.github.wulkanowy.utils.init
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
import io.github.wulkanowy.utils.uniqueSubtract
|
import io.github.wulkanowy.utils.uniqueSubtract
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -56,7 +57,7 @@ class GradeStatisticsRepository @Inject constructor(
|
|||||||
query = { gradePartialStatisticsDb.loadAll(semester.semesterId, semester.studentId) },
|
query = { gradePartialStatisticsDb.loadAll(semester.semesterId, semester.studentId) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getGradesPartialStatistics(semester.semesterId)
|
.getGradesPartialStatistics(semester.semesterId)
|
||||||
.mapToEntities(semester)
|
.mapToEntities(semester)
|
||||||
},
|
},
|
||||||
@ -101,7 +102,7 @@ class GradeStatisticsRepository @Inject constructor(
|
|||||||
query = { gradeSemesterStatisticsDb.loadAll(semester.semesterId, semester.studentId) },
|
query = { gradeSemesterStatisticsDb.loadAll(semester.semesterId, semester.studentId) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getGradesSemesterStatistics(semester.semesterId)
|
.getGradesSemesterStatistics(semester.semesterId)
|
||||||
.mapToEntities(semester)
|
.mapToEntities(semester)
|
||||||
},
|
},
|
||||||
@ -157,7 +158,7 @@ class GradeStatisticsRepository @Inject constructor(
|
|||||||
query = { gradePointsStatisticsDb.loadAll(semester.semesterId, semester.studentId) },
|
query = { gradePointsStatisticsDb.loadAll(semester.semesterId, semester.studentId) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getGradesPointsStatistics(semester.semesterId)
|
.getGradesPointsStatistics(semester.semesterId)
|
||||||
.mapToEntities(semester)
|
.mapToEntities(semester)
|
||||||
},
|
},
|
||||||
|
@ -7,7 +7,13 @@ import io.github.wulkanowy.data.db.entities.Student
|
|||||||
import io.github.wulkanowy.data.mappers.mapToEntities
|
import io.github.wulkanowy.data.mappers.mapToEntities
|
||||||
import io.github.wulkanowy.data.networkBoundResource
|
import io.github.wulkanowy.data.networkBoundResource
|
||||||
import io.github.wulkanowy.sdk.Sdk
|
import io.github.wulkanowy.sdk.Sdk
|
||||||
import io.github.wulkanowy.utils.*
|
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||||
|
import io.github.wulkanowy.utils.getRefreshKey
|
||||||
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.monday
|
||||||
|
import io.github.wulkanowy.utils.sunday
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
|
import io.github.wulkanowy.utils.uniqueSubtract
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -50,7 +56,7 @@ class HomeworkRepository @Inject constructor(
|
|||||||
},
|
},
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getHomework(start.monday, end.sunday)
|
.getHomework(start.monday, end.sunday)
|
||||||
.mapToEntities(semester)
|
.mapToEntities(semester)
|
||||||
},
|
},
|
||||||
|
@ -35,12 +35,15 @@ class LuckyNumberRepository @Inject constructor(
|
|||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student).getLuckyNumber(student.schoolShortName)?.mapToEntity(student)
|
sdk.init(student).getLuckyNumber(student.schoolShortName)?.mapToEntity(student)
|
||||||
},
|
},
|
||||||
saveFetchResult = { old, new ->
|
saveFetchResult = { oldLuckyNumber, newLuckyNumber ->
|
||||||
if (new != old) {
|
newLuckyNumber ?: return@networkBoundResource
|
||||||
old?.let { luckyNumberDb.deleteAll(listOfNotNull(it)) }
|
|
||||||
luckyNumberDb.insertAll(listOfNotNull((new?.apply {
|
if (newLuckyNumber != oldLuckyNumber) {
|
||||||
if (notify) isNotified = false
|
val updatedLuckNumberList =
|
||||||
})))
|
listOf(newLuckyNumber.apply { if (notify) isNotified = false })
|
||||||
|
|
||||||
|
oldLuckyNumber?.let { luckyNumberDb.deleteAll(listOfNotNull(it)) }
|
||||||
|
luckyNumberDb.insertAll(updatedLuckNumberList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -12,6 +12,7 @@ import io.github.wulkanowy.sdk.Sdk
|
|||||||
import io.github.wulkanowy.utils.AutoRefreshHelper
|
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||||
import io.github.wulkanowy.utils.getRefreshKey
|
import io.github.wulkanowy.utils.getRefreshKey
|
||||||
import io.github.wulkanowy.utils.init
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
import io.github.wulkanowy.utils.uniqueSubtract
|
import io.github.wulkanowy.utils.uniqueSubtract
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -42,7 +43,7 @@ class MobileDeviceRepository @Inject constructor(
|
|||||||
query = { mobileDb.loadAll(student.userLoginId) },
|
query = { mobileDb.loadAll(student.userLoginId) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getRegisteredDevices()
|
.getRegisteredDevices()
|
||||||
.mapToEntities(student)
|
.mapToEntities(student)
|
||||||
},
|
},
|
||||||
@ -56,7 +57,7 @@ class MobileDeviceRepository @Inject constructor(
|
|||||||
|
|
||||||
suspend fun unregisterDevice(student: Student, semester: Semester, device: MobileDevice) {
|
suspend fun unregisterDevice(student: Student, semester: Semester, device: MobileDevice) {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.unregisterDevice(device.deviceId)
|
.unregisterDevice(device.deviceId)
|
||||||
|
|
||||||
mobileDb.deleteAll(listOf(device))
|
mobileDb.deleteAll(listOf(device))
|
||||||
@ -64,7 +65,7 @@ class MobileDeviceRepository @Inject constructor(
|
|||||||
|
|
||||||
suspend fun getToken(student: Student, semester: Semester): MobileDeviceToken {
|
suspend fun getToken(student: Student, semester: Semester): MobileDeviceToken {
|
||||||
return sdk.init(student)
|
return sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getToken()
|
.getToken()
|
||||||
.mapToMobileDeviceToken()
|
.mapToMobileDeviceToken()
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class NoteRepository @Inject constructor(
|
|||||||
query = { noteDb.loadAll(student.studentId) },
|
query = { noteDb.loadAll(student.studentId) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getNotes()
|
.getNotes()
|
||||||
.mapToEntities(semester)
|
.mapToEntities(semester)
|
||||||
},
|
},
|
||||||
|
@ -9,7 +9,12 @@ import com.fredporciuncula.flow.preferences.Preference
|
|||||||
import com.fredporciuncula.flow.preferences.Serializer
|
import com.fredporciuncula.flow.preferences.Serializer
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.enums.*
|
import io.github.wulkanowy.data.enums.AppTheme
|
||||||
|
import io.github.wulkanowy.data.enums.GradeColorTheme
|
||||||
|
import io.github.wulkanowy.data.enums.GradeExpandMode
|
||||||
|
import io.github.wulkanowy.data.enums.GradeSortingMode
|
||||||
|
import io.github.wulkanowy.data.enums.TimetableGapsMode
|
||||||
|
import io.github.wulkanowy.data.enums.TimetableMode
|
||||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
||||||
import io.github.wulkanowy.ui.modules.grade.GradeAverageMode
|
import io.github.wulkanowy.ui.modules.grade.GradeAverageMode
|
||||||
import io.github.wulkanowy.ui.modules.settings.appearance.menuorder.AppMenuItem
|
import io.github.wulkanowy.ui.modules.settings.appearance.menuorder.AppMenuItem
|
||||||
@ -18,7 +23,7 @@ import kotlinx.coroutines.flow.map
|
|||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.util.*
|
import java.util.UUID
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@ -194,12 +199,6 @@ class PreferencesRepository @Inject constructor(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val showTimetableTimers: Boolean
|
|
||||||
get() = getBoolean(
|
|
||||||
R.string.pref_key_timetable_show_timers,
|
|
||||||
R.bool.pref_default_timetable_show_timers
|
|
||||||
)
|
|
||||||
|
|
||||||
val showTimetableGaps: TimetableGapsMode
|
val showTimetableGaps: TimetableGapsMode
|
||||||
get() = TimetableGapsMode.getByValue(
|
get() = TimetableGapsMode.getByValue(
|
||||||
getString(
|
getString(
|
||||||
@ -309,19 +308,6 @@ class PreferencesRepository @Inject constructor(
|
|||||||
get() = sharedPref.getBoolean(PREF_KEY_APP_SUPPORT_SHOWN, false)
|
get() = sharedPref.getBoolean(PREF_KEY_APP_SUPPORT_SHOWN, false)
|
||||||
set(value) = sharedPref.edit { putBoolean(PREF_KEY_APP_SUPPORT_SHOWN, value) }
|
set(value) = sharedPref.edit { putBoolean(PREF_KEY_APP_SUPPORT_SHOWN, value) }
|
||||||
|
|
||||||
var isAgreeToProcessData: Boolean
|
|
||||||
get() = getBoolean(
|
|
||||||
R.string.pref_key_ads_consent_data_processing,
|
|
||||||
R.bool.pref_default_ads_consent_data_processing
|
|
||||||
)
|
|
||||||
set(value) = sharedPref.edit {
|
|
||||||
putBoolean(context.getString(R.string.pref_key_ads_consent_data_processing), value)
|
|
||||||
}
|
|
||||||
|
|
||||||
var isPersonalizedAdsEnabled: Boolean
|
|
||||||
get() = sharedPref.getBoolean(PREF_KEY_PERSONALIZED_ADS_ENABLED, false)
|
|
||||||
set(value) = sharedPref.edit { putBoolean(PREF_KEY_PERSONALIZED_ADS_ENABLED, value) }
|
|
||||||
|
|
||||||
val isAdsEnabledFlow = flowSharedPref.getBoolean(
|
val isAdsEnabledFlow = flowSharedPref.getBoolean(
|
||||||
context.getString(R.string.pref_key_ads_enabled),
|
context.getString(R.string.pref_key_ads_enabled),
|
||||||
context.resources.getBoolean(R.bool.pref_default_ads_enabled)
|
context.resources.getBoolean(R.bool.pref_default_ads_enabled)
|
||||||
@ -404,7 +390,6 @@ class PreferencesRepository @Inject constructor(
|
|||||||
private const val PREF_KEY_IN_APP_REVIEW_DATE = "in_app_review_date"
|
private const val PREF_KEY_IN_APP_REVIEW_DATE = "in_app_review_date"
|
||||||
private const val PREF_KEY_IN_APP_REVIEW_DONE = "in_app_review_done"
|
private const val PREF_KEY_IN_APP_REVIEW_DONE = "in_app_review_done"
|
||||||
private const val PREF_KEY_APP_SUPPORT_SHOWN = "app_support_shown"
|
private const val PREF_KEY_APP_SUPPORT_SHOWN = "app_support_shown"
|
||||||
private const val PREF_KEY_PERSONALIZED_ADS_ENABLED = "personalized_ads_enabled"
|
|
||||||
private const val PREF_KEY_ADMIN_DISMISSED_MESSAGE_IDS = "admin_message_dismissed_ids"
|
private const val PREF_KEY_ADMIN_DISMISSED_MESSAGE_IDS = "admin_message_dismissed_ids"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import io.github.wulkanowy.sdk.Sdk
|
|||||||
import io.github.wulkanowy.utils.AutoRefreshHelper
|
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||||
import io.github.wulkanowy.utils.getRefreshKey
|
import io.github.wulkanowy.utils.getRefreshKey
|
||||||
import io.github.wulkanowy.utils.init
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
@ -40,7 +41,7 @@ class SchoolRepository @Inject constructor(
|
|||||||
query = { schoolDb.load(semester.studentId, semester.classId) },
|
query = { schoolDb.load(semester.studentId, semester.classId) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getSchool()
|
.getSchool()
|
||||||
.mapToEntity(semester)
|
.mapToEntity(semester)
|
||||||
},
|
},
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
package io.github.wulkanowy.data.repositories
|
||||||
|
|
||||||
|
import io.github.wulkanowy.data.api.SchoolsService
|
||||||
|
import io.github.wulkanowy.data.db.entities.Semester
|
||||||
|
import io.github.wulkanowy.data.db.entities.Student
|
||||||
|
import io.github.wulkanowy.data.db.entities.StudentWithSemesters
|
||||||
|
import io.github.wulkanowy.data.pojos.IntegrityRequest
|
||||||
|
import io.github.wulkanowy.data.pojos.LoginEvent
|
||||||
|
import io.github.wulkanowy.sdk.Sdk
|
||||||
|
import io.github.wulkanowy.ui.modules.login.LoginData
|
||||||
|
import io.github.wulkanowy.utils.IntegrityHelper
|
||||||
|
import io.github.wulkanowy.utils.getCurrentOrLast
|
||||||
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
|
import kotlinx.coroutines.withTimeout
|
||||||
|
import timber.log.Timber
|
||||||
|
import java.util.UUID
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class SchoolsRepository @Inject constructor(
|
||||||
|
private val integrityHelper: IntegrityHelper,
|
||||||
|
private val schoolsService: SchoolsService,
|
||||||
|
private val sdk: Sdk,
|
||||||
|
) {
|
||||||
|
|
||||||
|
suspend fun logSchoolLogin(loginData: LoginData, students: List<StudentWithSemesters>) {
|
||||||
|
students.forEach {
|
||||||
|
runCatching {
|
||||||
|
withTimeout(10.seconds) {
|
||||||
|
logLogin(loginData, it.student, it.semesters.getCurrentOrLast())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onFailure { Timber.e(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun logLogin(loginData: LoginData, student: Student, semester: Semester) {
|
||||||
|
val requestId = UUID.randomUUID().toString()
|
||||||
|
val token = integrityHelper.getIntegrityToken(requestId) ?: return
|
||||||
|
|
||||||
|
val schoolInfo = sdk
|
||||||
|
.init(student.copy(password = loginData.password))
|
||||||
|
.switchSemester(semester)
|
||||||
|
.getSchool()
|
||||||
|
|
||||||
|
schoolsService.logLoginEvent(
|
||||||
|
IntegrityRequest(
|
||||||
|
tokenString = token,
|
||||||
|
data = LoginEvent(
|
||||||
|
uuid = requestId,
|
||||||
|
schoolAddress = schoolInfo.address,
|
||||||
|
schoolName = schoolInfo.name,
|
||||||
|
schoolShort = student.schoolShortName,
|
||||||
|
scraperBaseUrl = student.scrapperBaseUrl,
|
||||||
|
loginType = student.loginType,
|
||||||
|
symbol = student.symbol,
|
||||||
|
schoolId = student.schoolSymbol,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ import io.github.wulkanowy.data.mappers.mapToEntity
|
|||||||
import io.github.wulkanowy.data.networkBoundResource
|
import io.github.wulkanowy.data.networkBoundResource
|
||||||
import io.github.wulkanowy.sdk.Sdk
|
import io.github.wulkanowy.sdk.Sdk
|
||||||
import io.github.wulkanowy.utils.init
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
@ -30,7 +31,7 @@ class StudentInfoRepository @Inject constructor(
|
|||||||
query = { studentInfoDao.loadStudentInfo(student.studentId) },
|
query = { studentInfoDao.loadStudentInfo(student.studentId) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getStudentInfo().mapToEntity(semester)
|
.getStudentInfo().mapToEntity(semester)
|
||||||
},
|
},
|
||||||
saveFetchResult = { old, new ->
|
saveFetchResult = { old, new ->
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package io.github.wulkanowy.data.repositories
|
package io.github.wulkanowy.data.repositories
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.room.withTransaction
|
import androidx.room.withTransaction
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
||||||
import io.github.wulkanowy.data.db.AppDatabase
|
import io.github.wulkanowy.data.db.AppDatabase
|
||||||
import io.github.wulkanowy.data.db.dao.SemesterDao
|
import io.github.wulkanowy.data.db.dao.SemesterDao
|
||||||
import io.github.wulkanowy.data.db.dao.StudentDao
|
import io.github.wulkanowy.data.db.dao.StudentDao
|
||||||
@ -17,20 +15,20 @@ import io.github.wulkanowy.data.pojos.RegisterUser
|
|||||||
import io.github.wulkanowy.sdk.Sdk
|
import io.github.wulkanowy.sdk.Sdk
|
||||||
import io.github.wulkanowy.utils.DispatchersProvider
|
import io.github.wulkanowy.utils.DispatchersProvider
|
||||||
import io.github.wulkanowy.utils.init
|
import io.github.wulkanowy.utils.init
|
||||||
import io.github.wulkanowy.utils.security.decrypt
|
import io.github.wulkanowy.utils.security.Scrambler
|
||||||
import io.github.wulkanowy.utils.security.encrypt
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class StudentRepository @Inject constructor(
|
class StudentRepository @Inject constructor(
|
||||||
@ApplicationContext private val context: Context,
|
|
||||||
private val dispatchers: DispatchersProvider,
|
private val dispatchers: DispatchersProvider,
|
||||||
private val studentDb: StudentDao,
|
private val studentDb: StudentDao,
|
||||||
private val semesterDb: SemesterDao,
|
private val semesterDb: SemesterDao,
|
||||||
private val sdk: Sdk,
|
private val sdk: Sdk,
|
||||||
private val appDatabase: AppDatabase
|
private val appDatabase: AppDatabase,
|
||||||
|
private val scrambler: Scrambler,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun isCurrentStudentSet() = studentDb.loadCurrent()?.isCurrent ?: false
|
suspend fun isCurrentStudentSet() = studentDb.loadCurrent()?.isCurrent ?: false
|
||||||
@ -62,23 +60,31 @@ class StudentRepository @Inject constructor(
|
|||||||
.getStudentsHybrid(email, password, scrapperBaseUrl, "", symbol)
|
.getStudentsHybrid(email, password, scrapperBaseUrl, "", symbol)
|
||||||
.mapToPojo(password)
|
.mapToPojo(password)
|
||||||
|
|
||||||
suspend fun getSavedStudents(decryptPass: Boolean = true) =
|
suspend fun getSavedStudents(decryptPass: Boolean = true): List<StudentWithSemesters> {
|
||||||
studentDb.loadStudentsWithSemesters()
|
return studentDb.loadStudentsWithSemesters().map { (student, semesters) ->
|
||||||
.map {
|
StudentWithSemesters(
|
||||||
it.apply {
|
student = student.apply {
|
||||||
if (decryptPass && Sdk.Mode.valueOf(student.loginMode) != Sdk.Mode.HEBE) {
|
if (decryptPass && Sdk.Mode.valueOf(student.loginMode) != Sdk.Mode.HEBE) {
|
||||||
student.password = withContext(dispatchers.io) {
|
student.password = withContext(dispatchers.io) {
|
||||||
decrypt(student.password)
|
scrambler.decrypt(student.password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
semesters = semesters,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getSavedStudentById(id: Long, decryptPass: Boolean = true) =
|
suspend fun getSavedStudentById(id: Long, decryptPass: Boolean = true): StudentWithSemesters? =
|
||||||
studentDb.loadStudentWithSemestersById(id)?.apply {
|
studentDb.loadStudentWithSemestersById(id).let { res ->
|
||||||
|
StudentWithSemesters(
|
||||||
|
student = res.keys.firstOrNull() ?: return null,
|
||||||
|
semesters = res.values.first(),
|
||||||
|
)
|
||||||
|
}.apply {
|
||||||
if (decryptPass && Sdk.Mode.valueOf(student.loginMode) != Sdk.Mode.HEBE) {
|
if (decryptPass && Sdk.Mode.valueOf(student.loginMode) != Sdk.Mode.HEBE) {
|
||||||
student.password = withContext(dispatchers.io) {
|
student.password = withContext(dispatchers.io) {
|
||||||
decrypt(student.password)
|
scrambler.decrypt(student.password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +94,7 @@ class StudentRepository @Inject constructor(
|
|||||||
|
|
||||||
if (decryptPass && Sdk.Mode.valueOf(student.loginMode) != Sdk.Mode.HEBE) {
|
if (decryptPass && Sdk.Mode.valueOf(student.loginMode) != Sdk.Mode.HEBE) {
|
||||||
student.password = withContext(dispatchers.io) {
|
student.password = withContext(dispatchers.io) {
|
||||||
decrypt(student.password)
|
scrambler.decrypt(student.password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return student
|
return student
|
||||||
@ -99,7 +105,7 @@ class StudentRepository @Inject constructor(
|
|||||||
|
|
||||||
if (decryptPass && Sdk.Mode.valueOf(student.loginMode) != Sdk.Mode.HEBE) {
|
if (decryptPass && Sdk.Mode.valueOf(student.loginMode) != Sdk.Mode.HEBE) {
|
||||||
student.password = withContext(dispatchers.io) {
|
student.password = withContext(dispatchers.io) {
|
||||||
decrypt(student.password)
|
scrambler.decrypt(student.password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return student
|
return student
|
||||||
@ -112,7 +118,7 @@ class StudentRepository @Inject constructor(
|
|||||||
it.apply {
|
it.apply {
|
||||||
if (Sdk.Mode.valueOf(it.loginMode) != Sdk.Mode.HEBE) {
|
if (Sdk.Mode.valueOf(it.loginMode) != Sdk.Mode.HEBE) {
|
||||||
password = withContext(dispatchers.io) {
|
password = withContext(dispatchers.io) {
|
||||||
encrypt(password, context)
|
scrambler.encrypt(password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,12 +150,12 @@ class StudentRepository @Inject constructor(
|
|||||||
|
|
||||||
suspend fun authorizePermission(student: Student, semester: Semester, pesel: String) =
|
suspend fun authorizePermission(student: Student, semester: Semester, pesel: String) =
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.authorizePermission(pesel)
|
.authorizePermission(pesel)
|
||||||
|
|
||||||
suspend fun refreshStudentName(student: Student, semester: Semester) {
|
suspend fun refreshStudentName(student: Student, semester: Semester) {
|
||||||
val newCurrentApiStudent = sdk.init(student)
|
val newCurrentApiStudent = sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getCurrentStudent() ?: return
|
.getCurrentStudent() ?: return
|
||||||
|
|
||||||
val studentName = StudentName(
|
val studentName = StudentName(
|
||||||
@ -158,4 +164,15 @@ class StudentRepository @Inject constructor(
|
|||||||
|
|
||||||
studentDb.update(studentName)
|
studentDb.update(studentName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun deleteStudentsAssociatedWithAccount(student: Student) {
|
||||||
|
studentDb.deleteByEmailAndUserName(student.email, student.userName)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun clearAll() {
|
||||||
|
withContext(dispatchers.io) {
|
||||||
|
scrambler.clearKeyPair()
|
||||||
|
appDatabase.clearAllTables()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import io.github.wulkanowy.sdk.Sdk
|
|||||||
import io.github.wulkanowy.utils.AutoRefreshHelper
|
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||||
import io.github.wulkanowy.utils.getRefreshKey
|
import io.github.wulkanowy.utils.getRefreshKey
|
||||||
import io.github.wulkanowy.utils.init
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
import io.github.wulkanowy.utils.uniqueSubtract
|
import io.github.wulkanowy.utils.uniqueSubtract
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -39,8 +40,9 @@ class SubjectRepository @Inject constructor(
|
|||||||
query = { subjectDao.loadAll(semester.diaryId, semester.studentId) },
|
query = { subjectDao.loadAll(semester.diaryId, semester.studentId) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getSubjects().mapToEntities(semester)
|
.getSubjects()
|
||||||
|
.mapToEntities(semester)
|
||||||
},
|
},
|
||||||
saveFetchResult = { old, new ->
|
saveFetchResult = { old, new ->
|
||||||
subjectDao.deleteAll(old uniqueSubtract new)
|
subjectDao.deleteAll(old uniqueSubtract new)
|
||||||
|
@ -9,6 +9,7 @@ import io.github.wulkanowy.sdk.Sdk
|
|||||||
import io.github.wulkanowy.utils.AutoRefreshHelper
|
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||||
import io.github.wulkanowy.utils.getRefreshKey
|
import io.github.wulkanowy.utils.getRefreshKey
|
||||||
import io.github.wulkanowy.utils.init
|
import io.github.wulkanowy.utils.init
|
||||||
|
import io.github.wulkanowy.utils.switchSemester
|
||||||
import io.github.wulkanowy.utils.uniqueSubtract
|
import io.github.wulkanowy.utils.uniqueSubtract
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -39,7 +40,7 @@ class TeacherRepository @Inject constructor(
|
|||||||
query = { teacherDb.loadAll(semester.studentId, semester.classId) },
|
query = { teacherDb.loadAll(semester.studentId, semester.classId) },
|
||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student)
|
sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getTeachers()
|
.getTeachers()
|
||||||
.mapToEntities(semester)
|
.mapToEntities(semester)
|
||||||
},
|
},
|
||||||
|
@ -65,7 +65,7 @@ class TimetableRepository @Inject constructor(
|
|||||||
query = { getFullTimetableFromDatabase(student, semester, start, end) },
|
query = { getFullTimetableFromDatabase(student, semester, start, end) },
|
||||||
fetch = {
|
fetch = {
|
||||||
val timetableFull = sdk.init(student)
|
val timetableFull = sdk.init(student)
|
||||||
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
|
.switchSemester(semester)
|
||||||
.getTimetable(start.monday, end.sunday)
|
.getTimetable(start.monday, end.sunday)
|
||||||
|
|
||||||
timetableFull.mapToEntities(semester)
|
timetableFull.mapToEntities(semester)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user