forked from github/szkolny
Compare commits
95 Commits
v4.13-rc.2
...
feature/ma
Author | SHA1 | Date | |
---|---|---|---|
a8ba41a7ad | |||
d5697b54bd | |||
db247a876c | |||
838b92add3 | |||
eff99e7966 | |||
661f0912cb | |||
1e6016c446 | |||
bc8c952853 | |||
743050712b | |||
a4ac17143f | |||
9fbafd0eee | |||
40ea700e0b | |||
2a93cd5ebd | |||
8fa2ca5bd5 | |||
c187c0579f | |||
494c132c84 | |||
11d3502be6 | |||
663243da8b | |||
92ef6b211d | |||
567dd8e6a2 | |||
29fd96acb4 | |||
8d0b5b8fc7 | |||
b65f2828cd | |||
beed9f858f | |||
b148f7197f | |||
eca2028595 | |||
d2789342da | |||
ab3af67663 | |||
4b4901e440 | |||
4d9c9368dd | |||
c123b28652 | |||
225070abd9 | |||
1540a6cfcd | |||
9915150c33 | |||
cefb0deba8 | |||
90a151c129 | |||
9fd9721ae7 | |||
ceca75ef4b | |||
21c00bbe53 | |||
db00566ebf | |||
07ab1b984f | |||
8177d4aa2d | |||
beff1b6460 | |||
31b569b02e | |||
8bf77817d2 | |||
27b61adf1d | |||
a0244841ad | |||
12c0c6f2ec | |||
aaa3b8626e | |||
48c9e2dfe3 | |||
81d4801d27 | |||
5f8016061d | |||
5007587192 | |||
dfd1083e41 | |||
678baf46e5 | |||
4077fe448d | |||
f085e17ef7 | |||
7fd2cad46b | |||
93dc2ac9ab | |||
ac53e267fc | |||
86eb1a0f42 | |||
710d82da27 | |||
0123f50810 | |||
6d3eb65445 | |||
a9a0630226 | |||
ec7577f999 | |||
05c7c0012c | |||
d65c6db954 | |||
771dc437e6 | |||
3d5d3847cc | |||
9c79a4003f | |||
18cc60a80b | |||
fedde9f739 | |||
9fde97bef0 | |||
742bd03e9e | |||
62ffc652ab | |||
bfd2e9883a | |||
00e077d01f | |||
c21d89cf60 | |||
f52cc1b197 | |||
c90ad97f55 | |||
845e09d875 | |||
158b69a8d3 | |||
9535f53563 | |||
eeb3fc4621 | |||
41693a9fc8 | |||
d3599b8c89 | |||
ffd81f8b82 | |||
2c34924052 | |||
26ad6373e6 | |||
cac8f94407 | |||
6628b97faf | |||
8424414317 | |||
f46d389b83 | |||
dda64489d7 |
4
.github/utils/extract_changelogs.py
vendored
4
.github/utils/extract_changelogs.py
vendored
@ -23,11 +23,11 @@ if __name__ == "__main__":
|
||||
(title, changelog) = get_changelog(project_dir, format="plain")
|
||||
|
||||
# plain text changelog - Firebase App Distribution
|
||||
with open(dir + "whatsnew-titled.txt", "w", encoding="utf-8") as f:
|
||||
with open(dir + "whatsnew_titled.txt", "w", encoding="utf-8") as f:
|
||||
f.write(title)
|
||||
f.write("\n")
|
||||
f.write(changelog)
|
||||
print("::set-output name=changelogPlainTitledFile::" + dir + "whatsnew-titled.txt")
|
||||
print("::set-output name=changelogPlainTitledFile::" + dir + "whatsnew_titled.txt")
|
||||
|
||||
print("::set-output name=changelogTitle::" + title)
|
||||
|
||||
|
3
.github/workflows/build-release-aab-play.yml
vendored
3
.github/workflows/build-release-aab-play.yml
vendored
@ -113,10 +113,11 @@ jobs:
|
||||
with:
|
||||
serviceAccountJsonPlainText: ${{ secrets.PLAY_SERVICE_ACCOUNT_JSON }}
|
||||
packageName: pl.szczodrzynski.edziennik
|
||||
releaseFile: ${{ needs.sign.outputs.signedReleaseFile }}
|
||||
releaseFiles: ${{ needs.sign.outputs.signedReleaseFile }}
|
||||
releaseName: ${{ steps.changelog.outputs.appVersionName }}
|
||||
track: ${{ secrets.PLAY_RELEASE_TRACK }}
|
||||
whatsNewDirectory: ${{ steps.changelog.outputs.changelogDir }}
|
||||
status: completed
|
||||
|
||||
- name: Upload workflow artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
|
@ -20,8 +20,9 @@ android {
|
||||
|
||||
buildConfigField "java.util.Map<String, String>", "GIT_INFO", gitInfoMap
|
||||
buildConfigField "String", "VERSION_BASE", "\"${release.versionName}\""
|
||||
|
||||
manifestPlaceholders = [
|
||||
buildTimestamp: String.valueOf(System.currentTimeMillis())
|
||||
buildTimestamp: String.valueOf(System.currentTimeMillis())
|
||||
]
|
||||
|
||||
multiDexEnabled = true
|
||||
@ -36,6 +37,8 @@ android {
|
||||
arguments {
|
||||
arg("room.schemaLocation", "$projectDir/schemas")
|
||||
}
|
||||
|
||||
correctErrorTypes true
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,10 +46,12 @@ android {
|
||||
debug {
|
||||
getIsDefault().set(true)
|
||||
minifyEnabled = false
|
||||
applicationIdSuffix ".debug"
|
||||
manifestPlaceholders = [
|
||||
buildTimestamp: 0
|
||||
buildTimestamp: 0
|
||||
]
|
||||
}
|
||||
|
||||
release {
|
||||
minifyEnabled = true
|
||||
shrinkResources = true
|
||||
@ -54,28 +59,35 @@ android {
|
||||
proguardFiles fileTree('proguard').asList().toArray()
|
||||
}
|
||||
}
|
||||
flavorDimensions "platform"
|
||||
|
||||
flavorDimensions += "platform"
|
||||
|
||||
productFlavors {
|
||||
unofficial {
|
||||
getIsDefault().set(true)
|
||||
versionName "${release.versionName}-${gitInfo.versionSuffix}"
|
||||
}
|
||||
|
||||
official {}
|
||||
play {}
|
||||
}
|
||||
|
||||
variantFilter { variant ->
|
||||
def flavors = variant.flavors*.name
|
||||
setIgnore(variant.buildType.name == "debug" && !flavors.contains("unofficial") || flavors.contains("main"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
unofficial {
|
||||
java.srcDirs = ["src/main/java", "src/play-not/java"]
|
||||
manifest.srcFile("src/play-not/AndroidManifest.xml")
|
||||
}
|
||||
|
||||
official {
|
||||
java.srcDirs = ["src/main/java", "src/play-not/java"]
|
||||
manifest.srcFile("src/play-not/AndroidManifest.xml")
|
||||
}
|
||||
|
||||
play {
|
||||
java.srcDirs = ["src/main/java", "src/play/java"]
|
||||
}
|
||||
@ -84,37 +96,47 @@ android {
|
||||
defaultConfig {
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
dataBinding = true
|
||||
viewBinding = true
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
coreLibraryDesugaringEnabled = true
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
resources {
|
||||
excludes += ['META-INF/library-core_release.kotlin_module']
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "src/main/cpp/CMakeLists.txt"
|
||||
version "3.10.2"
|
||||
}
|
||||
}
|
||||
|
||||
lint {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
|
||||
namespace 'pl.szczodrzynski.edziennik'
|
||||
}
|
||||
|
||||
tasks.whenTaskAdded { task ->
|
||||
if (!task.name.endsWith("Release") && !task.name.endsWith("ReleaseWithR8"))
|
||||
return
|
||||
|
||||
def renameTaskName = "rename${task.name.capitalize()}"
|
||||
|
||||
def flavor = ""
|
||||
@ -125,16 +147,20 @@ tasks.whenTaskAdded { task ->
|
||||
if (task.name.startsWith("minify"))
|
||||
flavor = task.name.substring("minify".length(), task.name.indexOf("Release")).uncapitalize()
|
||||
|
||||
def taskName = "package${flavor.capitalize()}Release"
|
||||
|
||||
if (flavor != "") {
|
||||
tasks.create(renameTaskName, Copy) {
|
||||
tasks.register(renameTaskName, Copy) {
|
||||
dependsOn(taskName)
|
||||
from file("${projectDir}/${flavor}/release/"),
|
||||
file("${buildDir}/outputs/mapping/${flavor}Release/"),
|
||||
file("${buildDir}/outputs/apk/${flavor}/release/"),
|
||||
file("${buildDir}/outputs/bundle/${flavor}Release/")
|
||||
file("${layout.buildDirectory}/outputs/mapping/${flavor}Release/"),
|
||||
file("${layout.buildDirectory}/outputs/apk/${flavor}/release/"),
|
||||
file("${layout.buildDirectory}/outputs/bundle/${flavor}Release/")
|
||||
include "*.aab", "*.apk", "mapping.txt", "output-metadata.json"
|
||||
destinationDir file("${projectDir}/release/")
|
||||
rename ".+?\\.(.+)", "Edziennik_${android.defaultConfig.versionName}_${flavor}." + '$1'
|
||||
}
|
||||
|
||||
task.finalizedBy(renameTaskName)
|
||||
}
|
||||
}
|
||||
@ -142,31 +168,35 @@ tasks.whenTaskAdded { task ->
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
|
||||
implementation files('libs/navlib-debug.aar')
|
||||
implementation files('libs/navlib-font-debug.aar')
|
||||
|
||||
// Language cores
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation "androidx.multidex:multidex:2.0.1"
|
||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
|
||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.0.4"
|
||||
|
||||
// Android Jetpack
|
||||
implementation "androidx.appcompat:appcompat:1.5.1"
|
||||
implementation "androidx.appcompat:appcompat:1.7.0"
|
||||
implementation "androidx.cardview:cardview:1.0.0"
|
||||
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
|
||||
implementation "androidx.core:core-ktx:1.9.0"
|
||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
|
||||
implementation "androidx.navigation:navigation-fragment-ktx:2.5.2"
|
||||
implementation "androidx.recyclerview:recyclerview:1.2.1"
|
||||
implementation "androidx.room:room-runtime:2.4.3"
|
||||
implementation "androidx.work:work-runtime-ktx:2.7.1"
|
||||
kapt "androidx.room:room-compiler:2.4.3"
|
||||
implementation "androidx.core:core-ktx:1.13.1"
|
||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.8.2"
|
||||
implementation "androidx.navigation:navigation-fragment-ktx:2.7.7"
|
||||
implementation "androidx.recyclerview:recyclerview:1.3.2"
|
||||
implementation "androidx.room:room-runtime:2.6.1"
|
||||
implementation "androidx.room:room-ktx:2.6.1"
|
||||
implementation "androidx.work:work-runtime-ktx:2.9.0"
|
||||
kapt "androidx.room:room-compiler:2.6.1"
|
||||
|
||||
// Google design libs
|
||||
implementation "com.google.android.material:material:1.6.1"
|
||||
implementation "com.google.android.material:material:1.12.0"
|
||||
implementation "com.google.android.flexbox:flexbox:3.0.0"
|
||||
|
||||
// Play Services/Firebase
|
||||
implementation "com.google.android.gms:play-services-wearable:17.1.0"
|
||||
implementation "com.google.android.gms:play-services-wearable:18.2.0"
|
||||
implementation("com.google.firebase:firebase-core") { version { strictly "19.0.2" } }
|
||||
implementation "com.google.firebase:firebase-crashlytics:18.2.13"
|
||||
implementation "com.google.firebase:firebase-crashlytics:19.0.1"
|
||||
implementation("com.google.firebase:firebase-messaging") { version { strictly "20.1.3" } }
|
||||
|
||||
// OkHttp, Retrofit, Gson, Jsoup
|
||||
@ -174,12 +204,13 @@ dependencies {
|
||||
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
||||
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
|
||||
implementation "com.squareup.retrofit2:converter-scalars:2.9.0"
|
||||
implementation 'com.google.code.gson:gson:2.8.8'
|
||||
implementation 'com.google.code.gson:gson:2.11.0'
|
||||
implementation 'org.jsoup:jsoup:1.14.3'
|
||||
implementation "pl.droidsonroids:jspoon:1.3.2"
|
||||
implementation "pl.droidsonroids.retrofit2:converter-jspoon:1.3.2"
|
||||
|
||||
// Szkolny.eu libraries/forks
|
||||
implementation project(":navlib")
|
||||
implementation "eu.szkolny:android-snowfall:1ca9ea2da3"
|
||||
implementation "eu.szkolny:agendacalendarview:1.0.4"
|
||||
implementation "eu.szkolny:cafebar:5bf0c618de"
|
||||
@ -187,28 +218,30 @@ dependencies {
|
||||
implementation "eu.szkolny:material-about-library:1d5ebaf47c"
|
||||
implementation "eu.szkolny:mhttp:af4b62e6e9"
|
||||
implementation "eu.szkolny:nachos:0e5dfcaceb"
|
||||
implementation "eu.szkolny.selective-dao:annotation:27f8f3f194"
|
||||
implementation "eu.szkolny.selective-dao:annotation:6a337f9"
|
||||
officialImplementation "eu.szkolny:ssl-provider:1.0.0"
|
||||
unofficialImplementation "eu.szkolny:ssl-provider:1.0.0"
|
||||
implementation "pl.szczodrzynski:navlib:0.8.0"
|
||||
implementation "pl.szczodrzynski:numberslidingpicker:2921225f76"
|
||||
implementation "pl.szczodrzynski:recyclertablayout:700f980584"
|
||||
implementation "pl.szczodrzynski:tachyon:551943a6b5"
|
||||
kapt "eu.szkolny.selective-dao:codegen:27f8f3f194"
|
||||
kapt "eu.szkolny.selective-dao:codegen:6a337f9"
|
||||
|
||||
// Iconics & related
|
||||
implementation "com.mikepenz:iconics-core:5.3.2"
|
||||
implementation "com.mikepenz:iconics-views:5.3.2"
|
||||
implementation "com.mikepenz:materialdrawer:9.0.1"
|
||||
implementation "com.mikepenz:community-material-typeface:5.8.55.0-kotlin@aar"
|
||||
implementation 'com.mikepenz:google-material-typeface:4.0.0.2-kotlin@aar'
|
||||
implementation "eu.szkolny:szkolny-font:77e33acc2a"
|
||||
|
||||
// Other dependencies
|
||||
debugApi "com.mikepenz:materialize:1.2.1" // required for all R.color.md_* colors
|
||||
implementation "cat.ereza:customactivityoncrash:2.3.0"
|
||||
implementation "com.android.volley:volley:1.2.1"
|
||||
implementation "com.daimajia.swipelayout:library:1.2.0@aar"
|
||||
implementation "com.github.Applandeo:Material-Calendar-View:15de569cbc" // https://github.com/Applandeo/Material-Calendar-View
|
||||
implementation "com.github.CanHub:Android-Image-Cropper:2.2.2" // https://github.com/CanHub/Android-Image-Cropper
|
||||
implementation "com.github.ChuckerTeam.Chucker:library:3.0.1" // https://github.com/ChuckerTeam/chucker
|
||||
implementation "com.github.ChuckerTeam.Chucker:library:3.5.2" // https://github.com/ChuckerTeam/chucker
|
||||
implementation "com.github.antonKozyriatskyi:CircularProgressIndicator:1.2.2" // https://github.com/antonKozyriatskyi/CircularProgressIndicator
|
||||
implementation "com.github.bassaer:chatmessageview:2.0.1" // https://github.com/bassaer/ChatMessageView
|
||||
implementation "com.github.hypertrack:hyperlog-android:0.0.10" // https://github.com/hypertrack/hyperlog-android
|
||||
@ -225,6 +258,10 @@ dependencies {
|
||||
implementation("com.heinrichreimersoftware:material-intro") { version { strictly "1.5.8" } }
|
||||
implementation("pl.droidsonroids.gif:android-gif-drawable") { version { strictly "1.2.15" } }
|
||||
|
||||
// Debug-only dependencies
|
||||
debugImplementation "com.github.amitshekhariitbhu.Android-Debug-Database:debug-db:v1.0.6"
|
||||
// NavLib dependencies
|
||||
// TODO: try to move these dependencies to NavLib build.gradle file
|
||||
implementation "com.mikepenz:materialize:1.2.1"
|
||||
implementation "com.mikepenz:itemanimators:1.1.0"
|
||||
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.eclipse.jgit:org.eclipse.jgit:5.5.+"
|
||||
|
@ -36,6 +36,37 @@
|
||||
"status": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:640759989760:android:4aa71407b25cdc8d",
|
||||
"android_client_info": {
|
||||
"package_name": "pl.szczodrzynski.edziennik.debug"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "640759989760-6f8q00u864lnuh3gh36e8g4cer9lv8pv.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyAvq9HMPxulz9ntdAHZ0eZuPf2YQs4nDSU"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"analytics_service": {
|
||||
"status": 1
|
||||
},
|
||||
"appinvite_service": {
|
||||
"status": 1,
|
||||
"other_platform_oauth_client": []
|
||||
},
|
||||
"ads_service": {
|
||||
"status": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
|
43
app/proguard-rules.pro
vendored
43
app/proguard-rules.pro
vendored
@ -19,7 +19,10 @@
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
-keepattributes Signature
|
||||
-keep class android.support.v7.widget.** { *; }
|
||||
-keep class com.google.gson.reflect.TypeToken { *; }
|
||||
-keep class * extends com.google.gson.reflect.TypeToken
|
||||
|
||||
-keep class pl.szczodrzynski.edziennik.utils.models.** { *; }
|
||||
-keep class pl.szczodrzynski.edziennik.data.db.enums.* { *; }
|
||||
@ -55,8 +58,19 @@
|
||||
|
||||
-keep class com.google.android.material.tabs.** {*;}
|
||||
|
||||
# Exclude AgendaCalendarView
|
||||
# Preserve generic type information for EventRenderer and its subclasses
|
||||
-keepclassmembers class * extends com.github.tibolte.agendacalendarview.render.EventRenderer {
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
|
||||
# Keep the EventRenderer class itself and all its subclasses
|
||||
-keep class com.github.tibolte.agendacalendarview.render.EventRenderer
|
||||
-keep class * extends com.github.tibolte.agendacalendarview.render.EventRenderer
|
||||
|
||||
# ServiceLoader support
|
||||
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
|
||||
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
|
||||
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
|
||||
|
||||
# Most of volatile fields are updated with AFU and should not be mangled
|
||||
@ -70,9 +84,36 @@
|
||||
|
||||
-keep class pl.szczodrzynski.edziennik.data.api.szkolny.interceptor.Signing { public final byte[] pleaseStopRightNow(java.lang.String, long); }
|
||||
|
||||
-keepclassmembers class pl.szczodrzynski.edziennik.ui.login.qr.* { *; }
|
||||
-keepclassmembers class pl.szczodrzynski.edziennik.data.api.szkolny.request.** { *; }
|
||||
-keepclassmembers class pl.szczodrzynski.edziennik.data.api.szkolny.response.** { *; }
|
||||
-keepclassmembernames class pl.szczodrzynski.edziennik.ui.login.LoginInfo$Platform { *; }
|
||||
|
||||
-keepclassmembernames class pl.szczodrzynski.fslogin.realm.RealmData { *; }
|
||||
-keepclassmembernames class pl.szczodrzynski.fslogin.realm.RealmData$Type { *; }
|
||||
|
||||
# Exclude Retrofit2
|
||||
-keepattributes Signature, InnerClasses, EnclosingMethod
|
||||
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
|
||||
-keepattributes AnnotationDefault
|
||||
|
||||
-keepclassmembers,allowshrinking,allowobfuscation interface * {
|
||||
@retrofit2.http.* <methods>;
|
||||
}
|
||||
|
||||
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
|
||||
-dontwarn javax.annotation.**
|
||||
-dontwarn kotlin.Unit
|
||||
-dontwarn retrofit2.KotlinExtensions
|
||||
-dontwarn retrofit2.KotlinExtensions$*
|
||||
|
||||
-if interface * { @retrofit2.http.* <methods>; }
|
||||
-keep,allowobfuscation interface <1>
|
||||
|
||||
-if interface * { @retrofit2.http.* <methods>; }
|
||||
-keep,allowobfuscation interface * extends <1>
|
||||
|
||||
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
|
||||
-if interface * { @retrofit2.http.* public *** *(...); }
|
||||
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>
|
||||
-keep,allowobfuscation,allowshrinking class retrofit2.Response
|
2320
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/100.json
Normal file
2320
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/100.json
Normal file
File diff suppressed because it is too large
Load Diff
2326
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/101.json
Normal file
2326
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/101.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -137,6 +137,7 @@
|
||||
"columnNames": [
|
||||
"profileId"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_grades_profileId` ON `${TABLE_NAME}` (`profileId`)"
|
||||
}
|
||||
],
|
||||
@ -290,6 +291,7 @@
|
||||
"columnNames": [
|
||||
"profileId"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_teacherAbsence_profileId` ON `${TABLE_NAME}` (`profileId`)"
|
||||
}
|
||||
],
|
||||
@ -452,6 +454,7 @@
|
||||
"columnNames": [
|
||||
"profileId"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_notices_profileId` ON `${TABLE_NAME}` (`profileId`)"
|
||||
}
|
||||
],
|
||||
@ -629,6 +632,7 @@
|
||||
"columnNames": [
|
||||
"profileId"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_attendances_profileId` ON `${TABLE_NAME}` (`profileId`)"
|
||||
}
|
||||
],
|
||||
@ -781,6 +785,7 @@
|
||||
"eventDate",
|
||||
"eventTime"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_events_profileId_eventDate_eventTime` ON `${TABLE_NAME}` (`profileId`, `eventDate`, `eventTime`)"
|
||||
},
|
||||
{
|
||||
@ -790,6 +795,7 @@
|
||||
"profileId",
|
||||
"eventType"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_events_profileId_eventType` ON `${TABLE_NAME}` (`profileId`, `eventType`)"
|
||||
}
|
||||
],
|
||||
@ -1166,6 +1172,7 @@
|
||||
"columnNames": [
|
||||
"profileId"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_announcements_profileId` ON `${TABLE_NAME}` (`profileId`)"
|
||||
}
|
||||
],
|
||||
@ -1407,6 +1414,7 @@
|
||||
"profileId",
|
||||
"messageType"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_messages_profileId_messageType` ON `${TABLE_NAME}` (`profileId`, `messageType`)"
|
||||
}
|
||||
],
|
||||
@ -1918,6 +1926,7 @@
|
||||
"type",
|
||||
"date"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_timetable_profileId_type_date` ON `${TABLE_NAME}` (`profileId`, `type`, `date`)"
|
||||
},
|
||||
{
|
||||
@ -1928,6 +1937,7 @@
|
||||
"type",
|
||||
"oldDate"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_timetable_profileId_type_oldDate` ON `${TABLE_NAME}` (`profileId`, `type`, `oldDate`)"
|
||||
}
|
||||
],
|
||||
@ -2015,6 +2025,7 @@
|
||||
"columnNames": [
|
||||
"profileId"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_librusLessons_profileId` ON `${TABLE_NAME}` (`profileId`)"
|
||||
}
|
||||
],
|
||||
@ -2117,6 +2128,7 @@
|
||||
"profileId",
|
||||
"date"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_timetableManual_profileId_date` ON `${TABLE_NAME}` (`profileId`, `date`)"
|
||||
},
|
||||
{
|
||||
@ -2126,6 +2138,7 @@
|
||||
"profileId",
|
||||
"weekDay"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_timetableManual_profileId_weekDay` ON `${TABLE_NAME}` (`profileId`, `weekDay`)"
|
||||
}
|
||||
],
|
||||
@ -2217,6 +2230,7 @@
|
||||
"noteOwnerType",
|
||||
"noteOwnerId"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_notes_profileId_noteOwnerType_noteOwnerId` ON `${TABLE_NAME}` (`profileId`, `noteOwnerType`, `noteOwnerId`)"
|
||||
}
|
||||
],
|
||||
@ -2278,6 +2292,7 @@
|
||||
"thingType",
|
||||
"thingId"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_metadata_profileId_thingType_thingId` ON `${TABLE_NAME}` (`profileId`, `thingType`, `thingId`)"
|
||||
}
|
||||
],
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
8
app/src/debug/res/values/ic_launcher_background.xml
Normal file
8
app/src/debug/res/values/ic_launcher_background.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (c) Kuba Szczodrzyński 2020-5-11.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#FF7D54</color>
|
||||
</resources>
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="pl.szczodrzynski.edziennik">
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
@ -10,11 +9,13 @@
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
|
||||
<!-- PowerPermission uses minSdk 21, it's safe to override as it is used only in >= 23 -->
|
||||
<uses-sdk tools:overrideLibrary="com.qifan.powerpermission.coroutines, com.qifan.powerpermission.core" />
|
||||
<uses-sdk tools:overrideLibrary="com.qifan.powerpermission.coroutines, com.qifan.powerpermission.core, com.mikepenz:materialdrawer, com.mikepenz.iconics.typeface.library.navlibfont" />
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
@ -40,7 +41,6 @@
|
||||
|___/ -->
|
||||
<activity android:name=".MainActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop"
|
||||
android:exported="true"
|
||||
android:theme="@style/SplashTheme">
|
||||
@ -84,7 +84,7 @@
|
||||
android:resource="@xml/widget_timetable_info" />
|
||||
</receiver>
|
||||
<service android:name=".ui.widgets.timetable.WidgetTimetableService"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" android:foregroundServiceType="dataSync"/>
|
||||
<activity android:name=".ui.widgets.LessonDialogActivity"
|
||||
android:label=""
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
@ -105,7 +105,7 @@
|
||||
android:resource="@xml/widget_notifications_info" />
|
||||
</receiver>
|
||||
<service android:name=".ui.widgets.notifications.WidgetNotificationsService"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" android:foregroundServiceType="dataSync"/>
|
||||
<!-- LUCKY NUMBER -->
|
||||
<receiver android:name=".ui.widgets.luckynumber.WidgetLuckyNumberProvider"
|
||||
android:label="@string/widget_lucky_number_title"
|
||||
@ -133,7 +133,6 @@
|
||||
android:theme="@style/DeadTheme" />
|
||||
<activity android:name=".ui.intro.ChangelogIntroActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:label="@string/app_name"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.Intro" />
|
||||
<activity android:name=".ui.login.LoginActivity"
|
||||
@ -146,7 +145,6 @@
|
||||
android:theme="@style/AppTheme.Black" />
|
||||
<activity android:name=".ui.feedback.FeedbackActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:label="@string/app_name"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity android:name=".ui.settings.SettingsLicenseActivity"
|
||||
@ -160,7 +158,11 @@
|
||||
<activity android:name=".ui.login.oauth.OAuthLoginActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.Light" />
|
||||
android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar" />
|
||||
<activity android:name=".ui.login.recaptcha.RecaptchaActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar" />
|
||||
<activity android:name=".ui.base.BuildInvalidActivity" android:exported="false" />
|
||||
<activity android:name=".ui.settings.contributors.ContributorsActivity" android:exported="false" />
|
||||
|
||||
@ -198,15 +200,15 @@
|
||||
____) | __/ | \ V /| | (_| __/\__ \
|
||||
|_____/ \___|_| \_/ |_|\___\___||___/
|
||||
-->
|
||||
<service android:name=".data.api.ApiService" />
|
||||
<service android:name=".data.api.ApiService" android:foregroundServiceType="dataSync"/>
|
||||
<service android:name=".data.firebase.MyFirebaseService"
|
||||
android:exported="false">
|
||||
android:exported="false" android:foregroundServiceType="dataSync">
|
||||
<intent-filter android:priority="10000000">
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
||||
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service android:name=".sync.UpdateDownloaderService" />
|
||||
<service android:name=".sync.UpdateDownloaderService" android:foregroundServiceType="dataSync"/>
|
||||
|
||||
<!--
|
||||
_____ _ _
|
||||
|
@ -1,13 +1,10 @@
|
||||
<h3>Wersja 4.13-rc.2, 2022-10-22</h3>
|
||||
<h3>Wersja 4.13.6, 2023-03-24</h3>
|
||||
<ul>
|
||||
<li>Poprawione powiadomienia na Androidzie 13. @santoni0</li>
|
||||
<li>Możliwość dostosowania wyświetlania planu lekcji.</li>
|
||||
<li>Opcja kolorowania bloków w planie lekcji.</li>
|
||||
<li><b>USOS</b> - pierwsza wersja obsługi systemu. Osobne rodzaje wydarzeń (oraz wygląd niektórych części aplikacji) lepiej dostosowany do nauki na studiach.</li>
|
||||
<li>Poprawione opcje filtrowania powiadomień i wyboru przycisków menu bocznego.</li>
|
||||
<li>Ulepszony system pobierania aktualizacji aplikacji.</li>
|
||||
<li>Naprawiono pobieranie załączników na Androidzie 13 i nowszym.</li>
|
||||
<li>Dodano opcję odświeżenia planu lekcji na wybrany tydzień.</li>
|
||||
<li>Usunięto błędy logowania. @BxOxSxS</li>
|
||||
</ul>
|
||||
<br>
|
||||
<br>
|
||||
Dzięki za korzystanie ze Szkolnego!<br>
|
||||
<i>© [Kuba Szczodrzyński](@kuba2k2), [Kacper Ziubryniewicz](@kapi2289) 2022</i>
|
||||
<i>© [Kuba Szczodrzyński](@kuba2k2) 2023</i>
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
/*secret password - removed for source code publication*/
|
||||
static toys AES_IV[16] = {
|
||||
0x54, 0xe7, 0x2a, 0xdd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
0x6d, 0xa5, 0x32, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
|
||||
unsigned char *agony(unsigned int laugh, unsigned char *box, unsigned char *heat);
|
||||
|
||||
|
BIN
app/src/main/ic_launcher_monochrome-playstore.png
Normal file
BIN
app/src/main/ic_launcher_monochrome-playstore.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
@ -124,7 +124,8 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
private val job = Job()
|
||||
override val coroutineContext: CoroutineContext
|
||||
get() = job + Dispatchers.Main
|
||||
override fun getWorkManagerConfiguration() = Configuration.Builder()
|
||||
|
||||
override val workManagerConfiguration: Configuration = Configuration.Builder()
|
||||
.setMinimumLoggingLevel(Log.VERBOSE)
|
||||
.build()
|
||||
|
||||
@ -235,6 +236,7 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
}
|
||||
|
||||
Signing.getCert(this)
|
||||
Utils.initializeStorageDir(this)
|
||||
|
||||
launch {
|
||||
withContext(Dispatchers.Default) {
|
||||
@ -422,6 +424,12 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
try {
|
||||
App.data = AppData.get(profile.loginStoreType)
|
||||
d("App", "Loaded AppData: ${App.data}")
|
||||
// apply newly-added config overrides, if not changed by the user yet
|
||||
for ((key, value) in App.data.configOverrides) {
|
||||
val config = App.profile.config
|
||||
if (!config.has(key))
|
||||
config.set(key, value)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("App", "Cannot load AppData", e)
|
||||
Toast.makeText(this, R.string.app_cannot_load_data, Toast.LENGTH_LONG).show()
|
||||
@ -462,6 +470,8 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
}
|
||||
fun profileSave() = profileSave(profile)
|
||||
fun profileSave(profile: Profile) {
|
||||
if (profile.id == profileId)
|
||||
App.profile = profile
|
||||
launch(Dispatchers.Default) {
|
||||
App.db.profileDao().add(profile)
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package pl.szczodrzynski.edziennik
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.ActivityManager
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
@ -15,10 +16,11 @@ import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.navigation.NavOptions
|
||||
import com.danimahardhika.cafebar.CafeBar
|
||||
import com.danimahardhika.cafebar.CafeBarTheme
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.jetradarmobile.snowfall.SnowfallView
|
||||
import com.mikepenz.iconics.IconicsDrawable
|
||||
@ -39,7 +41,6 @@ import pl.szczodrzynski.edziennik.data.api.events.*
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.api.szkolny.response.Update
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Message
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata.*
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.databinding.ActivitySzkolnyBinding
|
||||
@ -66,19 +67,16 @@ import pl.szczodrzynski.edziennik.ui.messages.list.MessagesFragment
|
||||
import pl.szczodrzynski.edziennik.ui.timetable.TimetableFragment
|
||||
import pl.szczodrzynski.edziennik.utils.*
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.dpToPx
|
||||
import pl.szczodrzynski.edziennik.utils.managers.AvailabilityManager.Error.Type
|
||||
import pl.szczodrzynski.edziennik.utils.managers.UserActionManager
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.navlib.*
|
||||
import pl.szczodrzynski.navlib.SystemBarsUtil.Companion.COLOR_HALF_TRANSPARENT
|
||||
import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet
|
||||
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem
|
||||
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem
|
||||
import pl.szczodrzynski.navlib.drawer.NavDrawer
|
||||
import pl.szczodrzynski.navlib.drawer.items.DrawerPrimaryItem
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@ -148,10 +146,10 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
errorSnackbar.setCoordinator(b.navView.coordinator, b.navView.bottomBar)
|
||||
|
||||
val versionBadge = app.buildManager.versionBadge
|
||||
b.nightlyText.isVisible = versionBadge != null
|
||||
b.nightlyText.text = versionBadge
|
||||
navView.nightlyText.isVisible = versionBadge != null
|
||||
navView.nightlyText.text = versionBadge
|
||||
if (versionBadge != null) {
|
||||
b.nightlyText.background.setTintColor(0xa0ff0000.toInt())
|
||||
navView.nightlyText.background.setTintColor(0xa0ff0000.toInt())
|
||||
}
|
||||
|
||||
navLoading = true
|
||||
@ -159,51 +157,11 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
b.navView.apply {
|
||||
drawer.init(this@MainActivity)
|
||||
|
||||
SystemBarsUtil(this@MainActivity).run {
|
||||
//paddingByKeyboard = b.navView
|
||||
appFullscreen = false
|
||||
statusBarColor = getColorFromAttr(context, android.R.attr.colorBackground)
|
||||
statusBarDarker = false
|
||||
statusBarFallbackLight = COLOR_HALF_TRANSPARENT
|
||||
statusBarFallbackGradient = COLOR_HALF_TRANSPARENT
|
||||
navigationBarTransparent = false
|
||||
|
||||
b.navView.configSystemBarsUtil(this)
|
||||
|
||||
// fix for setting status bar color to window color, outside of navlib
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
window.statusBarColor = statusBarColor
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
&& ColorUtils.calculateLuminance(statusBarColor) > 0.6
|
||||
) {
|
||||
@Suppress("deprecation")
|
||||
window.decorView.systemUiVisibility =
|
||||
window.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||
}
|
||||
|
||||
// TODO fix navlib navbar detection, orientation change issues, status bar color setting if not fullscreen
|
||||
|
||||
commit()
|
||||
}
|
||||
|
||||
toolbar.apply {
|
||||
subtitleFormat = R.string.toolbar_subtitle
|
||||
subtitleFormatWithUnread = R.plurals.toolbar_subtitle_with_unread
|
||||
}
|
||||
|
||||
bottomBar.apply {
|
||||
fabEnable = false
|
||||
fabExtendable = true
|
||||
fabExtended = false
|
||||
fabGravity = Gravity.CENTER
|
||||
if (Themes.isDark) {
|
||||
setBackgroundColor(blendColors(
|
||||
getColorFromAttr(context, R.attr.colorSurface),
|
||||
getColorFromRes(R.color.colorSurface_4dp)
|
||||
))
|
||||
elevation = dpToPx(4).toFloat()
|
||||
}
|
||||
fabGravity = Gravity.RIGHT
|
||||
}
|
||||
|
||||
bottomSheet.apply {
|
||||
@ -322,7 +280,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
|
||||
// IT'S WINTER MY DUDES
|
||||
val today = Date.getToday()
|
||||
if ((today.month % 11 == 1) && app.config.ui.snowfall) {
|
||||
if ((today.month / 3 % 4 == 0) && app.config.ui.snowfall) {
|
||||
b.rootFrame.addView(layoutInflater.inflate(R.layout.snowfall, b.rootFrame, false))
|
||||
} else if (app.config.ui.eggfall && BigNightUtil().isDataWielkanocyNearDzisiaj()) {
|
||||
val eggfall = layoutInflater.inflate(
|
||||
@ -358,6 +316,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
if (app.config.appRateSnackbarTime != 0L && app.config.appRateSnackbarTime <= System.currentTimeMillis()) {
|
||||
navView.coordinator.postDelayed({
|
||||
CafeBar.builder(this)
|
||||
.theme(CafeBarTheme.Custom(getColorFromAttr(this, R.attr.colorSurfaceInverse)))
|
||||
.content(R.string.rate_snackbar_text)
|
||||
.icon(IconicsDrawable(this).apply {
|
||||
icon = CommunityMaterial.Icon3.cmd_star_outline
|
||||
@ -560,8 +519,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
swipeRefreshLayout.isRefreshing = true
|
||||
if (event.profileId == App.profileId) {
|
||||
navView.toolbar.apply {
|
||||
subtitleFormat = null
|
||||
subtitleFormatWithUnread = null
|
||||
subtitle = getString(R.string.toolbar_subtitle_syncing)
|
||||
}
|
||||
}
|
||||
@ -579,8 +536,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
fun onApiTaskProgressEvent(event: ApiTaskProgressEvent) {
|
||||
if (event.profileId == App.profileId) {
|
||||
navView.toolbar.apply {
|
||||
subtitleFormat = null
|
||||
subtitleFormatWithUnread = null
|
||||
subtitle = if (event.progress < 0f)
|
||||
event.progressText ?: ""
|
||||
else
|
||||
@ -599,8 +554,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
EventBus.getDefault().removeStickyEvent(event)
|
||||
if (event.profileId == App.profileId) {
|
||||
navView.toolbar.apply {
|
||||
subtitleFormat = R.string.toolbar_subtitle
|
||||
subtitleFormatWithUnread = R.plurals.toolbar_subtitle_with_unread
|
||||
subtitle = "Gotowe"
|
||||
}
|
||||
}
|
||||
@ -621,8 +574,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
ErrorDetailsDialog(this, listOf(event.error)).show()
|
||||
}
|
||||
navView.toolbar.apply {
|
||||
subtitleFormat = R.string.toolbar_subtitle
|
||||
subtitleFormatWithUnread = R.plurals.toolbar_subtitle_with_unread
|
||||
subtitle = "Gotowe"
|
||||
}
|
||||
mainSnackbar.dismiss()
|
||||
@ -829,7 +780,13 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
d(TAG, "Activity resumed")
|
||||
val filter = IntentFilter()
|
||||
filter.addAction(Intent.ACTION_MAIN)
|
||||
registerReceiver(intentReceiver, filter)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
|
||||
registerReceiver(intentReceiver, filter, RECEIVER_NOT_EXPORTED)
|
||||
else
|
||||
@Suppress("UnspecifiedRegisterReceiverFlag")
|
||||
registerReceiver(intentReceiver, filter)
|
||||
|
||||
EventBus.getDefault().register(this)
|
||||
super.onResume()
|
||||
}
|
||||
@ -856,6 +813,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
handleIntent(intent?.extras)
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
@Suppress("deprecation")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
@ -975,16 +933,19 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
bottomSheet.removeAllContextual()
|
||||
bottomSheet.toggleGroupEnabled = false
|
||||
drawer.close()
|
||||
|
||||
if (drawer.getSelection() != navTarget.id)
|
||||
drawer.setSelection(navTarget.id, fireOnClick = false)
|
||||
navView.toolbar.setTitle(navTarget.titleRes ?: navTarget.nameRes)
|
||||
|
||||
navView.bottomBar.fabEnable = false
|
||||
navView.bottomBar.fabExtended = false
|
||||
navView.bottomBar.setFabOnClickListener(null)
|
||||
|
||||
navView.toolbar.setTitle(navTarget.titleRes ?: navTarget.nameRes)
|
||||
|
||||
d("NavDebug", "Navigating from ${this.navTarget.name} to ${navTarget.name}")
|
||||
|
||||
val fragment = navTarget.fragmentClass?.newInstance() ?: return
|
||||
val fragment = navTarget.fragmentClass?.getDeclaredConstructor()?.newInstance() ?: return
|
||||
fragment.arguments = arguments
|
||||
val transaction = fragmentManager.beginTransaction()
|
||||
|
||||
@ -1051,20 +1012,18 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
transaction.commitAllowingStateLoss()
|
||||
|
||||
// TASK DESCRIPTION
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
val bm = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
|
||||
val bm = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
|
||||
|
||||
@Suppress("deprecation")
|
||||
val taskDesc = ActivityManager.TaskDescription(
|
||||
if (navTarget == NavTarget.HOME)
|
||||
getString(R.string.app_name)
|
||||
else
|
||||
getString(R.string.app_task_format, getString(navTarget.nameRes)),
|
||||
bm,
|
||||
getColorFromAttr(this, R.attr.colorSurface)
|
||||
)
|
||||
setTaskDescription(taskDesc)
|
||||
}
|
||||
@Suppress("deprecation")
|
||||
val taskDesc = ActivityManager.TaskDescription(
|
||||
if (navTarget == NavTarget.HOME)
|
||||
getString(R.string.app_name)
|
||||
else
|
||||
getString(R.string.app_task_format, getString(navTarget.nameRes)),
|
||||
bm,
|
||||
getColorFromAttr(this, R.attr.colorSurface)
|
||||
)
|
||||
setTaskDescription(taskDesc)
|
||||
return
|
||||
}
|
||||
|
||||
@ -1094,7 +1053,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
|
||||
fun navigateUp(skipBeforeNavigate: Boolean = false) {
|
||||
if (!popBackStack(skipBeforeNavigate)) {
|
||||
super.onBackPressed()
|
||||
super.onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1105,9 +1064,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
fun gainAttention() {
|
||||
if (app.config.ui.bottomSheetOpened)
|
||||
return
|
||||
b.navView.postDelayed({
|
||||
navView.gainAttentionOnBottomBar()
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
fun gainAttentionFAB() {
|
||||
@ -1225,6 +1181,8 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
drawer.addProfileSettings(*drawerProfiles.toTypedArray())
|
||||
}
|
||||
|
||||
@SuppressLint("MissingSuperCall")
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onBackPressed() {
|
||||
if (App.config.ui.openDrawerOnBackPressed) {
|
||||
if (drawer.isOpen)
|
||||
|
@ -59,10 +59,11 @@ data class AppData(
|
||||
val lessonHeight: Int,
|
||||
val enableMarkAsReadAnnouncements: Boolean,
|
||||
val enableNoticePoints: Boolean,
|
||||
val eventManualShowSubjectDropdown: Boolean,
|
||||
)
|
||||
|
||||
data class EventType(
|
||||
val id: Int,
|
||||
val id: Long,
|
||||
val color: String,
|
||||
val name: String,
|
||||
)
|
||||
|
@ -14,6 +14,7 @@ import pl.szczodrzynski.edziennik.ext.takePositive
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
abstract class BaseConfig(
|
||||
@Transient
|
||||
val db: AppDb,
|
||||
val profileId: Int? = null,
|
||||
protected var entries: List<ConfigEntry>? = null,
|
||||
@ -42,4 +43,6 @@ abstract class BaseConfig(
|
||||
db.configDao().add(ConfigEntry(profileId ?: -1, key, value))
|
||||
}
|
||||
}
|
||||
|
||||
fun has(key: String) = values.containsKey(key)
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class Config(db: AppDb) : BaseConfig(db) {
|
||||
var update by config<Update?>(null)
|
||||
var updatesChannel by config<String>("release")
|
||||
|
||||
var devMode by config<Boolean?>(null)
|
||||
var devMode by config<Boolean?>("debugMode", null)
|
||||
var devModePassword by config<String?>(null)
|
||||
var enableChucker by config<Boolean?>(null)
|
||||
|
||||
@ -55,11 +55,9 @@ class Config(db: AppDb) : BaseConfig(db) {
|
||||
ConfigMigration(app, this)
|
||||
}
|
||||
|
||||
fun getFor(profileId: Int): ProfileConfig {
|
||||
operator fun get(profileId: Int): ProfileConfig {
|
||||
return profileConfigs[profileId] ?: ProfileConfig(db, profileId, entries).also {
|
||||
profileConfigs[profileId] = it
|
||||
}
|
||||
}
|
||||
|
||||
fun forProfile() = getFor(App.profileId)
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ class ConfigUI(base: Config) {
|
||||
var appBackground by base.config<String?>("appBg", null)
|
||||
var headerBackground by base.config<String?>("headerBg", null)
|
||||
|
||||
var lockLayout by base.config<Boolean>(false)
|
||||
var miniMenuVisible by base.config<Boolean>(false)
|
||||
var miniMenuButtons by base.config<Set<NavTarget>> {
|
||||
setOf(
|
||||
|
@ -115,9 +115,9 @@ class ConfigDelegate<T>(
|
||||
is Boolean -> value
|
||||
// enums, maps & collections
|
||||
is Enum<*> -> value.toInt()
|
||||
is Collection<*> -> JsonArray(value.map {
|
||||
is Collection<*> -> value.map {
|
||||
if (it is Number || it is Boolean) it else serialize(it, serializeObjects = false)
|
||||
})
|
||||
}.toJsonElement()
|
||||
is Map<*, *> -> gson.toJson(value.mapValues { (_, it) ->
|
||||
if (it is Number || it is Boolean) it else serialize(it, serializeObjects = false)
|
||||
})
|
||||
@ -144,7 +144,7 @@ class ConfigDelegate<T>(
|
||||
java.lang.Float::class.java -> value.toFloatOrNull()
|
||||
// enums, maps & collections
|
||||
else -> when {
|
||||
Enum::class.java.isAssignableFrom(type) -> value.toIntOrNull()?.toEnum(type) as Enum<*>
|
||||
Enum::class.java.isAssignableFrom(type) -> value.toIntOrNull()?.toEnum(type) as Enum
|
||||
Collection::class.java.isAssignableFrom(type) -> {
|
||||
val array = value.toJsonArray()
|
||||
val genericType = getGenericType()
|
||||
|
@ -15,7 +15,7 @@ class ProfileConfig(
|
||||
entries: List<ConfigEntry>?,
|
||||
) : BaseConfig(db, profileId, entries) {
|
||||
companion object {
|
||||
const val DATA_VERSION = 4
|
||||
const val DATA_VERSION = 5
|
||||
}
|
||||
|
||||
val grades by lazy { ProfileConfigGrades(this) }
|
||||
@ -29,6 +29,8 @@ class ProfileConfig(
|
||||
var dataVersion by config<Int>(DATA_VERSION)
|
||||
var hash by config<String>("")
|
||||
|
||||
var shareByDefault by config<Boolean>(false)
|
||||
|
||||
init {
|
||||
if (dataVersion < DATA_VERSION)
|
||||
ProfileConfigMigration(this)
|
||||
|
@ -15,6 +15,7 @@ class ProfileConfigUI(base: ProfileConfig) {
|
||||
var agendaGroupByType by base.config<Boolean>(false)
|
||||
var agendaLessonChanges by base.config<Boolean>(true)
|
||||
var agendaTeacherAbsence by base.config<Boolean>(true)
|
||||
var agendaSubjectImportant by base.config<Boolean>(false)
|
||||
var agendaElearningMark by base.config<Boolean>(false)
|
||||
var agendaElearningGroup by base.config<Boolean>(true)
|
||||
|
||||
|
@ -16,6 +16,8 @@ import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_AL
|
||||
class ProfileConfigMigration(config: ProfileConfig) {
|
||||
init { config.apply {
|
||||
|
||||
val profile = db.profileDao().getByIdNow(profileId ?: -1)
|
||||
|
||||
if (dataVersion < 2) {
|
||||
sync.notificationFilter = sync.notificationFilter + NotificationType.TEACHER_ABSENCE
|
||||
|
||||
@ -37,11 +39,23 @@ class ProfileConfigMigration(config: ProfileConfig) {
|
||||
// switch to new event types (USOS)
|
||||
dataVersion = 4
|
||||
|
||||
val profile = db.profileDao().getByIdNow(profileId ?: -1)
|
||||
if (profile?.loginStoreType?.schoolType == SchoolType.UNIVERSITY) {
|
||||
db.eventTypeDao().clear(profileId ?: -1)
|
||||
db.eventTypeDao().addDefaultTypes(profile)
|
||||
}
|
||||
}
|
||||
|
||||
if (dataVersion < 5) {
|
||||
// update USOS event types and the appropriate events (2022-12-25)
|
||||
dataVersion = 5
|
||||
|
||||
if (profile?.loginStoreType?.schoolType == SchoolType.UNIVERSITY) {
|
||||
db.eventTypeDao().getAllWithDefaults(profile)
|
||||
// wejściówka (4) -> kartkówka (3)
|
||||
db.eventDao().getRawNow("UPDATE events SET eventType = 3 WHERE profileId = $profileId AND eventType = 4;")
|
||||
// zadanie (6) -> zadanie domowe (-1)
|
||||
db.eventDao().getRawNow("UPDATE events SET eventType = -1 WHERE profileId = $profileId AND eventType = 6;")
|
||||
}
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
@ -26,9 +26,10 @@ val LIBRUS_USER_AGENT = "${SYSTEM_USER_AGENT}LibrusMobileApp"
|
||||
const val SYNERGIA_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Gecko/20100101 Firefox/62.0"
|
||||
const val LIBRUS_CLIENT_ID = "VaItV6oRutdo8fnjJwysnTjVlvaswf52ZqmXsJGP"
|
||||
const val LIBRUS_REDIRECT_URL = "app://librus"
|
||||
const val LIBRUS_AUTHORIZE_URL = "https://portal.librus.pl/oauth2/authorize?client_id=$LIBRUS_CLIENT_ID&redirect_uri=$LIBRUS_REDIRECT_URL&response_type=code"
|
||||
const val LIBRUS_LOGIN_URL = "https://portal.librus.pl/rodzina/login/action"
|
||||
const val LIBRUS_AUTHORIZE_URL = "https://portal.librus.pl/konto-librus/redirect/dru"
|
||||
const val LIBRUS_LOGIN_URL = "https://portal.librus.pl/konto-librus/login/action"
|
||||
const val LIBRUS_TOKEN_URL = "https://portal.librus.pl/oauth2/access_token"
|
||||
const val LIBRUS_HEADER = "pl.librus.synergiaDru2"
|
||||
|
||||
const val LIBRUS_ACCOUNT_URL = "/v3/SynergiaAccounts/fresh/" // + login
|
||||
const val LIBRUS_ACCOUNTS_URL = "/v3/SynergiaAccounts"
|
||||
@ -59,9 +60,6 @@ const val LIBRUS_SANDBOX_URL = "https://sandbox.librus.pl/index.php?action="
|
||||
const val LIBRUS_SYNERGIA_HOMEWORK_ATTACHMENT_URL = "https://synergia.librus.pl/homework/downloadFile"
|
||||
const val LIBRUS_SYNERGIA_MESSAGES_ATTACHMENT_URL = "https://synergia.librus.pl/wiadomosci/pobierz_zalacznik"
|
||||
|
||||
const val LIBRUS_PORTAL_RECAPTCHA_KEY = "6Lf48moUAAAAAB9ClhdvHr46gRWR"
|
||||
const val LIBRUS_PORTAL_RECAPTCHA_REFERER = "https://portal.librus.pl/rodzina/login"
|
||||
|
||||
|
||||
val MOBIDZIENNIK_USER_AGENT = SYSTEM_USER_AGENT
|
||||
|
||||
|
@ -24,6 +24,25 @@ object Regexes {
|
||||
"""^\[META:([A-z0-9-&=]+)]""".toRegex()
|
||||
}
|
||||
|
||||
val HTML_INPUT_HIDDEN by lazy {
|
||||
"""<input .*?type="hidden".+?>""".toRegex()
|
||||
}
|
||||
val HTML_INPUT_NAME by lazy {
|
||||
"""name="(.+?)"""".toRegex()
|
||||
}
|
||||
val HTML_INPUT_VALUE by lazy {
|
||||
"""value="(.+?)"""".toRegex()
|
||||
}
|
||||
val HTML_CSRF_TOKEN by lazy {
|
||||
"""name="csrf-token" content="([A-z0-9=+/\-_]+?)"""".toRegex()
|
||||
}
|
||||
val HTML_FORM_ACTION by lazy {
|
||||
"""<form .*?action="(.+?)"""".toRegex()
|
||||
}
|
||||
val HTML_RECAPTCHA_KEY by lazy {
|
||||
"""data-sitekey="(.+?)"""".toRegex()
|
||||
}
|
||||
|
||||
|
||||
|
||||
val MOBIDZIENNIK_GRADES_SUBJECT_NAME by lazy {
|
||||
|
@ -28,6 +28,8 @@ import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
|
||||
import pl.szczodrzynski.edziennik.ext.isBeforeYear
|
||||
import pl.szczodrzynski.edziennik.ext.shouldArchive
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
import pl.szczodrzynski.edziennik.utils.managers.AvailabilityManager.Error.Type
|
||||
|
||||
|
@ -52,28 +52,29 @@ class ProfileArchiver(val app: App, val profile: Profile) {
|
||||
|
||||
when (profile.loginStoreType) {
|
||||
LoginType.LIBRUS -> {
|
||||
profile.removeStudentData("isPremium")
|
||||
profile.removeStudentData("pushDeviceId")
|
||||
profile.removeStudentData("startPointsSemester1")
|
||||
profile.removeStudentData("startPointsSemester2")
|
||||
profile.removeStudentData("enablePointGrades")
|
||||
profile.removeStudentData("enableDescriptiveGrades")
|
||||
profile.studentData.remove("isPremium")
|
||||
profile.studentData.remove("pushDeviceId")
|
||||
profile.studentData.remove("startPointsSemester1")
|
||||
profile.studentData.remove("startPointsSemester2")
|
||||
profile.studentData.remove("enablePointGrades")
|
||||
profile.studentData.remove("enableDescriptiveGrades")
|
||||
}
|
||||
LoginType.MOBIDZIENNIK -> {}
|
||||
LoginType.VULCAN -> {
|
||||
// DataVulcan.isApiLoginValid() returns false so it will update the semester
|
||||
profile.removeStudentData("currentSemesterEndDate")
|
||||
profile.removeStudentData("studentSemesterId")
|
||||
profile.removeStudentData("studentSemesterNumber")
|
||||
profile.removeStudentData("semester1Id")
|
||||
profile.removeStudentData("semester2Id")
|
||||
profile.removeStudentData("studentClassId")
|
||||
profile.studentData.remove("currentSemesterEndDate")
|
||||
profile.studentData.remove("studentSemesterId")
|
||||
profile.studentData.remove("studentSemesterNumber")
|
||||
profile.studentData.remove("semester1Id")
|
||||
profile.studentData.remove("semester2Id")
|
||||
profile.studentData.remove("studentClassId")
|
||||
}
|
||||
LoginType.IDZIENNIK -> {
|
||||
profile.removeStudentData("schoolYearId")
|
||||
profile.studentData.remove("schoolYearId")
|
||||
}
|
||||
LoginType.EDUDZIENNIK -> {}
|
||||
LoginType.PODLASIE -> {}
|
||||
LoginType.USOS -> {}
|
||||
LoginType.DEMO -> {}
|
||||
LoginType.TEMPLATE -> {}
|
||||
}
|
||||
|
@ -10,7 +10,9 @@ import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.ext.currentTimeUnix
|
||||
import pl.szczodrzynski.edziennik.ext.getStudentData
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
import pl.szczodrzynski.edziennik.ext.set
|
||||
|
||||
class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app, profile, loginStore) {
|
||||
|
||||
@ -117,7 +119,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mApiLogin: String? = null
|
||||
var apiLogin: String?
|
||||
get() { mApiLogin = mApiLogin ?: profile?.getStudentData("accountLogin", null); return mApiLogin }
|
||||
set(value) { profile?.putStudentData("accountLogin", value); mApiLogin = value }
|
||||
set(value) { profile["accountLogin"] = value; mApiLogin = value }
|
||||
/**
|
||||
* A Synergia password.
|
||||
* Used: for login (API Login Method) in Synergia mode.
|
||||
@ -126,7 +128,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mApiPassword: String? = null
|
||||
var apiPassword: String?
|
||||
get() { mApiPassword = mApiPassword ?: profile?.getStudentData("accountPassword", null); return mApiPassword }
|
||||
set(value) { profile?.putStudentData("accountPassword", value); mApiPassword = value }
|
||||
set(value) { profile["accountPassword"] = value; mApiPassword = value }
|
||||
|
||||
/**
|
||||
* A JST login Code.
|
||||
@ -135,7 +137,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mApiCode: String? = null
|
||||
var apiCode: String?
|
||||
get() { mApiCode = mApiCode ?: loginStore.getLoginData("accountCode", null); return mApiCode }
|
||||
set(value) { profile?.putStudentData("accountCode", value); mApiCode = value }
|
||||
set(value) { profile["accountCode"] = value; mApiCode = value }
|
||||
/**
|
||||
* A JST login PIN.
|
||||
* Used only during first login in JST mode.
|
||||
@ -143,7 +145,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mApiPin: String? = null
|
||||
var apiPin: String?
|
||||
get() { mApiPin = mApiPin ?: loginStore.getLoginData("accountPin", null); return mApiPin }
|
||||
set(value) { profile?.putStudentData("accountPin", value); mApiPin = value }
|
||||
set(value) { profile["accountPin"] = value; mApiPin = value }
|
||||
|
||||
/**
|
||||
* A Synergia API access token.
|
||||
@ -154,7 +156,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mApiAccessToken: String? = null
|
||||
var apiAccessToken: String?
|
||||
get() { mApiAccessToken = mApiAccessToken ?: profile?.getStudentData("accountToken", null); return mApiAccessToken }
|
||||
set(value) { mApiAccessToken = value; profile?.putStudentData("accountToken", value) ?: return; }
|
||||
set(value) { mApiAccessToken = value; profile["accountToken"] = value ?: return; }
|
||||
/**
|
||||
* A Synergia API refresh token.
|
||||
* Used when refreshing the [apiAccessToken] in JST, Synergia modes.
|
||||
@ -162,7 +164,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mApiRefreshToken: String? = null
|
||||
var apiRefreshToken: String?
|
||||
get() { mApiRefreshToken = mApiRefreshToken ?: profile?.getStudentData("accountRefreshToken", null); return mApiRefreshToken }
|
||||
set(value) { mApiRefreshToken = value; profile?.putStudentData("accountRefreshToken", value) ?: return; }
|
||||
set(value) { mApiRefreshToken = value; profile["accountRefreshToken"] = value ?: return; }
|
||||
/**
|
||||
* The expiry time for [apiAccessToken], as a UNIX timestamp.
|
||||
* Used when refreshing the [apiAccessToken] in JST, Synergia modes.
|
||||
@ -171,7 +173,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mApiTokenExpiryTime: Long? = null
|
||||
var apiTokenExpiryTime: Long
|
||||
get() { mApiTokenExpiryTime = mApiTokenExpiryTime ?: profile?.getStudentData("accountTokenTime", 0L); return mApiTokenExpiryTime ?: 0L }
|
||||
set(value) { mApiTokenExpiryTime = value; profile?.putStudentData("accountTokenTime", value) ?: return; }
|
||||
set(value) { mApiTokenExpiryTime = value; profile["accountTokenTime"] = value; }
|
||||
|
||||
/**
|
||||
* A push device ID, generated by Librus when registering
|
||||
@ -181,7 +183,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mPushDeviceId: Int? = null
|
||||
var pushDeviceId: Int
|
||||
get() { mPushDeviceId = mPushDeviceId ?: profile?.getStudentData("pushDeviceId", 0); return mPushDeviceId ?: 0 }
|
||||
set(value) { mPushDeviceId = value; profile?.putStudentData("pushDeviceId", value) ?: return; }
|
||||
set(value) { mPushDeviceId = value; profile["pushDeviceId"] = value; }
|
||||
|
||||
/* _____ _
|
||||
/ ____| (_)
|
||||
@ -198,7 +200,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mSynergiaSessionId: String? = null
|
||||
var synergiaSessionId: String?
|
||||
get() { mSynergiaSessionId = mSynergiaSessionId ?: profile?.getStudentData("accountSID", null); return mSynergiaSessionId }
|
||||
set(value) { profile?.putStudentData("accountSID", value) ?: return; mSynergiaSessionId = value }
|
||||
set(value) { profile["accountSID"] = value; mSynergiaSessionId = value }
|
||||
/**
|
||||
* The expiry time for [synergiaSessionId], as a UNIX timestamp.
|
||||
* Used in endpoints with Synergia login method.
|
||||
@ -207,7 +209,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mSynergiaSessionIdExpiryTime: Long? = null
|
||||
var synergiaSessionIdExpiryTime: Long
|
||||
get() { mSynergiaSessionIdExpiryTime = mSynergiaSessionIdExpiryTime ?: profile?.getStudentData("accountSIDTime", 0L); return mSynergiaSessionIdExpiryTime ?: 0L }
|
||||
set(value) { profile?.putStudentData("accountSIDTime", value) ?: return; mSynergiaSessionIdExpiryTime = value }
|
||||
set(value) { profile["accountSIDTime"] = value; mSynergiaSessionIdExpiryTime = value }
|
||||
|
||||
|
||||
/**
|
||||
@ -217,7 +219,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mMessagesSessionId: String? = null
|
||||
var messagesSessionId: String?
|
||||
get() { mMessagesSessionId = mMessagesSessionId ?: profile?.getStudentData("messagesSID", null); return mMessagesSessionId }
|
||||
set(value) { profile?.putStudentData("messagesSID", value) ?: return; mMessagesSessionId = value }
|
||||
set(value) { profile["messagesSID"] = value; mMessagesSessionId = value }
|
||||
/**
|
||||
* The expiry time for [messagesSessionId], as a UNIX timestamp.
|
||||
* Used in endpoints with Messages login method.
|
||||
@ -226,7 +228,7 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mMessagesSessionIdExpiryTime: Long? = null
|
||||
var messagesSessionIdExpiryTime: Long
|
||||
get() { mMessagesSessionIdExpiryTime = mMessagesSessionIdExpiryTime ?: profile?.getStudentData("messagesSIDTime", 0L); return mMessagesSessionIdExpiryTime ?: 0L }
|
||||
set(value) { profile?.putStudentData("messagesSIDTime", value) ?: return; mMessagesSessionIdExpiryTime = value }
|
||||
set(value) { profile["messagesSIDTime"] = value; mMessagesSessionIdExpiryTime = value }
|
||||
|
||||
/* ____ _ _
|
||||
/ __ \| | | |
|
||||
@ -236,42 +238,42 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
\____/ \__|_| |_|\___|*/
|
||||
var isPremium
|
||||
get() = profile?.getStudentData("isPremium", false) ?: false
|
||||
set(value) { profile?.putStudentData("isPremium", value) }
|
||||
set(value) { profile["isPremium"] = value }
|
||||
|
||||
private var mSchoolName: String? = null
|
||||
var schoolName: String?
|
||||
get() { mSchoolName = mSchoolName ?: profile?.getStudentData("schoolName", null); return mSchoolName }
|
||||
set(value) { profile?.putStudentData("schoolName", value) ?: return; mSchoolName = value }
|
||||
set(value) { profile["schoolName"] = value; mSchoolName = value }
|
||||
|
||||
private var mUnitId: Long? = null
|
||||
var unitId: Long
|
||||
get() { mUnitId = mUnitId ?: profile?.getStudentData("unitId", 0L); return mUnitId ?: 0L }
|
||||
set(value) { profile?.putStudentData("unitId", value) ?: return; mUnitId = value }
|
||||
set(value) { profile["unitId"] = value; mUnitId = value }
|
||||
|
||||
private var mStartPointsSemester1: Int? = null
|
||||
var startPointsSemester1: Int
|
||||
get() { mStartPointsSemester1 = mStartPointsSemester1 ?: profile?.getStudentData("startPointsSemester1", 0); return mStartPointsSemester1 ?: 0 }
|
||||
set(value) { profile?.putStudentData("startPointsSemester1", value) ?: return; mStartPointsSemester1 = value }
|
||||
set(value) { profile["startPointsSemester1"] = value; mStartPointsSemester1 = value }
|
||||
|
||||
private var mStartPointsSemester2: Int? = null
|
||||
var startPointsSemester2: Int
|
||||
get() { mStartPointsSemester2 = mStartPointsSemester2 ?: profile?.getStudentData("startPointsSemester2", 0); return mStartPointsSemester2 ?: 0 }
|
||||
set(value) { profile?.putStudentData("startPointsSemester2", value) ?: return; mStartPointsSemester2 = value }
|
||||
set(value) { profile["startPointsSemester2"] = value; mStartPointsSemester2 = value }
|
||||
|
||||
private var mEnablePointGrades: Boolean? = null
|
||||
var enablePointGrades: Boolean
|
||||
get() { mEnablePointGrades = mEnablePointGrades ?: profile?.getStudentData("enablePointGrades", true); return mEnablePointGrades ?: true }
|
||||
set(value) { profile?.putStudentData("enablePointGrades", value) ?: return; mEnablePointGrades = value }
|
||||
set(value) { profile["enablePointGrades"] = value; mEnablePointGrades = value }
|
||||
|
||||
private var mEnableDescriptiveGrades: Boolean? = null
|
||||
var enableDescriptiveGrades: Boolean
|
||||
get() { mEnableDescriptiveGrades = mEnableDescriptiveGrades ?: profile?.getStudentData("enableDescriptiveGrades", true); return mEnableDescriptiveGrades ?: true }
|
||||
set(value) { profile?.putStudentData("enableDescriptiveGrades", value) ?: return; mEnableDescriptiveGrades = value }
|
||||
set(value) { profile["enableDescriptiveGrades"] = value; mEnableDescriptiveGrades = value }
|
||||
|
||||
private var mTimetableNotPublic: Boolean? = null
|
||||
var timetableNotPublic: Boolean
|
||||
get() { mTimetableNotPublic = mTimetableNotPublic ?: profile?.getStudentData("timetableNotPublic", false); return mTimetableNotPublic ?: false }
|
||||
set(value) { profile?.putStudentData("timetableNotPublic", value) ?: return; mTimetableNotPublic = value }
|
||||
set(value) { profile["timetableNotPublic"] = value; mTimetableNotPublic = value }
|
||||
|
||||
/**
|
||||
* Set to false when Recaptcha helper doesn't provide a working token.
|
||||
|
@ -39,6 +39,7 @@ class LibrusRecaptchaHelper(
|
||||
private var timedOut = false
|
||||
|
||||
inner class WebViewClient : android.webkit.WebViewClient() {
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
|
||||
timeout?.cancel()
|
||||
if (!timedOut) {
|
||||
|
@ -36,7 +36,7 @@ class LibrusApiNotices(override val data: DataLibrus,
|
||||
val id = note.getLong("Id") ?: return@forEach
|
||||
val text = note.getString("Text") ?: ""
|
||||
val categoryId = note.getJsonObject("Category")?.getLong("Id") ?: -1
|
||||
val teacherId = note.getJsonObject("AddedBy")?.getLong("Id") ?: -1
|
||||
val teacherId = note.getJsonObject("Teacher")?.getLong("Id") ?: -1
|
||||
val addedDate = note.getString("Date")?.let { Date.fromY_m_d(it) } ?: return@forEach
|
||||
|
||||
val type = when (note.getInt("Positive")) {
|
||||
|
@ -190,6 +190,7 @@ class LibrusApiTimetables(override val data: DataLibrus,
|
||||
}
|
||||
|
||||
lessonObject.id = lessonObject.buildId()
|
||||
lessonObject.ownerId = lessonObject.buildOwnerId()
|
||||
|
||||
val seen = profile.empty || lessonDate < Date.getToday()
|
||||
|
||||
|
@ -125,7 +125,7 @@ class LibrusMessagesGetMessage(override val data: DataLibrus,
|
||||
val receiverId = teacher?.id ?: -1
|
||||
teacher?.loginId = receiverLoginId
|
||||
|
||||
val readDateText = message.select("readed").text()
|
||||
val readDateText = receiver.select("readed").text()
|
||||
val readDate = when (readDateText.isNotNullNorEmpty()) {
|
||||
true -> Date.fromIso(readDateText)
|
||||
else -> 0
|
||||
|
@ -16,6 +16,7 @@ import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.HOUR
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
import pl.szczodrzynski.edziennik.ext.getSemesterStart
|
||||
import pl.szczodrzynski.edziennik.ext.singleOrNull
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
|
||||
|
@ -24,6 +24,9 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
private const val TAG = "LoginLibrusPortal"
|
||||
}
|
||||
|
||||
// loop failsafe
|
||||
private var loginPerformed = false
|
||||
|
||||
init { run {
|
||||
if (data.loginStore.mode != LoginMode.LIBRUS_EMAIL) {
|
||||
data.error(ApiError(TAG, ERROR_INVALID_LOGIN_MODE))
|
||||
@ -33,6 +36,7 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
data.error(ApiError(TAG, ERROR_LOGIN_DATA_MISSING))
|
||||
return@run
|
||||
}
|
||||
loginPerformed = false
|
||||
|
||||
// succeed having a non-expired access token and a refresh token
|
||||
if (data.isPortalLoginValid()) {
|
||||
@ -58,18 +62,23 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
}
|
||||
}}
|
||||
|
||||
private fun authorize(url: String?) {
|
||||
private fun authorize(url: String, referer: String? = null) {
|
||||
d(TAG, "Request: Librus/Login/Portal - $url")
|
||||
|
||||
Request.builder()
|
||||
.url(url)
|
||||
.userAgent(LIBRUS_USER_AGENT)
|
||||
.also {
|
||||
if (referer != null)
|
||||
it.addHeader("Referer", referer)
|
||||
}
|
||||
.addHeader("X-Requested-With", LIBRUS_HEADER)
|
||||
.withClient(data.app.httpLazy)
|
||||
.callback(object : TextCallbackHandler() {
|
||||
override fun onSuccess(text: String, response: Response) {
|
||||
val location = response.headers().get("Location")
|
||||
if (location != null) {
|
||||
val authMatcher = Pattern.compile("$LIBRUS_REDIRECT_URL\\?code=([A-z0-9]+?)$", Pattern.DOTALL or Pattern.MULTILINE).matcher(location)
|
||||
val authMatcher = Pattern.compile("$LIBRUS_REDIRECT_URL\\?code=([^&?]+)", Pattern.DOTALL or Pattern.MULTILINE).matcher(location)
|
||||
when {
|
||||
authMatcher.find() -> {
|
||||
accessToken(authMatcher.group(1), null)
|
||||
@ -83,16 +92,31 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
authorize(location)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val csrfMatcher = Pattern.compile("name=\"csrf-token\" content=\"([A-z0-9=+/\\-_]+?)\"", Pattern.DOTALL).matcher(text)
|
||||
if (csrfMatcher.find()) {
|
||||
login(csrfMatcher.group(1) ?: "")
|
||||
} else {
|
||||
data.error(ApiError(TAG, ERROR_LOGIN_LIBRUS_PORTAL_CSRF_MISSING)
|
||||
.withResponse(response)
|
||||
.withApiResponse(text))
|
||||
return
|
||||
}
|
||||
|
||||
if (checkError(text, response))
|
||||
return
|
||||
|
||||
var loginUrl = if (data.fakeLogin) FAKE_LIBRUS_LOGIN else LIBRUS_LOGIN_URL
|
||||
val csrfToken = Regexes.HTML_CSRF_TOKEN.find(text)?.get(1) ?: ""
|
||||
|
||||
for (match in Regexes.HTML_FORM_ACTION.findAll(text)) {
|
||||
val form = match.value.lowercase()
|
||||
if ("login" in form && "post" in form) {
|
||||
loginUrl = match[1]
|
||||
}
|
||||
}
|
||||
|
||||
val params = mutableMapOf<String, String>()
|
||||
for (match in Regexes.HTML_INPUT_HIDDEN.findAll(text)) {
|
||||
val input = match.value
|
||||
val name = Regexes.HTML_INPUT_NAME.find(input)?.get(1) ?: continue
|
||||
val value = Regexes.HTML_INPUT_VALUE.find(input)?.get(1) ?: continue
|
||||
params[name] = value
|
||||
}
|
||||
|
||||
login(url = loginUrl, referer = url, csrfToken, params)
|
||||
}
|
||||
|
||||
override fun onFailure(response: Response, throwable: Throwable) {
|
||||
@ -105,8 +129,54 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
.enqueue()
|
||||
}
|
||||
|
||||
private fun login(csrfToken: String) {
|
||||
d(TAG, "Request: Librus/Login/Portal - ${if (data.fakeLogin) FAKE_LIBRUS_LOGIN else LIBRUS_LOGIN_URL}")
|
||||
private fun checkError(text: String, response: Response): Boolean {
|
||||
when {
|
||||
text.contains("librus_account_settings_main") -> return false
|
||||
text.contains("Sesja logowania wygasła") -> ERROR_LOGIN_LIBRUS_PORTAL_CSRF_EXPIRED
|
||||
text.contains("Upewnij się, że nie") -> ERROR_LOGIN_LIBRUS_PORTAL_INVALID_LOGIN
|
||||
text.contains("Podany adres e-mail jest nieprawidłowy.") -> ERROR_LOGIN_LIBRUS_PORTAL_INVALID_LOGIN
|
||||
else -> null // no error for now
|
||||
}?.let { errorCode ->
|
||||
data.error(ApiError(TAG, errorCode)
|
||||
.withApiResponse(text)
|
||||
.withResponse(response))
|
||||
return true
|
||||
}
|
||||
|
||||
if ("robotem" in text || "g-recaptcha" in text || "captchaValidate" in text) {
|
||||
val siteKey = Regexes.HTML_RECAPTCHA_KEY.find(text)?.get(1)
|
||||
if (siteKey == null) {
|
||||
data.error(ApiError(TAG, ERROR_LOGIN_LIBRUS_PORTAL_ACTION_ERROR)
|
||||
.withApiResponse(text)
|
||||
.withResponse(response))
|
||||
return true
|
||||
}
|
||||
data.requireUserAction(
|
||||
type = UserActionRequiredEvent.Type.RECAPTCHA,
|
||||
params = Bundle(
|
||||
"siteKey" to siteKey,
|
||||
"referer" to response.request().url().toString(),
|
||||
"userAgent" to LIBRUS_USER_AGENT,
|
||||
),
|
||||
errorText = R.string.notification_user_action_required_captcha_librus,
|
||||
)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun login(
|
||||
url: String,
|
||||
referer: String,
|
||||
csrfToken: String?,
|
||||
params: Map<String, String>,
|
||||
) {
|
||||
if (loginPerformed) {
|
||||
data.error(ApiError(TAG, ERROR_LOGIN_LIBRUS_PORTAL_ACTION_ERROR))
|
||||
return
|
||||
}
|
||||
|
||||
d(TAG, "Request: Librus/Login/Portal - $url")
|
||||
|
||||
val recaptchaCode = data.arguments?.getString("recaptchaCode") ?: data.loginStore.getLoginData("recaptchaCode", null)
|
||||
val recaptchaTime = data.arguments?.getLong("recaptchaTime") ?: data.loginStore.getLoginData("recaptchaTime", 0L)
|
||||
@ -116,67 +186,46 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
Request.builder()
|
||||
.url(if (data.fakeLogin) FAKE_LIBRUS_LOGIN else LIBRUS_LOGIN_URL)
|
||||
.userAgent(LIBRUS_USER_AGENT)
|
||||
.addHeader("X-Requested-With", LIBRUS_HEADER)
|
||||
.addHeader("Referer", referer)
|
||||
.withClient(data.app.httpLazy)
|
||||
.addParameter("email", data.portalEmail)
|
||||
.addParameter("password", data.portalPassword)
|
||||
.also {
|
||||
if (recaptchaCode != null && System.currentTimeMillis() - recaptchaTime < 2*60*1000 /* 2 minutes */)
|
||||
it.addParameter("g-recaptcha-response", recaptchaCode)
|
||||
if (csrfToken != null)
|
||||
it.addHeader("X-CSRF-TOKEN", csrfToken)
|
||||
for ((key, value) in params) {
|
||||
it.addParameter(key, value)
|
||||
}
|
||||
}
|
||||
.addHeader("X-CSRF-TOKEN", csrfToken)
|
||||
.allowErrorCode(HTTP_BAD_REQUEST)
|
||||
.allowErrorCode(HTTP_FORBIDDEN)
|
||||
.contentType(MediaTypeUtils.APPLICATION_JSON)
|
||||
.contentType(MediaTypeUtils.APPLICATION_FORM)
|
||||
.post()
|
||||
.callback(object : JsonCallbackHandler() {
|
||||
override fun onSuccess(json: JsonObject?, response: Response) {
|
||||
.callback(object : TextCallbackHandler() {
|
||||
override fun onSuccess(text: String?, response: Response) {
|
||||
loginPerformed = true
|
||||
val location = response.headers()?.get("Location")
|
||||
if (location == "$LIBRUS_REDIRECT_URL?command=close") {
|
||||
data.error(ApiError(TAG, ERROR_LIBRUS_PORTAL_MAINTENANCE)
|
||||
.withApiResponse(json)
|
||||
.withApiResponse(text)
|
||||
.withResponse(response))
|
||||
return
|
||||
}
|
||||
|
||||
if (json == null) {
|
||||
if (response.parserErrorBody?.contains("wciąż nieaktywne") == true) {
|
||||
data.error(ApiError(TAG, ERROR_LOGIN_LIBRUS_PORTAL_NOT_ACTIVATED)
|
||||
.withResponse(response))
|
||||
return
|
||||
}
|
||||
if (text == null) {
|
||||
data.error(ApiError(TAG, ERROR_RESPONSE_EMPTY)
|
||||
.withResponse(response))
|
||||
return
|
||||
}
|
||||
val error = if (response.code() == 200) null else
|
||||
json.getJsonArray("errors")?.getString(0)
|
||||
?: json.getJsonObject("errors")?.entrySet()?.firstOrNull()?.value?.asString
|
||||
|
||||
if (error?.contains("robotem") == true || json.getBoolean("captchaRequired") == true) {
|
||||
data.requireUserAction(
|
||||
type = UserActionRequiredEvent.Type.RECAPTCHA,
|
||||
params = Bundle(
|
||||
"siteKey" to LIBRUS_PORTAL_RECAPTCHA_KEY,
|
||||
"referer" to LIBRUS_PORTAL_RECAPTCHA_REFERER,
|
||||
),
|
||||
errorText = R.string.notification_user_action_required_captcha_librus,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
error?.let { code ->
|
||||
when {
|
||||
code.contains("Sesja logowania wygasła") -> ERROR_LOGIN_LIBRUS_PORTAL_CSRF_EXPIRED
|
||||
code.contains("Upewnij się, że nie") -> ERROR_LOGIN_LIBRUS_PORTAL_INVALID_LOGIN
|
||||
code.contains("Podany adres e-mail jest nieprawidłowy.") -> ERROR_LOGIN_LIBRUS_PORTAL_INVALID_LOGIN
|
||||
else -> ERROR_LOGIN_LIBRUS_PORTAL_ACTION_ERROR
|
||||
}.let { errorCode ->
|
||||
data.error(ApiError(TAG, errorCode)
|
||||
.withApiResponse(json)
|
||||
.withResponse(response))
|
||||
return
|
||||
}
|
||||
}
|
||||
authorize(json.getString("redirect", LIBRUS_AUTHORIZE_URL))
|
||||
authorize(
|
||||
url = location
|
||||
?: if (data.fakeLogin)
|
||||
FAKE_LIBRUS_AUTHORIZE
|
||||
else
|
||||
LIBRUS_AUTHORIZE_URL,
|
||||
referer = referer,
|
||||
)
|
||||
}
|
||||
|
||||
override fun onFailure(response: Response, throwable: Throwable) {
|
||||
|
@ -11,7 +11,9 @@ import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.ext.currentTimeUnix
|
||||
import pl.szczodrzynski.edziennik.ext.getStudentData
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
import pl.szczodrzynski.edziennik.ext.set
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
|
||||
@ -85,7 +87,7 @@ class DataMobidziennik(app: App, profile: Profile?, loginStore: LoginStore) : Da
|
||||
private var mStudentId: Int? = null
|
||||
var studentId: Int
|
||||
get() { mStudentId = mStudentId ?: profile?.getStudentData("studentId", 0); return mStudentId ?: 0 }
|
||||
set(value) { profile?.putStudentData("studentId", value) ?: return; mStudentId = value }
|
||||
set(value) { profile["studentId"] = value; mStudentId = value }
|
||||
|
||||
/* __ __ _
|
||||
\ \ / / | |
|
||||
@ -125,7 +127,7 @@ class DataMobidziennik(app: App, profile: Profile?, loginStore: LoginStore) : Da
|
||||
*/
|
||||
var globalId: String?
|
||||
get() { mGlobalId = mGlobalId ?: profile?.getStudentData("globalId", null); return mGlobalId }
|
||||
set(value) { profile?.putStudentData("globalId", value) ?: return; mGlobalId = value }
|
||||
set(value) { profile["globalId"] = value; mGlobalId = value }
|
||||
private var mGlobalId: String? = null
|
||||
|
||||
/**
|
||||
@ -135,7 +137,7 @@ class DataMobidziennik(app: App, profile: Profile?, loginStore: LoginStore) : Da
|
||||
*/
|
||||
var loginEmail: String?
|
||||
get() { mLoginEmail = mLoginEmail ?: profile?.getStudentData("email", null); return mLoginEmail }
|
||||
set(value) { profile?.putStudentData("email", value); mLoginEmail = value }
|
||||
set(value) { profile["email"] = value; mLoginEmail = value }
|
||||
private var mLoginEmail: String? = null
|
||||
|
||||
/**
|
||||
@ -144,7 +146,7 @@ class DataMobidziennik(app: App, profile: Profile?, loginStore: LoginStore) : Da
|
||||
*/
|
||||
var loginId: String?
|
||||
get() { mLoginId = mLoginId ?: profile?.getStudentData("loginId", null); return mLoginId }
|
||||
set(value) { profile?.putStudentData("loginId", value) ?: return; mLoginId = value }
|
||||
set(value) { profile["loginId"] = value; mLoginId = value }
|
||||
private var mLoginId: String? = null
|
||||
|
||||
/**
|
||||
@ -152,7 +154,7 @@ class DataMobidziennik(app: App, profile: Profile?, loginStore: LoginStore) : Da
|
||||
*/
|
||||
var ciasteczkoAutoryzacji: String?
|
||||
get() { mCiasteczkoAutoryzacji = mCiasteczkoAutoryzacji ?: profile?.getStudentData("ciasteczkoAutoryzacji", null); return mCiasteczkoAutoryzacji }
|
||||
set(value) { profile?.putStudentData("ciasteczkoAutoryzacji", value) ?: return; mCiasteczkoAutoryzacji = value }
|
||||
set(value) { profile["ciasteczkoAutoryzacji"] = value; mCiasteczkoAutoryzacji = value }
|
||||
private var mCiasteczkoAutoryzacji: String? = null
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Attendance.Companion.TYPE_PRESE
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Attendance.Companion.TYPE_RELEASED
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.dateToSemester
|
||||
|
||||
class MobidziennikApiAttendance(val data: DataMobidziennik, rows: List<String>) {
|
||||
init { run {
|
||||
|
@ -88,6 +88,7 @@ class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List<String>) {
|
||||
}
|
||||
|
||||
it.id = it.buildId()
|
||||
it.ownerId = it.buildOwnerId()
|
||||
|
||||
val seen = profile.empty || date < Date.getToday()
|
||||
|
||||
|
@ -10,6 +10,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.ENDPOINT_MOBID
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.MobidziennikWeb
|
||||
import pl.szczodrzynski.edziennik.ext.DAY
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorBlank
|
||||
|
||||
class MobidziennikWebAccountEmail(override val data: DataMobidziennik,
|
||||
override val lastSync: Long?,
|
||||
@ -24,7 +25,8 @@ class MobidziennikWebAccountEmail(override val data: DataMobidziennik,
|
||||
MobidziennikLuckyNumberExtractor(data, text)
|
||||
|
||||
val email = Regexes.MOBIDZIENNIK_ACCOUNT_EMAIL.find(text)?.let { it[1] }
|
||||
data.loginEmail = email
|
||||
if (email.isNotNullNorBlank())
|
||||
data.loginEmail = email
|
||||
|
||||
data.setSyncNext(ENDPOINT_MOBIDZIENNIK_WEB_ACCOUNT_EMAIL, if (email == null) 3* DAY else 7* DAY)
|
||||
onSuccess(ENDPOINT_MOBIDZIENNIK_WEB_ACCOUNT_EMAIL)
|
||||
|
@ -21,6 +21,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Attendance.Companion.TYPE_UNKNO
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.dateToSemester
|
||||
import pl.szczodrzynski.edziennik.ext.fixName
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
import pl.szczodrzynski.edziennik.ext.singleOrNull
|
||||
|
@ -15,6 +15,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_NORMAL
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.dateToSemester
|
||||
import pl.szczodrzynski.edziennik.ext.fixWhiteSpaces
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
import pl.szczodrzynski.edziennik.ext.singleOrNull
|
||||
|
@ -336,6 +336,7 @@ class MobidziennikWebTimetable(
|
||||
}
|
||||
|
||||
it.id = it.buildId()
|
||||
it.ownerId = it.buildOwnerId()
|
||||
it.isExtra = isExtra
|
||||
|
||||
val seen = profile?.empty == false || lessonDate < Date.getToday()
|
||||
|
@ -16,6 +16,7 @@ import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.ext.JsonObject
|
||||
import pl.szczodrzynski.edziennik.ext.getJsonObject
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorBlank
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
import pl.szczodrzynski.edziennik.utils.Utils
|
||||
|
||||
@ -77,7 +78,9 @@ class MobidziennikLoginApi2(val data: DataMobidziennik, val onSuccess: () -> Uni
|
||||
}
|
||||
}
|
||||
|
||||
data.loginEmail = json.getString("email")
|
||||
val email = json.getString("email")
|
||||
if (email.isNotNullNorBlank())
|
||||
data.loginEmail = email
|
||||
data.globalId = json.getString("id_global")
|
||||
data.loginId = json.getString("login")
|
||||
onSuccess()
|
||||
|
@ -10,7 +10,9 @@ import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.ext.crc32
|
||||
import pl.szczodrzynski.edziennik.ext.getStudentData
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
import pl.szczodrzynski.edziennik.ext.set
|
||||
|
||||
class DataPodlasie(app: App, profile: Profile?, loginStore: LoginStore) : Data(app, profile, loginStore) {
|
||||
|
||||
@ -40,7 +42,7 @@ class DataPodlasie(app: App, profile: Profile?, loginStore: LoginStore) : Data(a
|
||||
private var mApiUrl: String? = null
|
||||
var apiUrl: String?
|
||||
get() { mApiUrl = mApiUrl ?: profile?.getStudentData("apiUrl", null); return mApiUrl }
|
||||
set(value) { profile?.putStudentData("apiUrl", value) ?: return; mApiUrl = value }
|
||||
set(value) { profile["apiUrl"] = value; mApiUrl = value }
|
||||
|
||||
/* ____ _ _
|
||||
/ __ \| | | |
|
||||
@ -51,32 +53,32 @@ class DataPodlasie(app: App, profile: Profile?, loginStore: LoginStore) : Data(a
|
||||
private var mStudentId: String? = null
|
||||
var studentId: String?
|
||||
get() { mStudentId = mStudentId ?: profile?.getStudentData("studentId", null); return mStudentId }
|
||||
set(value) { profile?.putStudentData("studentId", value) ?: return; mStudentId = value }
|
||||
set(value) { profile["studentId"] = value; mStudentId = value }
|
||||
|
||||
private var mStudentLogin: String? = null
|
||||
var studentLogin: String?
|
||||
get() { mStudentLogin = mStudentLogin ?: profile?.getStudentData("studentLogin", null); return mStudentLogin }
|
||||
set(value) { profile?.putStudentData("studentLogin", value) ?: return; mStudentLogin = value }
|
||||
set(value) { profile["studentLogin"] = value; mStudentLogin = value }
|
||||
|
||||
private var mSchoolName: String? = null
|
||||
var schoolName: String?
|
||||
get() { mSchoolName = mSchoolName ?: profile?.getStudentData("schoolName", null); return mSchoolName }
|
||||
set(value) { profile?.putStudentData("schoolName", value) ?: return; mSchoolName = value }
|
||||
set(value) { profile["schoolName"] = value; mSchoolName = value }
|
||||
|
||||
private var mClassName: String? = null
|
||||
var className: String?
|
||||
get() { mClassName = mClassName ?: profile?.getStudentData("className", null); return mClassName }
|
||||
set(value) { profile?.putStudentData("className", value) ?: return; mClassName = value }
|
||||
set(value) { profile["className"] = value; mClassName = value }
|
||||
|
||||
private var mSchoolYear: String? = null
|
||||
var schoolYear: String?
|
||||
get() { mSchoolYear = mSchoolYear ?: profile?.getStudentData("schoolYear", null); return mSchoolYear }
|
||||
set(value) { profile?.putStudentData("schoolYear", value) ?: return; mSchoolYear = value }
|
||||
set(value) { profile["schoolYear"] = value; mSchoolYear = value }
|
||||
|
||||
private var mCurrentSemester: Int? = null
|
||||
var currentSemester: Int
|
||||
get() { mCurrentSemester = mCurrentSemester ?: profile?.getStudentData("currentSemester", 0); return mCurrentSemester ?: 0 }
|
||||
set(value) { profile?.putStudentData("currentSemester", value) ?: return; mCurrentSemester = value }
|
||||
set(value) { profile["currentSemester"] = value; mCurrentSemester = value }
|
||||
|
||||
val schoolShortName: String?
|
||||
get() = studentLogin?.split('@')?.get(1)?.replace(".podlaskie.pl", "")
|
||||
|
@ -17,6 +17,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_YEAR_PROPO
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.getLong
|
||||
import pl.szczodrzynski.edziennik.ext.getSemesterStart
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
|
||||
class PodlasieApiFinalGrades(val data: DataPodlasie, val rows: List<JsonObject>) {
|
||||
|
@ -26,7 +26,8 @@ class PodlasieApiGrades(val data: DataPodlasie, val rows: List<JsonObject>) {
|
||||
val weight = grade.getFloat("Weight") ?: 0f
|
||||
val includeToAverage = grade.getInt("IncludeToAverage") != 0
|
||||
val color = grade.getString("Color")?.let { Color.parseColor(it) } ?: -1
|
||||
val category = grade.getString("Category") ?: ""
|
||||
val category = grade.getString("Category")
|
||||
val code = grade.getString("Code")
|
||||
val comment = grade.getString("Comment") ?: ""
|
||||
val semester = grade.getString("TermShortcut")?.length ?: data.currentSemester
|
||||
|
||||
@ -40,6 +41,12 @@ class PodlasieApiGrades(val data: DataPodlasie, val rows: List<JsonObject>) {
|
||||
val addedDate = grade.getString("ReceivedDate")?.let { Date.fromY_m_d(it).inMillis }
|
||||
?: System.currentTimeMillis()
|
||||
|
||||
val categoryText: String = when {
|
||||
code != null && category != null -> "$code - $category"
|
||||
code != null -> code
|
||||
else -> category ?: ""
|
||||
}
|
||||
|
||||
val gradeObject = Grade(
|
||||
profileId = data.profileId,
|
||||
id = id,
|
||||
@ -48,7 +55,7 @@ class PodlasieApiGrades(val data: DataPodlasie, val rows: List<JsonObject>) {
|
||||
value = value,
|
||||
weight = if (includeToAverage) weight else 0f,
|
||||
color = color,
|
||||
category = category,
|
||||
category = categoryText,
|
||||
description = null,
|
||||
comment = comment,
|
||||
semester = semester,
|
||||
|
@ -72,6 +72,7 @@ class PodlasieApiTimetable(val data: DataPodlasie, rows: List<JsonObject>) {
|
||||
it.classroom = classroom
|
||||
|
||||
it.id = it.buildId()
|
||||
it.ownerId = it.buildOwnerId()
|
||||
data.lessonList += it
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,9 @@ import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.ext.currentTimeUnix
|
||||
import pl.szczodrzynski.edziennik.ext.getStudentData
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
import pl.szczodrzynski.edziennik.ext.set
|
||||
|
||||
/**
|
||||
* Use http://patorjk.com/software/taag/#p=display&f=Big for the ascii art
|
||||
@ -43,12 +45,12 @@ class DataTemplate(app: App, profile: Profile?, loginStore: LoginStore) : Data(a
|
||||
private var mWebCookie: String? = null
|
||||
var webCookie: String?
|
||||
get() { mWebCookie = mWebCookie ?: profile?.getStudentData("webCookie", null); return mWebCookie }
|
||||
set(value) { profile?.putStudentData("webCookie", value) ?: return; mWebCookie = value }
|
||||
set(value) { profile["webCookie"] = value; mWebCookie = value }
|
||||
|
||||
private var mWebExpiryTime: Long? = null
|
||||
var webExpiryTime: Long
|
||||
get() { mWebExpiryTime = mWebExpiryTime ?: profile?.getStudentData("webExpiryTime", 0L); return mWebExpiryTime ?: 0L }
|
||||
set(value) { profile?.putStudentData("webExpiryTime", value) ?: return; mWebExpiryTime = value }
|
||||
set(value) { profile["webExpiryTime"] = value; mWebExpiryTime = value }
|
||||
|
||||
/* _
|
||||
/\ (_)
|
||||
@ -61,10 +63,10 @@ class DataTemplate(app: App, profile: Profile?, loginStore: LoginStore) : Data(a
|
||||
private var mApiToken: String? = null
|
||||
var apiToken: String?
|
||||
get() { mApiToken = mApiToken ?: profile?.getStudentData("apiToken", null); return mApiToken }
|
||||
set(value) { profile?.putStudentData("apiToken", value) ?: return; mApiToken = value }
|
||||
set(value) { profile["apiToken"] = value; mApiToken = value }
|
||||
|
||||
private var mApiExpiryTime: Long? = null
|
||||
var apiExpiryTime: Long
|
||||
get() { mApiExpiryTime = mApiExpiryTime ?: profile?.getStudentData("apiExpiryTime", 0L); return mApiExpiryTime ?: 0L }
|
||||
set(value) { profile?.putStudentData("apiExpiryTime", value) ?: return; mApiExpiryTime = value }
|
||||
set(value) { profile["apiExpiryTime"] = value; mApiExpiryTime = value }
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ import pl.szczodrzynski.edziennik.data.api.models.Data
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.ext.getStudentData
|
||||
import pl.szczodrzynski.edziennik.ext.set
|
||||
|
||||
class DataUsos(
|
||||
app: App,
|
||||
@ -69,6 +71,6 @@ class DataUsos(
|
||||
|
||||
var studentId: Int
|
||||
get() { mStudentId = mStudentId ?: profile?.getStudentData("studentId", 0); return mStudentId ?: 0 }
|
||||
set(value) { profile?.putStudentData("studentId", value) ?: return; mStudentId = value }
|
||||
set(value) { profile["studentId"] = value; mStudentId = value }
|
||||
private var mStudentId: Int? = null
|
||||
}
|
||||
|
@ -41,24 +41,18 @@ class UsosApiTerms(
|
||||
}
|
||||
|
||||
private fun processResponse(json: JsonArray): Boolean {
|
||||
val dates = mutableSetOf<Date>()
|
||||
val today = Date.getToday()
|
||||
for (term in json.asJsonObjectList()) {
|
||||
if (!term.getBoolean("is_active", false))
|
||||
continue
|
||||
val startDate = term.getString("start_date")?.let { Date.fromY_m_d(it) }
|
||||
val finishDate = term.getString("finish_date")?.let { Date.fromY_m_d(it) }
|
||||
if (startDate != null)
|
||||
dates += startDate
|
||||
if (finishDate != null)
|
||||
dates += finishDate
|
||||
val startDate = term.getString("start_date")?.let { Date.fromY_m_d(it) } ?: continue
|
||||
val finishDate = term.getString("finish_date")?.let { Date.fromY_m_d(it) } ?: continue
|
||||
if (today in startDate..finishDate) {
|
||||
profile?.studentSchoolYearStart = startDate.year
|
||||
profile?.dateSemester1Start = startDate
|
||||
profile?.dateSemester2Start = finishDate
|
||||
}
|
||||
}
|
||||
val datesSorted = dates.sorted()
|
||||
if (datesSorted.size != 3)
|
||||
return false
|
||||
profile?.studentSchoolYearStart = datesSorted[0].year
|
||||
profile?.dateSemester1Start = datesSorted[0]
|
||||
profile?.dateSemester2Start = datesSorted[1]
|
||||
profile?.dateYearEnd = datesSorted[2]
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -104,8 +104,9 @@ class UsosApiTimetable(
|
||||
it.teacherId = lecturerIds?.firstOrNull() ?: -1L
|
||||
it.teamId = unitId
|
||||
val groupName = classTypeId?.plus(groupNumber)?.let { s -> "($s)" }
|
||||
it.classroom = "$buildingId / $roomNumber ${groupName ?: ""}"
|
||||
it.classroom = "Sala $roomNumber / bud. $buildingId ${groupName ?: ""}"
|
||||
it.id = it.buildId()
|
||||
it.ownerId = it.buildOwnerId()
|
||||
|
||||
it.color = when (classTypeId) {
|
||||
"WYK" -> 0xff0d6091
|
||||
|
@ -12,7 +12,9 @@ import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.ext.crc16
|
||||
import pl.szczodrzynski.edziennik.ext.currentTimeUnix
|
||||
import pl.szczodrzynski.edziennik.ext.getStudentData
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
import pl.szczodrzynski.edziennik.ext.set
|
||||
import pl.szczodrzynski.fslogin.realm.RealmData
|
||||
|
||||
class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app, profile, loginStore) {
|
||||
@ -57,7 +59,7 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mSymbol: String? = null
|
||||
var symbol: String?
|
||||
get() { mSymbol = mSymbol ?: profile?.getStudentData("symbol", null); return mSymbol }
|
||||
set(value) { profile?.putStudentData("symbol", value); mSymbol = value }
|
||||
set(value) { profile["symbol"] = value; mSymbol = value }
|
||||
|
||||
/**
|
||||
* Group symbol/number of the student's school.
|
||||
@ -69,7 +71,7 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mSchoolSymbol: String? = null
|
||||
var schoolSymbol: String?
|
||||
get() { mSchoolSymbol = mSchoolSymbol ?: profile?.getStudentData("schoolSymbol", null); return mSchoolSymbol }
|
||||
set(value) { profile?.putStudentData("schoolSymbol", value) ?: return; mSchoolSymbol = value }
|
||||
set(value) { profile["schoolSymbol"] = value; mSchoolSymbol = value }
|
||||
|
||||
/**
|
||||
* Short name of the school, used in some places.
|
||||
@ -79,7 +81,7 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mSchoolShort: String? = null
|
||||
var schoolShort: String?
|
||||
get() { mSchoolShort = mSchoolShort ?: profile?.getStudentData("schoolShort", null); return mSchoolShort }
|
||||
set(value) { profile?.putStudentData("schoolShort", value) ?: return; mSchoolShort = value }
|
||||
set(value) { profile["schoolShort"] = value; mSchoolShort = value }
|
||||
|
||||
/**
|
||||
* A school code consisting of the [symbol] and [schoolSymbol].
|
||||
@ -91,7 +93,7 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mSchoolCode: String? = null
|
||||
var schoolCode: String?
|
||||
get() { mSchoolCode = mSchoolCode ?: profile?.getStudentData("schoolName", null); return mSchoolCode }
|
||||
set(value) { profile?.putStudentData("schoolName", value) ?: return; mSchoolCode = value }
|
||||
set(value) { profile["schoolName"] = value; mSchoolCode = value }
|
||||
|
||||
/**
|
||||
* ID of the student.
|
||||
@ -101,7 +103,7 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mStudentId: Int? = null
|
||||
var studentId: Int
|
||||
get() { mStudentId = mStudentId ?: profile?.getStudentData("studentId", 0); return mStudentId ?: 0 }
|
||||
set(value) { profile?.putStudentData("studentId", value) ?: return; mStudentId = value }
|
||||
set(value) { profile["studentId"] = value; mStudentId = value }
|
||||
|
||||
/**
|
||||
* ID of the student's account.
|
||||
@ -111,7 +113,7 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mStudentLoginId: Int? = null
|
||||
var studentLoginId: Int
|
||||
get() { mStudentLoginId = mStudentLoginId ?: profile?.getStudentData("studentLoginId", 0); return mStudentLoginId ?: 0 }
|
||||
set(value) { profile?.putStudentData("studentLoginId", value) ?: return; mStudentLoginId = value }
|
||||
set(value) { profile["studentLoginId"] = value; mStudentLoginId = value }
|
||||
|
||||
/**
|
||||
* ID of the student's class.
|
||||
@ -121,7 +123,7 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mStudentClassId: Int? = null
|
||||
var studentClassId: Int
|
||||
get() { mStudentClassId = mStudentClassId ?: profile?.getStudentData("studentClassId", 0); return mStudentClassId ?: 0 }
|
||||
set(value) { profile?.putStudentData("studentClassId", value) ?: return; mStudentClassId = value }
|
||||
set(value) { profile["studentClassId"] = value; mStudentClassId = value }
|
||||
|
||||
/**
|
||||
* ListaUczniow/IdOkresKlasyfikacyjny, e.g. 321
|
||||
@ -129,26 +131,26 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mStudentSemesterId: Int? = null
|
||||
var studentSemesterId: Int
|
||||
get() { mStudentSemesterId = mStudentSemesterId ?: profile?.getStudentData("studentSemesterId", 0); return mStudentSemesterId ?: 0 }
|
||||
set(value) { profile?.putStudentData("studentSemesterId", value) ?: return; mStudentSemesterId = value }
|
||||
set(value) { profile["studentSemesterId"] = value; mStudentSemesterId = value }
|
||||
|
||||
private var mStudentUnitId: Int? = null
|
||||
var studentUnitId: Int
|
||||
get() { mStudentUnitId = mStudentUnitId ?: profile?.getStudentData("studentUnitId", 0); return mStudentUnitId ?: 0 }
|
||||
set(value) { profile?.putStudentData("studentUnitId", value) ?: return; mStudentUnitId = value }
|
||||
set(value) { profile["studentUnitId"] = value; mStudentUnitId = value }
|
||||
|
||||
private var mStudentConstituentId: Int? = null
|
||||
var studentConstituentId: Int
|
||||
get() { mStudentConstituentId = mStudentConstituentId ?: profile?.getStudentData("studentConstituentId", 0); return mStudentConstituentId ?: 0 }
|
||||
set(value) { profile?.putStudentData("studentConstituentId", value) ?: return; mStudentConstituentId = value }
|
||||
set(value) { profile["studentConstituentId"] = value; mStudentConstituentId = value }
|
||||
|
||||
private var mSemester1Id: Int? = null
|
||||
var semester1Id: Int
|
||||
get() { mSemester1Id = mSemester1Id ?: profile?.getStudentData("semester1Id", 0); return mSemester1Id ?: 0 }
|
||||
set(value) { profile?.putStudentData("semester1Id", value) ?: return; mSemester1Id = value }
|
||||
set(value) { profile["semester1Id"] = value; mSemester1Id = value }
|
||||
private var mSemester2Id: Int? = null
|
||||
var semester2Id: Int
|
||||
get() { mSemester2Id = mSemester2Id ?: profile?.getStudentData("semester2Id", 0); return mSemester2Id ?: 0 }
|
||||
set(value) { profile?.putStudentData("semester2Id", value) ?: return; mSemester2Id = value }
|
||||
set(value) { profile["semester2Id"] = value; mSemester2Id = value }
|
||||
|
||||
/**
|
||||
* ListaUczniow/OkresNumer, e.g. 1 or 2
|
||||
@ -156,7 +158,7 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mStudentSemesterNumber: Int? = null
|
||||
var studentSemesterNumber: Int
|
||||
get() { mStudentSemesterNumber = mStudentSemesterNumber ?: profile?.getStudentData("studentSemesterNumber", 0); return mStudentSemesterNumber ?: 0 }
|
||||
set(value) { profile?.putStudentData("studentSemesterNumber", value) ?: return; mStudentSemesterNumber = value }
|
||||
set(value) { profile["studentSemesterNumber"] = value; mStudentSemesterNumber = value }
|
||||
|
||||
/**
|
||||
* Date of the end of the current semester ([studentSemesterNumber]).
|
||||
@ -166,7 +168,7 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mCurrentSemesterEndDate: Long? = null
|
||||
var currentSemesterEndDate: Long
|
||||
get() { mCurrentSemesterEndDate = mCurrentSemesterEndDate ?: profile?.getStudentData("currentSemesterEndDate", 0L); return mCurrentSemesterEndDate ?: 0L }
|
||||
set(value) { profile?.putStudentData("currentSemesterEndDate", value) ?: return; mCurrentSemesterEndDate = value }
|
||||
set(value) { profile["currentSemesterEndDate"] = value; mCurrentSemesterEndDate = value }
|
||||
|
||||
/* _____ _____ ____
|
||||
/\ | __ \_ _| |___ \
|
||||
@ -219,17 +221,17 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
private var mHebeContext: String? = null
|
||||
var hebeContext: String?
|
||||
get() { mHebeContext = mHebeContext ?: profile?.getStudentData("hebeContext", null); return mHebeContext }
|
||||
set(value) { profile?.putStudentData("hebeContext", value) ?: return; mHebeContext = value }
|
||||
set(value) { profile["hebeContext"] = value; mHebeContext = value }
|
||||
|
||||
private var mMessageBoxKey: String? = null
|
||||
var messageBoxKey: String?
|
||||
get() { mMessageBoxKey = mMessageBoxKey ?: profile?.getStudentData("messageBoxKey", null); return mMessageBoxKey }
|
||||
set(value) { profile?.putStudentData("messageBoxKey", value) ?: return; mMessageBoxKey = value }
|
||||
set(value) { profile["messageBoxKey"] = value; mMessageBoxKey = value }
|
||||
|
||||
private var mMessageBoxName: String? = null
|
||||
var messageBoxName: String?
|
||||
get() { mMessageBoxName = mMessageBoxName ?: profile?.getStudentData("messageBoxName", null); return mMessageBoxName }
|
||||
set(value) { profile?.putStudentData("messageBoxName", value) ?: return; mMessageBoxName = value }
|
||||
set(value) { profile["messageBoxName"] = value; mMessageBoxName = value }
|
||||
|
||||
val apiUrl: String?
|
||||
get() {
|
||||
|
@ -26,6 +26,7 @@ import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.HttpURLConnection.HTTP_NOT_FOUND
|
||||
import java.net.URLEncoder
|
||||
import java.time.Instant
|
||||
import java.time.LocalDateTime
|
||||
@ -183,6 +184,7 @@ open class VulcanHebe(open val data: DataVulcan, open val lastSync: Long?) {
|
||||
payload: JsonElement? = null,
|
||||
baseUrl: Boolean = false,
|
||||
firebaseToken: String? = null,
|
||||
allow404: Boolean = false,
|
||||
crossinline onSuccess: (json: T, response: Response?) -> Unit
|
||||
) {
|
||||
val url = "${if (baseUrl) data.apiUrl else data.fullApiUrl}$endpoint"
|
||||
@ -295,6 +297,19 @@ open class VulcanHebe(open val data: DataVulcan, open val lastSync: Long?) {
|
||||
}
|
||||
|
||||
override fun onFailure(response: Response?, throwable: Throwable?) {
|
||||
if (allow404 && response?.code() == HTTP_NOT_FOUND) {
|
||||
try {
|
||||
onSuccess(null as T, response)
|
||||
} catch (e: Exception) {
|
||||
data.error(
|
||||
ApiError(tag, EXCEPTION_VULCAN_HEBE_REQUEST)
|
||||
.withResponse(response)
|
||||
.withThrowable(e)
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
data.error(
|
||||
ApiError(tag, ERROR_REQUEST_FAILURE)
|
||||
.withResponse(response)
|
||||
@ -338,6 +353,7 @@ open class VulcanHebe(open val data: DataVulcan, open val lastSync: Long?) {
|
||||
query: Map<String, String> = mapOf(),
|
||||
baseUrl: Boolean = false,
|
||||
firebaseToken: String? = null,
|
||||
allow404: Boolean = false,
|
||||
crossinline onSuccess: (json: T, response: Response?) -> Unit
|
||||
) {
|
||||
val queryPath = query.map {
|
||||
@ -348,6 +364,7 @@ open class VulcanHebe(open val data: DataVulcan, open val lastSync: Long?) {
|
||||
if (query.isNotEmpty()) "$endpoint?$queryPath" else endpoint,
|
||||
baseUrl = baseUrl,
|
||||
firebaseToken = firebaseToken,
|
||||
allow404 = allow404,
|
||||
onSuccess = onSuccess
|
||||
)
|
||||
}
|
||||
@ -382,6 +399,7 @@ open class VulcanHebe(open val data: DataVulcan, open val lastSync: Long?) {
|
||||
messageBox: String? = null,
|
||||
params: Map<String, String> = mapOf(),
|
||||
includeFilterType: Boolean = true,
|
||||
allow404: Boolean = false,
|
||||
onSuccess: (data: List<JsonObject>, response: Response?) -> Unit
|
||||
) {
|
||||
val url = if (includeFilterType && filterType != null)
|
||||
@ -406,6 +424,7 @@ open class VulcanHebe(open val data: DataVulcan, open val lastSync: Long?) {
|
||||
HebeFilterType.BY_MESSAGEBOX -> {
|
||||
query["box"] = messageBox ?: data.messageBoxKey ?: ""
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
if (dateFrom != null)
|
||||
@ -427,8 +446,8 @@ open class VulcanHebe(open val data: DataVulcan, open val lastSync: Long?) {
|
||||
)
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
|
||||
|
||||
apiGet(tag, url, query) { json: JsonArray, response ->
|
||||
onSuccess(json.map { it.asJsonObject }, response)
|
||||
apiGet(tag, url, query, allow404 = allow404) { json: JsonArray?, response ->
|
||||
onSuccess(json?.map { it.asJsonObject } ?: listOf(), response)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Teacher.Companion.TYPE_PARENTS_
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher.Companion.TYPE_STUDENT
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher.Companion.TYPE_TEACHER
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import java.net.HttpURLConnection.HTTP_NOT_FOUND
|
||||
|
||||
class VulcanHebeAddressbook(
|
||||
override val data: DataVulcan,
|
||||
@ -41,8 +42,15 @@ class VulcanHebeAddressbook(
|
||||
VULCAN_HEBE_ENDPOINT_ADDRESSBOOK,
|
||||
HebeFilterType.BY_PERSON,
|
||||
lastSync = lastSync,
|
||||
includeFilterType = false
|
||||
) { list, _ ->
|
||||
includeFilterType = false,
|
||||
allow404 = true,
|
||||
) { list, response ->
|
||||
if (response?.code() == HTTP_NOT_FOUND) {
|
||||
data.setSyncNext(ENDPOINT_VULCAN_HEBE_ADDRESSBOOK, 2 * DAY)
|
||||
onSuccess(ENDPOINT_VULCAN_HEBE_ADDRESSBOOK)
|
||||
return@apiGetList
|
||||
}
|
||||
|
||||
list.forEach { person ->
|
||||
val id = person.getString("Id") ?: return@forEach
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.hebe
|
||||
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.api.VULCAN_HEBE_ENDPOINT_GRADES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.DataVulcan
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.ENDPOINT_VULCAN_HEBE_GRADES
|
||||
@ -39,6 +38,7 @@ class VulcanHebeGrades(
|
||||
val column = grade.getJsonObject("Column")
|
||||
val category = column.getJsonObject("Category")
|
||||
val categoryText = category.getString("Name")
|
||||
val code = column.getString("Code").takeValue()
|
||||
|
||||
val teacherId = getTeacherId(grade, "Creator") ?: -1
|
||||
val subjectId = getSubjectId(column, "Subject") ?: -1
|
||||
@ -91,6 +91,12 @@ class VulcanHebeGrades(
|
||||
else
|
||||
columnColor
|
||||
|
||||
val categoryFormattedText: String = when {
|
||||
code != null && category != null -> "$code - $categoryText"
|
||||
code != null -> code
|
||||
else -> categoryText ?: ""
|
||||
}
|
||||
|
||||
val gradeObject = Grade(
|
||||
profileId = profileId,
|
||||
id = id,
|
||||
@ -99,7 +105,7 @@ class VulcanHebeGrades(
|
||||
value = value ?: 0.0f,
|
||||
weight = weight,
|
||||
color = color,
|
||||
category = categoryText,
|
||||
category = categoryFormattedText,
|
||||
description = finalDescription,
|
||||
comment = null,
|
||||
semester = getSemester(column),
|
||||
|
@ -247,7 +247,9 @@ class VulcanHebeTimetable(
|
||||
}
|
||||
|
||||
lessonObject.id = lessonObject.buildId()
|
||||
lessonObject.ownerId = lessonObject.buildOwnerId()
|
||||
lessonShift?.id = lessonShift?.buildId() ?: -1
|
||||
lessonShift?.ownerId = lessonShift?.buildOwnerId() ?: -1
|
||||
|
||||
lessonList.add(lessonObject)
|
||||
lessonShift?.let { lessonList.add(it) }
|
||||
|
@ -198,7 +198,6 @@ class SzkolnyApi(val app: App) : CoroutineScope {
|
||||
val teams = app.db.teamDao().allNow
|
||||
|
||||
val users = profiles.mapNotNull { profile ->
|
||||
val config = app.config.getFor(profile.id)
|
||||
val user = ServerSyncRequest.User(
|
||||
profile.userCode,
|
||||
profile.studentNameLong,
|
||||
@ -207,9 +206,9 @@ class SzkolnyApi(val app: App) : CoroutineScope {
|
||||
teams.filter { it.profileId == profile.id }.map { it.code }
|
||||
)
|
||||
val hash = user.toString().md5()
|
||||
if (hash == config.hash)
|
||||
if (hash == profile.config.hash)
|
||||
return@mapNotNull null
|
||||
return@mapNotNull user to config
|
||||
return@mapNotNull user to profile.config
|
||||
}
|
||||
|
||||
val response = api.serverSync(ServerSyncRequest(
|
||||
@ -258,12 +257,10 @@ class SzkolnyApi(val app: App) : CoroutineScope {
|
||||
seen = profile.empty
|
||||
notified = profile.empty
|
||||
|
||||
if (profile.userCode == event.sharedBy) {
|
||||
sharedBy = "self"
|
||||
addedManually = true
|
||||
} else {
|
||||
sharedBy = eventSharedBy
|
||||
}
|
||||
sharedBy = if (profile.userCode == event.sharedBy)
|
||||
"self"
|
||||
else
|
||||
eventSharedBy
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -327,11 +324,14 @@ class SzkolnyApi(val app: App) : CoroutineScope {
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun shareNote(note: Note) {
|
||||
fun shareNote(note: Note, teamId: Long? = null) {
|
||||
val profile = app.db.profileDao().getByIdNow(note.profileId)
|
||||
?: throw NullPointerException("Profile is not found")
|
||||
val team = app.db.teamDao().getClassNow(note.profileId)
|
||||
?: throw NullPointerException("TeamClass is not found")
|
||||
val team = if (teamId == null)
|
||||
app.db.teamDao().getClassNow(note.profileId)
|
||||
else
|
||||
app.db.teamDao().getByIdNow(note.profileId, teamId)
|
||||
team ?: throw NullPointerException("TeamClass is not found")
|
||||
|
||||
val response = api.shareNote(NoteShareRequest(
|
||||
deviceId = app.deviceId,
|
||||
|
@ -29,11 +29,12 @@ class SignatureInterceptor(val app: App) : Interceptor {
|
||||
return chain.proceed(
|
||||
request.newBuilder()
|
||||
.header("X-ApiKey", app.config.apiKeyCustom?.takeValue() ?: API_KEY)
|
||||
.header("X-AppVersion", BuildConfig.VERSION_CODE.toString())
|
||||
.header("X-Timestamp", timestamp.toString())
|
||||
.header("X-Signature", sign(timestamp, body, url))
|
||||
.header("X-AppBuild", BuildConfig.BUILD_TYPE)
|
||||
.header("X-AppFlavor", BuildConfig.FLAVOR)
|
||||
.header("X-AppVersion", BuildConfig.VERSION_CODE.toString())
|
||||
.header("X-DeviceId", app.deviceId)
|
||||
.header("X-Signature", sign(timestamp, body, url))
|
||||
.header("X-Timestamp", timestamp.toString())
|
||||
.build())
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,6 @@ object Signing {
|
||||
|
||||
/*fun provideKey(param1: String, param2: Long): ByteArray {*/
|
||||
fun pleaseStopRightNow(param1: String, param2: Long): ByteArray {
|
||||
return "$param1.MTIzNDU2Nzg5MDCOnsIOWR===.$param2".sha256()
|
||||
return "$param1.MTIzNDU2Nzg5MD01uMP7oW===.$param2".sha256()
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class SzkolnyTask(val app: App, val syncingProfiles: List<Profile>) : IApiTask(-
|
||||
notificationList
|
||||
.mapNotNull { it.profileId }
|
||||
.distinct()
|
||||
.map { app.config.getFor(it).sync.notificationFilter }
|
||||
.map { app.config[it].sync.notificationFilter }
|
||||
.forEach { filter ->
|
||||
filter.forEach { type ->
|
||||
notificationList.removeAll { it.type == type }
|
||||
|
@ -44,7 +44,7 @@ import pl.szczodrzynski.edziennik.data.db.migration.*
|
||||
TimetableManual::class,
|
||||
Note::class,
|
||||
Metadata::class
|
||||
], version = 99)
|
||||
], version = 100)
|
||||
@TypeConverters(
|
||||
ConverterTime::class,
|
||||
ConverterDate::class,
|
||||
@ -188,6 +188,7 @@ abstract class AppDb : RoomDatabase() {
|
||||
Migration97(),
|
||||
Migration98(),
|
||||
Migration99(),
|
||||
Migration100()
|
||||
).allowMainThreadQueries().build()
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,37 @@
|
||||
package pl.szczodrzynski.edziennik.data.db.converter
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMode
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.NotificationType
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import pl.szczodrzynski.edziennik.ui.base.enums.NavTarget
|
||||
|
||||
class ConverterEnums {
|
||||
|
||||
@TypeConverter
|
||||
fun fromEnum(value: Enum<*>?) = value?.toInt()
|
||||
fun fromFeatureType(value: FeatureType?) = value?.id
|
||||
|
||||
@TypeConverter
|
||||
fun fromLoginMethod(value: LoginMethod?) = value?.id
|
||||
|
||||
@TypeConverter
|
||||
fun fromLoginMode(value: LoginMode?) = value?.id
|
||||
|
||||
@TypeConverter
|
||||
fun fromLoginType(value: LoginType?) = value?.id
|
||||
|
||||
@TypeConverter
|
||||
fun fromMetadataType(value: MetadataType?) = value?.id
|
||||
|
||||
@TypeConverter
|
||||
fun fromNotificationType(value: NotificationType?) = value?.id
|
||||
|
||||
@TypeConverter
|
||||
fun fromNavTarget(value: NavTarget?) = value?.id
|
||||
|
||||
@TypeConverter
|
||||
fun toFeatureType(value: Int?) = value.asFeatureTypeOrNull()
|
||||
|
@ -25,6 +25,9 @@ abstract class EventTypeDao {
|
||||
@Query("DELETE FROM eventTypes WHERE profileId = :profileId")
|
||||
abstract fun clear(profileId: Int)
|
||||
|
||||
@Query("DELETE FROM eventTypes WHERE profileId = :profileId AND eventTypeSource = :source")
|
||||
abstract fun clearBySource(profileId: Int, source: Int)
|
||||
|
||||
@Query("SELECT * FROM eventTypes WHERE profileId = :profileId AND eventType = :typeId")
|
||||
abstract fun getByIdNow(profileId: Int, typeId: Long): EventType?
|
||||
|
||||
@ -43,7 +46,7 @@ abstract class EventTypeDao {
|
||||
val typeList = data.eventTypes.map {
|
||||
EventType(
|
||||
profileId = profile.id,
|
||||
id = it.id.toLong(),
|
||||
id = it.id,
|
||||
name = it.name,
|
||||
color = Color.parseColor(it.color),
|
||||
order = order++,
|
||||
@ -53,4 +56,21 @@ abstract class EventTypeDao {
|
||||
addAll(typeList)
|
||||
return typeList
|
||||
}
|
||||
|
||||
fun getAllWithDefaults(profile: Profile): List<EventType> {
|
||||
val eventTypes = getAllNow(profile.id)
|
||||
|
||||
val defaultIdsExpected = AppData.get(profile.loginStoreType).eventTypes
|
||||
.map { it.id }
|
||||
val defaultIdsFound = eventTypes.filter { it.source == SOURCE_DEFAULT }
|
||||
.sortedBy { it.order }
|
||||
.map { it.id }
|
||||
|
||||
if (defaultIdsExpected == defaultIdsFound)
|
||||
return eventTypes
|
||||
|
||||
clearBySource(profile.id, SOURCE_DEFAULT)
|
||||
addDefaultTypes(profile)
|
||||
return eventTypes
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,9 @@ interface ProfileDao {
|
||||
@Query("SELECT * FROM profiles WHERE profileId = :profileId")
|
||||
fun getByIdNow(profileId: Int): Profile?
|
||||
|
||||
@Query("SELECT * FROM profiles WHERE profileId = :profileId")
|
||||
suspend fun getByIdSuspend(profileId: Int): Profile?
|
||||
|
||||
@get:Query("SELECT * FROM profiles WHERE profileId >= 0 ORDER BY profileId")
|
||||
val all: LiveData<List<Profile>>
|
||||
|
||||
@ -49,7 +52,7 @@ interface ProfileDao {
|
||||
@get:Query("SELECT profileId FROM profiles WHERE profileId >= 0 ORDER BY profileId")
|
||||
val idsNow: List<Int>
|
||||
|
||||
@Query("SELECT profiles.* FROM teams JOIN profiles USING(profileId) WHERE teamCode = :teamCode AND registration = " + Profile.REGISTRATION_ENABLED + " AND enableSharedEvents = 1")
|
||||
@Query("SELECT profiles.* FROM teams JOIN profiles USING(profileId) WHERE teamCode = :teamCode AND registration = " + Profile.REGISTRATION_ENABLED)
|
||||
fun getByTeamCodeNowWithRegistration(teamCode: String?): List<Profile>
|
||||
|
||||
@get:Query("SELECT profileId FROM profiles WHERE profileId > 0 ORDER BY profileId ASC LIMIT 1")
|
||||
|
@ -107,6 +107,9 @@ abstract class TimetableDao : BaseDao<Lesson, LessonFull> {
|
||||
fun getByIdNow(profileId: Int, id: Long) =
|
||||
getOneNow("$QUERY WHERE timetable.profileId = $profileId AND timetable.id = $id")
|
||||
|
||||
fun getByOwnerIdNow(profileId: Int, ownerId: Long) =
|
||||
getOneNow("$QUERY WHERE timetable.profileId = $profileId AND timetable.ownerId = $ownerId")
|
||||
|
||||
@Query("UPDATE timetable SET keep = 0 WHERE profileId = :profileId AND isExtra = :isExtra AND type != -1 AND ((type != 3 AND date >= :dateFrom) OR ((type = 3 OR type = 1) AND oldDate >= :dateFrom))")
|
||||
abstract fun dontKeepFromDate(profileId: Int, dateFrom: Date, isExtra: Boolean)
|
||||
|
||||
|
@ -73,13 +73,22 @@ open class Event(
|
||||
const val COLOR_INFORMATION = 0xff039be5.toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Added manually - added by self, shared by self, or shared by someone else.
|
||||
*/
|
||||
@ColumnInfo(name = "eventAddedManually")
|
||||
var addedManually: Boolean = false
|
||||
get() = field || sharedBy == "self"
|
||||
get() = field || isShared
|
||||
|
||||
/**
|
||||
* Shared by - user code who shared the event. Null if not shared.
|
||||
* "Self" if shared by this app user.
|
||||
*/
|
||||
@ColumnInfo(name = "eventSharedBy")
|
||||
var sharedBy: String? = null
|
||||
@ColumnInfo(name = "eventSharedByName")
|
||||
var sharedByName: String? = null
|
||||
|
||||
@ColumnInfo(name = "eventBlacklisted")
|
||||
var blacklisted: Boolean = false
|
||||
@ColumnInfo(name = "eventIsDone")
|
||||
@ -104,6 +113,27 @@ open class Event(
|
||||
var attachmentIds: MutableList<Long>? = null
|
||||
var attachmentNames: MutableList<String>? = null
|
||||
|
||||
val isHomework
|
||||
get() = type == TYPE_HOMEWORK
|
||||
|
||||
/**
|
||||
* Whether the event is shared by anyone. Note that this implies [addedManually].
|
||||
*/
|
||||
val isShared
|
||||
get() = sharedBy != null
|
||||
|
||||
/**
|
||||
* Whether the event is shared by "self" (this app user).
|
||||
*/
|
||||
val isSharedSent
|
||||
get() = sharedBy == "self"
|
||||
|
||||
/**
|
||||
* Whether the event is shared by someone else from the class group.
|
||||
*/
|
||||
val isSharedReceived
|
||||
get() = sharedBy != null && sharedBy != "self"
|
||||
|
||||
/**
|
||||
* Add an attachment
|
||||
* @param id attachment ID
|
||||
@ -134,9 +164,6 @@ open class Event(
|
||||
it.timeInMillis += 45 * MINUTE * 1000
|
||||
}
|
||||
|
||||
val isHomework
|
||||
get() = type == TYPE_HOMEWORK
|
||||
|
||||
@Ignore
|
||||
fun withMetadata(metadata: Metadata) = EventFull(this, metadata)
|
||||
}
|
||||
|
@ -5,31 +5,6 @@ package pl.szczodrzynski.edziennik.data.db.entity
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_CLASS_EVENT
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_DEFAULT
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_ELEARNING
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_ESSAY
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_EXAM
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_EXCURSION
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_HOMEWORK
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_INFORMATION
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_PROJECT
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_PT_MEETING
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_READING
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_SHORT_QUIZ
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_CLASS_EVENT
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_DEFAULT
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_ELEARNING
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_ESSAY
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_EXAM
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_EXCURSION
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_HOMEWORK
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_INFORMATION
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_PROJECT
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_PT_MEETING
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_READING
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_SHORT_QUIZ
|
||||
|
||||
@Entity(
|
||||
tableName = "eventTypes",
|
||||
@ -55,35 +30,5 @@ class EventType(
|
||||
const val SOURCE_REGISTER = 1
|
||||
const val SOURCE_CUSTOM = 2
|
||||
const val SOURCE_SHARED = 3
|
||||
|
||||
fun getTypeColorMap() = mapOf(
|
||||
TYPE_ELEARNING to COLOR_ELEARNING,
|
||||
TYPE_HOMEWORK to COLOR_HOMEWORK,
|
||||
TYPE_DEFAULT to COLOR_DEFAULT,
|
||||
TYPE_EXAM to COLOR_EXAM,
|
||||
TYPE_SHORT_QUIZ to COLOR_SHORT_QUIZ,
|
||||
TYPE_ESSAY to COLOR_ESSAY,
|
||||
TYPE_PROJECT to COLOR_PROJECT,
|
||||
TYPE_PT_MEETING to COLOR_PT_MEETING,
|
||||
TYPE_EXCURSION to COLOR_EXCURSION,
|
||||
TYPE_READING to COLOR_READING,
|
||||
TYPE_CLASS_EVENT to COLOR_CLASS_EVENT,
|
||||
TYPE_INFORMATION to COLOR_INFORMATION
|
||||
)
|
||||
|
||||
fun getTypeNameMap() = mapOf(
|
||||
TYPE_ELEARNING to R.string.event_type_elearning,
|
||||
TYPE_HOMEWORK to R.string.event_type_homework,
|
||||
TYPE_DEFAULT to R.string.event_other,
|
||||
TYPE_EXAM to R.string.event_exam,
|
||||
TYPE_SHORT_QUIZ to R.string.event_short_quiz,
|
||||
TYPE_ESSAY to R.string.event_essay,
|
||||
TYPE_PROJECT to R.string.event_project,
|
||||
TYPE_PT_MEETING to R.string.event_pt_meeting,
|
||||
TYPE_EXCURSION to R.string.event_excursion,
|
||||
TYPE_READING to R.string.event_reading,
|
||||
TYPE_CLASS_EVENT to R.string.event_class_event,
|
||||
TYPE_INFORMATION to R.string.event_information
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,13 @@ open class Lesson(
|
||||
|
||||
var isExtra: Boolean = false
|
||||
|
||||
/**
|
||||
* Stable ID denoting this lesson, used for note sharing (i.e. [profileId]-independent).
|
||||
*
|
||||
* This is simply the Unix timestamp of the lesson (in seconds).
|
||||
*/
|
||||
var ownerId: Long = id
|
||||
|
||||
val displayDate: Date?
|
||||
get() {
|
||||
if (type == TYPE_SHIFTED_SOURCE)
|
||||
@ -69,7 +76,12 @@ open class Lesson(
|
||||
val isChange
|
||||
get() = type == TYPE_CHANGE || type == TYPE_SHIFTED_TARGET
|
||||
|
||||
fun buildId(): Long = (displayDate?.combineWith(displayStartTime) ?: 0L) / 6L * 10L + (hashCode() and 0xFFFF)
|
||||
fun buildId(): Long =
|
||||
(displayDate?.combineWith(displayStartTime) ?: 0L) / 6L * 10L +
|
||||
(hashCode() and 0xFFFF)
|
||||
|
||||
fun buildOwnerId(): Long =
|
||||
(displayDate?.combineWith(displayStartTime) ?: 0L)
|
||||
|
||||
@Ignore
|
||||
var showAsUnseen = false
|
||||
|
@ -9,6 +9,7 @@ interface Noteable {
|
||||
fun getNoteType(): Note.OwnerType
|
||||
fun getNoteOwnerProfileId(): Int
|
||||
fun getNoteOwnerId(): Long
|
||||
fun getNoteShareTeamId(): Long? = null
|
||||
|
||||
var notes: MutableList<Note>
|
||||
|
||||
|
@ -5,25 +5,18 @@
|
||||
package pl.szczodrzynski.edziennik.data.db.entity
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.PorterDuffColorFilter
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.widget.ImageView
|
||||
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Ignore
|
||||
import com.google.gson.JsonObject
|
||||
import pl.droidsonroids.gif.GifDrawable
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import pl.szczodrzynski.edziennik.utils.ProfileImageHolder
|
||||
import pl.szczodrzynski.edziennik.ext.dateToSemester
|
||||
import pl.szczodrzynski.edziennik.ext.getDrawable
|
||||
import pl.szczodrzynski.edziennik.ext.getHolder
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.navlib.ImageHolder
|
||||
import pl.szczodrzynski.navlib.R
|
||||
import pl.szczodrzynski.navlib.drawer.IDrawerProfile
|
||||
import pl.szczodrzynski.navlib.getDrawableFromRes
|
||||
|
||||
@Entity(tableName = "profiles", primaryKeys = ["profileId"])
|
||||
open class Profile(
|
||||
@ -60,9 +53,13 @@ open class Profile(
|
||||
}
|
||||
|
||||
override var image: String? = null
|
||||
|
||||
var empty = true
|
||||
var archived = false
|
||||
var syncEnabled = true
|
||||
@ColumnInfo(name = "enableSharedEvents")
|
||||
var unused1 = true
|
||||
var registration = REGISTRATION_UNSPECIFIED
|
||||
var userCode = ""
|
||||
|
||||
/**
|
||||
* A unique ID matching [archived] profiles with current ones
|
||||
@ -70,117 +67,35 @@ open class Profile(
|
||||
*/
|
||||
var archiveId: Int? = null
|
||||
|
||||
var syncEnabled = true
|
||||
var enableSharedEvents = true
|
||||
var registration = REGISTRATION_UNSPECIFIED
|
||||
var userCode = ""
|
||||
|
||||
/**
|
||||
* The student's number in the class register.
|
||||
*/
|
||||
var studentNumber = -1
|
||||
var studentClassName: String? = null
|
||||
var studentSchoolYearStart = Date.getToday().let { if (it.month < 9) it.year - 1 else it.year }
|
||||
|
||||
var dateSemester1Start = Date(studentSchoolYearStart, 9, 1)
|
||||
var dateSemester2Start = Date(studentSchoolYearStart + 1, 2, 1)
|
||||
var dateYearEnd = Date(studentSchoolYearStart + 1, 6, 30)
|
||||
fun getSemesterStart(semester: Int) = if (semester == 1) dateSemester1Start else dateSemester2Start
|
||||
fun getSemesterEnd(semester: Int) = if (semester == 1) dateSemester2Start.clone().stepForward(0, 0, -1) else dateYearEnd
|
||||
fun dateToSemester(date: Date) = if (date >= dateSemester2Start) 2 else 1
|
||||
@delegate:Ignore
|
||||
val currentSemester by lazy { dateToSemester(Date.getToday()) }
|
||||
|
||||
fun shouldArchive(): Boolean {
|
||||
// vulcan hotfix
|
||||
if (dateYearEnd.month > 6) {
|
||||
dateYearEnd.month = 6
|
||||
dateYearEnd.day = 30
|
||||
}
|
||||
// fix for when versions <4.3 synced 2020/2021 year dates to older profiles during 2020 Jun-Aug
|
||||
if (dateSemester1Start.year > studentSchoolYearStart) {
|
||||
val diff = dateSemester1Start.year - studentSchoolYearStart
|
||||
dateSemester1Start.year -= diff
|
||||
dateSemester2Start.year -= diff
|
||||
dateYearEnd.year -= diff
|
||||
}
|
||||
return App.config.archiverEnabled
|
||||
&& Date.getToday() >= dateYearEnd
|
||||
&& Date.getToday().year > studentSchoolYearStart
|
||||
}
|
||||
fun isBeforeYear() = false && Date.getToday() < dateSemester1Start
|
||||
|
||||
var disabledNotifications: List<Long>? = null
|
||||
|
||||
var lastReceiversSync: Long = 0
|
||||
|
||||
fun hasStudentData(key: String) = studentData.has(key)
|
||||
fun getStudentData(key: String, defaultValue: Boolean) = studentData.getBoolean(key) ?: defaultValue
|
||||
fun getStudentData(key: String, defaultValue: String?) = studentData.getString(key) ?: defaultValue
|
||||
fun getStudentData(key: String, defaultValue: Int) = studentData.getInt(key) ?: defaultValue
|
||||
fun getStudentData(key: String, defaultValue: Long) = studentData.getLong(key) ?: defaultValue
|
||||
fun getStudentData(key: String, defaultValue: Float) = studentData.getFloat(key) ?: defaultValue
|
||||
fun getStudentData(key: String, defaultValue: Char) = studentData.getChar(key) ?: defaultValue
|
||||
fun putStudentData(key: String, value: Boolean) { studentData[key] = value }
|
||||
fun putStudentData(key: String, value: String?) { studentData[key] = value }
|
||||
fun putStudentData(key: String, value: Number) { studentData[key] = value }
|
||||
fun putStudentData(key: String, value: Char) { studentData[key] = value }
|
||||
fun removeStudentData(key: String) { studentData.remove(key) }
|
||||
|
||||
val currentSemester
|
||||
get() = dateToSemester(Date.getToday())
|
||||
val isParent
|
||||
get() = accountName != null
|
||||
|
||||
val accountOwnerName
|
||||
get() = accountName ?: studentNameLong
|
||||
|
||||
@Ignore
|
||||
val registerName = loginStoreType.name.lowercase()
|
||||
|
||||
val registerName
|
||||
get() = loginStoreType.name.lowercase()
|
||||
val canShare
|
||||
get() = registration == REGISTRATION_ENABLED && !archived
|
||||
|
||||
override fun getImageDrawable(context: Context): Drawable {
|
||||
if (archived) {
|
||||
return context.getDrawableFromRes(pl.szczodrzynski.edziennik.R.drawable.profile_archived).also {
|
||||
it.colorFilter = PorterDuffColorFilter(colorFromName(name), PorterDuff.Mode.DST_OVER)
|
||||
}
|
||||
}
|
||||
@delegate:Ignore
|
||||
@delegate:Transient
|
||||
val config by lazy { App.config[this.id] }
|
||||
|
||||
if (!image.isNullOrEmpty()) {
|
||||
try {
|
||||
return if (image?.endsWith(".gif", true) == true) {
|
||||
GifDrawable(image ?: "")
|
||||
} else {
|
||||
RoundedBitmapDrawableFactory.create(context.resources, image ?: "")
|
||||
//return Drawable.createFromPath(image ?: "") ?: throw Exception()
|
||||
}
|
||||
}
|
||||
catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
return context.getDrawableFromRes(R.drawable.profile).also {
|
||||
it.colorFilter = PorterDuffColorFilter(colorFromName(name), PorterDuff.Mode.DST_OVER)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getImageHolder(context: Context): ImageHolder {
|
||||
if (archived) {
|
||||
return ImageHolder(pl.szczodrzynski.edziennik.R.drawable.profile_archived, colorFromName(name))
|
||||
}
|
||||
|
||||
return if (!image.isNullOrEmpty()) {
|
||||
try {
|
||||
ProfileImageHolder(image ?: "")
|
||||
} catch (_: Exception) {
|
||||
ImageHolder(R.drawable.profile, colorFromName(name))
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImageHolder(R.drawable.profile, colorFromName(name))
|
||||
}
|
||||
}
|
||||
override fun getImageDrawable(context: Context) = this.getDrawable(context)
|
||||
override fun getImageHolder(context: Context) = this.getHolder()
|
||||
override fun applyImageTo(imageView: ImageView) {
|
||||
getImageHolder(imageView.context).applyTo(imageView)
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ package pl.szczodrzynski.edziennik.data.db.enums
|
||||
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorBlank
|
||||
|
||||
enum class LoginMethod(
|
||||
val loginType: LoginType,
|
||||
@ -26,7 +28,7 @@ enum class LoginMethod(
|
||||
MOBIDZIENNIK_API2(
|
||||
loginType = LoginType.MOBIDZIENNIK,
|
||||
id = 1300,
|
||||
isPossible = { profile, _ -> profile?.studentData?.has("email") ?: false },
|
||||
isPossible = { profile, _ -> profile?.studentData?.getString("email").isNotNullNorBlank() },
|
||||
),
|
||||
LIBRUS_PORTAL(
|
||||
loginType = LoginType.LIBRUS,
|
||||
@ -57,7 +59,7 @@ enum class LoginMethod(
|
||||
VULCAN_WEB_MAIN(
|
||||
loginType = LoginType.VULCAN,
|
||||
id = 4100,
|
||||
isPossible = { _, loginStore -> loginStore.hasLoginData("webHost") },
|
||||
isPossible = { _, loginStore -> loginStore.getLoginData("webHost", null).isNotNullNorBlank() },
|
||||
),
|
||||
VULCAN_HEBE(
|
||||
loginType = LoginType.VULCAN,
|
||||
|
@ -9,6 +9,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Note
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Noteable
|
||||
import pl.szczodrzynski.edziennik.ext.takePositive
|
||||
import pl.szczodrzynski.edziennik.ui.search.Searchable
|
||||
import pl.szczodrzynski.edziennik.utils.html.BetterHtml
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
@ -118,4 +119,5 @@ class EventFull(
|
||||
override fun getNoteType() = Note.OwnerType.EVENT
|
||||
override fun getNoteOwnerProfileId() = profileId
|
||||
override fun getNoteOwnerId() = id
|
||||
override fun getNoteShareTeamId() = teamId.takePositive()
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Note
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Noteable
|
||||
import pl.szczodrzynski.edziennik.ext.takePositive
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
|
||||
class LessonFull(
|
||||
@ -137,9 +138,10 @@ class LessonFull(
|
||||
var seen: Boolean = false
|
||||
var notified: Boolean = false
|
||||
|
||||
@Relation(parentColumn = "id", entityColumn = "noteOwnerId", entity = Note::class)
|
||||
@Relation(parentColumn = "ownerId", entityColumn = "noteOwnerId", entity = Note::class)
|
||||
override lateinit var notes: MutableList<Note>
|
||||
override fun getNoteType() = Note.OwnerType.LESSON
|
||||
override fun getNoteOwnerProfileId() = profileId
|
||||
override fun getNoteOwnerId() = id
|
||||
override fun getNoteOwnerId() = ownerId
|
||||
override fun getNoteShareTeamId() = teamId.takePositive()
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) Kuba Szczodrzyński 2022-10-25.
|
||||
*/
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.db.migration
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
class Migration100 : Migration(99, 100) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
// add Note Owner ID to Lesson, to make it profileId-independent
|
||||
// calculate the new owner ID based on the old ID
|
||||
database.execSQL("ALTER TABLE timetable ADD COLUMN ownerId INT NOT NULL DEFAULT 0;")
|
||||
// set new ID for actual lessons
|
||||
database.execSQL("UPDATE timetable SET ownerId = ROUND((id & ~65535) / 500000.0) * 300000;")
|
||||
// copy the old ID (date value) for NO_LESSONS
|
||||
database.execSQL("UPDATE timetable SET ownerId = id WHERE type = -1;")
|
||||
// update ID for notes as well
|
||||
database.execSQL("UPDATE notes SET noteOwnerId = ROUND((noteOwnerId & ~65535) / 500000.0) * 300000 WHERE noteOwnerType = 'LESSON' AND noteOwnerId > 2000000000000;")
|
||||
// force full app sync to download notes with new IDs
|
||||
database.execSQL("DELETE FROM config WHERE `key` = 'hash';")
|
||||
database.execSQL("DELETE FROM config WHERE `key` = 'lastAppSync';")
|
||||
}
|
||||
}
|
@ -160,11 +160,11 @@ class SzkolnyAppFirebase(val app: App, val profiles: List<Profile>, val message:
|
||||
if (event.color == -1)
|
||||
event.color = null
|
||||
|
||||
event.addedManually = true
|
||||
event.sharedBy = json.getString("sharedBy")
|
||||
event.sharedByName = json.getString("sharedByName")
|
||||
if (profile.userCode == event.sharedBy) {
|
||||
event.sharedBy = "self"
|
||||
event.addedManually = true
|
||||
}
|
||||
|
||||
val metadata = Metadata(
|
||||
@ -176,7 +176,7 @@ class SzkolnyAppFirebase(val app: App, val profiles: List<Profile>, val message:
|
||||
)
|
||||
|
||||
val type = if (event.isHomework) NotificationType.SHARED_HOMEWORK else NotificationType.SHARED_EVENT
|
||||
val notificationFilter = app.config.getFor(event.profileId).sync.notificationFilter
|
||||
val notificationFilter = app.config[event.profileId].sync.notificationFilter
|
||||
|
||||
if (!notificationFilter.contains(type) && event.sharedBy != "self" && event.date >= Date.getToday()) {
|
||||
val notification = Notification(
|
||||
@ -211,7 +211,7 @@ class SzkolnyAppFirebase(val app: App, val profiles: List<Profile>, val message:
|
||||
val profile = profiles.firstOrNull { it.id == team.profileId } ?: return@forEach
|
||||
if (!profile.canShare)
|
||||
return@forEach
|
||||
val notificationFilter = app.config.getFor(team.profileId).sync.notificationFilter
|
||||
val notificationFilter = app.config[team.profileId].sync.notificationFilter
|
||||
|
||||
if (!notificationFilter.contains(NotificationType.REMOVED_SHARED_EVENT)) {
|
||||
val notification = Notification(
|
||||
@ -265,7 +265,7 @@ class SzkolnyAppFirebase(val app: App, val profiles: List<Profile>, val message:
|
||||
return@forEach
|
||||
|
||||
val type = NotificationType.SHARED_NOTE
|
||||
val notificationFilter = app.config.getFor(note.profileId).sync.notificationFilter
|
||||
val notificationFilter = app.config[note.profileId].sync.notificationFilter
|
||||
|
||||
if (!notificationFilter.contains(type) && note.sharedBy != "self") {
|
||||
val notification = Notification(
|
||||
|
@ -6,12 +6,37 @@ package pl.szczodrzynski.edziennik.data.firebase
|
||||
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.EdziennikTask
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_ANNOUNCEMENTS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_ATTENDANCES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_BEHAVIOUR_GRADES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_BEHAVIOUR_GRADE_CATEGORIES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_BEHAVIOUR_GRADE_COMMENTS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_CLASS_FREE_DAYS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_DESCRIPTIVE_GRADES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_DESCRIPTIVE_GRADE_CATEGORIES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_DESCRIPTIVE_TEXT_GRADES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_EVENTS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_HOMEWORK
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_LUCKY_NUMBER
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_NORMAL_GRADES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_NORMAL_GRADE_CATEGORIES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_NORMAL_GRADE_COMMENTS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_NOTICES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_POINT_GRADES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_POINT_GRADE_CATEGORIES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_PT_MEETINGS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_SCHOOL_FREE_DAYS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_TEXT_GRADES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_TIMETABLES
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_MESSAGES_RECEIVED
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_SYNERGIA_HOMEWORK
|
||||
import pl.szczodrzynski.edziennik.data.api.task.IApiTask
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
import pl.szczodrzynski.edziennik.ext.getStudentData
|
||||
|
||||
class SzkolnyLibrusFirebase(val app: App, val profiles: List<Profile>, val message: FirebaseService.Message) {
|
||||
/*{
|
||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.getLong
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
import pl.szczodrzynski.edziennik.ext.getStudentData
|
||||
|
||||
class SzkolnyMobidziennikFirebase(val app: App, val profiles: List<Profile>, val message: FirebaseService.Message) {
|
||||
/*{
|
||||
|
@ -4,15 +4,15 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.firebase
|
||||
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.EdziennikTask
|
||||
import pl.szczodrzynski.edziennik.data.api.task.IApiTask
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Message
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.getInt
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
import pl.szczodrzynski.edziennik.ext.getStudentData
|
||||
import pl.szczodrzynski.edziennik.ext.toJsonObject
|
||||
|
||||
class SzkolnyVulcanFirebase(val app: App, val profiles: List<Profile>, val message: FirebaseService.Message) {
|
||||
|
@ -6,14 +6,9 @@ package pl.szczodrzynski.edziennik.ext
|
||||
|
||||
import android.util.LongSparseArray
|
||||
import androidx.core.util.forEach
|
||||
import com.google.android.material.datepicker.CalendarConstraints
|
||||
import com.google.gson.JsonElement
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.config.AppData
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Team
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
|
||||
fun List<Teacher>.byId(id: Long) = firstOrNull { it.id == id }
|
||||
fun List<Teacher>.byNameFirstLast(nameFirstLast: String) = firstOrNull { it.name + " " + it.surname == nameFirstLast }
|
||||
@ -34,22 +29,3 @@ fun LongSparseArray<Team>.getById(id: Long): Team? {
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
operator fun Profile.set(key: String, value: JsonElement) = this.studentData.add(key, value)
|
||||
operator fun Profile.set(key: String, value: Boolean) = this.studentData.addProperty(key, value)
|
||||
operator fun Profile.set(key: String, value: String?) = this.studentData.addProperty(key, value)
|
||||
operator fun Profile.set(key: String, value: Number) = this.studentData.addProperty(key, value)
|
||||
operator fun Profile.set(key: String, value: Char) = this.studentData.addProperty(key, value)
|
||||
|
||||
fun Profile.getSchoolYearConstrains(): CalendarConstraints {
|
||||
return CalendarConstraints.Builder()
|
||||
.setStart(dateSemester1Start.inMillisUtc)
|
||||
.setEnd(dateYearEnd.inMillisUtc)
|
||||
.build()
|
||||
}
|
||||
|
||||
fun Profile.hasFeature(featureType: FeatureType) = featureType in this.loginStoreType.features
|
||||
fun Profile.hasUIFeature(featureType: FeatureType) = featureType.isUIAlwaysAvailable || hasFeature(featureType)
|
||||
|
||||
fun Profile.getAppData() =
|
||||
if (App.profileId == this.id) App.data else AppData.get(this.loginStoreType)
|
||||
|
@ -83,13 +83,13 @@ fun AlertDialog.overlayBackgroundColor(color: Int, alpha: Int) {
|
||||
val backgroundInsets = MaterialDialogs.getDialogBackgroundInsets(
|
||||
context,
|
||||
R.attr.alertDialogStyle,
|
||||
R.style.MaterialAlertDialog_MaterialComponents,
|
||||
R.style.MaterialAlertDialog_Material3,
|
||||
)
|
||||
val background = MaterialShapeDrawable(
|
||||
context,
|
||||
null,
|
||||
R.attr.alertDialogStyle,
|
||||
R.style.MaterialAlertDialog_MaterialComponents
|
||||
R.style.MaterialAlertDialog_Material3
|
||||
)
|
||||
with(background) {
|
||||
initializeElevationOverlay(context)
|
||||
|
@ -5,6 +5,7 @@
|
||||
package pl.szczodrzynski.edziennik.ext
|
||||
|
||||
import android.os.Bundle
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonObject
|
||||
@ -48,6 +49,11 @@ fun JsonObject.putEnum(key: String, value: Enum<*>) = addProperty(key, value.toI
|
||||
fun String.toJsonObject(): JsonObject? = try { JsonParser.parseString(this).asJsonObject } catch (ignore: Exception) { null }
|
||||
fun String.toJsonArray(): JsonArray? = try { JsonParser.parseString(this).asJsonArray } catch (ignore: Exception) { null }
|
||||
|
||||
fun Any?.toJsonElement(): JsonElement = when (this) {
|
||||
is Collection<*> -> JsonArray(this)
|
||||
else -> Gson().toJsonTree(this)
|
||||
}
|
||||
|
||||
operator fun JsonObject.set(key: String, value: JsonElement) = this.add(key, value)
|
||||
operator fun JsonObject.set(key: String, value: Boolean) = this.addProperty(key, value)
|
||||
operator fun JsonObject.set(key: String, value: String?) = this.addProperty(key, value)
|
||||
@ -67,6 +73,8 @@ fun JsonObject(vararg properties: Pair<String, Any?>): JsonObject {
|
||||
is Number -> addProperty(key, value)
|
||||
is Boolean -> addProperty(key, value)
|
||||
is Enum<*> -> addProperty(key, value.toInt())
|
||||
null -> add(key, null)
|
||||
else -> add(key, value.toJsonElement())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -98,6 +106,8 @@ fun JsonArray(properties: Collection<Any?>): JsonArray {
|
||||
is Char -> add(property as Char?)
|
||||
is Number -> add(property as Number?)
|
||||
is Boolean -> add(property as Boolean?)
|
||||
is Enum<*> -> add(property.toInt())
|
||||
else -> add(property.toJsonElement())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ import java.io.StringWriter
|
||||
|
||||
fun <T> LiveData<T>.observeOnce(lifecycleOwner: LifecycleOwner, observer: Observer<T>) {
|
||||
observe(lifecycleOwner, object : Observer<T> {
|
||||
override fun onChanged(t: T?) {
|
||||
observer.onChanged(t)
|
||||
override fun onChanged(value: T) {
|
||||
observer.onChanged(value)
|
||||
removeObserver(this)
|
||||
}
|
||||
})
|
||||
@ -73,9 +73,18 @@ fun pendingIntentFlag(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
fun pendingIntentMutable(): Int {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
|
||||
return PendingIntent.FLAG_MUTABLE
|
||||
return 0
|
||||
}
|
||||
|
||||
fun Int?.takeValue() = if (this == -1) null else this
|
||||
fun Int?.takePositive() = if (this == -1 || this == 0) null else this
|
||||
|
||||
fun Long?.takeValue() = if (this == -1L) null else this
|
||||
fun Long?.takePositive() = if (this == -1L || this == 0L) null else this
|
||||
|
||||
fun String?.takeValue() = if (this.isNullOrBlank()) null else this
|
||||
|
||||
fun Any?.ignore() = Unit
|
||||
|
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) Kuba Szczodrzyński 2022-10-25.
|
||||
*/
|
||||
|
||||
package pl.szczodrzynski.edziennik.ext
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.PorterDuffColorFilter
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
|
||||
import com.google.android.material.datepicker.CalendarConstraints
|
||||
import com.google.gson.JsonElement
|
||||
import pl.droidsonroids.gif.GifDrawable
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.config.AppData
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.utils.ProfileImageHolder
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.navlib.ImageHolder
|
||||
import pl.szczodrzynski.navlib.getDrawableFromRes
|
||||
|
||||
// TODO refactor Data* fields and make the receiver non-nullable
|
||||
operator fun Profile?.set(key: String, value: JsonElement) = this?.studentData?.add(key, value)
|
||||
operator fun Profile?.set(key: String, value: Boolean) = this?.studentData?.addProperty(key, value)
|
||||
operator fun Profile?.set(key: String, value: String?) = this?.studentData?.addProperty(key, value)
|
||||
operator fun Profile?.set(key: String, value: Number) = this?.studentData?.addProperty(key, value)
|
||||
operator fun Profile?.set(key: String, value: Char) = this?.studentData?.addProperty(key, value)
|
||||
|
||||
fun Profile.getStudentData(key: String, defaultValue: Boolean) =
|
||||
studentData.getBoolean(key) ?: defaultValue
|
||||
|
||||
fun Profile.getStudentData(key: String, defaultValue: String?) =
|
||||
studentData.getString(key) ?: defaultValue
|
||||
|
||||
fun Profile.getStudentData(key: String, defaultValue: Int) =
|
||||
studentData.getInt(key) ?: defaultValue
|
||||
|
||||
fun Profile.getStudentData(key: String, defaultValue: Long) =
|
||||
studentData.getLong(key) ?: defaultValue
|
||||
|
||||
fun Profile.getStudentData(key: String, defaultValue: Float) =
|
||||
studentData.getFloat(key) ?: defaultValue
|
||||
|
||||
fun Profile.getStudentData(key: String, defaultValue: Char) =
|
||||
studentData.getChar(key) ?: defaultValue
|
||||
|
||||
fun Profile.getSemesterStart(semester: Int) =
|
||||
if (semester == 1) dateSemester1Start else dateSemester2Start
|
||||
|
||||
fun Profile.getSemesterEnd(semester: Int) =
|
||||
if (semester == 1) dateSemester2Start.clone().stepForward(0, 0, -1) else dateYearEnd
|
||||
|
||||
fun Profile.dateToSemester(date: Date) = if (date >= dateSemester2Start) 2 else 1
|
||||
fun Profile.isBeforeYear() = false && Date.getToday() < dateSemester1Start
|
||||
|
||||
fun Profile.getSchoolYearConstrains(): CalendarConstraints {
|
||||
return CalendarConstraints.Builder()
|
||||
.setStart(dateSemester1Start.inMillisUtc)
|
||||
.setEnd(dateYearEnd.inMillisUtc)
|
||||
.build()
|
||||
}
|
||||
|
||||
fun Profile.hasFeature(featureType: FeatureType) = featureType in this.loginStoreType.features
|
||||
fun Profile.hasUIFeature(featureType: FeatureType) =
|
||||
featureType.isUIAlwaysAvailable || hasFeature(featureType)
|
||||
|
||||
fun Profile.getAppData() =
|
||||
if (App.profileId == this.id) App.data else AppData.get(this.loginStoreType)
|
||||
|
||||
fun Profile.shouldArchive(): Boolean {
|
||||
// vulcan hotfix
|
||||
if (dateYearEnd.month > 6) {
|
||||
dateYearEnd.month = 6
|
||||
dateYearEnd.day = 30
|
||||
}
|
||||
// fix for when versions <4.3 synced 2020/2021 year dates to older profiles during 2020 Jun-Aug
|
||||
if (dateSemester1Start.year > studentSchoolYearStart) {
|
||||
val diff = dateSemester1Start.year - studentSchoolYearStart
|
||||
dateSemester1Start.year -= diff
|
||||
dateSemester2Start.year -= diff
|
||||
dateYearEnd.year -= diff
|
||||
}
|
||||
return App.config.archiverEnabled && Date.getToday() >= dateYearEnd && Date.getToday().year > studentSchoolYearStart
|
||||
}
|
||||
|
||||
fun Profile.getDrawable(context: Context): Drawable {
|
||||
if (archived) {
|
||||
return context.getDrawableFromRes(R.drawable.profile_archived).also {
|
||||
it.colorFilter = PorterDuffColorFilter(colorFromName(name), PorterDuff.Mode.DST_OVER)
|
||||
}
|
||||
}
|
||||
|
||||
if (!image.isNullOrEmpty()) {
|
||||
try {
|
||||
return if (image?.endsWith(".gif", true) == true) {
|
||||
GifDrawable(image ?: "")
|
||||
} else {
|
||||
RoundedBitmapDrawableFactory.create(context.resources, image ?: "")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
return context.getDrawableFromRes(R.drawable.profile).also {
|
||||
it.colorFilter = PorterDuffColorFilter(colorFromName(name), PorterDuff.Mode.DST_OVER)
|
||||
}
|
||||
}
|
||||
|
||||
fun Profile.getHolder(): ImageHolder {
|
||||
if (archived) {
|
||||
return ImageHolder(R.drawable.profile_archived, colorFromName(name))
|
||||
}
|
||||
|
||||
return if (!image.isNullOrEmpty()) {
|
||||
try {
|
||||
ProfileImageHolder(image ?: "")
|
||||
} catch (_: Exception) {
|
||||
ImageHolder(R.drawable.profile, colorFromName(name))
|
||||
}
|
||||
} else {
|
||||
ImageHolder(R.drawable.profile, colorFromName(name))
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ import android.text.style.CharacterStyle
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.text.style.StrikethroughSpan
|
||||
import android.text.style.StyleSpan
|
||||
import android.text.style.UnderlineSpan
|
||||
import androidx.annotation.PluralsRes
|
||||
import androidx.annotation.StringRes
|
||||
import com.mikepenz.materialdrawer.holder.StringHolder
|
||||
@ -160,6 +161,11 @@ fun CharSequence?.asBoldSpannable(): Spannable {
|
||||
spannable.setSpan(StyleSpan(Typeface.BOLD), 0, spannable.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
return spannable
|
||||
}
|
||||
fun CharSequence?.asUnderlineSpannable(): Spannable {
|
||||
val spannable = SpannableString(this)
|
||||
spannable.setSpan(UnderlineSpan(), 0, spannable.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
return spannable
|
||||
}
|
||||
fun CharSequence.asSpannable(
|
||||
vararg spans: CharacterStyle,
|
||||
substring: CharSequence? = null,
|
||||
|
@ -8,6 +8,7 @@ import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Rect
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.widget.*
|
||||
import androidx.annotation.StringRes
|
||||
@ -161,3 +162,12 @@ val SwipeRefreshLayout.onScrollListener: RecyclerView.OnScrollListener
|
||||
}
|
||||
}
|
||||
|
||||
fun View.removeFromParent() {
|
||||
(parent as? ViewGroup)?.removeView(this)
|
||||
}
|
||||
|
||||
fun View.appendView(child: View) {
|
||||
val parent = parent as? ViewGroup ?: return
|
||||
val index = parent.indexOfChild(this)
|
||||
parent.addView(child, index + 1)
|
||||
}
|
||||
|
@ -5,8 +5,20 @@
|
||||
package pl.szczodrzynski.edziennik.network.cookie
|
||||
|
||||
import okhttp3.Cookie
|
||||
import okhttp3.HttpUrl
|
||||
|
||||
class DumbCookie(var cookie: Cookie) {
|
||||
companion object {
|
||||
fun deserialize(key: String, value: String): DumbCookie? {
|
||||
val (domain, _) = key.split('|', limit = 2)
|
||||
val url = HttpUrl.Builder()
|
||||
.scheme("https")
|
||||
.host(domain)
|
||||
.build()
|
||||
val cookie = Cookie.parse(url, value) ?: return null
|
||||
return DumbCookie(cookie)
|
||||
}
|
||||
}
|
||||
|
||||
constructor(domain: String, name: String, value: String, expiresAt: Long? = null) : this(
|
||||
Cookie.Builder()
|
||||
@ -21,7 +33,10 @@ class DumbCookie(var cookie: Cookie) {
|
||||
cookie = Cookie.Builder()
|
||||
.name(cookie.name())
|
||||
.value(cookie.value())
|
||||
.expiresAt(cookie.expiresAt())
|
||||
.also {
|
||||
if (cookie.persistent())
|
||||
it.expiresAt(cookie.expiresAt())
|
||||
}
|
||||
.domain(cookie.domain())
|
||||
.build()
|
||||
}
|
||||
@ -45,4 +60,7 @@ class DumbCookie(var cookie: Cookie) {
|
||||
hash = 31 * hash + cookie.domain().hashCode()
|
||||
return hash
|
||||
}
|
||||
|
||||
fun serializeKey() = cookie.domain() + "|" + cookie.name()
|
||||
fun serialize() = serializeKey() to cookie.toString()
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
package pl.szczodrzynski.edziennik.network.cookie
|
||||
|
||||
import android.content.Context
|
||||
import androidx.core.content.edit
|
||||
import okhttp3.Cookie
|
||||
import okhttp3.CookieJar
|
||||
import okhttp3.HttpUrl
|
||||
@ -26,22 +27,48 @@ class DumbCookieJar(
|
||||
) : CookieJar {
|
||||
|
||||
private val prefs = context.getSharedPreferences("cookies", Context.MODE_PRIVATE)
|
||||
val sessionCookies = mutableSetOf<DumbCookie>()
|
||||
private val savedCookies = mutableSetOf<DumbCookie>()
|
||||
private val sessionCookies = mutableSetOf<DumbCookie>()
|
||||
|
||||
init {
|
||||
val toRemove = mutableListOf<String>()
|
||||
prefs.all.forEach { (key, value) ->
|
||||
if (value !is String)
|
||||
return@forEach
|
||||
val dc = DumbCookie.deserialize(key, value) ?: return@forEach
|
||||
if (dc.cookie.expiresAt() > System.currentTimeMillis())
|
||||
sessionCookies.add(dc)
|
||||
else
|
||||
toRemove.add(key)
|
||||
}
|
||||
prefs.edit {
|
||||
for (key in toRemove) {
|
||||
remove(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun save(dc: DumbCookie) {
|
||||
sessionCookies.remove(dc)
|
||||
sessionCookies.add(dc)
|
||||
if (dc.cookie.persistent() || persistAll) {
|
||||
savedCookies.remove(dc)
|
||||
savedCookies.add(dc)
|
||||
prefs.edit {
|
||||
val (key, value) = dc.serialize()
|
||||
putString(key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun delete(vararg toRemove: DumbCookie) {
|
||||
sessionCookies.removeAll(toRemove)
|
||||
savedCookies.removeAll(toRemove)
|
||||
sessionCookies.removeAll(toRemove.toSet())
|
||||
prefs.edit {
|
||||
for (dc in toRemove) {
|
||||
val key = dc.serializeKey()
|
||||
if (prefs.contains(key))
|
||||
remove(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun saveFromResponse(url: HttpUrl?, cookies: List<Cookie>) {
|
||||
override fun saveFromResponse(url: HttpUrl, cookies: MutableList<Cookie>) {
|
||||
for (cookie in cookies) {
|
||||
val dc = DumbCookie(cookie)
|
||||
save(dc)
|
||||
@ -54,6 +81,10 @@ class DumbCookieJar(
|
||||
}.map { it.cookie }
|
||||
}
|
||||
|
||||
fun getAllDomains(): List<Cookie> {
|
||||
return sessionCookies.map { it.cookie }
|
||||
}
|
||||
|
||||
fun get(domain: String, name: String): String? {
|
||||
return sessionCookies.firstOrNull {
|
||||
it.domainMatches(domain) && it.cookie.name() == name
|
||||
@ -84,7 +115,7 @@ class DumbCookieJar(
|
||||
fun getAll(domain: String): Map<String, String> {
|
||||
return sessionCookies.filter {
|
||||
it.domainMatches(domain)
|
||||
}.map { it.cookie.name() to it.cookie.value() }.toMap()
|
||||
}.associate { it.cookie.name() to it.cookie.value() }
|
||||
}
|
||||
|
||||
fun remove(domain: String, name: String) {
|
||||
@ -100,4 +131,11 @@ class DumbCookieJar(
|
||||
}
|
||||
delete(*toRemove.toTypedArray())
|
||||
}
|
||||
|
||||
fun clearAllDomains() {
|
||||
sessionCookies.clear()
|
||||
prefs.edit {
|
||||
clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,20 +23,24 @@ object WorkerUtils {
|
||||
inline fun scheduleNext(app: App, rescheduleIfFailedFound: Boolean = true, crossinline onReschedule: () -> Unit) {
|
||||
AsyncTask.execute {
|
||||
val workManager = WorkManager.getInstance(app) as WorkManagerImpl
|
||||
val scheduledWork = workManager.workDatabase.workSpecDao().scheduledWork
|
||||
val scheduledWork = workManager.workDatabase.workSpecDao().getScheduledWork() as MutableList;
|
||||
|
||||
scheduledWork.forEach {
|
||||
Utils.d("WorkerUtils", "Work: ${it.id} at ${(it.periodStartTime + it.initialDelay).formatDate()}. State = ${it.state} (finished = ${it.state.isFinished})")
|
||||
Utils.d("WorkerUtils", "Work: ${it.id} at ${it.calculateNextRunTime().formatDate()}. State = ${it.state} (finished = ${it.state.isFinished})")
|
||||
}
|
||||
|
||||
// remove finished work and other than SyncWorker
|
||||
scheduledWork.removeAll { it.workerClassName != SyncWorker::class.java.canonicalName || it.isPeriodic || it.state.isFinished }
|
||||
Utils.d("WorkerUtils", "Found ${scheduledWork.size} unfinished work")
|
||||
|
||||
// remove all enqueued work that had to (but didn't) run at some point in the past (at least 1min ago)
|
||||
val failedWork = scheduledWork.filter { it.state == WorkInfo.State.ENQUEUED && it.periodStartTime + it.initialDelay < System.currentTimeMillis() - 1 * MINUTE * 1000 }
|
||||
val failedWork = scheduledWork.filter { it.state == WorkInfo.State.ENQUEUED && it.calculateNextRunTime() < System.currentTimeMillis() - 1 * MINUTE * 1000 }
|
||||
Utils.d("WorkerUtils", "${failedWork.size} work requests failed to start (out of ${scheduledWork.size} requests)")
|
||||
|
||||
if (rescheduleIfFailedFound) {
|
||||
if (failedWork.isNotEmpty()) {
|
||||
Utils.d("WorkerUtils", "App Manager detected!")
|
||||
EventBus.getDefault().postSticky(AppManagerDetectedEvent(failedWork.map { it.periodStartTime + it.initialDelay }))
|
||||
EventBus.getDefault().postSticky(AppManagerDetectedEvent(failedWork.map { it.calculateNextRunTime() }))
|
||||
}
|
||||
if (scheduledWork.size - failedWork.size < 1) {
|
||||
Utils.d("WorkerUtils", "No pending work found, scheduling next:")
|
||||
|
@ -17,7 +17,12 @@ import com.mikepenz.iconics.typeface.library.community.material.CommunityMateria
|
||||
import com.mikepenz.iconics.utils.colorInt
|
||||
import com.mikepenz.iconics.utils.sizeDp
|
||||
import eu.szkolny.font.SzkolnyFont
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.MainActivity
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
@ -53,7 +58,7 @@ class AgendaFragment : Fragment(), CoroutineScope {
|
||||
if (getActivity() == null || context == null) return null
|
||||
activity = getActivity() as MainActivity
|
||||
context?.theme?.applyStyle(Themes.appTheme, true)
|
||||
type = app.config.forProfile().ui.agendaViewType
|
||||
type = app.profile.config.ui.agendaViewType
|
||||
b = when (type) {
|
||||
Profile.AGENDA_DEFAULT -> FragmentAgendaDefaultBinding.inflate(inflater, container, false)
|
||||
Profile.AGENDA_CALENDAR -> FragmentAgendaCalendarBinding.inflate(inflater, container, false)
|
||||
@ -92,7 +97,7 @@ class AgendaFragment : Fragment(), CoroutineScope {
|
||||
activity.bottomSheet.close()
|
||||
type =
|
||||
if (type == Profile.AGENDA_DEFAULT) Profile.AGENDA_CALENDAR else Profile.AGENDA_DEFAULT
|
||||
app.config.forProfile().ui.agendaViewType = type
|
||||
app.profile.config.ui.agendaViewType = type
|
||||
activity.reloadTarget()
|
||||
},
|
||||
BottomSheetSeparatorItem(true),
|
||||
@ -137,13 +142,7 @@ class AgendaFragment : Fragment(), CoroutineScope {
|
||||
|
||||
private suspend fun checkEventTypes() {
|
||||
withContext(Dispatchers.Default) {
|
||||
val eventTypes = app.db.eventTypeDao().getAllNow(app.profileId).map {
|
||||
it.id
|
||||
}
|
||||
val defaultEventTypes = EventType.getTypeColorMap().keys
|
||||
if (!eventTypes.containsAll(defaultEventTypes)) {
|
||||
app.db.eventTypeDao().addDefaultTypes(app.profile)
|
||||
}
|
||||
app.db.eventTypeDao().getAllWithDefaults(app.profile)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,12 @@ import com.github.tibolte.agendacalendarview.agenda.AgendaAdapter
|
||||
import com.github.tibolte.agendacalendarview.models.BaseCalendarEvent
|
||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent
|
||||
import com.github.tibolte.agendacalendarview.models.IDayItem
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.MainActivity
|
||||
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
@ -49,7 +54,6 @@ class AgendaFragmentDefault(
|
||||
private val unreadDates = mutableSetOf<Int>()
|
||||
private val events = mutableListOf<CalendarEvent>()
|
||||
private var isInitialized = false
|
||||
private val profileConfig by lazy { app.config.forProfile().ui }
|
||||
|
||||
private val listView
|
||||
get() = b.agendaDefaultView.agendaView.agendaListView
|
||||
@ -107,10 +111,10 @@ class AgendaFragmentDefault(
|
||||
isInitialized = false
|
||||
|
||||
withContext(Dispatchers.Default) {
|
||||
if (profileConfig.agendaLessonChanges)
|
||||
if (app.profile.config.ui.agendaLessonChanges)
|
||||
addLessonChanges(events)
|
||||
|
||||
if (profileConfig.agendaTeacherAbsence)
|
||||
if (app.profile.config.ui.agendaTeacherAbsence)
|
||||
addTeacherAbsence(events)
|
||||
}
|
||||
|
||||
@ -127,7 +131,7 @@ class AgendaFragmentDefault(
|
||||
val dateStart = app.profile.dateSemester1Start.asCalendar
|
||||
val dateEnd = app.profile.dateYearEnd.asCalendar
|
||||
|
||||
val isCompactMode = profileConfig.agendaCompactMode
|
||||
val isCompactMode = app.profile.config.ui.agendaCompactMode
|
||||
|
||||
b.agendaDefaultView.init(
|
||||
events,
|
||||
@ -247,7 +251,7 @@ class AgendaFragmentDefault(
|
||||
) {
|
||||
events.removeAll { it is AgendaEvent || it is AgendaEventGroup }
|
||||
|
||||
if (!profileConfig.agendaGroupByType) {
|
||||
if (!app.profile.config.ui.agendaGroupByType) {
|
||||
events += eventList.map {
|
||||
if (!it.seen)
|
||||
unreadDates.add(it.date.value)
|
||||
|
@ -10,6 +10,7 @@ import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import com.github.tibolte.agendacalendarview.render.EventRenderer
|
||||
import com.google.android.material.color.MaterialColors
|
||||
import com.mikepenz.iconics.view.IconicsTextView
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventBinding
|
||||
@ -46,7 +47,8 @@ class AgendaEventRenderer(
|
||||
) {
|
||||
val event = aEvent.event
|
||||
|
||||
val textColor = Colors.legibleTextColor(event.eventColor)
|
||||
val harmonizedColor = MaterialColors.harmonizeWithPrimary(card.context, event.eventColor)
|
||||
val textColor = Colors.legibleTextColor(harmonizedColor)
|
||||
|
||||
val timeText = if (event.time == null)
|
||||
card.context.getString(R.string.agenda_event_all_day)
|
||||
@ -60,8 +62,8 @@ class AgendaEventRenderer(
|
||||
event.teamName
|
||||
).join(", ")
|
||||
|
||||
card.foreground.setTintColor(event.eventColor)
|
||||
card.background.setTintColor(event.eventColor)
|
||||
card.foreground.setTintColor(harmonizedColor)
|
||||
card.background.setTintColor(harmonizedColor)
|
||||
manager.setEventTopic(title, event, doneIconColor = textColor)
|
||||
title.setTextColor(textColor)
|
||||
subtitle?.text = eventSubtitle
|
||||
|
@ -17,7 +17,6 @@ import pl.szczodrzynski.edziennik.data.db.full.LessonFull
|
||||
import pl.szczodrzynski.edziennik.databinding.TimetableLessonBinding
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import pl.szczodrzynski.edziennik.utils.managers.NoteManager
|
||||
import pl.szczodrzynski.navlib.getColorFromAttr
|
||||
|
||||
class LessonChangesAdapter(
|
||||
val context: Context,
|
||||
@ -64,7 +63,9 @@ class LessonChangesAdapter(
|
||||
lesson.teacherName ?: "?"
|
||||
else
|
||||
mutableListOf<CharSequence>().apply {
|
||||
lesson.oldTeacherName?.let { add(it.asStrikethroughSpannable()) }
|
||||
if (lesson.teacherName == null)
|
||||
lesson.oldTeacherName?.let { add(it) }
|
||||
else lesson.oldTeacherName?.let { add(it.asStrikethroughSpannable()) }
|
||||
lesson.teacherName?.let { add(it) }
|
||||
}.concat(arrowRight)
|
||||
|
||||
@ -73,7 +74,9 @@ class LessonChangesAdapter(
|
||||
lesson.teamName ?: "?"
|
||||
else
|
||||
mutableListOf<CharSequence>().apply {
|
||||
lesson.oldTeamName?.let { add(it.asStrikethroughSpannable()) }
|
||||
if (lesson.teamName == null)
|
||||
lesson.oldTeamName?.let { add(it) }
|
||||
else lesson.oldTeamName?.let { add(it.asStrikethroughSpannable()) }
|
||||
lesson.teamName?.let { add(it) }
|
||||
}.concat(arrowRight)
|
||||
|
||||
@ -82,7 +85,9 @@ class LessonChangesAdapter(
|
||||
lesson.classroom ?: "?"
|
||||
else
|
||||
mutableListOf<CharSequence>().apply {
|
||||
lesson.oldClassroom?.let { add(it.asStrikethroughSpannable()) }
|
||||
if (lesson.classroom == null)
|
||||
lesson.oldClassroom?.let { add(it) }
|
||||
else lesson.oldClassroom?.let { add(it.asStrikethroughSpannable()) }
|
||||
lesson.classroom?.let { add(it) }
|
||||
}.concat(arrowRight)
|
||||
|
||||
@ -109,40 +114,11 @@ class LessonChangesAdapter(
|
||||
Lesson.TYPE_CANCELLED -> {
|
||||
b.annotationVisible = true
|
||||
b.annotation.setText(R.string.timetable_lesson_cancelled)
|
||||
b.annotation.background.colorFilter = PorterDuffColorFilter(
|
||||
getColorFromAttr(context, R.attr.timetable_lesson_cancelled_color),
|
||||
PorterDuff.Mode.SRC_ATOP
|
||||
)
|
||||
//lb.subjectName.typeface = Typeface.DEFAULT
|
||||
}
|
||||
Lesson.TYPE_CHANGE -> {
|
||||
b.annotationVisible = true
|
||||
when {
|
||||
lesson.subjectId != lesson.oldSubjectId && lesson.teacherId != lesson.oldTeacherId
|
||||
&& lesson.oldSubjectName != null && lesson.oldTeacherName != null ->
|
||||
b.annotation.setText(
|
||||
R.string.timetable_lesson_change_format,
|
||||
"${lesson.oldSubjectName ?: "?"}, ${lesson.oldTeacherName ?: "?"}"
|
||||
)
|
||||
|
||||
lesson.subjectId != lesson.oldSubjectId && lesson.oldSubjectName != null ->
|
||||
b.annotation.setText(
|
||||
R.string.timetable_lesson_change_format,
|
||||
lesson.oldSubjectName ?: "?"
|
||||
)
|
||||
|
||||
lesson.teacherId != lesson.oldTeacherId && lesson.oldTeacherName != null ->
|
||||
b.annotation.setText(
|
||||
R.string.timetable_lesson_change_format,
|
||||
lesson.oldTeacherName ?: "?"
|
||||
)
|
||||
else -> b.annotation.setText(R.string.timetable_lesson_change)
|
||||
}
|
||||
|
||||
b.annotation.background.colorFilter = PorterDuffColorFilter(
|
||||
getColorFromAttr(context, R.attr.timetable_lesson_change_color),
|
||||
PorterDuff.Mode.SRC_ATOP
|
||||
)
|
||||
b.annotation.setText(R.string.timetable_lesson_change)
|
||||
}
|
||||
Lesson.TYPE_SHIFTED_SOURCE -> {
|
||||
b.annotationVisible = true
|
||||
@ -162,8 +138,6 @@ class LessonChangesAdapter(
|
||||
|
||||
else -> b.annotation.setText(R.string.timetable_lesson_shifted)
|
||||
}
|
||||
|
||||
b.annotation.background.setTintColor(R.attr.timetable_lesson_shifted_source_color.resolveAttr(context))
|
||||
}
|
||||
Lesson.TYPE_SHIFTED_TARGET -> {
|
||||
b.annotationVisible = true
|
||||
@ -183,11 +157,6 @@ class LessonChangesAdapter(
|
||||
|
||||
else -> b.annotation.setText(R.string.timetable_lesson_shifted_from)
|
||||
}
|
||||
|
||||
b.annotation.background.colorFilter = PorterDuffColorFilter(
|
||||
getColorFromAttr(context, R.attr.timetable_lesson_shifted_target_color),
|
||||
PorterDuff.Mode.SRC_ATOP
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ package pl.szczodrzynski.edziennik.ui.agenda.lessonchanges
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import com.github.tibolte.agendacalendarview.render.EventRenderer
|
||||
import com.google.android.material.color.MaterialColors
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaCounterItemBinding
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedCounterBinding
|
||||
@ -18,10 +19,11 @@ class LessonChangesEventRenderer : EventRenderer<LessonChangesEvent>() {
|
||||
|
||||
override fun render(view: View, event: LessonChangesEvent) {
|
||||
val b = AgendaWrappedCounterBinding.bind(view).item
|
||||
val textColor = Colors.legibleTextColor(event.color)
|
||||
val harmonizedColor = MaterialColors.harmonizeWithPrimary(view.context, event.color)
|
||||
val textColor = Colors.legibleTextColor(harmonizedColor)
|
||||
|
||||
b.card.foreground.setTintColor(event.color)
|
||||
b.card.background.setTintColor(event.color)
|
||||
b.card.foreground.setTintColor(harmonizedColor)
|
||||
b.card.background.setTintColor(harmonizedColor)
|
||||
b.name.setText(R.string.agenda_lesson_changes)
|
||||
b.name.setTextColor(textColor)
|
||||
b.count.text = event.count.toString()
|
||||
@ -35,10 +37,10 @@ class LessonChangesEventRenderer : EventRenderer<LessonChangesEvent>() {
|
||||
}
|
||||
|
||||
fun render(b: AgendaCounterItemBinding, event: LessonChangesEvent) {
|
||||
val textColor = Colors.legibleTextColor(event.color)
|
||||
|
||||
b.card.foreground.setTintColor(event.color)
|
||||
b.card.background.setTintColor(event.color)
|
||||
val harmonizedColor = MaterialColors.harmonizeWithPrimary(b.root.context, event.color)
|
||||
val textColor = Colors.legibleTextColor(harmonizedColor)
|
||||
b.card.foreground.setTintColor(harmonizedColor)
|
||||
b.card.background.setTintColor(harmonizedColor)
|
||||
b.name.setText(R.string.agenda_lesson_changes)
|
||||
b.name.setTextColor(textColor)
|
||||
b.count.text = event.count.toString()
|
||||
|
@ -7,6 +7,7 @@ package pl.szczodrzynski.edziennik.ui.agenda.teacherabsence
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import com.github.tibolte.agendacalendarview.render.EventRenderer
|
||||
import com.google.android.material.color.MaterialColors
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaCounterItemBinding
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedCounterBinding
|
||||
@ -17,10 +18,11 @@ class TeacherAbsenceEventRenderer : EventRenderer<TeacherAbsenceEvent>() {
|
||||
|
||||
override fun render(view: View, event: TeacherAbsenceEvent) {
|
||||
val b = AgendaWrappedCounterBinding.bind(view).item
|
||||
val textColor = Colors.legibleTextColor(event.color)
|
||||
val harmonizedColor = MaterialColors.harmonizeWithPrimary(view.context, event.color)
|
||||
val textColor = Colors.legibleTextColor(harmonizedColor)
|
||||
|
||||
b.card.foreground.setTintColor(event.color)
|
||||
b.card.background.setTintColor(event.color)
|
||||
b.card.foreground.setTintColor(harmonizedColor)
|
||||
b.card.background.setTintColor(harmonizedColor)
|
||||
b.name.setText(R.string.agenda_teacher_absence)
|
||||
b.name.setTextColor(textColor)
|
||||
b.count.text = event.count.toString()
|
||||
@ -31,10 +33,11 @@ class TeacherAbsenceEventRenderer : EventRenderer<TeacherAbsenceEvent>() {
|
||||
}
|
||||
|
||||
fun render(b: AgendaCounterItemBinding, event: TeacherAbsenceEvent) {
|
||||
val textColor = Colors.legibleTextColor(event.color)
|
||||
val harmonizedColor = MaterialColors.harmonizeWithPrimary(b.root.context, event.color)
|
||||
val textColor = Colors.legibleTextColor(harmonizedColor)
|
||||
|
||||
b.card.foreground.setTintColor(event.color)
|
||||
b.card.background.setTintColor(event.color)
|
||||
b.card.foreground.setTintColor(harmonizedColor)
|
||||
b.card.background.setTintColor(harmonizedColor)
|
||||
b.name.setText(R.string.agenda_teacher_absence)
|
||||
b.name.setTextColor(textColor)
|
||||
b.count.text = event.count.toString()
|
||||
|
@ -66,7 +66,7 @@ class AttendanceBar : View {
|
||||
}
|
||||
|
||||
@SuppressLint("DrawAllocation", "CanvasSize")
|
||||
override fun onDraw(canvas: Canvas?) {
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
canvas ?: return
|
||||
|
||||
val sum = attendancesList.sumOf { it.count }
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user