mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 04:46:44 -06:00
[API] Refactor integer-based types to enum classes. (#145)
* [App] Add enum classes for common IDs. * [App] Rename enum package names. * [App] Migrate code to use new enums. * [DB] Migrate loginStoreMode IDs to be unique. * [UI] Fix minor issues after refactor. * [API] Update sync method signature. * [UI] Correct pop-to-home and back button drawer behavior. * [App] Update Bundle extensions usage. * [App] Migrate notification types to enum. * [UI] Make Lab fragment compatible with enums. * [API] Make EndpointTimer use FeatureType. * [App] Migrate config & API lists to sets.
This commit is contained in:
parent
1450d63fcb
commit
ba10d10a10
2314
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/99.json
Normal file
2314
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/99.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -37,14 +37,17 @@ import pl.szczodrzynski.edziennik.data.api.szkolny.SzkolnyApi
|
||||
import pl.szczodrzynski.edziennik.data.api.szkolny.interceptor.Signing
|
||||
import pl.szczodrzynski.edziennik.data.db.AppDb
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.DAY
|
||||
import pl.szczodrzynski.edziennik.ext.MS
|
||||
import pl.szczodrzynski.edziennik.ext.putExtras
|
||||
import pl.szczodrzynski.edziennik.ext.setLanguage
|
||||
import pl.szczodrzynski.edziennik.network.SSLProviderInstaller
|
||||
import pl.szczodrzynski.edziennik.network.cookie.DumbCookieJar
|
||||
import pl.szczodrzynski.edziennik.sync.SyncWorker
|
||||
import pl.szczodrzynski.edziennik.sync.UpdateWorker
|
||||
import pl.szczodrzynski.edziennik.ui.base.CrashActivity
|
||||
import pl.szczodrzynski.edziennik.ui.base.enums.NavTarget
|
||||
import pl.szczodrzynski.edziennik.utils.*
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
import pl.szczodrzynski.edziennik.utils.managers.*
|
||||
@ -180,7 +183,7 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
// initialize companion object values
|
||||
App.db = AppDb(this)
|
||||
App.config = Config(App.db)
|
||||
App.profile = Profile(0, 0, 0, "")
|
||||
App.profile = Profile(0, 0, LoginType.TEMPLATE, "")
|
||||
debugMode = BuildConfig.DEBUG
|
||||
devMode = config.devMode ?: debugMode
|
||||
enableChucker = config.enableChucker ?: devMode
|
||||
@ -224,35 +227,35 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
.setShortLabel(getString(R.string.shortcut_timetable)).setLongLabel(getString(R.string.shortcut_timetable))
|
||||
.setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_timetable))
|
||||
.setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java)
|
||||
.putExtra("fragmentId", MainActivity.DRAWER_ITEM_TIMETABLE))
|
||||
.putExtras("fragmentId" to NavTarget.TIMETABLE))
|
||||
.build()
|
||||
|
||||
val shortcutAgenda = ShortcutInfo.Builder(this@App, "item_agenda")
|
||||
.setShortLabel(getString(R.string.shortcut_agenda)).setLongLabel(getString(R.string.shortcut_agenda))
|
||||
.setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_agenda))
|
||||
.setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java)
|
||||
.putExtra("fragmentId", MainActivity.DRAWER_ITEM_AGENDA))
|
||||
.putExtras("fragmentId" to NavTarget.AGENDA))
|
||||
.build()
|
||||
|
||||
val shortcutGrades = ShortcutInfo.Builder(this@App, "item_grades")
|
||||
.setShortLabel(getString(R.string.shortcut_grades)).setLongLabel(getString(R.string.shortcut_grades))
|
||||
.setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_grades))
|
||||
.setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java)
|
||||
.putExtra("fragmentId", MainActivity.DRAWER_ITEM_GRADES))
|
||||
.putExtras("fragmentId" to NavTarget.GRADES))
|
||||
.build()
|
||||
|
||||
val shortcutHomework = ShortcutInfo.Builder(this@App, "item_homeworks")
|
||||
.setShortLabel(getString(R.string.shortcut_homework)).setLongLabel(getString(R.string.shortcut_homework))
|
||||
.setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_homework))
|
||||
.setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java)
|
||||
.putExtra("fragmentId", MainActivity.DRAWER_ITEM_HOMEWORK))
|
||||
.putExtras("fragmentId" to NavTarget.HOMEWORK))
|
||||
.build()
|
||||
|
||||
val shortcutMessages = ShortcutInfo.Builder(this@App, "item_messages")
|
||||
.setShortLabel(getString(R.string.shortcut_messages)).setLongLabel(getString(R.string.shortcut_messages))
|
||||
.setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_messages))
|
||||
.setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java)
|
||||
.putExtra("fragmentId", MainActivity.DRAWER_ITEM_MESSAGES))
|
||||
.putExtras("fragmentId" to NavTarget.MESSAGES))
|
||||
.build()
|
||||
|
||||
shortcutManager.dynamicShortcuts = listOf(
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,8 @@ package pl.szczodrzynski.edziennik.config
|
||||
import pl.szczodrzynski.edziennik.config.utils.get
|
||||
import pl.szczodrzynski.edziennik.config.utils.getIntList
|
||||
import pl.szczodrzynski.edziennik.config.utils.set
|
||||
import pl.szczodrzynski.edziennik.ext.asNavTargetOrNull
|
||||
import pl.szczodrzynski.edziennik.ui.base.enums.NavTarget
|
||||
|
||||
class ConfigUI(private val config: Config) {
|
||||
private var mTheme: Int? = null
|
||||
@ -34,10 +36,10 @@ class ConfigUI(private val config: Config) {
|
||||
get() { mMiniMenuVisible = mMiniMenuVisible ?: config.values.get("miniMenuVisible", false); return mMiniMenuVisible ?: false }
|
||||
set(value) { config.set("miniMenuVisible", value); mMiniMenuVisible = value }
|
||||
|
||||
private var mMiniMenuButtons: List<Int>? = null
|
||||
var miniMenuButtons: List<Int>
|
||||
get() { mMiniMenuButtons = mMiniMenuButtons ?: config.values.getIntList("miniMenuButtons", listOf()); return mMiniMenuButtons ?: listOf() }
|
||||
set(value) { config.set("miniMenuButtons", value); mMiniMenuButtons = value }
|
||||
private var mMiniMenuButtons: Set<NavTarget>? = null
|
||||
var miniMenuButtons: Set<NavTarget>
|
||||
get() { mMiniMenuButtons = mMiniMenuButtons ?: config.values.getIntList("miniMenuButtons", listOf())?.mapNotNull { it.asNavTargetOrNull() }?.toSet(); return mMiniMenuButtons ?: setOf() }
|
||||
set(value) { config.set("miniMenuButtons", value.map { it.id }); mMiniMenuButtons = value }
|
||||
|
||||
private var mOpenDrawerOnBackPressed: Boolean? = null
|
||||
var openDrawerOnBackPressed: Boolean
|
||||
|
@ -6,10 +6,12 @@ package pl.szczodrzynski.edziennik.config
|
||||
|
||||
import pl.szczodrzynski.edziennik.config.utils.getIntList
|
||||
import pl.szczodrzynski.edziennik.config.utils.set
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.NotificationType
|
||||
import pl.szczodrzynski.edziennik.ext.asNotificationTypeOrNull
|
||||
|
||||
class ProfileConfigSync(private val config: ProfileConfig) {
|
||||
private var mNotificationFilter: List<Int>? = null
|
||||
var notificationFilter: List<Int>
|
||||
get() { mNotificationFilter = mNotificationFilter ?: config.values.getIntList("notificationFilter", listOf()); return mNotificationFilter ?: listOf() }
|
||||
set(value) { config.set("notificationFilter", value); mNotificationFilter = value }
|
||||
private var mNotificationFilter: Set<NotificationType>? = null
|
||||
var notificationFilter: Set<NotificationType>
|
||||
get() { mNotificationFilter = mNotificationFilter ?: config.values.getIntList("notificationFilter", listOf())?.mapNotNull { it.asNotificationTypeOrNull() }?.toSet(); return mNotificationFilter ?: setOf() }
|
||||
set(value) { config.set("notificationFilter", value.map { it.id }); mNotificationFilter = value }
|
||||
}
|
||||
|
@ -8,11 +8,10 @@ import android.content.SharedPreferences
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import pl.szczodrzynski.edziennik.BuildConfig
|
||||
import pl.szczodrzynski.edziennik.MainActivity
|
||||
import pl.szczodrzynski.edziennik.config.Config
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_LIBRUS
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_MOBIDZIENNIK
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_VULCAN
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.asNavTargetOrNull
|
||||
import pl.szczodrzynski.edziennik.ui.base.enums.NavTarget
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
import kotlin.math.abs
|
||||
|
||||
@ -26,16 +25,17 @@ class AppConfigMigrationV3(p: SharedPreferences, config: Config) {
|
||||
val oldButtons = p.getString("$s.miniDrawerButtonIds", null)?.let { str ->
|
||||
str.replace("[\\[\\]]*".toRegex(), "")
|
||||
.split(",\\s?".toRegex())
|
||||
.mapNotNull { it.toIntOrNull() }
|
||||
.mapNotNull { it.toIntOrNull().asNavTargetOrNull() }
|
||||
.toSet()
|
||||
}
|
||||
ui.miniMenuButtons = oldButtons ?: listOf(
|
||||
MainActivity.DRAWER_ITEM_HOME,
|
||||
MainActivity.DRAWER_ITEM_TIMETABLE,
|
||||
MainActivity.DRAWER_ITEM_AGENDA,
|
||||
MainActivity.DRAWER_ITEM_GRADES,
|
||||
MainActivity.DRAWER_ITEM_MESSAGES,
|
||||
MainActivity.DRAWER_ITEM_HOMEWORK,
|
||||
MainActivity.DRAWER_ITEM_SETTINGS
|
||||
ui.miniMenuButtons = oldButtons ?: setOf(
|
||||
NavTarget.HOME,
|
||||
NavTarget.TIMETABLE,
|
||||
NavTarget.AGENDA,
|
||||
NavTarget.GRADES,
|
||||
NavTarget.MESSAGES,
|
||||
NavTarget.HOMEWORK,
|
||||
NavTarget.SETTINGS
|
||||
)
|
||||
dataVersion = 1
|
||||
}
|
||||
@ -81,9 +81,9 @@ class AppConfigMigrationV3(p: SharedPreferences, config: Config) {
|
||||
tokens?.forEach {
|
||||
val token = it.value.first
|
||||
when (it.key) {
|
||||
LOGIN_TYPE_MOBIDZIENNIK -> sync.tokenMobidziennik = token
|
||||
LOGIN_TYPE_VULCAN -> sync.tokenVulcan = token
|
||||
LOGIN_TYPE_LIBRUS -> sync.tokenLibrus = token
|
||||
LoginType.MOBIDZIENNIK.id -> sync.tokenMobidziennik = token
|
||||
LoginType.VULCAN.id -> sync.tokenVulcan = token
|
||||
LoginType.LIBRUS.id -> sync.tokenLibrus = token
|
||||
}
|
||||
}
|
||||
dataVersion = 2
|
||||
|
@ -10,6 +10,7 @@ import pl.szczodrzynski.edziennik.BuildConfig
|
||||
import pl.szczodrzynski.edziennik.MainActivity
|
||||
import pl.szczodrzynski.edziennik.config.Config
|
||||
import pl.szczodrzynski.edziennik.ext.HOUR
|
||||
import pl.szczodrzynski.edziennik.ui.base.enums.NavTarget
|
||||
import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.ORDER_BY_DATE_DESC
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
import kotlin.math.abs
|
||||
@ -32,14 +33,14 @@ class ConfigMigration(app: App, config: Config) {
|
||||
ui.appBackground = null
|
||||
ui.headerBackground = null
|
||||
ui.miniMenuVisible = false
|
||||
ui.miniMenuButtons = listOf(
|
||||
MainActivity.DRAWER_ITEM_HOME,
|
||||
MainActivity.DRAWER_ITEM_TIMETABLE,
|
||||
MainActivity.DRAWER_ITEM_AGENDA,
|
||||
MainActivity.DRAWER_ITEM_GRADES,
|
||||
MainActivity.DRAWER_ITEM_MESSAGES,
|
||||
MainActivity.DRAWER_ITEM_HOMEWORK,
|
||||
MainActivity.DRAWER_ITEM_SETTINGS
|
||||
ui.miniMenuButtons = setOf(
|
||||
NavTarget.HOME,
|
||||
NavTarget.TIMETABLE,
|
||||
NavTarget.AGENDA,
|
||||
NavTarget.GRADES,
|
||||
NavTarget.MESSAGES,
|
||||
NavTarget.HOMEWORK,
|
||||
NavTarget.SETTINGS
|
||||
)
|
||||
sync.enabled = true
|
||||
sync.interval = 1* HOUR.toInt()
|
||||
|
@ -5,8 +5,8 @@
|
||||
package pl.szczodrzynski.edziennik.config.utils
|
||||
|
||||
import pl.szczodrzynski.edziennik.config.ProfileConfig
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Notification
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile.Companion.AGENDA_DEFAULT
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.NotificationType
|
||||
import pl.szczodrzynski.edziennik.ui.home.HomeCard
|
||||
import pl.szczodrzynski.edziennik.ui.home.HomeCardModel
|
||||
import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.COLOR_MODE_WEIGHTED
|
||||
@ -31,7 +31,7 @@ class ProfileConfigMigration(config: ProfileConfig) {
|
||||
}
|
||||
|
||||
if (dataVersion < 2) {
|
||||
sync.notificationFilter = sync.notificationFilter + Notification.TYPE_TEACHER_ABSENCE
|
||||
sync.notificationFilter = sync.notificationFilter + NotificationType.TEACHER_ABSENCE
|
||||
|
||||
dataVersion = 2
|
||||
}
|
||||
|
@ -2,115 +2,116 @@ package pl.szczodrzynski.edziennik.data.api
|
||||
|
||||
import pl.szczodrzynski.edziennik.data.api.models.Data
|
||||
import pl.szczodrzynski.edziennik.data.api.models.Feature
|
||||
import pl.szczodrzynski.edziennik.data.api.models.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.EndpointTimer
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_NEVER
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.ext.getFeatureTypesNecessary
|
||||
import pl.szczodrzynski.edziennik.ext.getFeatureTypesUnnecessary
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
|
||||
fun Data.prepare(loginMethods: List<LoginMethod>, features: List<Feature>, featureIds: List<Int>, viewId: Int?, onlyEndpoints: List<Int>?) {
|
||||
val data = this
|
||||
|
||||
val possibleLoginMethods = data.loginMethods.toMutableList()
|
||||
|
||||
for (loginMethod in loginMethods) {
|
||||
if (loginMethod.isPossible(profile, loginStore))
|
||||
possibleLoginMethods += loginMethod.loginMethodId
|
||||
fun Data.prepare(
|
||||
features: List<Feature>,
|
||||
featureTypes: Set<FeatureType>?,
|
||||
onlyEndpoints: Set<Int>?,
|
||||
) {
|
||||
val loginType = this.loginStore.type
|
||||
val possibleLoginMethods = this.loginMethods.toMutableList()
|
||||
possibleLoginMethods += LoginMethod.values().filter {
|
||||
it.loginType == loginType && it.isPossible?.invoke(profile, loginStore) != false
|
||||
}
|
||||
|
||||
//var highestLoginMethod = 0
|
||||
var endpointList = mutableListOf<Feature>()
|
||||
val requiredLoginMethods = mutableListOf<Int>()
|
||||
var possibleFeatures = mutableListOf<Feature>()
|
||||
val requiredLoginMethods = mutableListOf<LoginMethod>()
|
||||
|
||||
data.targetEndpointIds.clear()
|
||||
data.targetLoginMethodIds.clear()
|
||||
val syncFeatureTypes = when {
|
||||
featureTypes.isNotNullNorEmpty() -> featureTypes!!
|
||||
else -> getFeatureTypesUnnecessary()
|
||||
} + getFeatureTypesNecessary()
|
||||
val forceFeatureType = featureTypes?.singleOrNull()
|
||||
|
||||
this.targetEndpoints.clear()
|
||||
this.targetLoginMethods.clear()
|
||||
|
||||
// get all endpoints for every feature, only if possible to login and possible/necessary to sync
|
||||
for (featureId in featureIds) {
|
||||
features.filter {
|
||||
it.featureId == featureId // feature ID matches
|
||||
for (featureId in syncFeatureTypes) {
|
||||
possibleFeatures += features.filter {
|
||||
it.featureType == featureId // feature ID matches
|
||||
&& possibleLoginMethods.containsAll(it.requiredLoginMethods) // is possible to login
|
||||
&& it.shouldSync?.invoke(data) ?: true // is necessary/possible to sync
|
||||
}.let {
|
||||
endpointList.addAll(it)
|
||||
&& it.shouldSync?.invoke(this) ?: true // is necessary/possible to sync
|
||||
}
|
||||
}
|
||||
|
||||
val timestamp = System.currentTimeMillis()
|
||||
|
||||
endpointList = endpointList
|
||||
// sort the endpoint list by feature ID and priority
|
||||
.sortedWith(compareBy(Feature::featureId, Feature::priority))
|
||||
// select only the most important endpoint for each feature
|
||||
.distinctBy { it.featureId }
|
||||
.toMutableList()
|
||||
// add all endpoint IDs and required login methods, filtering using timers
|
||||
.onEach { feature ->
|
||||
feature.endpointIds.forEach { endpoint ->
|
||||
if (onlyEndpoints?.contains(endpoint.first) == false)
|
||||
return@forEach
|
||||
(data.endpointTimers
|
||||
.singleOrNull { it.endpointId == endpoint.first } ?: EndpointTimer(data.profile?.id
|
||||
?: -1, endpoint.first))
|
||||
.let { timer ->
|
||||
if (
|
||||
onlyEndpoints?.contains(endpoint.first) == true ||
|
||||
timer.nextSync == SYNC_ALWAYS ||
|
||||
viewId != null && timer.viewId == viewId ||
|
||||
timer.nextSync != SYNC_NEVER && timer.nextSync < timestamp
|
||||
) {
|
||||
data.targetEndpointIds[endpoint.first] = timer.lastSync
|
||||
requiredLoginMethods.add(endpoint.second)
|
||||
}
|
||||
}
|
||||
}
|
||||
possibleFeatures = possibleFeatures
|
||||
// sort the endpoint list by feature ID and priority
|
||||
.sortedWith(compareBy(Feature::featureType, Feature::priority))
|
||||
// select only the most important endpoint for each feature
|
||||
.distinctBy { it.featureType }
|
||||
.toMutableList()
|
||||
|
||||
for (feature in possibleFeatures) {
|
||||
// add all endpoint IDs and required login methods, filtering using timers
|
||||
feature.endpoints.forEach { endpoint ->
|
||||
if (onlyEndpoints?.contains(endpoint.first) == false)
|
||||
return@forEach
|
||||
val timer = this.endpointTimers
|
||||
.singleOrNull { it.endpointId == endpoint.first }
|
||||
?: EndpointTimer(this.profileId, endpoint.first)
|
||||
if (
|
||||
onlyEndpoints?.contains(endpoint.first) == true ||
|
||||
timer.nextSync == SYNC_ALWAYS ||
|
||||
forceFeatureType != null && timer.featureType == forceFeatureType ||
|
||||
timer.nextSync != SYNC_NEVER && timer.nextSync < timestamp
|
||||
) {
|
||||
this.targetEndpoints[endpoint.first] = timer.lastSync
|
||||
requiredLoginMethods += endpoint.second
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check every login method for any dependencies
|
||||
for (loginMethodId in requiredLoginMethods) {
|
||||
var requiredLoginMethod: Int? = loginMethodId
|
||||
while (requiredLoginMethod != LOGIN_METHOD_NOT_NEEDED) {
|
||||
loginMethods.singleOrNull { it.loginMethodId == requiredLoginMethod }?.let { loginMethod ->
|
||||
if (requiredLoginMethod != null)
|
||||
data.targetLoginMethodIds.add(requiredLoginMethod!!)
|
||||
requiredLoginMethod = loginMethod.requiredLoginMethod(data.profile, data.loginStore)
|
||||
}
|
||||
for (loginMethod in requiredLoginMethods) {
|
||||
var requiredLoginMethod: LoginMethod? = loginMethod
|
||||
while (requiredLoginMethod != null) {
|
||||
this.targetLoginMethods += requiredLoginMethod
|
||||
requiredLoginMethod = requiredLoginMethod.requiredLoginMethod?.invoke(this.profile, this.loginStore)
|
||||
}
|
||||
}
|
||||
|
||||
// sort and distinct every login method and endpoint
|
||||
data.targetLoginMethodIds = data.targetLoginMethodIds.toHashSet().toMutableList()
|
||||
data.targetLoginMethodIds.sort()
|
||||
this.targetLoginMethods = this.targetLoginMethods.toHashSet().toMutableList()
|
||||
this.targetLoginMethods.sort()
|
||||
|
||||
//data.targetEndpointIds = data.targetEndpointIds.toHashSet().toMutableList()
|
||||
//data.targetEndpointIds.sort()
|
||||
|
||||
progressCount = targetLoginMethodIds.size + targetEndpointIds.size
|
||||
progressCount = targetLoginMethods.size + targetEndpoints.size
|
||||
progressStep = if (progressCount <= 0) 0f else 100f / progressCount.toFloat()
|
||||
}
|
||||
|
||||
fun Data.prepareFor(loginMethods: List<LoginMethod>, loginMethodId: Int) {
|
||||
fun Data.prepareFor(loginMethod: LoginMethod) {
|
||||
val loginType = loginStore.type
|
||||
val possibleLoginMethods = this.loginMethods.toMutableList()
|
||||
|
||||
loginMethods.forEach {
|
||||
if (it.isPossible(profile, loginStore))
|
||||
possibleLoginMethods += it.loginMethodId
|
||||
possibleLoginMethods += LoginMethod.values().filter {
|
||||
it.loginType == loginType && it.isPossible?.invoke(profile, loginStore) != false
|
||||
}
|
||||
|
||||
targetLoginMethodIds.clear()
|
||||
this.targetLoginMethods.clear()
|
||||
|
||||
// check the login method for any dependencies
|
||||
var requiredLoginMethod: Int? = loginMethodId
|
||||
while (requiredLoginMethod != LOGIN_METHOD_NOT_NEEDED) {
|
||||
loginMethods.singleOrNull { it.loginMethodId == requiredLoginMethod }?.let {
|
||||
if (requiredLoginMethod != null)
|
||||
targetLoginMethodIds.add(requiredLoginMethod!!)
|
||||
requiredLoginMethod = it.requiredLoginMethod(profile, loginStore)
|
||||
}
|
||||
var requiredLoginMethod: LoginMethod? = loginMethod
|
||||
while (requiredLoginMethod != null) {
|
||||
this.targetLoginMethods += requiredLoginMethod
|
||||
requiredLoginMethod = requiredLoginMethod.requiredLoginMethod?.invoke(this.profile, this.loginStore)
|
||||
}
|
||||
|
||||
// sort and distinct every login method
|
||||
targetLoginMethodIds = targetLoginMethodIds.toHashSet().toMutableList()
|
||||
targetLoginMethodIds.sort()
|
||||
this.targetLoginMethods = this.targetLoginMethods.toHashSet().toMutableList()
|
||||
this.targetLoginMethods.sort()
|
||||
|
||||
progressCount = 0
|
||||
progressStep = 0f
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Kuba Szczodrzyński 2019-9-29.
|
||||
*/
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api
|
||||
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_AGENDA
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_ANNOUNCEMENTS
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_ATTENDANCE
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_BEHAVIOUR
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_GRADES
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_HOME
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_HOMEWORK
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_MESSAGES
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_TIMETABLE
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_RECEIVED
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_SENT
|
||||
|
||||
internal const val FEATURE_TIMETABLE = 1
|
||||
internal const val FEATURE_AGENDA = 2
|
||||
internal const val FEATURE_GRADES = 3
|
||||
internal const val FEATURE_HOMEWORK = 4
|
||||
internal const val FEATURE_BEHAVIOUR = 5
|
||||
internal const val FEATURE_ATTENDANCE = 6
|
||||
internal const val FEATURE_MESSAGES_INBOX = 7
|
||||
internal const val FEATURE_MESSAGES_SENT = 8
|
||||
internal const val FEATURE_ANNOUNCEMENTS = 9
|
||||
|
||||
internal const val FEATURE_ALWAYS_NEEDED = 100
|
||||
internal const val FEATURE_STUDENT_INFO = 101
|
||||
internal const val FEATURE_STUDENT_NUMBER = 109
|
||||
internal const val FEATURE_SCHOOL_INFO = 102
|
||||
internal const val FEATURE_CLASS_INFO = 103
|
||||
internal const val FEATURE_TEAM_INFO = 104
|
||||
internal const val FEATURE_LUCKY_NUMBER = 105
|
||||
internal const val FEATURE_TEACHERS = 106
|
||||
internal const val FEATURE_SUBJECTS = 107
|
||||
internal const val FEATURE_CLASSROOMS = 108
|
||||
internal const val FEATURE_PUSH_CONFIG = 120
|
||||
|
||||
object Features {
|
||||
private fun getAllNecessary(): List<Int> = listOf(
|
||||
FEATURE_ALWAYS_NEEDED,
|
||||
FEATURE_PUSH_CONFIG,
|
||||
FEATURE_STUDENT_INFO,
|
||||
FEATURE_STUDENT_NUMBER,
|
||||
FEATURE_SCHOOL_INFO,
|
||||
FEATURE_CLASS_INFO,
|
||||
FEATURE_TEAM_INFO,
|
||||
FEATURE_LUCKY_NUMBER,
|
||||
FEATURE_TEACHERS,
|
||||
FEATURE_SUBJECTS,
|
||||
FEATURE_CLASSROOMS)
|
||||
|
||||
private fun getAllFeatures(): List<Int> = listOf(
|
||||
FEATURE_TIMETABLE,
|
||||
FEATURE_AGENDA,
|
||||
FEATURE_GRADES,
|
||||
FEATURE_HOMEWORK,
|
||||
FEATURE_BEHAVIOUR,
|
||||
FEATURE_ATTENDANCE,
|
||||
FEATURE_MESSAGES_INBOX,
|
||||
FEATURE_MESSAGES_SENT,
|
||||
FEATURE_ANNOUNCEMENTS)
|
||||
|
||||
fun getAllIds(): List<Int> = getAllFeatures() + getAllNecessary()
|
||||
|
||||
fun getIdsByView(targetId: Int, targetType: Int): List<Int> {
|
||||
return (when (targetId) {
|
||||
DRAWER_ITEM_HOME -> getAllFeatures()
|
||||
DRAWER_ITEM_TIMETABLE -> listOf(FEATURE_TIMETABLE)
|
||||
DRAWER_ITEM_AGENDA -> listOf(FEATURE_AGENDA)
|
||||
DRAWER_ITEM_GRADES -> listOf(FEATURE_GRADES)
|
||||
DRAWER_ITEM_MESSAGES -> when (targetType) {
|
||||
TYPE_RECEIVED -> listOf(FEATURE_MESSAGES_INBOX)
|
||||
TYPE_SENT -> listOf(FEATURE_MESSAGES_SENT)
|
||||
else -> listOf(FEATURE_MESSAGES_INBOX, FEATURE_MESSAGES_SENT)
|
||||
}
|
||||
DRAWER_ITEM_HOMEWORK -> listOf(FEATURE_HOMEWORK)
|
||||
DRAWER_ITEM_BEHAVIOUR -> listOf(FEATURE_BEHAVIOUR)
|
||||
DRAWER_ITEM_ATTENDANCE -> listOf(FEATURE_ATTENDANCE)
|
||||
DRAWER_ITEM_ANNOUNCEMENTS -> listOf(FEATURE_ANNOUNCEMENTS)
|
||||
else -> getAllFeatures()
|
||||
} + getAllNecessary()).sorted()
|
||||
}
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Kuba Szczodrzyński 2019-9-20.
|
||||
*/
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api
|
||||
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.login.LibrusLoginApi
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.login.LibrusLoginMessages
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.login.LibrusLoginPortal
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.login.LibrusLoginSynergia
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.login.MobidziennikLoginApi2
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.login.MobidziennikLoginWeb
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.login.PodlasieLoginApi
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.login.TemplateLoginApi
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.login.TemplateLoginWeb
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.usos.login.UsosLoginApi
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.login.VulcanLoginHebe
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.login.VulcanLoginWebMain
|
||||
import pl.szczodrzynski.edziennik.data.api.models.LoginMethod
|
||||
|
||||
// librus
|
||||
// mobidziennik
|
||||
// idziennik [*]
|
||||
// vulcan
|
||||
// mobireg
|
||||
|
||||
const val SYNERGIA_API_ENABLED = false
|
||||
|
||||
// the graveyard
|
||||
const val LOGIN_TYPE_IDZIENNIK = 3
|
||||
const val LOGIN_TYPE_EDUDZIENNIK = 5
|
||||
|
||||
const val LOGIN_TYPE_TEMPLATE = 21
|
||||
|
||||
// LOGIN MODES
|
||||
const val LOGIN_MODE_TEMPLATE_WEB = 0
|
||||
|
||||
// LOGIN METHODS
|
||||
const val LOGIN_METHOD_NOT_NEEDED = -1
|
||||
const val LOGIN_METHOD_TEMPLATE_WEB = 100
|
||||
const val LOGIN_METHOD_TEMPLATE_API = 200
|
||||
|
||||
const val LOGIN_TYPE_LIBRUS = 2
|
||||
const val LOGIN_MODE_LIBRUS_EMAIL = 0
|
||||
const val LOGIN_MODE_LIBRUS_SYNERGIA = 1
|
||||
const val LOGIN_MODE_LIBRUS_JST = 2
|
||||
const val LOGIN_METHOD_LIBRUS_PORTAL = 100
|
||||
const val LOGIN_METHOD_LIBRUS_API = 200
|
||||
const val LOGIN_METHOD_LIBRUS_SYNERGIA = 300
|
||||
const val LOGIN_METHOD_LIBRUS_MESSAGES = 400
|
||||
val librusLoginMethods = listOf(
|
||||
LoginMethod(LOGIN_TYPE_LIBRUS, LOGIN_METHOD_LIBRUS_PORTAL, LibrusLoginPortal::class.java)
|
||||
.withIsPossible { _, loginStore ->
|
||||
loginStore.mode == LOGIN_MODE_LIBRUS_EMAIL
|
||||
}
|
||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED },
|
||||
|
||||
LoginMethod(LOGIN_TYPE_LIBRUS, LOGIN_METHOD_LIBRUS_API, LibrusLoginApi::class.java)
|
||||
.withIsPossible { _, loginStore ->
|
||||
loginStore.mode != LOGIN_MODE_LIBRUS_SYNERGIA || SYNERGIA_API_ENABLED
|
||||
}
|
||||
.withRequiredLoginMethod { _, loginStore ->
|
||||
if (loginStore.mode == LOGIN_MODE_LIBRUS_EMAIL) LOGIN_METHOD_LIBRUS_PORTAL else LOGIN_METHOD_NOT_NEEDED
|
||||
},
|
||||
|
||||
LoginMethod(LOGIN_TYPE_LIBRUS, LOGIN_METHOD_LIBRUS_SYNERGIA, LibrusLoginSynergia::class.java)
|
||||
.withIsPossible { _, loginStore -> !loginStore.hasLoginData("fakeLogin") }
|
||||
.withRequiredLoginMethod { profile, _ ->
|
||||
if (profile?.hasStudentData("accountPassword") == false || true) LOGIN_METHOD_LIBRUS_API else LOGIN_METHOD_NOT_NEEDED
|
||||
},
|
||||
|
||||
LoginMethod(LOGIN_TYPE_LIBRUS, LOGIN_METHOD_LIBRUS_MESSAGES, LibrusLoginMessages::class.java)
|
||||
.withIsPossible { _, loginStore -> !loginStore.hasLoginData("fakeLogin") }
|
||||
.withRequiredLoginMethod { profile, _ ->
|
||||
if (profile?.hasStudentData("accountPassword") == false || true) LOGIN_METHOD_LIBRUS_SYNERGIA else LOGIN_METHOD_NOT_NEEDED
|
||||
}
|
||||
)
|
||||
|
||||
const val LOGIN_TYPE_MOBIDZIENNIK = 1
|
||||
const val LOGIN_MODE_MOBIDZIENNIK_WEB = 0
|
||||
const val LOGIN_METHOD_MOBIDZIENNIK_WEB = 100
|
||||
const val LOGIN_METHOD_MOBIDZIENNIK_API2 = 300
|
||||
val mobidziennikLoginMethods = listOf(
|
||||
LoginMethod(LOGIN_TYPE_MOBIDZIENNIK, LOGIN_METHOD_MOBIDZIENNIK_WEB, MobidziennikLoginWeb::class.java)
|
||||
.withIsPossible { _, _ -> true }
|
||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED },
|
||||
|
||||
LoginMethod(LOGIN_TYPE_MOBIDZIENNIK, LOGIN_METHOD_MOBIDZIENNIK_API2, MobidziennikLoginApi2::class.java)
|
||||
.withIsPossible { profile, _ -> profile?.getStudentData("email", null) != null }
|
||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED }
|
||||
)
|
||||
|
||||
const val LOGIN_TYPE_VULCAN = 4
|
||||
const val LOGIN_MODE_VULCAN_API = 0
|
||||
const val LOGIN_MODE_VULCAN_WEB = 1
|
||||
const val LOGIN_MODE_VULCAN_HEBE = 2
|
||||
const val LOGIN_METHOD_VULCAN_WEB_MAIN = 100
|
||||
const val LOGIN_METHOD_VULCAN_WEB_NEW = 200
|
||||
const val LOGIN_METHOD_VULCAN_WEB_OLD = 300
|
||||
const val LOGIN_METHOD_VULCAN_WEB_MESSAGES = 400
|
||||
const val LOGIN_METHOD_VULCAN_HEBE = 600
|
||||
val vulcanLoginMethods = listOf(
|
||||
LoginMethod(LOGIN_TYPE_VULCAN, LOGIN_METHOD_VULCAN_WEB_MAIN, VulcanLoginWebMain::class.java)
|
||||
.withIsPossible { _, loginStore -> loginStore.hasLoginData("webHost") }
|
||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED },
|
||||
|
||||
/*LoginMethod(LOGIN_TYPE_VULCAN, LOGIN_METHOD_VULCAN_WEB_NEW, VulcanLoginWebNew::class.java)
|
||||
.withIsPossible { _, _ -> false }
|
||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_VULCAN_WEB_MAIN },
|
||||
|
||||
LoginMethod(LOGIN_TYPE_VULCAN, LOGIN_METHOD_VULCAN_WEB_OLD, VulcanLoginWebOld::class.java)
|
||||
.withIsPossible { _, _ -> false }
|
||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_VULCAN_WEB_MAIN },*/
|
||||
|
||||
LoginMethod(LOGIN_TYPE_VULCAN, LOGIN_METHOD_VULCAN_HEBE, VulcanLoginHebe::class.java)
|
||||
.withIsPossible { _, loginStore ->
|
||||
loginStore.mode != LOGIN_MODE_VULCAN_API
|
||||
}
|
||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED }
|
||||
)
|
||||
|
||||
const val LOGIN_TYPE_PODLASIE = 6
|
||||
const val LOGIN_MODE_PODLASIE_API = 0
|
||||
const val LOGIN_METHOD_PODLASIE_API = 100
|
||||
val podlasieLoginMethods = listOf(
|
||||
LoginMethod(LOGIN_TYPE_PODLASIE, LOGIN_METHOD_PODLASIE_API, PodlasieLoginApi::class.java)
|
||||
.withIsPossible { _, _ -> true }
|
||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED }
|
||||
)
|
||||
|
||||
const val LOGIN_TYPE_USOS = 7
|
||||
const val LOGIN_MODE_USOS_OAUTH = 0
|
||||
const val LOGIN_METHOD_USOS_API = 100
|
||||
val usosLoginMethods = listOf(
|
||||
LoginMethod(LOGIN_TYPE_USOS, LOGIN_METHOD_USOS_API, UsosLoginApi::class.java)
|
||||
.withIsPossible { _, _ -> true }
|
||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED }
|
||||
)
|
||||
|
||||
val templateLoginMethods = listOf(
|
||||
LoginMethod(LOGIN_TYPE_TEMPLATE, LOGIN_METHOD_TEMPLATE_WEB, TemplateLoginWeb::class.java)
|
||||
.withIsPossible { _, _ -> true }
|
||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED },
|
||||
|
||||
LoginMethod(LOGIN_TYPE_TEMPLATE, LOGIN_METHOD_TEMPLATE_API, TemplateLoginApi::class.java)
|
||||
.withIsPossible { _, _ -> true }
|
||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_TEMPLATE_WEB }
|
||||
)
|
@ -6,8 +6,9 @@ package pl.szczodrzynski.edziennik.data.api.edziennik
|
||||
|
||||
import com.google.gson.JsonObject
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.data.api.ERROR_PROFILE_ARCHIVED
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.Librus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.Mobidziennik
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.Podlasie
|
||||
@ -22,6 +23,8 @@ import pl.szczodrzynski.edziennik.data.api.task.IApiTask
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
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
|
||||
@ -37,10 +40,10 @@ open class EdziennikTask(override val profileId: Int, val request: Any) : IApiTa
|
||||
|
||||
fun firstLogin(loginStore: LoginStore) = EdziennikTask(-1, FirstLoginRequest(loginStore))
|
||||
fun sync() = EdziennikTask(-1, SyncRequest())
|
||||
fun syncProfile(profileId: Int, viewIds: List<Pair<Int, Int>>? = null, onlyEndpoints: List<Int>? = null, arguments: JsonObject? = null) = EdziennikTask(profileId, SyncProfileRequest(viewIds, onlyEndpoints, arguments))
|
||||
fun syncProfileList(profileList: List<Int>) = EdziennikTask(-1, SyncProfileListRequest(profileList))
|
||||
fun syncProfile(profileId: Int, featureTypes: Set<FeatureType>? = null, onlyEndpoints: Set<Int>? = null, arguments: JsonObject? = null) = EdziennikTask(profileId, SyncProfileRequest(featureTypes, onlyEndpoints, arguments))
|
||||
fun syncProfileList(profileList: Set<Int>) = EdziennikTask(-1, SyncProfileListRequest(profileList))
|
||||
fun messageGet(profileId: Int, message: MessageFull) = EdziennikTask(profileId, MessageGetRequest(message))
|
||||
fun messageSend(profileId: Int, recipients: List<Teacher>, subject: String, text: String) = EdziennikTask(profileId, MessageSendRequest(recipients, subject, text))
|
||||
fun messageSend(profileId: Int, recipients: Set<Teacher>, subject: String, text: String) = EdziennikTask(profileId, MessageSendRequest(recipients, subject, text))
|
||||
fun announcementsRead(profileId: Int) = EdziennikTask(profileId, AnnouncementsReadRequest())
|
||||
fun announcementGet(profileId: Int, announcement: AnnouncementFull) = EdziennikTask(profileId, AnnouncementGetRequest(announcement))
|
||||
fun attachmentGet(profileId: Int, owner: Any, attachmentId: Long, attachmentName: String) = EdziennikTask(profileId, AttachmentGetRequest(owner, attachmentId, attachmentName))
|
||||
@ -109,12 +112,12 @@ open class EdziennikTask(override val profileId: Int, val request: Any) : IApiTa
|
||||
}
|
||||
|
||||
edziennikInterface = when (loginStore.type) {
|
||||
LOGIN_TYPE_LIBRUS -> Librus(app, profile, loginStore, taskCallback)
|
||||
LOGIN_TYPE_MOBIDZIENNIK -> Mobidziennik(app, profile, loginStore, taskCallback)
|
||||
LOGIN_TYPE_VULCAN -> Vulcan(app, profile, loginStore, taskCallback)
|
||||
LOGIN_TYPE_PODLASIE -> Podlasie(app, profile, loginStore, taskCallback)
|
||||
LOGIN_TYPE_TEMPLATE -> Template(app, profile, loginStore, taskCallback)
|
||||
LOGIN_TYPE_USOS -> Usos(app, profile, loginStore, taskCallback)
|
||||
LoginType.LIBRUS -> Librus(app, profile, loginStore, taskCallback)
|
||||
LoginType.MOBIDZIENNIK -> Mobidziennik(app, profile, loginStore, taskCallback)
|
||||
LoginType.VULCAN -> Vulcan(app, profile, loginStore, taskCallback)
|
||||
LoginType.PODLASIE -> Podlasie(app, profile, loginStore, taskCallback)
|
||||
LoginType.TEMPLATE -> Template(app, profile, loginStore, taskCallback)
|
||||
LoginType.USOS -> Usos(app, profile, loginStore, taskCallback)
|
||||
else -> null
|
||||
}
|
||||
if (edziennikInterface == null) {
|
||||
@ -123,9 +126,7 @@ open class EdziennikTask(override val profileId: Int, val request: Any) : IApiTa
|
||||
|
||||
when (request) {
|
||||
is SyncProfileRequest -> edziennikInterface?.sync(
|
||||
featureIds = request.viewIds?.flatMap { Features.getIdsByView(it.first, it.second) }
|
||||
?: Features.getAllIds(),
|
||||
viewId = request.viewIds?.get(0)?.first,
|
||||
featureTypes = request.featureTypes,
|
||||
onlyEndpoints = request.onlyEndpoints,
|
||||
arguments = request.arguments)
|
||||
is MessageGetRequest -> edziennikInterface?.getMessage(request.message)
|
||||
@ -150,10 +151,10 @@ open class EdziennikTask(override val profileId: Int, val request: Any) : IApiTa
|
||||
|
||||
data class FirstLoginRequest(val loginStore: LoginStore)
|
||||
class SyncRequest
|
||||
data class SyncProfileRequest(val viewIds: List<Pair<Int, Int>>? = null, val onlyEndpoints: List<Int>? = null, val arguments: JsonObject? = null)
|
||||
data class SyncProfileListRequest(val profileList: List<Int>)
|
||||
data class SyncProfileRequest(val featureTypes: Set<FeatureType>? = null, val onlyEndpoints: Set<Int>? = null, val arguments: JsonObject? = null)
|
||||
data class SyncProfileListRequest(val profileList: Set<Int>)
|
||||
data class MessageGetRequest(val message: MessageFull)
|
||||
data class MessageSendRequest(val recipients: List<Teacher>, val subject: String, val text: String)
|
||||
data class MessageSendRequest(val recipients: Set<Teacher>, val subject: String, val text: String)
|
||||
class AnnouncementsReadRequest
|
||||
data class AnnouncementGetRequest(val announcement: AnnouncementFull)
|
||||
data class AttachmentGetRequest(val owner: Any, val attachmentId: Long, val attachmentName: String)
|
||||
|
@ -6,8 +6,8 @@ package pl.szczodrzynski.edziennik.data.api.edziennik
|
||||
|
||||
import android.content.Intent
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.Intent
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
@ -51,7 +51,7 @@ class ProfileArchiver(val app: App, val profile: Profile) {
|
||||
d(TAG, "New profile ID for ${profile.name}: ${profile.id}")
|
||||
|
||||
when (profile.loginStoreType) {
|
||||
LOGIN_TYPE_LIBRUS -> {
|
||||
LoginType.LIBRUS -> {
|
||||
profile.removeStudentData("isPremium")
|
||||
profile.removeStudentData("pushDeviceId")
|
||||
profile.removeStudentData("startPointsSemester1")
|
||||
@ -59,10 +59,8 @@ class ProfileArchiver(val app: App, val profile: Profile) {
|
||||
profile.removeStudentData("enablePointGrades")
|
||||
profile.removeStudentData("enableDescriptiveGrades")
|
||||
}
|
||||
LOGIN_TYPE_MOBIDZIENNIK -> {
|
||||
|
||||
}
|
||||
LOGIN_TYPE_VULCAN -> {
|
||||
LoginType.MOBIDZIENNIK -> {}
|
||||
LoginType.VULCAN -> {
|
||||
// DataVulcan.isApiLoginValid() returns false so it will update the semester
|
||||
profile.removeStudentData("currentSemesterEndDate")
|
||||
profile.removeStudentData("studentSemesterId")
|
||||
@ -71,15 +69,13 @@ class ProfileArchiver(val app: App, val profile: Profile) {
|
||||
profile.removeStudentData("semester2Id")
|
||||
profile.removeStudentData("studentClassId")
|
||||
}
|
||||
LOGIN_TYPE_IDZIENNIK -> {
|
||||
LoginType.IDZIENNIK -> {
|
||||
profile.removeStudentData("schoolYearId")
|
||||
}
|
||||
LOGIN_TYPE_EDUDZIENNIK -> {
|
||||
|
||||
}
|
||||
LOGIN_TYPE_PODLASIE -> {
|
||||
|
||||
}
|
||||
LoginType.EDUDZIENNIK -> {}
|
||||
LoginType.PODLASIE -> {}
|
||||
LoginType.DEMO -> {}
|
||||
LoginType.TEMPLATE -> {}
|
||||
}
|
||||
|
||||
d(TAG, "Processed student data: ${profile.studentData}")
|
||||
|
@ -5,13 +5,10 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus
|
||||
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_LIBRUS_API
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_LIBRUS_MESSAGES
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_LIBRUS_PORTAL
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_LIBRUS_SYNERGIA
|
||||
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.currentTimeUnix
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
|
||||
@ -25,15 +22,15 @@ class DataLibrus(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
override fun satisfyLoginMethods() {
|
||||
loginMethods.clear()
|
||||
if (isPortalLoginValid())
|
||||
loginMethods += LOGIN_METHOD_LIBRUS_PORTAL
|
||||
loginMethods += LoginMethod.LIBRUS_PORTAL
|
||||
if (isApiLoginValid())
|
||||
loginMethods += LOGIN_METHOD_LIBRUS_API
|
||||
loginMethods += LoginMethod.LIBRUS_API
|
||||
if (isSynergiaLoginValid()) {
|
||||
loginMethods += LOGIN_METHOD_LIBRUS_SYNERGIA
|
||||
loginMethods += LoginMethod.LIBRUS_SYNERGIA
|
||||
app.cookieJar.set("synergia.librus.pl", "DZIENNIKSID", synergiaSessionId)
|
||||
}
|
||||
if (isMessagesLoginValid()) {
|
||||
loginMethods += LOGIN_METHOD_LIBRUS_MESSAGES
|
||||
loginMethods += LoginMethod.LIBRUS_MESSAGES
|
||||
app.cookieJar.set("wiadomosci.librus.pl", "DZIENNIKSID", messagesSessionId)
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Message
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
|
||||
@ -58,19 +60,19 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
|_| |_| |_|\___| /_/ \_\_|\__, |\___/|_| |_|\__|_| |_|_| |_| |_|
|
||||
__/ |
|
||||
|__*/
|
||||
override fun sync(featureIds: List<Int>, viewId: Int?, onlyEndpoints: List<Int>?, arguments: JsonObject?) {
|
||||
override fun sync(featureTypes: Set<FeatureType>?, onlyEndpoints: Set<Int>?, arguments: JsonObject?) {
|
||||
data.arguments = arguments
|
||||
data.prepare(librusLoginMethods, LibrusFeatures, featureIds, viewId, onlyEndpoints)
|
||||
data.prepare(LibrusFeatures, featureTypes, onlyEndpoints)
|
||||
login()
|
||||
}
|
||||
|
||||
private fun login(loginMethodId: Int? = null, afterLogin: (() -> Unit)? = null) {
|
||||
d(TAG, "Trying to login with ${data.targetLoginMethodIds}")
|
||||
private fun login(loginMethod: LoginMethod? = null, afterLogin: (() -> Unit)? = null) {
|
||||
d(TAG, "Trying to login with ${data.targetLoginMethods}")
|
||||
if (internalErrorList.isNotEmpty()) {
|
||||
d(TAG, " - Internal errors:")
|
||||
internalErrorList.forEach { d(TAG, " - code $it") }
|
||||
}
|
||||
loginMethodId?.let { data.prepareFor(librusLoginMethods, it) }
|
||||
loginMethod?.let { data.prepareFor(it) }
|
||||
afterLogin?.let { this.afterLogin = it }
|
||||
LibrusLogin(data) {
|
||||
data()
|
||||
@ -78,7 +80,7 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
}
|
||||
|
||||
private fun data() {
|
||||
d(TAG, "Endpoint IDs: ${data.targetEndpointIds}")
|
||||
d(TAG, "Endpoint IDs: ${data.targetEndpoints}")
|
||||
if (internalErrorList.isNotEmpty()) {
|
||||
d(TAG, " - Internal errors:")
|
||||
internalErrorList.forEach { d(TAG, " - code $it") }
|
||||
@ -89,14 +91,14 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
}
|
||||
|
||||
override fun getMessage(message: MessageFull) {
|
||||
login(LOGIN_METHOD_LIBRUS_MESSAGES) {
|
||||
login(LoginMethod.LIBRUS_MESSAGES) {
|
||||
if (data.messagesLoginSuccessful) LibrusMessagesGetMessage(data, message) { completed() }
|
||||
else LibrusSynergiaGetMessage(data, message) { completed() }
|
||||
}
|
||||
}
|
||||
|
||||
override fun sendMessage(recipients: List<Teacher>, subject: String, text: String) {
|
||||
login(LOGIN_METHOD_LIBRUS_MESSAGES) {
|
||||
override fun sendMessage(recipients: Set<Teacher>, subject: String, text: String) {
|
||||
login(LoginMethod.LIBRUS_MESSAGES) {
|
||||
LibrusMessagesSendMessage(data, recipients, subject, text) {
|
||||
completed()
|
||||
}
|
||||
@ -104,7 +106,7 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
}
|
||||
|
||||
override fun markAllAnnouncementsAsRead() {
|
||||
login(LOGIN_METHOD_LIBRUS_SYNERGIA) {
|
||||
login(LoginMethod.LIBRUS_SYNERGIA) {
|
||||
LibrusSynergiaMarkAllAnnouncementsAsRead(data) {
|
||||
completed()
|
||||
}
|
||||
@ -112,7 +114,7 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
}
|
||||
|
||||
override fun getAnnouncement(announcement: AnnouncementFull) {
|
||||
login(LOGIN_METHOD_LIBRUS_API) {
|
||||
login(LoginMethod.LIBRUS_API) {
|
||||
LibrusApiAnnouncementMarkAsRead(data, announcement) {
|
||||
completed()
|
||||
}
|
||||
@ -122,13 +124,13 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
override fun getAttachment(owner: Any, attachmentId: Long, attachmentName: String) {
|
||||
when (owner) {
|
||||
is Message -> {
|
||||
login(LOGIN_METHOD_LIBRUS_SYNERGIA) {
|
||||
login(LoginMethod.LIBRUS_SYNERGIA) {
|
||||
if (data.messagesLoginSuccessful) LibrusMessagesGetAttachment(data, owner, attachmentId, attachmentName) { completed() }
|
||||
LibrusSynergiaGetAttachment(data, owner, attachmentId, attachmentName) { completed() }
|
||||
}
|
||||
}
|
||||
is EventFull -> {
|
||||
login(LOGIN_METHOD_LIBRUS_SYNERGIA) {
|
||||
login(LoginMethod.LIBRUS_SYNERGIA) {
|
||||
LibrusSynergiaHomeworkGetAttachment(data, owner, attachmentId, attachmentName) {
|
||||
completed()
|
||||
}
|
||||
@ -139,7 +141,7 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
}
|
||||
|
||||
override fun getRecipientList() {
|
||||
login(LOGIN_METHOD_LIBRUS_MESSAGES) {
|
||||
login(LoginMethod.LIBRUS_MESSAGES) {
|
||||
LibrusMessagesGetRecipientList(data) {
|
||||
completed()
|
||||
}
|
||||
@ -147,7 +149,7 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
}
|
||||
|
||||
override fun getEvent(eventFull: EventFull) {
|
||||
login(LOGIN_METHOD_LIBRUS_SYNERGIA) {
|
||||
login(LoginMethod.LIBRUS_SYNERGIA) {
|
||||
LibrusSynergiaGetHomework(data, eventFull) {
|
||||
completed()
|
||||
}
|
||||
@ -175,27 +177,27 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
internalErrorList.add(apiError.errorCode)
|
||||
when (apiError.errorCode) {
|
||||
ERROR_LIBRUS_PORTAL_ACCESS_DENIED -> {
|
||||
data.loginMethods.remove(LOGIN_METHOD_LIBRUS_PORTAL)
|
||||
data.prepareFor(librusLoginMethods, LOGIN_METHOD_LIBRUS_PORTAL)
|
||||
data.loginMethods.remove(LoginMethod.LIBRUS_PORTAL)
|
||||
data.prepareFor(LoginMethod.LIBRUS_PORTAL)
|
||||
data.portalTokenExpiryTime = 0
|
||||
login()
|
||||
}
|
||||
ERROR_LIBRUS_API_ACCESS_DENIED,
|
||||
ERROR_LIBRUS_API_TOKEN_EXPIRED -> {
|
||||
data.loginMethods.remove(LOGIN_METHOD_LIBRUS_API)
|
||||
data.prepareFor(librusLoginMethods, LOGIN_METHOD_LIBRUS_API)
|
||||
data.loginMethods.remove(LoginMethod.LIBRUS_API)
|
||||
data.prepareFor(LoginMethod.LIBRUS_API)
|
||||
data.apiTokenExpiryTime = 0
|
||||
login()
|
||||
}
|
||||
ERROR_LIBRUS_SYNERGIA_ACCESS_DENIED -> {
|
||||
data.loginMethods.remove(LOGIN_METHOD_LIBRUS_SYNERGIA)
|
||||
data.prepareFor(librusLoginMethods, LOGIN_METHOD_LIBRUS_SYNERGIA)
|
||||
data.loginMethods.remove(LoginMethod.LIBRUS_SYNERGIA)
|
||||
data.prepareFor(LoginMethod.LIBRUS_SYNERGIA)
|
||||
data.synergiaSessionIdExpiryTime = 0
|
||||
login()
|
||||
}
|
||||
ERROR_LIBRUS_MESSAGES_ACCESS_DENIED -> {
|
||||
data.loginMethods.remove(LOGIN_METHOD_LIBRUS_MESSAGES)
|
||||
data.prepareFor(librusLoginMethods, LOGIN_METHOD_LIBRUS_MESSAGES)
|
||||
data.loginMethods.remove(LoginMethod.LIBRUS_MESSAGES)
|
||||
data.prepareFor(LoginMethod.LIBRUS_MESSAGES)
|
||||
data.messagesSessionIdExpiryTime = 0
|
||||
login()
|
||||
}
|
||||
|
@ -4,8 +4,10 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus
|
||||
|
||||
import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.models.Feature
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
|
||||
const val ENDPOINT_LIBRUS_API_ME = 1001
|
||||
const val ENDPOINT_LIBRUS_API_SCHOOLS = 1002
|
||||
@ -58,14 +60,14 @@ const val ENDPOINT_LIBRUS_MESSAGES_TRASH = 3030
|
||||
|
||||
val LibrusFeatures = listOf(
|
||||
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_ALWAYS_NEEDED, listOf(
|
||||
ENDPOINT_LIBRUS_API_LESSONS to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.ALWAYS_NEEDED, listOf(
|
||||
ENDPOINT_LIBRUS_API_LESSONS to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
|
||||
// push config
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_PUSH_CONFIG, listOf(
|
||||
ENDPOINT_LIBRUS_API_PUSH_CONFIG to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)).withShouldSync { data ->
|
||||
Feature(LoginType.LIBRUS, FeatureType.PUSH_CONFIG, listOf(
|
||||
ENDPOINT_LIBRUS_API_PUSH_CONFIG to LoginMethod.LIBRUS_API
|
||||
)).withShouldSync { data ->
|
||||
(data as DataLibrus).isPremium && !data.app.config.sync.tokenLibrusList.contains(data.profileId)
|
||||
},
|
||||
|
||||
@ -76,72 +78,72 @@ val LibrusFeatures = listOf(
|
||||
/**
|
||||
* Timetable - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_TIMETABLE, listOf(
|
||||
ENDPOINT_LIBRUS_API_TIMETABLES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_SUBSTITUTIONS to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.TIMETABLE, listOf(
|
||||
ENDPOINT_LIBRUS_API_TIMETABLES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_SUBSTITUTIONS to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
/**
|
||||
* Agenda - using API.
|
||||
* Events, Parent-teacher meetings, free days (teacher/school/class).
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_AGENDA, listOf(
|
||||
ENDPOINT_LIBRUS_API_EVENTS to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_EVENT_TYPES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_PT_MEETINGS to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_SCHOOL_FREE_DAYS to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_CLASS_FREE_DAYS to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.AGENDA, listOf(
|
||||
ENDPOINT_LIBRUS_API_EVENTS to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_EVENT_TYPES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_PT_MEETINGS to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAY_TYPES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_SCHOOL_FREE_DAYS to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_CLASS_FREE_DAYS to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
/**
|
||||
* Grades - using API.
|
||||
* All grades + categories.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_GRADES, listOf(
|
||||
ENDPOINT_LIBRUS_API_NORMAL_GRADE_CATEGORIES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_POINT_GRADE_CATEGORIES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_DESCRIPTIVE_GRADE_CATEGORIES to LOGIN_METHOD_LIBRUS_API,
|
||||
Feature(LoginType.LIBRUS, FeatureType.GRADES, listOf(
|
||||
ENDPOINT_LIBRUS_API_NORMAL_GRADE_CATEGORIES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_POINT_GRADE_CATEGORIES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_DESCRIPTIVE_GRADE_CATEGORIES to LoginMethod.LIBRUS_API,
|
||||
// Commented out, because TextGrades/Categories is the same as Grades/Categories
|
||||
/* ENDPOINT_LIBRUS_API_TEXT_GRADE_CATEGORIES to LOGIN_METHOD_LIBRUS_API, */
|
||||
ENDPOINT_LIBRUS_API_DESCRIPTIVE_TEXT_GRADE_CATEGORIES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_BEHAVIOUR_GRADE_CATEGORIES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_NORMAL_GRADE_COMMENTS to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_BEHAVIOUR_GRADE_COMMENTS to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_NORMAL_GRADES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_POINT_GRADES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_DESCRIPTIVE_GRADES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_TEXT_GRADES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_DESCRIPTIVE_TEXT_GRADES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_BEHAVIOUR_GRADES to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
/* ENDPOINT_LIBRUS_API_TEXT_GRADE_CATEGORIES to LoginMethod.LIBRUS_API, */
|
||||
ENDPOINT_LIBRUS_API_DESCRIPTIVE_TEXT_GRADE_CATEGORIES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_BEHAVIOUR_GRADE_CATEGORIES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_NORMAL_GRADE_COMMENTS to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_BEHAVIOUR_GRADE_COMMENTS to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_NORMAL_GRADES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_POINT_GRADES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_DESCRIPTIVE_GRADES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_TEXT_GRADES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_DESCRIPTIVE_TEXT_GRADES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_BEHAVIOUR_GRADES to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
/**
|
||||
* Homework - using API.
|
||||
* Sync only if account has premium access.
|
||||
*/
|
||||
/*Feature(LOGIN_TYPE_LIBRUS, FEATURE_HOMEWORK, listOf(
|
||||
ENDPOINT_LIBRUS_API_HOMEWORK to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)).withShouldSync { data ->
|
||||
/*Feature(LoginType.LIBRUS, FeatureType.HOMEWORK, listOf(
|
||||
ENDPOINT_LIBRUS_API_HOMEWORK to LoginMethod.LIBRUS_API
|
||||
)).withShouldSync { data ->
|
||||
(data as DataLibrus).isPremium
|
||||
},*/
|
||||
/**
|
||||
* Behaviour - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_BEHAVIOUR, listOf(
|
||||
ENDPOINT_LIBRUS_API_NOTICES to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.BEHAVIOUR, listOf(
|
||||
ENDPOINT_LIBRUS_API_NOTICES to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
/**
|
||||
* Attendance - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_ATTENDANCE, listOf(
|
||||
ENDPOINT_LIBRUS_API_ATTENDANCE_TYPES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_ATTENDANCES to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.ATTENDANCE, listOf(
|
||||
ENDPOINT_LIBRUS_API_ATTENDANCE_TYPES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_ATTENDANCES to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
/**
|
||||
* Announcements - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_ANNOUNCEMENTS, listOf(
|
||||
ENDPOINT_LIBRUS_API_ANNOUNCEMENTS to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.ANNOUNCEMENTS, listOf(
|
||||
ENDPOINT_LIBRUS_API_ANNOUNCEMENTS to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
|
||||
|
||||
|
||||
@ -150,99 +152,99 @@ val LibrusFeatures = listOf(
|
||||
/**
|
||||
* Student info - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_STUDENT_INFO, listOf(
|
||||
ENDPOINT_LIBRUS_API_ME to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.STUDENT_INFO, listOf(
|
||||
ENDPOINT_LIBRUS_API_ME to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
/**
|
||||
* School info - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_SCHOOL_INFO, listOf(
|
||||
ENDPOINT_LIBRUS_API_SCHOOLS to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_UNITS to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.SCHOOL_INFO, listOf(
|
||||
ENDPOINT_LIBRUS_API_SCHOOLS to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_UNITS to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
/**
|
||||
* Class info - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_CLASS_INFO, listOf(
|
||||
ENDPOINT_LIBRUS_API_CLASSES to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.CLASS_INFO, listOf(
|
||||
ENDPOINT_LIBRUS_API_CLASSES to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
/**
|
||||
* Team info - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_TEAM_INFO, listOf(
|
||||
ENDPOINT_LIBRUS_API_VIRTUAL_CLASSES to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.TEAM_INFO, listOf(
|
||||
ENDPOINT_LIBRUS_API_VIRTUAL_CLASSES to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
/**
|
||||
* Lucky number - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_LIBRUS_API_LUCKY_NUMBER to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)).withShouldSync { data -> data.shouldSyncLuckyNumber() },
|
||||
Feature(LoginType.LIBRUS, FeatureType.LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_LIBRUS_API_LUCKY_NUMBER to LoginMethod.LIBRUS_API
|
||||
)).withShouldSync { data -> data.shouldSyncLuckyNumber() },
|
||||
/**
|
||||
* Teacher list - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_TEACHERS, listOf(
|
||||
ENDPOINT_LIBRUS_API_USERS to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.TEACHERS, listOf(
|
||||
ENDPOINT_LIBRUS_API_USERS to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
/**
|
||||
* Subject list - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_SUBJECTS, listOf(
|
||||
ENDPOINT_LIBRUS_API_SUBJECTS to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.SUBJECTS, listOf(
|
||||
ENDPOINT_LIBRUS_API_SUBJECTS to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
/**
|
||||
* Classroom list - using API.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_CLASSROOMS, listOf(
|
||||
ENDPOINT_LIBRUS_API_CLASSROOMS to LOGIN_METHOD_LIBRUS_API
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.CLASSROOMS, listOf(
|
||||
ENDPOINT_LIBRUS_API_CLASSROOMS to LoginMethod.LIBRUS_API
|
||||
)),
|
||||
|
||||
/**
|
||||
* Student info - using synergia scrapper.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_STUDENT_INFO, listOf(
|
||||
ENDPOINT_LIBRUS_SYNERGIA_INFO to LOGIN_METHOD_LIBRUS_SYNERGIA
|
||||
), listOf(LOGIN_METHOD_LIBRUS_SYNERGIA)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.STUDENT_INFO, listOf(
|
||||
ENDPOINT_LIBRUS_SYNERGIA_INFO to LoginMethod.LIBRUS_SYNERGIA
|
||||
)),
|
||||
/**
|
||||
* Student number - using synergia scrapper.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_STUDENT_NUMBER, listOf(
|
||||
ENDPOINT_LIBRUS_SYNERGIA_INFO to LOGIN_METHOD_LIBRUS_SYNERGIA
|
||||
), listOf(LOGIN_METHOD_LIBRUS_SYNERGIA)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.STUDENT_NUMBER, listOf(
|
||||
ENDPOINT_LIBRUS_SYNERGIA_INFO to LoginMethod.LIBRUS_SYNERGIA
|
||||
)),
|
||||
|
||||
|
||||
/**
|
||||
* Grades - using API + synergia scrapper.
|
||||
*/
|
||||
/*Feature(LOGIN_TYPE_LIBRUS, FEATURE_GRADES, listOf(
|
||||
ENDPOINT_LIBRUS_API_NORMAL_GC to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_NORMAL_GRADES to LOGIN_METHOD_LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_SYNERGIA_GRADES to LOGIN_METHOD_LIBRUS_SYNERGIA
|
||||
), listOf(LOGIN_METHOD_LIBRUS_API, LOGIN_METHOD_LIBRUS_SYNERGIA)),*/
|
||||
/*Endpoint(LOGIN_TYPE_LIBRUS, FEATURE_GRADES, listOf(
|
||||
ENDPOINT_LIBRUS_SYNERGIA_GRADES to LOGIN_METHOD_LIBRUS_SYNERGIA
|
||||
), listOf(LOGIN_METHOD_LIBRUS_SYNERGIA)),*/
|
||||
/*Feature(LoginType.LIBRUS, FeatureType.GRADES, listOf(
|
||||
ENDPOINT_LIBRUS_API_NORMAL_GC to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_API_NORMAL_GRADES to LoginMethod.LIBRUS_API,
|
||||
ENDPOINT_LIBRUS_SYNERGIA_GRADES to LoginMethod.LIBRUS_SYNERGIA
|
||||
)),*/
|
||||
/*Endpoint(LoginType.LIBRUS, FeatureType.GRADES, listOf(
|
||||
ENDPOINT_LIBRUS_SYNERGIA_GRADES to LoginMethod.LIBRUS_SYNERGIA
|
||||
)),*/
|
||||
|
||||
/**
|
||||
* Homework - using scrapper.
|
||||
* Sync only if account has not premium access.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_HOMEWORK, listOf(
|
||||
ENDPOINT_LIBRUS_SYNERGIA_HOMEWORK to LOGIN_METHOD_LIBRUS_SYNERGIA
|
||||
), listOf(LOGIN_METHOD_LIBRUS_SYNERGIA))/*.withShouldSync { data ->
|
||||
Feature(LoginType.LIBRUS, FeatureType.HOMEWORK, listOf(
|
||||
ENDPOINT_LIBRUS_SYNERGIA_HOMEWORK to LoginMethod.LIBRUS_SYNERGIA
|
||||
))/*.withShouldSync { data ->
|
||||
!(data as DataLibrus).isPremium
|
||||
}*/,
|
||||
|
||||
/**
|
||||
* Messages inbox - using messages website.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_MESSAGES_INBOX, listOf(
|
||||
ENDPOINT_LIBRUS_MESSAGES_RECEIVED to LOGIN_METHOD_LIBRUS_MESSAGES
|
||||
), listOf(LOGIN_METHOD_LIBRUS_MESSAGES)),
|
||||
Feature(LoginType.LIBRUS, FeatureType.MESSAGES_INBOX, listOf(
|
||||
ENDPOINT_LIBRUS_MESSAGES_RECEIVED to LoginMethod.LIBRUS_MESSAGES
|
||||
)),
|
||||
/**
|
||||
* Messages sent - using messages website.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_LIBRUS, FEATURE_MESSAGES_SENT, listOf(
|
||||
ENDPOINT_LIBRUS_MESSAGES_SENT to LOGIN_METHOD_LIBRUS_MESSAGES
|
||||
), listOf(LOGIN_METHOD_LIBRUS_MESSAGES))
|
||||
Feature(LoginType.LIBRUS, FeatureType.MESSAGES_SENT, listOf(
|
||||
ENDPOINT_LIBRUS_MESSAGES_SENT to LoginMethod.LIBRUS_MESSAGES
|
||||
))
|
||||
)
|
||||
|
@ -24,7 +24,7 @@ class LibrusData(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
private fun nextEndpoint(onSuccess: () -> Unit) {
|
||||
if (data.targetEndpointIds.isEmpty()) {
|
||||
if (data.targetEndpoints.isEmpty()) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
@ -32,8 +32,8 @@ class LibrusData(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
val id = data.targetEndpointIds.firstKey()
|
||||
val lastSync = data.targetEndpointIds.remove(id)
|
||||
val id = data.targetEndpoints.firstKey()
|
||||
val lastSync = data.targetEndpoints.remove(id)
|
||||
useEndpoint(id, lastSync) { endpointId ->
|
||||
data.progress(data.progressStep)
|
||||
nextEndpoint(onSuccess)
|
||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
import pl.szczodrzynski.edziennik.data.api.events.AnnouncementGetEvent
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull
|
||||
|
||||
class LibrusApiAnnouncementMarkAsRead(override val data: DataLibrus,
|
||||
@ -34,7 +35,7 @@ class LibrusApiAnnouncementMarkAsRead(override val data: DataLibrus,
|
||||
|
||||
data.setSeenMetadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_ANNOUNCEMENT,
|
||||
MetadataType.ANNOUNCEMENT,
|
||||
announcement.id,
|
||||
announcement.seen,
|
||||
announcement.notified
|
||||
|
@ -11,6 +11,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Announcement
|
||||
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.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
|
||||
@ -54,7 +55,7 @@ class LibrusApiAnnouncements(override val data: DataLibrus,
|
||||
data.announcementList.add(announcementObject)
|
||||
data.setSeenMetadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_ANNOUNCEMENT,
|
||||
MetadataType.ANNOUNCEMENT,
|
||||
id,
|
||||
read,
|
||||
profile.empty || read
|
||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Attendance
|
||||
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.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
|
||||
@ -76,7 +77,7 @@ class LibrusApiAttendances(override val data: DataLibrus,
|
||||
if(type?.baseType != Attendance.TYPE_PRESENT) {
|
||||
data.metadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_ATTENDANCE,
|
||||
MetadataType.ATTENDANCE,
|
||||
id,
|
||||
profile?.empty ?: false || type?.baseType == Attendance.TYPE_PRESENT_CUSTOM || type?.baseType == Attendance.TYPE_UNKNOWN,
|
||||
profile?.empty ?: false || type?.baseType == Attendance.TYPE_PRESENT_CUSTOM || type?.baseType == Attendance.TYPE_UNKNOWN
|
||||
|
@ -14,6 +14,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_POINT_SUM
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.GradeCategory
|
||||
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.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import java.text.DecimalFormat
|
||||
@ -63,7 +64,7 @@ class LibrusApiBehaviourGrades(override val data: DataLibrus,
|
||||
data.gradeList.add(semester1StartGradeObject)
|
||||
data.metadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
semester1StartGradeObject.id,
|
||||
true,
|
||||
true
|
||||
@ -91,7 +92,7 @@ class LibrusApiBehaviourGrades(override val data: DataLibrus,
|
||||
data.gradeList.add(semester2StartGradeObject)
|
||||
data.metadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
semester2StartGradeObject.id,
|
||||
true,
|
||||
true
|
||||
@ -165,7 +166,7 @@ class LibrusApiBehaviourGrades(override val data: DataLibrus,
|
||||
data.gradeList.add(gradeObject)
|
||||
data.metadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
id,
|
||||
profile.empty,
|
||||
profile.empty
|
||||
|
@ -15,6 +15,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_TEXT
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.GradeCategory
|
||||
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.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
|
||||
@ -73,7 +74,7 @@ class LibrusApiDescriptiveGrades(override val data: DataLibrus,
|
||||
data.gradeList.add(gradeObject)
|
||||
data.metadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
id,
|
||||
profile.empty,
|
||||
profile.empty
|
||||
|
@ -13,6 +13,7 @@ import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||
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.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
@ -71,7 +72,7 @@ class LibrusApiEvents(override val data: DataLibrus,
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_EVENT,
|
||||
MetadataType.EVENT,
|
||||
id,
|
||||
profile?.empty ?: false,
|
||||
profile?.empty ?: false
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.api
|
||||
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_NORMAL_GRADE_COMMENTS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
|
@ -16,6 +16,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_YEAR_PROPO
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.GradeCategory
|
||||
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.*
|
||||
import pl.szczodrzynski.edziennik.utils.Utils
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
@ -97,7 +98,7 @@ class LibrusApiGrades(override val data: DataLibrus,
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
id,
|
||||
profile.empty,
|
||||
profile.empty
|
||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||
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.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
|
||||
@ -51,7 +52,7 @@ class LibrusApiHomework(override val data: DataLibrus,
|
||||
data.eventList.add(eventObject)
|
||||
data.metadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_HOMEWORK,
|
||||
MetadataType.HOMEWORK,
|
||||
id,
|
||||
profile?.empty ?: false,
|
||||
profile?.empty ?: false
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.api
|
||||
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_LESSONS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
|
@ -9,6 +9,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LuckyNumber
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
@ -47,7 +48,7 @@ class LibrusApiLuckyNumber(override val data: DataLibrus,
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_LUCKY_NUMBER,
|
||||
MetadataType.LUCKY_NUMBER,
|
||||
luckyNumberObject.date.value.toLong(),
|
||||
true,
|
||||
profile?.empty ?: false
|
||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Notice
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
|
||||
@ -62,7 +63,7 @@ class LibrusApiNotices(override val data: DataLibrus,
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_NOTICE,
|
||||
MetadataType.NOTICE,
|
||||
id,
|
||||
profile?.empty ?: false,
|
||||
profile?.empty ?: false
|
||||
|
@ -14,6 +14,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_POINT_AVG
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.GradeCategory
|
||||
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.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
|
||||
@ -66,7 +67,7 @@ class LibrusApiPointGrades(override val data: DataLibrus,
|
||||
data.gradeList.add(gradeObject)
|
||||
data.metadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
id,
|
||||
profile.empty,
|
||||
profile.empty
|
||||
|
@ -11,6 +11,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
@ -56,7 +57,7 @@ class LibrusApiPtMeetings(override val data: DataLibrus,
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_EVENT,
|
||||
MetadataType.EVENT,
|
||||
id,
|
||||
profile?.empty ?: false,
|
||||
profile?.empty ?: false
|
||||
|
@ -4,14 +4,12 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.api
|
||||
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_SCHOOLS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LessonRange
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
import java.util.*
|
||||
|
||||
class LibrusApiSchools(override val data: DataLibrus,
|
||||
override val lastSync: Long?,
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.api
|
||||
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_SUBJECTS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
|
@ -5,13 +5,13 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.api
|
||||
|
||||
import androidx.core.util.isEmpty
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_AGENDA
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.TeacherAbsence
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
@ -56,14 +56,14 @@ class LibrusApiTeacherFreeDays(override val data: DataLibrus,
|
||||
data.teacherAbsenceList.add(teacherAbsenceObject)
|
||||
data.metadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_TEACHER_ABSENCE,
|
||||
MetadataType.TEACHER_ABSENCE,
|
||||
id,
|
||||
true,
|
||||
profile?.empty ?: false
|
||||
))
|
||||
}
|
||||
|
||||
data.setSyncNext(ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS, 6* HOUR, DRAWER_ITEM_AGENDA)
|
||||
data.setSyncNext(ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS, 6* HOUR, FeatureType.AGENDA)
|
||||
onSuccess(ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS)
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_DESCRIPTIV
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.GradeCategory
|
||||
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.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
|
||||
@ -68,7 +69,7 @@ class LibrusApiTextGrades(override val data: DataLibrus,
|
||||
data.gradeList.add(gradeObject)
|
||||
data.metadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
id,
|
||||
profile.empty,
|
||||
profile.empty
|
||||
|
@ -14,6 +14,7 @@ import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
||||
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.*
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
@ -196,7 +197,7 @@ class LibrusApiTimetables(override val data: DataLibrus,
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_LESSON_CHANGE,
|
||||
MetadataType.LESSON_CHANGE,
|
||||
lessonObject.id,
|
||||
seen,
|
||||
seen
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.messages
|
||||
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_MESSAGES
|
||||
import pl.szczodrzynski.edziennik.data.api.ERROR_NOT_IMPLEMENTED
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_MESSAGES_RECEIVED
|
||||
@ -12,6 +11,8 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_MESS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusMessages
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.*
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_RECEIVED
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.DAY
|
||||
import pl.szczodrzynski.edziennik.ext.fixName
|
||||
import pl.szczodrzynski.edziennik.ext.singleOrNull
|
||||
@ -65,16 +66,17 @@ class LibrusMessagesGetList(override val data: DataLibrus,
|
||||
|
||||
val recipientId = data.teacherList.singleOrNull {
|
||||
it.name == recipientFirstName && it.surname == recipientLastName
|
||||
}?.id ?: {
|
||||
}?.id ?: run {
|
||||
val teacherObject = Teacher(
|
||||
profileId,
|
||||
-1 * Utils.crc16("$recipientFirstName $recipientLastName".toByteArray()).toLong(),
|
||||
recipientFirstName,
|
||||
recipientLastName
|
||||
profileId,
|
||||
-1 * Utils.crc16("$recipientFirstName $recipientLastName".toByteArray())
|
||||
.toLong(),
|
||||
recipientFirstName,
|
||||
recipientLastName
|
||||
)
|
||||
data.teacherList.put(teacherObject.id, teacherObject)
|
||||
teacherObject.id
|
||||
}.invoke()
|
||||
}
|
||||
|
||||
val senderId = when (type) {
|
||||
TYPE_RECEIVED -> recipientId
|
||||
@ -118,7 +120,7 @@ class LibrusMessagesGetList(override val data: DataLibrus,
|
||||
data.messageRecipientList.add(messageRecipientObject)
|
||||
data.setSeenMetadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_MESSAGE,
|
||||
MetadataType.MESSAGE,
|
||||
id,
|
||||
notified,
|
||||
notified
|
||||
@ -127,7 +129,7 @@ class LibrusMessagesGetList(override val data: DataLibrus,
|
||||
|
||||
when (type) {
|
||||
TYPE_RECEIVED -> data.setSyncNext(ENDPOINT_LIBRUS_MESSAGES_RECEIVED, SYNC_ALWAYS)
|
||||
Message.TYPE_SENT -> data.setSyncNext(ENDPOINT_LIBRUS_MESSAGES_SENT, DAY, DRAWER_ITEM_MESSAGES)
|
||||
Message.TYPE_SENT -> data.setSyncNext(ENDPOINT_LIBRUS_MESSAGES_SENT, DAY, FeatureType.MESSAGES_SENT)
|
||||
}
|
||||
onSuccess(endpointId)
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_RECEIVED
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_SENT
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageRecipientFull
|
||||
import pl.szczodrzynski.edziennik.ext.fixName
|
||||
@ -147,7 +148,7 @@ class LibrusMessagesGetMessage(override val data: DataLibrus,
|
||||
if (!messageObject.seen) {
|
||||
data.setSeenMetadataList.add(Metadata(
|
||||
messageObject.profileId,
|
||||
Metadata.TYPE_MESSAGE,
|
||||
MetadataType.MESSAGE,
|
||||
messageObject.id,
|
||||
true,
|
||||
true
|
||||
|
@ -16,7 +16,7 @@ import pl.szczodrzynski.edziennik.ext.getLong
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
|
||||
class LibrusMessagesSendMessage(override val data: DataLibrus,
|
||||
val recipients: List<Teacher>,
|
||||
val recipients: Set<Teacher>,
|
||||
val subject: String,
|
||||
val text: String,
|
||||
val onSuccess: () -> Unit
|
||||
|
@ -8,6 +8,7 @@ import pl.szczodrzynski.edziennik.data.api.events.MessageGetEvent
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Message
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageRecipientFull
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
@ -139,7 +140,7 @@ class LibrusSynergiaGetMessage(override val data: DataLibrus,
|
||||
if (!messageObject.seen) {
|
||||
data.setSeenMetadataList.add(Metadata(
|
||||
messageObject.profileId,
|
||||
Metadata.TYPE_MESSAGE,
|
||||
MetadataType.MESSAGE,
|
||||
messageObject.id,
|
||||
true,
|
||||
true
|
||||
|
@ -1,12 +1,13 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.synergia
|
||||
|
||||
import org.jsoup.Jsoup
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.api.ERROR_NOT_IMPLEMENTED
|
||||
import pl.szczodrzynski.edziennik.data.api.Regexes
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusSynergia
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.*
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import pl.szczodrzynski.edziennik.utils.Utils
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
@ -96,7 +97,7 @@ class LibrusSynergiaGetMessages(override val data: DataLibrus,
|
||||
data.messageRecipientList.add(messageRecipientObject)
|
||||
data.setSeenMetadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_MESSAGE,
|
||||
MetadataType.MESSAGE,
|
||||
id,
|
||||
notified,
|
||||
notified
|
||||
@ -105,7 +106,7 @@ class LibrusSynergiaGetMessages(override val data: DataLibrus,
|
||||
|
||||
when (type) {
|
||||
Message.TYPE_RECEIVED -> data.setSyncNext(ENDPOINT_LIBRUS_MESSAGES_RECEIVED, SYNC_ALWAYS)
|
||||
Message.TYPE_SENT -> data.setSyncNext(ENDPOINT_LIBRUS_MESSAGES_SENT, DAY, MainActivity.DRAWER_ITEM_MESSAGES)
|
||||
Message.TYPE_SENT -> data.setSyncNext(ENDPOINT_LIBRUS_MESSAGES_SENT, DAY, FeatureType.MESSAGES_SENT)
|
||||
}
|
||||
onSuccess(endpointId)
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.synergia
|
||||
|
||||
import org.jsoup.Jsoup
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_HOMEWORK
|
||||
import pl.szczodrzynski.edziennik.data.api.POST
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.ENDPOINT_LIBRUS_SYNERGIA_HOMEWORK
|
||||
@ -13,6 +12,8 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusSynergia
|
||||
import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
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.singleOrNull
|
||||
@ -84,7 +85,7 @@ class LibrusSynergiaHomework(override val data: DataLibrus,
|
||||
data.eventList.add(eventObject)
|
||||
data.metadataList.add(Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_HOMEWORK,
|
||||
MetadataType.HOMEWORK,
|
||||
id,
|
||||
seen,
|
||||
seen
|
||||
@ -95,7 +96,7 @@ class LibrusSynergiaHomework(override val data: DataLibrus,
|
||||
data.toRemove.add(DataRemoveModel.Events.futureWithType(Event.TYPE_HOMEWORK))
|
||||
|
||||
// because this requires a synergia login (2 more requests!!!) sync this every few hours or if explicit :D
|
||||
data.setSyncNext(ENDPOINT_LIBRUS_SYNERGIA_HOMEWORK, 5 * HOUR, DRAWER_ITEM_HOMEWORK)
|
||||
data.setSyncNext(ENDPOINT_LIBRUS_SYNERGIA_HOMEWORK, 5 * HOUR, FeatureType.HOMEWORK)
|
||||
onSuccess(ENDPOINT_LIBRUS_SYNERGIA_HOMEWORK)
|
||||
}
|
||||
} ?: onSuccess(ENDPOINT_LIBRUS_SYNERGIA_HOMEWORK) }
|
||||
|
@ -7,6 +7,7 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.synergia
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusSynergia
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
|
||||
class LibrusSynergiaMarkAllAnnouncementsAsRead(override val data: DataLibrus,
|
||||
val onSuccess: () -> Unit
|
||||
@ -17,7 +18,7 @@ class LibrusSynergiaMarkAllAnnouncementsAsRead(override val data: DataLibrus,
|
||||
|
||||
init {
|
||||
synergiaGet(TAG, "ogloszenia") {
|
||||
data.app.db.metadataDao().setAllSeen(profileId, Metadata.TYPE_ANNOUNCEMENT, true)
|
||||
data.app.db.metadataDao().setAllSeen(profileId, MetadataType.ANNOUNCEMENT, true)
|
||||
onSuccess()
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.login.LibrusLoginPor
|
||||
import pl.szczodrzynski.edziennik.data.api.events.FirstLoginFinishedEvent
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMode
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
|
||||
class LibrusFirstLogin(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
@ -23,11 +25,9 @@ class LibrusFirstLogin(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
private val profileList = mutableListOf<Profile>()
|
||||
|
||||
init {
|
||||
val loginStoreId = data.loginStore.id
|
||||
val loginStoreType = LOGIN_TYPE_LIBRUS
|
||||
var firstProfileId = loginStoreId
|
||||
var firstProfileId = data.loginStore.id
|
||||
|
||||
if (data.loginStore.mode == LOGIN_MODE_LIBRUS_EMAIL) {
|
||||
if (data.loginStore.mode == LoginMode.LIBRUS_EMAIL) {
|
||||
// email login: use Portal for account list
|
||||
LibrusLoginPortal(data) {
|
||||
portal.portalGet(TAG, if (data.fakeLogin) FAKE_LIBRUS_ACCOUNTS else LIBRUS_ACCOUNTS_URL) { json, response ->
|
||||
@ -66,8 +66,8 @@ class LibrusFirstLogin(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
|
||||
val profile = Profile(
|
||||
firstProfileId++,
|
||||
loginStoreId,
|
||||
loginStoreType,
|
||||
data.loginStore.id,
|
||||
LoginType.LIBRUS,
|
||||
studentNameLong,
|
||||
data.portalEmail,
|
||||
studentNameLong,
|
||||
@ -107,8 +107,8 @@ class LibrusFirstLogin(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
|
||||
val profile = Profile(
|
||||
firstProfileId++,
|
||||
loginStoreId,
|
||||
loginStoreType,
|
||||
data.loginStore.id,
|
||||
LoginType.LIBRUS,
|
||||
studentNameLong,
|
||||
login,
|
||||
studentNameLong,
|
||||
|
@ -5,11 +5,8 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.librus.login
|
||||
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_LIBRUS_API
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_LIBRUS_MESSAGES
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_LIBRUS_PORTAL
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_LIBRUS_SYNERGIA
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.utils.Utils
|
||||
|
||||
class LibrusLogin(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
@ -24,7 +21,7 @@ class LibrusLogin(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
private fun nextLoginMethod(onSuccess: () -> Unit) {
|
||||
if (data.targetLoginMethodIds.isEmpty()) {
|
||||
if (data.targetLoginMethods.isEmpty()) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
@ -32,38 +29,39 @@ class LibrusLogin(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
useLoginMethod(data.targetLoginMethodIds.removeAt(0)) { usedMethodId ->
|
||||
useLoginMethod(data.targetLoginMethods.removeAt(0)) { usedMethod ->
|
||||
data.progress(data.progressStep)
|
||||
if (usedMethodId != -1)
|
||||
data.loginMethods.add(usedMethodId)
|
||||
if (usedMethod != null)
|
||||
data.loginMethods.add(usedMethod)
|
||||
nextLoginMethod(onSuccess)
|
||||
}
|
||||
}
|
||||
|
||||
private fun useLoginMethod(loginMethodId: Int, onSuccess: (usedMethodId: Int) -> Unit) {
|
||||
private fun useLoginMethod(loginMethod: LoginMethod, onSuccess: (usedMethod: LoginMethod?) -> Unit) {
|
||||
// this should never be true
|
||||
if (data.loginMethods.contains(loginMethodId)) {
|
||||
onSuccess(-1)
|
||||
if (data.loginMethods.contains(loginMethod)) {
|
||||
onSuccess(null)
|
||||
return
|
||||
}
|
||||
Utils.d(TAG, "Using login method $loginMethodId")
|
||||
when (loginMethodId) {
|
||||
LOGIN_METHOD_LIBRUS_PORTAL -> {
|
||||
Utils.d(TAG, "Using login method $loginMethod")
|
||||
when (loginMethod) {
|
||||
LoginMethod.LIBRUS_PORTAL -> {
|
||||
data.startProgress(R.string.edziennik_progress_login_librus_portal)
|
||||
LibrusLoginPortal(data) { onSuccess(loginMethodId) }
|
||||
LibrusLoginPortal(data) { onSuccess(loginMethod) }
|
||||
}
|
||||
LOGIN_METHOD_LIBRUS_API -> {
|
||||
LoginMethod.LIBRUS_API -> {
|
||||
data.startProgress(R.string.edziennik_progress_login_librus_api)
|
||||
LibrusLoginApi(data) { onSuccess(loginMethodId) }
|
||||
LibrusLoginApi(data) { onSuccess(loginMethod) }
|
||||
}
|
||||
LOGIN_METHOD_LIBRUS_SYNERGIA -> {
|
||||
LoginMethod.LIBRUS_SYNERGIA -> {
|
||||
data.startProgress(R.string.edziennik_progress_login_librus_synergia)
|
||||
LibrusLoginSynergia(data) { onSuccess(loginMethodId) }
|
||||
LibrusLoginSynergia(data) { onSuccess(loginMethod) }
|
||||
}
|
||||
LOGIN_METHOD_LIBRUS_MESSAGES -> {
|
||||
LoginMethod.LIBRUS_MESSAGES -> {
|
||||
data.startProgress(R.string.edziennik_progress_login_librus_messages)
|
||||
LibrusLoginMessages(data) { onSuccess(loginMethodId) }
|
||||
LibrusLoginMessages(data) { onSuccess(loginMethod) }
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import im.wangchao.mhttp.callback.JsonCallbackHandler
|
||||
import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMode
|
||||
import pl.szczodrzynski.edziennik.ext.getInt
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
import pl.szczodrzynski.edziennik.ext.getUnixDate
|
||||
@ -32,7 +34,7 @@ class LibrusLoginApi {
|
||||
this.data = data
|
||||
this.onSuccess = onSuccess
|
||||
|
||||
if (data.loginStore.mode == LOGIN_MODE_LIBRUS_EMAIL && data.profile == null) {
|
||||
if (data.loginStore.mode == LoginMode.LIBRUS_EMAIL && data.profile == null) {
|
||||
data.error(ApiError(TAG, ERROR_PROFILE_MISSING))
|
||||
return
|
||||
}
|
||||
@ -42,9 +44,9 @@ class LibrusLoginApi {
|
||||
}
|
||||
else {
|
||||
when (data.loginStore.mode) {
|
||||
LOGIN_MODE_LIBRUS_EMAIL -> loginWithPortal()
|
||||
LOGIN_MODE_LIBRUS_SYNERGIA -> loginWithSynergia()
|
||||
LOGIN_MODE_LIBRUS_JST -> loginWithJst()
|
||||
LoginMode.LIBRUS_EMAIL -> loginWithPortal()
|
||||
LoginMode.LIBRUS_SYNERGIA -> loginWithSynergia()
|
||||
LoginMode.LIBRUS_JST -> loginWithJst()
|
||||
else -> {
|
||||
data.error(ApiError(TAG, ERROR_INVALID_LOGIN_MODE))
|
||||
}
|
||||
@ -53,7 +55,7 @@ class LibrusLoginApi {
|
||||
}
|
||||
|
||||
private fun loginWithPortal() {
|
||||
if (!data.loginMethods.contains(LOGIN_METHOD_LIBRUS_PORTAL)) {
|
||||
if (!data.loginMethods.contains(LoginMethod.LIBRUS_PORTAL)) {
|
||||
data.error(ApiError(TAG, ERROR_LOGIN_METHOD_NOT_SATISFIED))
|
||||
return
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.LibrusRecaptchaHelper
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.ext.getUnixDate
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
import java.io.StringWriter
|
||||
@ -91,7 +92,7 @@ class LibrusLoginMessages(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
}
|
||||
else {
|
||||
data.app.cookieJar.clear("wiadomosci.librus.pl")
|
||||
if (data.loginMethods.contains(LOGIN_METHOD_LIBRUS_SYNERGIA)) {
|
||||
if (data.loginMethods.contains(LoginMethod.LIBRUS_SYNERGIA)) {
|
||||
loginWithSynergia()
|
||||
}
|
||||
else if (data.apiLogin != null && data.apiPassword != null && false) {
|
||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.events.UserActionRequiredEvent
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMode
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
import java.net.HttpURLConnection.*
|
||||
@ -24,7 +25,7 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
init { run {
|
||||
if (data.loginStore.mode != LOGIN_MODE_LIBRUS_EMAIL) {
|
||||
if (data.loginStore.mode != LoginMode.LIBRUS_EMAIL) {
|
||||
data.error(ApiError(TAG, ERROR_INVALID_LOGIN_MODE))
|
||||
return@run
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
import pl.szczodrzynski.edziennik.ext.getUnixDate
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
@ -34,7 +35,7 @@ class LibrusLoginSynergia(override val data: DataLibrus, val onSuccess: () -> Un
|
||||
}
|
||||
else {
|
||||
data.app.cookieJar.clear("synergia.librus.pl")
|
||||
if (data.loginMethods.contains(LOGIN_METHOD_LIBRUS_API)) {
|
||||
if (data.loginMethods.contains(LoginMethod.LIBRUS_API)) {
|
||||
loginWithApi()
|
||||
}
|
||||
else if (data.apiLogin != null && data.apiPassword != null && false) {
|
||||
|
@ -7,6 +7,7 @@ import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusPortal
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMode
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
|
||||
@ -16,7 +17,7 @@ class SynergiaTokenExtractor(override val data: DataLibrus, val onSuccess: () ->
|
||||
}
|
||||
|
||||
init { run {
|
||||
if (data.loginStore.mode != LOGIN_MODE_LIBRUS_EMAIL) {
|
||||
if (data.loginStore.mode != LoginMode.LIBRUS_EMAIL) {
|
||||
data.error(ApiError(TAG, ERROR_INVALID_LOGIN_MODE))
|
||||
return@run
|
||||
}
|
||||
|
@ -6,13 +6,11 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik
|
||||
|
||||
import android.util.LongSparseArray
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
import pl.szczodrzynski.edziennik.data.api.Regexes
|
||||
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.currentTimeUnix
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
@ -31,7 +29,7 @@ class DataMobidziennik(app: App, profile: Profile?, loginStore: LoginStore) : Da
|
||||
override fun satisfyLoginMethods() {
|
||||
loginMethods.clear()
|
||||
if (isWebLoginValid()) {
|
||||
loginMethods += LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
loginMethods += LoginMethod.MOBIDZIENNIK_WEB
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@ import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
|
||||
@ -54,19 +56,19 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto
|
||||
|_| |_| |_|\___| /_/ \_\_|\__, |\___/|_| |_|\__|_| |_|_| |_| |_|
|
||||
__/ |
|
||||
|__*/
|
||||
override fun sync(featureIds: List<Int>, viewId: Int?, onlyEndpoints: List<Int>?, arguments: JsonObject?) {
|
||||
override fun sync(featureTypes: Set<FeatureType>?, onlyEndpoints: Set<Int>?, arguments: JsonObject?) {
|
||||
data.arguments = arguments
|
||||
data.prepare(mobidziennikLoginMethods, MobidziennikFeatures, featureIds, viewId, onlyEndpoints)
|
||||
data.prepare(MobidziennikFeatures, featureTypes, onlyEndpoints)
|
||||
login()
|
||||
}
|
||||
|
||||
private fun login(loginMethodId: Int? = null, afterLogin: (() -> Unit)? = null) {
|
||||
d(TAG, "Trying to login with ${data.targetLoginMethodIds}")
|
||||
private fun login(loginMethod: LoginMethod? = null, afterLogin: (() -> Unit)? = null) {
|
||||
d(TAG, "Trying to login with ${data.targetLoginMethods}")
|
||||
if (internalErrorList.isNotEmpty()) {
|
||||
d(TAG, " - Internal errors:")
|
||||
internalErrorList.forEach { d(TAG, " - code $it") }
|
||||
}
|
||||
loginMethodId?.let { data.prepareFor(mobidziennikLoginMethods, it) }
|
||||
loginMethod?.let { data.prepareFor(it) }
|
||||
afterLogin?.let { this.afterLogin = it }
|
||||
MobidziennikLogin(data) {
|
||||
data()
|
||||
@ -74,7 +76,7 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto
|
||||
}
|
||||
|
||||
private fun data() {
|
||||
d(TAG, "Endpoint IDs: ${data.targetEndpointIds}")
|
||||
d(TAG, "Endpoint IDs: ${data.targetEndpoints}")
|
||||
if (internalErrorList.isNotEmpty()) {
|
||||
d(TAG, " - Internal errors:")
|
||||
internalErrorList.forEach { d(TAG, " - code $it") }
|
||||
@ -85,15 +87,15 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto
|
||||
}
|
||||
|
||||
override fun getMessage(message: MessageFull) {
|
||||
login(LOGIN_METHOD_MOBIDZIENNIK_WEB) {
|
||||
login(LoginMethod.MOBIDZIENNIK_WEB) {
|
||||
MobidziennikWebGetMessage(data, message) {
|
||||
completed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun sendMessage(recipients: List<Teacher>, subject: String, text: String) {
|
||||
login(LOGIN_METHOD_MOBIDZIENNIK_WEB) {
|
||||
override fun sendMessage(recipients: Set<Teacher>, subject: String, text: String) {
|
||||
login(LoginMethod.MOBIDZIENNIK_WEB) {
|
||||
MobidziennikWebSendMessage(data, recipients, subject, text) {
|
||||
completed()
|
||||
}
|
||||
@ -104,7 +106,7 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto
|
||||
override fun getAnnouncement(announcement: AnnouncementFull) {}
|
||||
|
||||
override fun getAttachment(owner: Any, attachmentId: Long, attachmentName: String) {
|
||||
login(LOGIN_METHOD_MOBIDZIENNIK_WEB) {
|
||||
login(LoginMethod.MOBIDZIENNIK_WEB) {
|
||||
MobidziennikWebGetAttachment(data, owner, attachmentId, attachmentName) {
|
||||
completed()
|
||||
}
|
||||
@ -112,7 +114,7 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto
|
||||
}
|
||||
|
||||
override fun getRecipientList() {
|
||||
login(LOGIN_METHOD_MOBIDZIENNIK_WEB) {
|
||||
login(LoginMethod.MOBIDZIENNIK_WEB) {
|
||||
MobidziennikWebGetRecipientList(data) {
|
||||
completed()
|
||||
}
|
||||
@ -120,7 +122,7 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto
|
||||
}
|
||||
|
||||
override fun getEvent(eventFull: EventFull) {
|
||||
login(LOGIN_METHOD_MOBIDZIENNIK_WEB) {
|
||||
login(LoginMethod.MOBIDZIENNIK_WEB) {
|
||||
if (eventFull.isHomework) {
|
||||
MobidziennikWebGetHomework(data, eventFull) {
|
||||
completed()
|
||||
@ -158,8 +160,8 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto
|
||||
ERROR_MOBIDZIENNIK_WEB_NO_SESSION_KEY,
|
||||
ERROR_MOBIDZIENNIK_WEB_NO_SESSION_VALUE,
|
||||
ERROR_MOBIDZIENNIK_WEB_NO_SERVER_ID -> {
|
||||
data.loginMethods.remove(LOGIN_METHOD_MOBIDZIENNIK_WEB)
|
||||
data.prepareFor(mobidziennikLoginMethods, LOGIN_METHOD_MOBIDZIENNIK_WEB)
|
||||
data.loginMethods.remove(LoginMethod.MOBIDZIENNIK_WEB)
|
||||
data.prepareFor(LoginMethod.MOBIDZIENNIK_WEB)
|
||||
data.webSessionIdExpiryTime = 0
|
||||
login()
|
||||
}
|
||||
|
@ -4,8 +4,10 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik
|
||||
|
||||
import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.models.Feature
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
|
||||
const val ENDPOINT_MOBIDZIENNIK_API_MAIN = 1000
|
||||
const val ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_INBOX = 2011
|
||||
@ -23,15 +25,15 @@ const val ENDPOINT_MOBIDZIENNIK_API2_MAIN = 3000
|
||||
|
||||
val MobidziennikFeatures = listOf(
|
||||
// always synced
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_ALWAYS_NEEDED, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_API_MAIN to LOGIN_METHOD_MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_ACCOUNT_EMAIL to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB)), // TODO divide features into separate view IDs (all with API_MAIN)
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.ALWAYS_NEEDED, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_API_MAIN to LoginMethod.MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_ACCOUNT_EMAIL to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)), // TODO divide features into separate view IDs (all with API_MAIN)
|
||||
|
||||
// push config
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_PUSH_CONFIG, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_API2_MAIN to LOGIN_METHOD_MOBIDZIENNIK_API2
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_API2)).withShouldSync { data ->
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.PUSH_CONFIG, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_API2_MAIN to LoginMethod.MOBIDZIENNIK_API2
|
||||
)).withShouldSync { data ->
|
||||
!data.app.config.sync.tokenMobidziennikList.contains(data.profileId)
|
||||
},
|
||||
|
||||
@ -42,36 +44,36 @@ val MobidziennikFeatures = listOf(
|
||||
/**
|
||||
* Timetable - web scraping - does nothing if the API_MAIN timetable is enough.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_TIMETABLE, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_TIMETABLE to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB, LOGIN_METHOD_MOBIDZIENNIK_WEB)),
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.TIMETABLE, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_TIMETABLE to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)),
|
||||
/**
|
||||
* Agenda - "API" + web scraping.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_AGENDA, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_API_MAIN to LOGIN_METHOD_MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_CALENDAR to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB, LOGIN_METHOD_MOBIDZIENNIK_WEB)),
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.AGENDA, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_API_MAIN to LoginMethod.MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_CALENDAR to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)),
|
||||
/**
|
||||
* Grades - "API" + web scraping.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_GRADES, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_API_MAIN to LOGIN_METHOD_MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_GRADES to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB, LOGIN_METHOD_MOBIDZIENNIK_WEB)),
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.GRADES, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_API_MAIN to LoginMethod.MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_GRADES to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)),
|
||||
/**
|
||||
* Behaviour - "API" + web scraping.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_BEHAVIOUR, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_API_MAIN to LOGIN_METHOD_MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_NOTICES to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB, LOGIN_METHOD_MOBIDZIENNIK_WEB)),
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.BEHAVIOUR, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_API_MAIN to LoginMethod.MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_NOTICES to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)),
|
||||
/**
|
||||
* Attendance - only web scraping.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_ATTENDANCE, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_ATTENDANCE to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB)),
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.ATTENDANCE, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_ATTENDANCE to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)),
|
||||
|
||||
|
||||
|
||||
@ -80,38 +82,38 @@ val MobidziennikFeatures = listOf(
|
||||
/**
|
||||
* Messages inbox - using web scraper.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_MESSAGES_INBOX, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_INBOX to LOGIN_METHOD_MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_ALL to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB)),
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.MESSAGES_INBOX, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_INBOX to LoginMethod.MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_ALL to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)),
|
||||
/**
|
||||
* Messages sent - using web scraper.
|
||||
*/
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_MESSAGES_SENT, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_SENT to LOGIN_METHOD_MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_ALL to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB))
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.MESSAGES_SENT, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_SENT to LoginMethod.MOBIDZIENNIK_WEB,
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_ALL to LoginMethod.MOBIDZIENNIK_WEB
|
||||
))
|
||||
|
||||
// lucky number possibilities
|
||||
// all endpoints that may supply the lucky number
|
||||
/*Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_MANUALS to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB)).apply { priority = 10 },
|
||||
/*Feature(LoginType.MOBIDZIENNIK, FeatureType.LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_MANUALS to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)).apply { priority = 10 },
|
||||
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_CALENDAR to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB)).apply { priority = 3 },
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_CALENDAR to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)).apply { priority = 3 },
|
||||
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_GRADES to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB)).apply { priority = 2 },
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_GRADES to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)).apply { priority = 2 },
|
||||
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_NOTICES to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB)).apply { priority = 1 },
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_NOTICES to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)).apply { priority = 1 },
|
||||
|
||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_ATTENDANCE to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB)).apply { priority = 4 }*/
|
||||
Feature(LoginType.MOBIDZIENNIK, FeatureType.LUCKY_NUMBER, listOf(
|
||||
ENDPOINT_MOBIDZIENNIK_WEB_ATTENDANCE to LoginMethod.MOBIDZIENNIK_WEB
|
||||
)).apply { priority = 4 }*/
|
||||
|
||||
)
|
||||
|
@ -21,7 +21,7 @@ class MobidziennikData(val data: DataMobidziennik, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
private fun nextEndpoint(onSuccess: () -> Unit) {
|
||||
if (data.targetEndpointIds.isEmpty()) {
|
||||
if (data.targetEndpoints.isEmpty()) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
@ -29,8 +29,8 @@ class MobidziennikData(val data: DataMobidziennik, val onSuccess: () -> Unit) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
val id = data.targetEndpointIds.firstKey()
|
||||
val lastSync = data.targetEndpointIds.remove(id)
|
||||
val id = data.targetEndpoints.firstKey()
|
||||
val lastSync = data.targetEndpoints.remove(id)
|
||||
useEndpoint(id, lastSync) { endpointId ->
|
||||
data.progress(data.progressStep)
|
||||
nextEndpoint(onSuccess)
|
||||
|
@ -11,6 +11,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Attendance.Companion.TYPE_ABSEN
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Attendance.Companion.TYPE_PRESENT
|
||||
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
|
||||
|
||||
class MobidziennikApiAttendance(val data: DataMobidziennik, rows: List<String>) {
|
||||
init { run {
|
||||
@ -70,7 +71,7 @@ class MobidziennikApiAttendance(val data: DataMobidziennik, rows: List<String>)
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_ATTENDANCE,
|
||||
MetadataType.ATTENDANCE,
|
||||
id,
|
||||
data.profile?.empty ?: false || baseType == Attendance.TYPE_PRESENT_CUSTOM || baseType == Attendance.TYPE_UNKNOWN,
|
||||
data.profile?.empty ?: false || baseType == Attendance.TYPE_PRESENT_CUSTOM || baseType == Attendance.TYPE_UNKNOWN
|
||||
|
@ -10,6 +10,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.DataMobidzienn
|
||||
import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
import java.text.ParseException
|
||||
@ -68,7 +69,7 @@ class MobidziennikApiEvents(val data: DataMobidziennik, rows: List<String>) {
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_EVENT,
|
||||
MetadataType.EVENT,
|
||||
id,
|
||||
data.profile?.empty ?: false,
|
||||
data.profile?.empty ?: false
|
||||
|
@ -15,6 +15,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_SEMESTER2_
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_YEAR_FINAL
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_YEAR_PROPOSED
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
|
||||
class MobidziennikApiGrades(val data: DataMobidziennik, rows: List<String>) {
|
||||
init { data.profile?.also { profile -> run {
|
||||
@ -91,7 +92,7 @@ class MobidziennikApiGrades(val data: DataMobidziennik, rows: List<String>) {
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
id,
|
||||
data.profile?.empty ?: false,
|
||||
data.profile?.empty ?: false
|
||||
|
@ -9,6 +9,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.DataMobidzienn
|
||||
import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.utils.html.BetterHtml
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
@ -47,7 +48,7 @@ class MobidziennikApiHomework(val data: DataMobidziennik, rows: List<String>) {
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_HOMEWORK,
|
||||
MetadataType.HOMEWORK,
|
||||
id,
|
||||
data.profile?.empty ?: false,
|
||||
data.profile?.empty ?: false
|
||||
|
@ -7,6 +7,7 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.api
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.DataMobidziennik
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Notice
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
|
||||
class MobidziennikApiNotices(val data: DataMobidziennik, rows: List<String>) {
|
||||
@ -48,7 +49,7 @@ class MobidziennikApiNotices(val data: DataMobidziennik, rows: List<String>) {
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_NOTICE,
|
||||
MetadataType.NOTICE,
|
||||
id,
|
||||
data.profile?.empty ?: false,
|
||||
data.profile?.empty ?: false
|
||||
|
@ -11,6 +11,7 @@ import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LessonRange
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.fixName
|
||||
import pl.szczodrzynski.edziennik.ext.keys
|
||||
import pl.szczodrzynski.edziennik.ext.singleOrNull
|
||||
@ -94,7 +95,7 @@ class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List<String>) {
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_LESSON_CHANGE,
|
||||
MetadataType.LESSON_CHANGE,
|
||||
it.id,
|
||||
seen,
|
||||
seen
|
||||
|
@ -8,6 +8,7 @@ import pl.szczodrzynski.edziennik.data.api.Regexes
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.DataMobidziennik
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LuckyNumber
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
|
||||
class MobidziennikLuckyNumberExtractor(val data: DataMobidziennik, text: String) {
|
||||
@ -26,7 +27,7 @@ class MobidziennikLuckyNumberExtractor(val data: DataMobidziennik, text: String)
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_LUCKY_NUMBER,
|
||||
MetadataType.LUCKY_NUMBER,
|
||||
luckyNumberObject.date.value.toLong(),
|
||||
true,
|
||||
data.profile?.empty ?: false
|
||||
|
@ -20,6 +20,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Attendance.Companion.TYPE_RELEA
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Attendance.Companion.TYPE_UNKNOWN
|
||||
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.fixName
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
import pl.szczodrzynski.edziennik.ext.singleOrNull
|
||||
@ -246,7 +247,7 @@ class MobidziennikWebAttendance(override val data: DataMobidziennik,
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_ATTENDANCE,
|
||||
MetadataType.ATTENDANCE,
|
||||
id,
|
||||
data.profile?.empty ?: false || baseType == Attendance.TYPE_PRESENT_CUSTOM || baseType == TYPE_UNKNOWN,
|
||||
data.profile?.empty ?: false || baseType == Attendance.TYPE_PRESENT_CUSTOM || baseType == TYPE_UNKNOWN
|
||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.Mobidzien
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||
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.getString
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.crc16
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
@ -86,7 +87,7 @@ class MobidziennikWebCalendar(override val data: DataMobidziennik,
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_EVENT,
|
||||
MetadataType.EVENT,
|
||||
eventObject.id,
|
||||
profile?.empty ?: false,
|
||||
profile?.empty ?: false
|
||||
|
@ -11,6 +11,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.DataMobidzienn
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.MobidziennikWeb
|
||||
import pl.szczodrzynski.edziennik.data.api.events.MessageGetEvent
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageRecipientFull
|
||||
import pl.szczodrzynski.edziennik.ext.fixName
|
||||
@ -133,7 +134,7 @@ class MobidziennikWebGetMessage(override val data: DataMobidziennik,
|
||||
if (!message.seen) { // TODO discover why this monstrosity instead of MetadataDao.setSeen
|
||||
data.setSeenMetadataList.add(Metadata(
|
||||
message.profileId,
|
||||
Metadata.TYPE_MESSAGE,
|
||||
MetadataType.MESSAGE,
|
||||
message.id,
|
||||
true,
|
||||
true
|
||||
|
@ -14,6 +14,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Grade
|
||||
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.fixWhiteSpaces
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
import pl.szczodrzynski.edziennik.ext.singleOrNull
|
||||
@ -135,7 +136,7 @@ class MobidziennikWebGrades(override val data: DataMobidziennik,
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
gradeObject.id,
|
||||
profile.empty,
|
||||
profile.empty
|
||||
|
@ -13,6 +13,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_RECEIVED
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_SENT
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.MessageRecipient
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.DAY
|
||||
import pl.szczodrzynski.edziennik.ext.fixName
|
||||
import pl.szczodrzynski.edziennik.ext.singleOrNull
|
||||
@ -84,7 +85,7 @@ class MobidziennikWebMessagesAll(override val data: DataMobidziennik,
|
||||
)
|
||||
|
||||
data.messageList.add(message)
|
||||
data.metadataList.add(Metadata(profileId, Metadata.TYPE_MESSAGE, message.id, true, true))
|
||||
data.metadataList.add(Metadata(profileId, MetadataType.MESSAGE, message.id, true, true))
|
||||
}
|
||||
|
||||
// sync every 7 days as we probably don't expect more than
|
||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Message
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.MessageRecipient
|
||||
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.fixName
|
||||
import pl.szczodrzynski.edziennik.ext.singleOrNull
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
@ -83,7 +84,7 @@ class MobidziennikWebMessagesInbox(override val data: DataMobidziennik,
|
||||
data.setSeenMetadataList.add(
|
||||
Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_MESSAGE,
|
||||
MetadataType.MESSAGE,
|
||||
message.id,
|
||||
isRead,
|
||||
isRead || profile?.empty ?: false
|
||||
|
@ -5,7 +5,6 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.web
|
||||
|
||||
import org.jsoup.Jsoup
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_MESSAGES
|
||||
import pl.szczodrzynski.edziennik.data.api.Regexes
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.DataMobidziennik
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_SENT
|
||||
@ -14,6 +13,8 @@ import pl.szczodrzynski.edziennik.data.db.entity.Message
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.MessageRecipient
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.DAY
|
||||
import pl.szczodrzynski.edziennik.ext.fixName
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
@ -100,14 +101,14 @@ class MobidziennikWebMessagesSent(override val data: DataMobidziennik,
|
||||
data.setSeenMetadataList.add(
|
||||
Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_MESSAGE,
|
||||
MetadataType.MESSAGE,
|
||||
message.id,
|
||||
true,
|
||||
true
|
||||
))
|
||||
}
|
||||
|
||||
data.setSyncNext(ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_SENT, 1* DAY, DRAWER_ITEM_MESSAGES)
|
||||
data.setSyncNext(ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_SENT, 1* DAY, FeatureType.MESSAGES_SENT)
|
||||
onSuccess(ENDPOINT_MOBIDZIENNIK_WEB_MESSAGES_SENT)
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,10 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.Mobidzien
|
||||
import pl.szczodrzynski.edziennik.data.api.events.MessageSentEvent
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
|
||||
class MobidziennikWebSendMessage(override val data: DataMobidziennik,
|
||||
val recipients: List<Teacher>,
|
||||
val recipients: Set<Teacher>,
|
||||
val subject: String,
|
||||
val text: String,
|
||||
val onSuccess: () -> Unit
|
||||
@ -43,7 +44,7 @@ class MobidziennikWebSendMessage(override val data: DataMobidziennik,
|
||||
// TODO create MobidziennikWebMessagesSent and replace this
|
||||
MobidziennikWebMessagesAll(data, null) {
|
||||
val message = data.messageList.firstOrNull { it.isSent && it.subject == subject }
|
||||
val metadata = data.metadataList.firstOrNull { it.thingType == Metadata.TYPE_MESSAGE && it.thingId == message?.id }
|
||||
val metadata = data.metadataList.firstOrNull { it.thingType == MetadataType.MESSAGE && it.thingId == message?.id }
|
||||
val event = MessageSentEvent(data.profileId, message, message?.addedDate)
|
||||
|
||||
EventBus.getDefault().postSticky(event)
|
||||
|
@ -15,6 +15,7 @@ import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel.Timetable.Comp
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
||||
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.DAY
|
||||
import pl.szczodrzynski.edziennik.ext.MS
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
@ -343,7 +344,7 @@ class MobidziennikWebTimetable(
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_LESSON_CHANGE,
|
||||
MetadataType.LESSON_CHANGE,
|
||||
it.id,
|
||||
seen,
|
||||
seen
|
||||
|
@ -1,12 +1,12 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.firstlogin
|
||||
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_MOBIDZIENNIK
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.DataMobidziennik
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.MobidziennikWeb
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.login.MobidziennikLoginWeb
|
||||
import pl.szczodrzynski.edziennik.data.api.events.FirstLoginFinishedEvent
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.fixName
|
||||
import pl.szczodrzynski.edziennik.ext.set
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
@ -20,9 +20,7 @@ class MobidziennikFirstLogin(val data: DataMobidziennik, val onSuccess: () -> Un
|
||||
private val profileList = mutableListOf<Profile>()
|
||||
|
||||
init {
|
||||
val loginStoreId = data.loginStore.id
|
||||
val loginStoreType = LOGIN_TYPE_MOBIDZIENNIK
|
||||
var firstProfileId = loginStoreId
|
||||
var firstProfileId = data.loginStore.id
|
||||
|
||||
MobidziennikLoginWeb(data) {
|
||||
web.webGet(TAG, "/api/zrzutbazy") { text ->
|
||||
@ -66,8 +64,8 @@ class MobidziennikFirstLogin(val data: DataMobidziennik, val onSuccess: () -> Un
|
||||
|
||||
val profile = Profile(
|
||||
firstProfileId++,
|
||||
loginStoreId,
|
||||
loginStoreType,
|
||||
data.loginStore.id,
|
||||
LoginType.MOBIDZIENNIK,
|
||||
studentNameLong,
|
||||
data.loginUsername,
|
||||
studentNameLong,
|
||||
|
@ -5,9 +5,8 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.login
|
||||
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_MOBIDZIENNIK_API2
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.DataMobidziennik
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.utils.Utils
|
||||
|
||||
class MobidziennikLogin(val data: DataMobidziennik, val onSuccess: () -> Unit) {
|
||||
@ -22,7 +21,7 @@ class MobidziennikLogin(val data: DataMobidziennik, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
private fun nextLoginMethod(onSuccess: () -> Unit) {
|
||||
if (data.targetLoginMethodIds.isEmpty()) {
|
||||
if (data.targetLoginMethods.isEmpty()) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
@ -30,30 +29,31 @@ class MobidziennikLogin(val data: DataMobidziennik, val onSuccess: () -> Unit) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
useLoginMethod(data.targetLoginMethodIds.removeAt(0)) { usedMethodId ->
|
||||
useLoginMethod(data.targetLoginMethods.removeAt(0)) { usedMethod ->
|
||||
data.progress(data.progressStep)
|
||||
if (usedMethodId != -1)
|
||||
data.loginMethods.add(usedMethodId)
|
||||
if (usedMethod != null)
|
||||
data.loginMethods.add(usedMethod)
|
||||
nextLoginMethod(onSuccess)
|
||||
}
|
||||
}
|
||||
|
||||
private fun useLoginMethod(loginMethodId: Int, onSuccess: (usedMethodId: Int) -> Unit) {
|
||||
private fun useLoginMethod(loginMethod: LoginMethod, onSuccess: (usedMethod: LoginMethod?) -> Unit) {
|
||||
// this should never be true
|
||||
if (data.loginMethods.contains(loginMethodId)) {
|
||||
onSuccess(-1)
|
||||
if (data.loginMethods.contains(loginMethod)) {
|
||||
onSuccess(null)
|
||||
return
|
||||
}
|
||||
Utils.d(TAG, "Using login method $loginMethodId")
|
||||
when (loginMethodId) {
|
||||
LOGIN_METHOD_MOBIDZIENNIK_WEB -> {
|
||||
Utils.d(TAG, "Using login method $loginMethod")
|
||||
when (loginMethod) {
|
||||
LoginMethod.MOBIDZIENNIK_WEB -> {
|
||||
data.startProgress(R.string.edziennik_progress_login_mobidziennik_web)
|
||||
MobidziennikLoginWeb(data) { onSuccess(loginMethodId) }
|
||||
MobidziennikLoginWeb(data) { onSuccess(loginMethod) }
|
||||
}
|
||||
LOGIN_METHOD_MOBIDZIENNIK_API2 -> {
|
||||
LoginMethod.MOBIDZIENNIK_API2 -> {
|
||||
data.startProgress(R.string.edziennik_progress_login_mobidziennik_api2)
|
||||
MobidziennikLoginApi2(data) { onSuccess(loginMethodId) }
|
||||
MobidziennikLoginApi2(data) { onSuccess(loginMethod) }
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie
|
||||
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_PODLASIE_API
|
||||
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.crc32
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
|
||||
@ -19,7 +19,7 @@ class DataPodlasie(app: App, profile: Profile?, loginStore: LoginStore) : Data(a
|
||||
override fun satisfyLoginMethods() {
|
||||
loginMethods.clear()
|
||||
if (isApiLoginValid())
|
||||
loginMethods += LOGIN_METHOD_PODLASIE_API
|
||||
loginMethods += LoginMethod.PODLASIE_API
|
||||
}
|
||||
|
||||
override fun generateUserCode(): String = "$schoolShortName:$loginShort:${studentId?.crc32()}"
|
||||
|
@ -16,11 +16,11 @@ import pl.szczodrzynski.edziennik.data.api.events.UserActionRequiredEvent
|
||||
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikCallback
|
||||
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikInterface
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.api.podlasieLoginMethods
|
||||
import pl.szczodrzynski.edziennik.data.api.prepare
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
|
||||
@ -55,11 +55,11 @@ class Podlasie(val app: App, val profile: Profile?, val loginStore: LoginStore,
|
||||
|_| |_| |_|\___| /_/ \_\_|\__, |\___/|_| |_|\__|_| |_|_| |_| |_|
|
||||
__/ |
|
||||
|__*/
|
||||
override fun sync(featureIds: List<Int>, viewId: Int?, onlyEndpoints: List<Int>?, arguments: JsonObject?) {
|
||||
override fun sync(featureTypes: Set<FeatureType>?, onlyEndpoints: Set<Int>?, arguments: JsonObject?) {
|
||||
data.arguments = arguments
|
||||
data.prepare(podlasieLoginMethods, PodlasieFeatures, featureIds, viewId, onlyEndpoints)
|
||||
Utils.d(TAG, "LoginMethod IDs: ${data.targetLoginMethodIds}")
|
||||
Utils.d(TAG, "Endpoint IDs: ${data.targetEndpointIds}")
|
||||
data.prepare(PodlasieFeatures, featureTypes, onlyEndpoints)
|
||||
Utils.d(TAG, "LoginMethod IDs: ${data.targetLoginMethods}")
|
||||
Utils.d(TAG, "Endpoint IDs: ${data.targetEndpoints}")
|
||||
PodlasieLogin(data) {
|
||||
PodlasieData(data) {
|
||||
completed()
|
||||
@ -71,7 +71,7 @@ class Podlasie(val app: App, val profile: Profile?, val loginStore: LoginStore,
|
||||
|
||||
}
|
||||
|
||||
override fun sendMessage(recipients: List<Teacher>, subject: String, text: String) {
|
||||
override fun sendMessage(recipients: Set<Teacher>, subject: String, text: String) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,15 +4,15 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie
|
||||
|
||||
import pl.szczodrzynski.edziennik.data.api.FEATURE_ALWAYS_NEEDED
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_PODLASIE_API
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_PODLASIE
|
||||
import pl.szczodrzynski.edziennik.data.api.models.Feature
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
|
||||
const val ENDPOINT_PODLASIE_API_MAIN = 1001
|
||||
|
||||
val PodlasieFeatures = listOf(
|
||||
Feature(LOGIN_TYPE_PODLASIE, FEATURE_ALWAYS_NEEDED, listOf(
|
||||
ENDPOINT_PODLASIE_API_MAIN to LOGIN_METHOD_PODLASIE_API
|
||||
), listOf(LOGIN_METHOD_PODLASIE_API))
|
||||
Feature(LoginType.PODLASIE, FeatureType.ALWAYS_NEEDED, listOf(
|
||||
ENDPOINT_PODLASIE_API_MAIN to LoginMethod.PODLASIE_API
|
||||
))
|
||||
)
|
||||
|
@ -20,7 +20,7 @@ class PodlasieData(val data: DataPodlasie, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
private fun nextEndpoint(onSuccess: () -> Unit) {
|
||||
if (data.targetEndpointIds.isEmpty()) {
|
||||
if (data.targetEndpoints.isEmpty()) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
@ -28,8 +28,8 @@ class PodlasieData(val data: DataPodlasie, val onSuccess: () -> Unit) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
val id = data.targetEndpointIds.firstKey()
|
||||
val lastSync = data.targetEndpointIds.remove(id)
|
||||
val id = data.targetEndpoints.firstKey()
|
||||
val lastSync = data.targetEndpoints.remove(id)
|
||||
useEndpoint(id, lastSync) {
|
||||
data.progress(data.progressStep)
|
||||
nextEndpoint(onSuccess)
|
||||
|
@ -9,6 +9,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||
import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||
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.getString
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
@ -64,7 +65,7 @@ class PodlasieApiEvents(val data: DataPodlasie, val rows: List<JsonObject>) {
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
if (type == Event.TYPE_HOMEWORK) Metadata.TYPE_HOMEWORK else Metadata.TYPE_EVENT,
|
||||
if (type == Event.TYPE_HOMEWORK) MetadataType.HOMEWORK else MetadataType.EVENT,
|
||||
id,
|
||||
data.profile?.empty ?: false,
|
||||
data.profile?.empty ?: false
|
||||
|
@ -15,6 +15,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_SEMESTER2_
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_YEAR_FINAL
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_YEAR_PROPOSED
|
||||
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.getString
|
||||
|
||||
@ -62,7 +63,7 @@ class PodlasieApiFinalGrades(val data: DataPodlasie, val rows: List<JsonObject>)
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
id,
|
||||
profile.empty,
|
||||
profile.empty
|
||||
@ -99,7 +100,7 @@ class PodlasieApiFinalGrades(val data: DataPodlasie, val rows: List<JsonObject>)
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
proposedGradeObject.id,
|
||||
profile.empty,
|
||||
profile.empty
|
||||
|
@ -10,6 +10,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||
import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Grade
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.getFloat
|
||||
import pl.szczodrzynski.edziennik.ext.getInt
|
||||
import pl.szczodrzynski.edziennik.ext.getLong
|
||||
@ -60,7 +61,7 @@ class PodlasieApiGrades(val data: DataPodlasie, val rows: List<JsonObject>) {
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_GRADE,
|
||||
MetadataType.GRADE,
|
||||
id,
|
||||
data.profile?.empty ?: false,
|
||||
data.profile?.empty ?: false
|
||||
|
@ -9,6 +9,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||
import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.ext.crc32
|
||||
import pl.szczodrzynski.edziennik.ext.get
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
@ -53,7 +54,7 @@ class PodlasieApiHomework(val data: DataPodlasie, val rows: List<JsonObject>) {
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_HOMEWORK,
|
||||
MetadataType.HOMEWORK,
|
||||
id,
|
||||
data.profile?.empty ?: false,
|
||||
data.profile?.empty ?: false
|
||||
|
@ -7,6 +7,7 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.api
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LuckyNumber
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
|
||||
class PodlasieApiLuckyNumber(val data: DataPodlasie, val luckyNumber: Int) {
|
||||
@ -21,7 +22,7 @@ class PodlasieApiLuckyNumber(val data: DataPodlasie, val luckyNumber: Int) {
|
||||
data.metadataList.add(
|
||||
Metadata(
|
||||
data.profileId,
|
||||
Metadata.TYPE_LUCKY_NUMBER,
|
||||
MetadataType.LUCKY_NUMBER,
|
||||
luckyNumberObject.date.value.toLong(),
|
||||
true,
|
||||
data.profile?.empty ?: false
|
||||
|
@ -5,7 +5,6 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.firstlogin
|
||||
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_PODLASIE
|
||||
import pl.szczodrzynski.edziennik.data.api.PODLASIE_API_LOGOUT_DEVICES_ENDPOINT
|
||||
import pl.szczodrzynski.edziennik.data.api.PODLASIE_API_USER_ENDPOINT
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||
@ -13,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.PodlasieApi
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.login.PodlasieLoginApi
|
||||
import pl.szczodrzynski.edziennik.data.api.events.FirstLoginFinishedEvent
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.fixName
|
||||
import pl.szczodrzynski.edziennik.ext.getShortName
|
||||
import pl.szczodrzynski.edziennik.ext.getString
|
||||
@ -32,9 +32,6 @@ class PodlasieFirstLogin(val data: DataPodlasie, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
private fun doLogin() {
|
||||
val loginStoreId = data.loginStore.id
|
||||
val loginStoreType = LOGIN_TYPE_PODLASIE
|
||||
|
||||
if (data.loginStore.getLoginData("logoutDevices", false)) {
|
||||
data.loginStore.removeLoginData("logoutDevices")
|
||||
api.apiGet(TAG, PODLASIE_API_LOGOUT_DEVICES_ENDPOINT) {
|
||||
@ -57,9 +54,9 @@ class PodlasieFirstLogin(val data: DataPodlasie, val onSuccess: () -> Unit) {
|
||||
val apiUrl = json.getString("URL")
|
||||
|
||||
val profile = Profile(
|
||||
loginStoreId,
|
||||
loginStoreId,
|
||||
loginStoreType,
|
||||
data.loginStore.id,
|
||||
data.loginStore.id,
|
||||
LoginType.PODLASIE,
|
||||
studentNameLong,
|
||||
login,
|
||||
studentNameLong,
|
||||
|
@ -5,8 +5,8 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.login
|
||||
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_PODLASIE_API
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.utils.Utils
|
||||
|
||||
class PodlasieLogin(val data: DataPodlasie, val onSuccess: () -> Unit) {
|
||||
@ -21,7 +21,7 @@ class PodlasieLogin(val data: DataPodlasie, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
private fun nextLoginMethod(onSuccess: () -> Unit) {
|
||||
if (data.targetLoginMethodIds.isEmpty()) {
|
||||
if (data.targetLoginMethods.isEmpty()) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
@ -29,26 +29,27 @@ class PodlasieLogin(val data: DataPodlasie, val onSuccess: () -> Unit) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
useLoginMethod(data.targetLoginMethodIds.removeAt(0)) { usedMethodId ->
|
||||
useLoginMethod(data.targetLoginMethods.removeAt(0)) { usedMethod ->
|
||||
data.progress(data.progressStep)
|
||||
if (usedMethodId != -1)
|
||||
data.loginMethods.add(usedMethodId)
|
||||
if (usedMethod != null)
|
||||
data.loginMethods.add(usedMethod)
|
||||
nextLoginMethod(onSuccess)
|
||||
}
|
||||
}
|
||||
|
||||
private fun useLoginMethod(loginMethodId: Int, onSuccess: (usedMethodId: Int) -> Unit) {
|
||||
private fun useLoginMethod(loginMethod: LoginMethod, onSuccess: (usedMethod: LoginMethod?) -> Unit) {
|
||||
// this should never be true
|
||||
if (data.loginMethods.contains(loginMethodId)) {
|
||||
onSuccess(-1)
|
||||
if (data.loginMethods.contains(loginMethod)) {
|
||||
onSuccess(null)
|
||||
return
|
||||
}
|
||||
Utils.d(TAG, "Using login method $loginMethodId")
|
||||
when (loginMethodId) {
|
||||
LOGIN_METHOD_PODLASIE_API -> {
|
||||
Utils.d(TAG, "Using login method $loginMethod")
|
||||
when (loginMethod) {
|
||||
LoginMethod.PODLASIE_API -> {
|
||||
data.startProgress(R.string.edziennik_progress_login_podlasie_api)
|
||||
PodlasieLoginApi(data) { onSuccess(loginMethodId) }
|
||||
PodlasieLoginApi(data) { onSuccess(loginMethod) }
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,10 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.template
|
||||
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_TEMPLATE_API
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_TEMPLATE_WEB
|
||||
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.currentTimeUnix
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
|
||||
@ -26,11 +25,11 @@ class DataTemplate(app: App, profile: Profile?, loginStore: LoginStore) : Data(a
|
||||
override fun satisfyLoginMethods() {
|
||||
loginMethods.clear()
|
||||
if (isWebLoginValid()) {
|
||||
loginMethods += LOGIN_METHOD_TEMPLATE_WEB
|
||||
loginMethods += LoginMethod.TEMPLATE_WEB
|
||||
app.cookieJar.set("eregister.example.com", "AuthCookie", webCookie)
|
||||
}
|
||||
if (isApiLoginValid())
|
||||
loginMethods += LOGIN_METHOD_TEMPLATE_API
|
||||
loginMethods += LoginMethod.TEMPLATE_API
|
||||
}
|
||||
|
||||
override fun generateUserCode() = "TEMPLATE:DO_NOT_USE"
|
||||
|
@ -15,10 +15,10 @@ import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikCallback
|
||||
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikInterface
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.api.prepare
|
||||
import pl.szczodrzynski.edziennik.data.api.templateLoginMethods
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
|
||||
@ -52,11 +52,11 @@ class Template(val app: App, val profile: Profile?, val loginStore: LoginStore,
|
||||
|_| |_| |_|\___| /_/ \_\_|\__, |\___/|_| |_|\__|_| |_|_| |_| |_|
|
||||
__/ |
|
||||
|__*/
|
||||
override fun sync(featureIds: List<Int>, viewId: Int?, onlyEndpoints: List<Int>?, arguments: JsonObject?) {
|
||||
override fun sync(featureTypes: Set<FeatureType>?, onlyEndpoints: Set<Int>?, arguments: JsonObject?) {
|
||||
data.arguments = arguments
|
||||
data.prepare(templateLoginMethods, TemplateFeatures, featureIds, viewId, onlyEndpoints)
|
||||
d(TAG, "LoginMethod IDs: ${data.targetLoginMethodIds}")
|
||||
d(TAG, "Endpoint IDs: ${data.targetEndpointIds}")
|
||||
data.prepare(TemplateFeatures, featureTypes, onlyEndpoints)
|
||||
d(TAG, "LoginMethod IDs: ${data.targetLoginMethods}")
|
||||
d(TAG, "Endpoint IDs: ${data.targetEndpoints}")
|
||||
TemplateLogin(data) {
|
||||
TemplateData(data) {
|
||||
completed()
|
||||
@ -68,7 +68,7 @@ class Template(val app: App, val profile: Profile?, val loginStore: LoginStore,
|
||||
|
||||
}
|
||||
|
||||
override fun sendMessage(recipients: List<Teacher>, subject: String, text: String) {
|
||||
override fun sendMessage(recipients: Set<Teacher>, subject: String, text: String) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,21 +4,23 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.template
|
||||
|
||||
import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.models.Feature
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
|
||||
const val ENDPOINT_TEMPLATE_WEB_SAMPLE = 9991
|
||||
const val ENDPOINT_TEMPLATE_WEB_SAMPLE_2 = 9992
|
||||
const val ENDPOINT_TEMPLATE_API_SAMPLE = 9993
|
||||
|
||||
val TemplateFeatures = listOf(
|
||||
Feature(LOGIN_TYPE_TEMPLATE, FEATURE_STUDENT_INFO, listOf(
|
||||
ENDPOINT_TEMPLATE_WEB_SAMPLE to LOGIN_METHOD_TEMPLATE_WEB
|
||||
), listOf(LOGIN_METHOD_TEMPLATE_WEB)),
|
||||
Feature(LOGIN_TYPE_TEMPLATE, FEATURE_SCHOOL_INFO, listOf(
|
||||
ENDPOINT_TEMPLATE_WEB_SAMPLE_2 to LOGIN_METHOD_TEMPLATE_WEB
|
||||
), listOf(LOGIN_METHOD_TEMPLATE_WEB)),
|
||||
Feature(LOGIN_TYPE_TEMPLATE, FEATURE_GRADES, listOf(
|
||||
ENDPOINT_TEMPLATE_API_SAMPLE to LOGIN_METHOD_TEMPLATE_API
|
||||
), listOf(LOGIN_METHOD_TEMPLATE_API))
|
||||
Feature(LoginType.TEMPLATE, FeatureType.STUDENT_INFO, listOf(
|
||||
ENDPOINT_TEMPLATE_WEB_SAMPLE to LoginMethod.TEMPLATE_WEB
|
||||
)),
|
||||
Feature(LoginType.TEMPLATE, FeatureType.SCHOOL_INFO, listOf(
|
||||
ENDPOINT_TEMPLATE_WEB_SAMPLE_2 to LoginMethod.TEMPLATE_WEB
|
||||
)),
|
||||
Feature(LoginType.TEMPLATE, FeatureType.GRADES, listOf(
|
||||
ENDPOINT_TEMPLATE_API_SAMPLE to LoginMethod.TEMPLATE_API
|
||||
))
|
||||
)
|
||||
|
@ -24,7 +24,7 @@ class TemplateData(val data: DataTemplate, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
private fun nextEndpoint(onSuccess: () -> Unit) {
|
||||
if (data.targetEndpointIds.isEmpty()) {
|
||||
if (data.targetEndpoints.isEmpty()) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
@ -32,8 +32,8 @@ class TemplateData(val data: DataTemplate, val onSuccess: () -> Unit) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
val id = data.targetEndpointIds.firstKey()
|
||||
val lastSync = data.targetEndpointIds.remove(id)
|
||||
val id = data.targetEndpoints.firstKey()
|
||||
val lastSync = data.targetEndpoints.remove(id)
|
||||
useEndpoint(id, lastSync) { endpointId ->
|
||||
data.progress(data.progressStep)
|
||||
nextEndpoint(onSuccess)
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.template.data.api
|
||||
|
||||
import pl.szczodrzynski.edziennik.MainActivity
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.DataTemplate
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.ENDPOINT_TEMPLATE_API_SAMPLE
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.data.TemplateApi
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.ext.DAY
|
||||
|
||||
class TemplateApiSample(override val data: DataTemplate,
|
||||
@ -29,9 +29,7 @@ class TemplateApiSample(override val data: DataTemplate,
|
||||
// not sooner than two days later
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_API_SAMPLE, 2 * DAY)
|
||||
// in two days OR on explicit "grades" sync
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_API_SAMPLE, 2 * DAY, MainActivity.DRAWER_ITEM_GRADES)
|
||||
// only if sync is executed on Home view
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_API_SAMPLE, syncIn = null, viewId = MainActivity.DRAWER_ITEM_HOME)
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_API_SAMPLE, 2 * DAY, FeatureType.GRADES)
|
||||
// always, in every sync
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_API_SAMPLE, SYNC_ALWAYS)
|
||||
|
||||
|
@ -4,12 +4,11 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.template.data.web
|
||||
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_GRADES
|
||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_HOME
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.DataTemplate
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.ENDPOINT_TEMPLATE_WEB_SAMPLE
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.data.TemplateWeb
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.ext.DAY
|
||||
|
||||
class TemplateWebSample(override val data: DataTemplate,
|
||||
@ -30,9 +29,7 @@ class TemplateWebSample(override val data: DataTemplate,
|
||||
// not sooner than two days later
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_WEB_SAMPLE, 2 * DAY)
|
||||
// in two days OR on explicit "grades" sync
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_WEB_SAMPLE, 2 * DAY, DRAWER_ITEM_GRADES)
|
||||
// only if sync is executed on Home view
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_WEB_SAMPLE, syncIn = null, viewId = DRAWER_ITEM_HOME)
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_WEB_SAMPLE, 2 * DAY, FeatureType.GRADES)
|
||||
// always, in every sync
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_WEB_SAMPLE, SYNC_ALWAYS)
|
||||
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.template.data.web
|
||||
|
||||
import pl.szczodrzynski.edziennik.MainActivity
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.DataTemplate
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.ENDPOINT_TEMPLATE_WEB_SAMPLE_2
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.data.TemplateWeb
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.ext.DAY
|
||||
|
||||
class TemplateWebSample2(override val data: DataTemplate,
|
||||
@ -29,9 +29,7 @@ class TemplateWebSample2(override val data: DataTemplate,
|
||||
// not sooner than two days later
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_WEB_SAMPLE_2, 2 * DAY)
|
||||
// in two days OR on explicit "grades" sync
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_WEB_SAMPLE_2, 2 * DAY, MainActivity.DRAWER_ITEM_GRADES)
|
||||
// only if sync is executed on Home view
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_WEB_SAMPLE_2, syncIn = null, viewId = MainActivity.DRAWER_ITEM_HOME)
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_WEB_SAMPLE_2, 2 * DAY, FeatureType.GRADES)
|
||||
// always, in every sync
|
||||
data.setSyncNext(ENDPOINT_TEMPLATE_WEB_SAMPLE_2, SYNC_ALWAYS)
|
||||
|
||||
|
@ -5,9 +5,8 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.template.login
|
||||
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_TEMPLATE_API
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_TEMPLATE_WEB
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.DataTemplate
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.utils.Utils
|
||||
|
||||
class TemplateLogin(val data: DataTemplate, val onSuccess: () -> Unit) {
|
||||
@ -22,7 +21,7 @@ class TemplateLogin(val data: DataTemplate, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
private fun nextLoginMethod(onSuccess: () -> Unit) {
|
||||
if (data.targetLoginMethodIds.isEmpty()) {
|
||||
if (data.targetLoginMethods.isEmpty()) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
@ -30,30 +29,31 @@ class TemplateLogin(val data: DataTemplate, val onSuccess: () -> Unit) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
useLoginMethod(data.targetLoginMethodIds.removeAt(0)) { usedMethodId ->
|
||||
useLoginMethod(data.targetLoginMethods.removeAt(0)) { usedMethod ->
|
||||
data.progress(data.progressStep)
|
||||
if (usedMethodId != -1)
|
||||
data.loginMethods.add(usedMethodId)
|
||||
if (usedMethod != null)
|
||||
data.loginMethods.add(usedMethod)
|
||||
nextLoginMethod(onSuccess)
|
||||
}
|
||||
}
|
||||
|
||||
private fun useLoginMethod(loginMethodId: Int, onSuccess: (usedMethodId: Int) -> Unit) {
|
||||
private fun useLoginMethod(loginMethod: LoginMethod, onSuccess: (usedMethod: LoginMethod?) -> Unit) {
|
||||
// this should never be true
|
||||
if (data.loginMethods.contains(loginMethodId)) {
|
||||
onSuccess(-1)
|
||||
if (data.loginMethods.contains(loginMethod)) {
|
||||
onSuccess(null)
|
||||
return
|
||||
}
|
||||
Utils.d(TAG, "Using login method $loginMethodId")
|
||||
when (loginMethodId) {
|
||||
LOGIN_METHOD_TEMPLATE_WEB -> {
|
||||
Utils.d(TAG, "Using login method $loginMethod")
|
||||
when (loginMethod) {
|
||||
LoginMethod.TEMPLATE_WEB -> {
|
||||
data.startProgress(R.string.edziennik_progress_login_template_web)
|
||||
TemplateLoginWeb(data) { onSuccess(loginMethodId) }
|
||||
TemplateLoginWeb(data) { onSuccess(loginMethod) }
|
||||
}
|
||||
LOGIN_METHOD_TEMPLATE_API -> {
|
||||
LoginMethod.TEMPLATE_API -> {
|
||||
data.startProgress(R.string.edziennik_progress_login_template_api)
|
||||
TemplateLoginApi(data) { onSuccess(loginMethodId) }
|
||||
TemplateLoginApi(data) { onSuccess(loginMethod) }
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.usos
|
||||
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_USOS_API
|
||||
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
|
||||
|
||||
class DataUsos(
|
||||
app: App,
|
||||
@ -21,7 +21,7 @@ class DataUsos(
|
||||
override fun satisfyLoginMethods() {
|
||||
loginMethods.clear()
|
||||
if (isApiLoginValid()) {
|
||||
loginMethods += LOGIN_METHOD_USOS_API
|
||||
loginMethods += LoginMethod.USOS_API
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,10 @@ import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikCallback
|
||||
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikInterface
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.api.prepare
|
||||
import pl.szczodrzynski.edziennik.data.api.usosLoginMethods
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
|
||||
@ -49,15 +49,14 @@ class Usos(
|
||||
}
|
||||
|
||||
override fun sync(
|
||||
featureIds: List<Int>,
|
||||
viewId: Int?,
|
||||
onlyEndpoints: List<Int>?,
|
||||
featureTypes: Set<FeatureType>?,
|
||||
onlyEndpoints: Set<Int>?,
|
||||
arguments: JsonObject?,
|
||||
) {
|
||||
data.arguments = arguments
|
||||
data.prepare(usosLoginMethods, UsosFeatures, featureIds, viewId, onlyEndpoints)
|
||||
d(TAG, "LoginMethod IDs: ${data.targetLoginMethodIds}")
|
||||
d(TAG, "Endpoint IDs: ${data.targetEndpointIds}")
|
||||
data.prepare(UsosFeatures, featureTypes, onlyEndpoints)
|
||||
d(TAG, "LoginMethod IDs: ${data.targetLoginMethods}")
|
||||
d(TAG, "Endpoint IDs: ${data.targetEndpoints}")
|
||||
UsosLogin(data) {
|
||||
UsosData(data) {
|
||||
completed()
|
||||
@ -66,7 +65,7 @@ class Usos(
|
||||
}
|
||||
|
||||
override fun getMessage(message: MessageFull) {}
|
||||
override fun sendMessage(recipients: List<Teacher>, subject: String, text: String) {}
|
||||
override fun sendMessage(recipients: Set<Teacher>, subject: String, text: String) {}
|
||||
override fun markAllAnnouncementsAsRead() {}
|
||||
override fun getAnnouncement(announcement: AnnouncementFull) {}
|
||||
override fun getAttachment(owner: Any, attachmentId: Long, attachmentName: String) {}
|
||||
|
@ -6,6 +6,9 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.usos
|
||||
|
||||
import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.models.Feature
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
|
||||
const val ENDPOINT_USOS_API_USER = 7000
|
||||
const val ENDPOINT_USOS_API_TERMS = 7010
|
||||
@ -16,24 +19,24 @@ val UsosFeatures = listOf(
|
||||
/*
|
||||
* Student information
|
||||
*/
|
||||
Feature(LOGIN_TYPE_USOS, FEATURE_STUDENT_INFO, listOf(
|
||||
ENDPOINT_USOS_API_USER to LOGIN_METHOD_USOS_API,
|
||||
), listOf(LOGIN_METHOD_USOS_API)),
|
||||
Feature(LoginType.USOS, FeatureType.STUDENT_INFO, listOf(
|
||||
ENDPOINT_USOS_API_USER to LoginMethod.USOS_API,
|
||||
)),
|
||||
|
||||
/*
|
||||
* Terms & courses
|
||||
*/
|
||||
Feature(LOGIN_TYPE_USOS, FEATURE_SCHOOL_INFO, listOf(
|
||||
ENDPOINT_USOS_API_TERMS to LOGIN_METHOD_USOS_API,
|
||||
), listOf(LOGIN_METHOD_USOS_API)),
|
||||
Feature(LOGIN_TYPE_USOS, FEATURE_TEAM_INFO, listOf(
|
||||
ENDPOINT_USOS_API_COURSES to LOGIN_METHOD_USOS_API,
|
||||
), listOf(LOGIN_METHOD_USOS_API)),
|
||||
Feature(LoginType.USOS, FeatureType.SCHOOL_INFO, listOf(
|
||||
ENDPOINT_USOS_API_TERMS to LoginMethod.USOS_API,
|
||||
)),
|
||||
Feature(LoginType.USOS, FeatureType.TEAM_INFO, listOf(
|
||||
ENDPOINT_USOS_API_COURSES to LoginMethod.USOS_API,
|
||||
)),
|
||||
|
||||
/*
|
||||
* Timetable
|
||||
*/
|
||||
Feature(LOGIN_TYPE_USOS, FEATURE_TIMETABLE, listOf(
|
||||
ENDPOINT_USOS_API_TIMETABLE to LOGIN_METHOD_USOS_API,
|
||||
), listOf(LOGIN_METHOD_USOS_API)),
|
||||
Feature(LoginType.USOS, FeatureType.TIMETABLE, listOf(
|
||||
ENDPOINT_USOS_API_TIMETABLE to LoginMethod.USOS_API,
|
||||
)),
|
||||
)
|
||||
|
@ -23,7 +23,7 @@ class UsosData(val data: DataUsos, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
private fun nextEndpoint(onSuccess: () -> Unit) {
|
||||
if (data.targetEndpointIds.isEmpty()) {
|
||||
if (data.targetEndpoints.isEmpty()) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
@ -31,8 +31,8 @@ class UsosData(val data: DataUsos, val onSuccess: () -> Unit) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
val id = data.targetEndpointIds.firstKey()
|
||||
val lastSync = data.targetEndpointIds.remove(id)
|
||||
val id = data.targetEndpoints.firstKey()
|
||||
val lastSync = data.targetEndpoints.remove(id)
|
||||
useEndpoint(id, lastSync) { endpointId ->
|
||||
data.progress(data.progressStep)
|
||||
nextEndpoint(onSuccess)
|
||||
|
@ -13,6 +13,7 @@ import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
||||
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.*
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
@ -122,7 +123,7 @@ class UsosApiTimetable(
|
||||
if (lesson.type != Lesson.TYPE_NORMAL)
|
||||
data.metadataList += Metadata(
|
||||
profileId,
|
||||
Metadata.TYPE_LESSON_CHANGE,
|
||||
MetadataType.LESSON_CHANGE,
|
||||
lesson.id,
|
||||
seen,
|
||||
seen,
|
||||
|
@ -7,14 +7,13 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.usos.firstlogin
|
||||
import com.google.gson.JsonObject
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import pl.szczodrzynski.edziennik.data.api.ERROR_USOS_NO_STUDENT_PROGRAMMES
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_USOS
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.firstlogin.LibrusFirstLogin
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.usos.DataUsos
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.usos.data.UsosApi
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.usos.login.UsosLoginApi
|
||||
import pl.szczodrzynski.edziennik.data.api.events.FirstLoginFinishedEvent
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.*
|
||||
|
||||
class UsosFirstLogin(val data: DataUsos, val onSuccess: () -> Unit) {
|
||||
@ -25,9 +24,7 @@ class UsosFirstLogin(val data: DataUsos, val onSuccess: () -> Unit) {
|
||||
private val api = UsosApi(data, null)
|
||||
|
||||
init {
|
||||
val loginStoreId = data.loginStore.id
|
||||
val loginStoreType = LOGIN_TYPE_USOS
|
||||
var firstProfileId = loginStoreId
|
||||
var firstProfileId = data.loginStore.id
|
||||
|
||||
UsosLoginApi(data) {
|
||||
api.apiRequest<JsonObject>(
|
||||
@ -60,7 +57,8 @@ class UsosFirstLogin(val data: DataUsos, val onSuccess: () -> Unit) {
|
||||
|
||||
val profile = Profile(
|
||||
id = firstProfileId++,
|
||||
loginStoreId = loginStoreId, loginStoreType = loginStoreType,
|
||||
loginStoreId = data.loginStore.id,
|
||||
loginStoreType = LoginType.USOS,
|
||||
name = studentName,
|
||||
subname = data.schoolId,
|
||||
studentNameLong = studentName,
|
||||
|
@ -5,8 +5,8 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.usos.login
|
||||
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_USOS_API
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.usos.DataUsos
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
|
||||
class UsosLogin(val data: DataUsos, val onSuccess: () -> Unit) {
|
||||
@ -21,7 +21,7 @@ class UsosLogin(val data: DataUsos, val onSuccess: () -> Unit) {
|
||||
}
|
||||
|
||||
private fun nextLoginMethod(onSuccess: () -> Unit) {
|
||||
if (data.targetLoginMethodIds.isEmpty()) {
|
||||
if (data.targetLoginMethods.isEmpty()) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
@ -29,26 +29,27 @@ class UsosLogin(val data: DataUsos, val onSuccess: () -> Unit) {
|
||||
onSuccess()
|
||||
return
|
||||
}
|
||||
useLoginMethod(data.targetLoginMethodIds.removeAt(0)) { usedMethodId ->
|
||||
useLoginMethod(data.targetLoginMethods.removeAt(0)) { usedMethod ->
|
||||
data.progress(data.progressStep)
|
||||
if (usedMethodId != -1)
|
||||
data.loginMethods.add(usedMethodId)
|
||||
if (usedMethod != null)
|
||||
data.loginMethods.add(usedMethod)
|
||||
nextLoginMethod(onSuccess)
|
||||
}
|
||||
}
|
||||
|
||||
private fun useLoginMethod(loginMethodId: Int, onSuccess: (usedMethodId: Int) -> Unit) {
|
||||
private fun useLoginMethod(loginMethod: LoginMethod, onSuccess: (usedMethod: LoginMethod?) -> Unit) {
|
||||
// this should never be true
|
||||
if (data.loginMethods.contains(loginMethodId)) {
|
||||
onSuccess(-1)
|
||||
if (data.loginMethods.contains(loginMethod)) {
|
||||
onSuccess(null)
|
||||
return
|
||||
}
|
||||
d(TAG, "Using login method $loginMethodId")
|
||||
when (loginMethodId) {
|
||||
LOGIN_METHOD_USOS_API -> {
|
||||
d(TAG, "Using login method $loginMethod")
|
||||
when (loginMethod) {
|
||||
LoginMethod.USOS_API -> {
|
||||
data.startProgress(R.string.edziennik_progress_login_usos_api)
|
||||
UsosLoginApi(data) { onSuccess(loginMethodId) }
|
||||
UsosLoginApi(data) { onSuccess(loginMethod) }
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,10 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.vulcan
|
||||
|
||||
import com.google.gson.JsonObject
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_VULCAN_HEBE
|
||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_METHOD_VULCAN_WEB_MAIN
|
||||
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.crc16
|
||||
import pl.szczodrzynski.edziennik.ext.currentTimeUnix
|
||||
import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty
|
||||
@ -28,10 +27,10 @@ class DataVulcan(app: App, profile: Profile?, loginStore: LoginStore) : Data(app
|
||||
override fun satisfyLoginMethods() {
|
||||
loginMethods.clear()
|
||||
if (isWebMainLoginValid()) {
|
||||
loginMethods += LOGIN_METHOD_VULCAN_WEB_MAIN
|
||||
loginMethods += LoginMethod.VULCAN_WEB_MAIN
|
||||
}
|
||||
if (isHebeLoginValid()) {
|
||||
loginMethods += LOGIN_METHOD_VULCAN_HEBE
|
||||
loginMethods += LoginMethod.VULCAN_HEBE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,8 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.vulcan
|
||||
import com.google.gson.JsonObject
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.ERROR_ONEDRIVE_DOWNLOAD
|
||||
import pl.szczodrzynski.edziennik.data.api.ERROR_VULCAN_API_DEPRECATED
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.helper.OneDriveDownloadAttachment
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.VulcanData
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.hebe.VulcanHebeMessagesChangeStatus
|
||||
@ -21,9 +22,14 @@ import pl.szczodrzynski.edziennik.data.api.events.UserActionRequiredEvent
|
||||
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikCallback
|
||||
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikInterface
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.api.prepare
|
||||
import pl.szczodrzynski.edziennik.data.api.prepareFor
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||
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.full.AnnouncementFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
|
||||
@ -60,24 +66,24 @@ class Vulcan(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
|_| |_| |_|\___| /_/ \_\_|\__, |\___/|_| |_|\__|_| |_|_| |_| |_|
|
||||
__/ |
|
||||
|__*/
|
||||
override fun sync(featureIds: List<Int>, viewId: Int?, onlyEndpoints: List<Int>?, arguments: JsonObject?) {
|
||||
override fun sync(featureTypes: Set<FeatureType>?, onlyEndpoints: Set<Int>?, arguments: JsonObject?) {
|
||||
data.arguments = arguments
|
||||
data.prepare(vulcanLoginMethods, VulcanFeatures, featureIds, viewId, onlyEndpoints)
|
||||
data.prepare(VulcanFeatures, featureTypes, onlyEndpoints)
|
||||
login()
|
||||
}
|
||||
|
||||
private fun login(loginMethodId: Int? = null, afterLogin: (() -> Unit)? = null) {
|
||||
if (data.loginStore.mode == LOGIN_MODE_VULCAN_API) {
|
||||
private fun login(loginMethod: LoginMethod? = null, afterLogin: (() -> Unit)? = null) {
|
||||
if (data.loginStore.mode == LoginMode.VULCAN_API) {
|
||||
data.error(TAG, ERROR_VULCAN_API_DEPRECATED)
|
||||
return
|
||||
}
|
||||
|
||||
d(TAG, "Trying to login with ${data.targetLoginMethodIds}")
|
||||
d(TAG, "Trying to login with ${data.targetLoginMethods}")
|
||||
if (internalErrorList.isNotEmpty()) {
|
||||
d(TAG, " - Internal errors:")
|
||||
internalErrorList.forEach { d(TAG, " - code $it") }
|
||||
}
|
||||
loginMethodId?.let { data.prepareFor(vulcanLoginMethods, it) }
|
||||
loginMethod?.let { data.prepareFor(it) }
|
||||
afterLogin?.let { this.afterLogin = it }
|
||||
VulcanLogin(data) {
|
||||
data()
|
||||
@ -85,7 +91,7 @@ class Vulcan(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
}
|
||||
|
||||
private fun data() {
|
||||
d(TAG, "Endpoint IDs: ${data.targetEndpointIds}")
|
||||
d(TAG, "Endpoint IDs: ${data.targetEndpoints}")
|
||||
if (internalErrorList.isNotEmpty()) {
|
||||
d(TAG, " - Internal errors:")
|
||||
internalErrorList.forEach { d(TAG, " - code $it") }
|
||||
@ -96,7 +102,7 @@ class Vulcan(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
}
|
||||
|
||||
override fun getMessage(message: MessageFull) {
|
||||
login(LOGIN_METHOD_VULCAN_HEBE) {
|
||||
login(LoginMethod.VULCAN_HEBE) {
|
||||
if (message.seen) {
|
||||
EventBus.getDefault().postSticky(MessageGetEvent(message))
|
||||
completed()
|
||||
@ -108,8 +114,8 @@ class Vulcan(val app: App, val profile: Profile?, val loginStore: LoginStore, va
|
||||
}
|
||||
}
|
||||
|
||||
override fun sendMessage(recipients: List<Teacher>, subject: String, text: String) {
|
||||
login(LOGIN_METHOD_VULCAN_HEBE) {
|
||||
override fun sendMessage(recipients: Set<Teacher>, subject: String, text: String) {
|
||||
login(LoginMethod.VULCAN_HEBE) {
|
||||
VulcanHebeSendMessage(data, recipients, subject, text) {
|
||||
completed()
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user