mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-31 05:48:19 +01:00
Merge branch 'feature/prymus' into develop
This commit is contained in:
commit
cadd1a3dbd
@ -1245,3 +1245,5 @@ val SwipeRefreshLayout.onScrollListener: RecyclerView.OnScrollListener
|
|||||||
operator fun <K, V> Iterable<Pair<K, V>>.get(key: K): V? {
|
operator fun <K, V> Iterable<Pair<K, V>>.get(key: K): V? {
|
||||||
return firstOrNull { it.first == key }?.second
|
return firstOrNull { it.first == key }?.second
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun ByteArray.toHexString() = joinToString("") { "%02x".format(it) }
|
||||||
|
@ -118,3 +118,7 @@ const val VULCAN_WEB_ENDPOINT_LUCKY_NUMBER = "Start.mvc/GetKidsLuckyNumbers"
|
|||||||
const val VULCAN_WEB_ENDPOINT_REGISTER_DEVICE = "RejestracjaUrzadzeniaToken.mvc/Get"
|
const val VULCAN_WEB_ENDPOINT_REGISTER_DEVICE = "RejestracjaUrzadzeniaToken.mvc/Get"
|
||||||
|
|
||||||
const val EDUDZIENNIK_USER_AGENT = "Szkolny.eu/${BuildConfig.VERSION_NAME}"
|
const val EDUDZIENNIK_USER_AGENT = "Szkolny.eu/${BuildConfig.VERSION_NAME}"
|
||||||
|
|
||||||
|
const val PODLASIE_API_VERSION = "1.0.31"
|
||||||
|
const val PODLASIE_API_URL = "https://cpdklaser.zeto.bialystok.pl/api"
|
||||||
|
const val PODLASIE_API_USER_ENDPOINT = "/pobierzDaneUcznia"
|
||||||
|
@ -200,6 +200,12 @@ const val ERROR_EDUDZIENNIK_WEB_LIMITED_ACCESS = 521
|
|||||||
const val ERROR_EDUDZIENNIK_WEB_SESSION_EXPIRED = 522
|
const val ERROR_EDUDZIENNIK_WEB_SESSION_EXPIRED = 522
|
||||||
const val ERROR_EDUDZIENNIK_WEB_TEAM_MISSING = 530
|
const val ERROR_EDUDZIENNIK_WEB_TEAM_MISSING = 530
|
||||||
|
|
||||||
|
const val ERROR_LOGIN_PODLASIE_API_INVALID_TOKEN = 601
|
||||||
|
const val ERROR_LOGIN_PODLASIE_API_DEVICE_LIMIT = 602
|
||||||
|
const val ERROR_PODLASIE_API_NO_TOKEN = 630
|
||||||
|
const val ERROR_PODLASIE_API_OTHER = 631
|
||||||
|
const val ERROR_PODLASIE_API_DATA_MISSING = 632
|
||||||
|
|
||||||
const val ERROR_TEMPLATE_WEB_OTHER = 801
|
const val ERROR_TEMPLATE_WEB_OTHER = 801
|
||||||
|
|
||||||
const val EXCEPTION_API_TASK = 900
|
const val EXCEPTION_API_TASK = 900
|
||||||
@ -222,5 +228,6 @@ const val EXCEPTION_EDUDZIENNIK_FILE_REQUEST = 921
|
|||||||
const val ERROR_ONEDRIVE_DOWNLOAD = 930
|
const val ERROR_ONEDRIVE_DOWNLOAD = 930
|
||||||
const val EXCEPTION_VULCAN_WEB_LOGIN = 931
|
const val EXCEPTION_VULCAN_WEB_LOGIN = 931
|
||||||
const val EXCEPTION_VULCAN_WEB_REQUEST = 932
|
const val EXCEPTION_VULCAN_WEB_REQUEST = 932
|
||||||
|
const val EXCEPTION_PODLASIE_API_REQUEST = 940
|
||||||
|
|
||||||
const val LOGIN_NO_ARGUMENTS = 1201
|
const val LOGIN_NO_ARGUMENTS = 1201
|
||||||
|
@ -13,6 +13,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.login.LibrusLoginPor
|
|||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.login.LibrusLoginSynergia
|
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.MobidziennikLoginApi2
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.login.MobidziennikLoginWeb
|
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.TemplateLoginApi
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.login.TemplateLoginWeb
|
import pl.szczodrzynski.edziennik.data.api.edziennik.template.login.TemplateLoginWeb
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.login.VulcanLoginApi
|
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.login.VulcanLoginApi
|
||||||
@ -28,7 +29,6 @@ import pl.szczodrzynski.edziennik.data.api.models.LoginMethod
|
|||||||
const val SYNERGIA_API_ENABLED = false
|
const val SYNERGIA_API_ENABLED = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const val LOGIN_TYPE_IDZIENNIK = 3
|
const val LOGIN_TYPE_IDZIENNIK = 3
|
||||||
|
|
||||||
const val LOGIN_TYPE_TEMPLATE = 21
|
const val LOGIN_TYPE_TEMPLATE = 21
|
||||||
@ -142,6 +142,15 @@ val edudziennikLoginMethods = listOf(
|
|||||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED }
|
.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 }
|
||||||
|
)
|
||||||
|
|
||||||
val templateLoginMethods = listOf(
|
val templateLoginMethods = listOf(
|
||||||
LoginMethod(LOGIN_TYPE_TEMPLATE, LOGIN_METHOD_TEMPLATE_WEB, TemplateLoginWeb::class.java)
|
LoginMethod(LOGIN_TYPE_TEMPLATE, LOGIN_METHOD_TEMPLATE_WEB, TemplateLoginWeb::class.java)
|
||||||
.withIsPossible { _, _ -> true }
|
.withIsPossible { _, _ -> true }
|
||||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.Edudziennik
|
|||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.idziennik.Idziennik
|
import pl.szczodrzynski.edziennik.data.api.edziennik.idziennik.Idziennik
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.librus.Librus
|
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.mobidziennik.Mobidziennik
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.Podlasie
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.template.Template
|
import pl.szczodrzynski.edziennik.data.api.edziennik.template.Template
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.Vulcan
|
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.Vulcan
|
||||||
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikCallback
|
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikCallback
|
||||||
@ -80,6 +81,7 @@ open class EdziennikTask(override val profileId: Int, val request: Any) : IApiTa
|
|||||||
LOGIN_TYPE_VULCAN -> Vulcan(app, profile, loginStore, taskCallback)
|
LOGIN_TYPE_VULCAN -> Vulcan(app, profile, loginStore, taskCallback)
|
||||||
LOGIN_TYPE_IDZIENNIK -> Idziennik(app, profile, loginStore, taskCallback)
|
LOGIN_TYPE_IDZIENNIK -> Idziennik(app, profile, loginStore, taskCallback)
|
||||||
LOGIN_TYPE_EDUDZIENNIK -> Edudziennik(app, profile, loginStore, taskCallback)
|
LOGIN_TYPE_EDUDZIENNIK -> Edudziennik(app, profile, loginStore, taskCallback)
|
||||||
|
LOGIN_TYPE_PODLASIE -> Podlasie(app, profile, loginStore, taskCallback)
|
||||||
LOGIN_TYPE_TEMPLATE -> Template(app, profile, loginStore, taskCallback)
|
LOGIN_TYPE_TEMPLATE -> Template(app, profile, loginStore, taskCallback)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie
|
||||||
|
|
||||||
|
import pl.szczodrzynski.edziennik.*
|
||||||
|
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.*
|
||||||
|
import kotlin.text.replace
|
||||||
|
|
||||||
|
class DataPodlasie(app: App, profile: Profile?, loginStore: LoginStore) : Data(app, profile, loginStore) {
|
||||||
|
|
||||||
|
fun isApiLoginValid() = apiToken.isNotNullNorEmpty()
|
||||||
|
|
||||||
|
override fun satisfyLoginMethods() {
|
||||||
|
loginMethods.clear()
|
||||||
|
if (isApiLoginValid())
|
||||||
|
loginMethods += LOGIN_METHOD_PODLASIE_API
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun generateUserCode(): String = "$schoolShortName:$loginShort:${studentId?.crc32()}"
|
||||||
|
|
||||||
|
/* _
|
||||||
|
/\ (_)
|
||||||
|
/ \ _ __ _
|
||||||
|
/ /\ \ | '_ \| |
|
||||||
|
/ ____ \| |_) | |
|
||||||
|
/_/ \_\ .__/|_|
|
||||||
|
| |
|
||||||
|
|*/
|
||||||
|
private var mApiToken: String? = null
|
||||||
|
var apiToken: String?
|
||||||
|
get() { mApiToken = mApiToken ?: loginStore.getLoginData("apiToken", null); return mApiToken }
|
||||||
|
set(value) { loginStore.putLoginData("apiToken", value); mApiToken = value }
|
||||||
|
|
||||||
|
private var mApiUrl: String? = null
|
||||||
|
var apiUrl: String?
|
||||||
|
get() { mApiUrl = mApiUrl ?: profile?.getStudentData("apiUrl", null); return mApiUrl }
|
||||||
|
set(value) { profile?.putStudentData("apiUrl", value) ?: return; mApiUrl = value }
|
||||||
|
|
||||||
|
/* ____ _ _
|
||||||
|
/ __ \| | | |
|
||||||
|
| | | | |_| |__ ___ _ __
|
||||||
|
| | | | __| '_ \ / _ \ '__|
|
||||||
|
| |__| | |_| | | | __/ |
|
||||||
|
\____/ \__|_| |_|\___|*/
|
||||||
|
private var mStudentId: String? = null
|
||||||
|
var studentId: String?
|
||||||
|
get() { mStudentId = mStudentId ?: profile?.getStudentData("studentId", null); return mStudentId }
|
||||||
|
set(value) { profile?.putStudentData("studentId", value) ?: return; mStudentId = value }
|
||||||
|
|
||||||
|
private var mStudentLogin: String? = null
|
||||||
|
var studentLogin: String?
|
||||||
|
get() { mStudentLogin = mStudentLogin ?: profile?.getStudentData("studentLogin", null); return mStudentLogin }
|
||||||
|
set(value) { profile?.putStudentData("studentLogin", value) ?: return; mStudentLogin = value }
|
||||||
|
|
||||||
|
private var mSchoolName: String? = null
|
||||||
|
var schoolName: String?
|
||||||
|
get() { mSchoolName = mSchoolName ?: profile?.getStudentData("schoolName", null); return mSchoolName }
|
||||||
|
set(value) { profile?.putStudentData("schoolName", value) ?: return; mSchoolName = value }
|
||||||
|
|
||||||
|
private var mClassName: String? = null
|
||||||
|
var className: String?
|
||||||
|
get() { mClassName = mClassName ?: profile?.getStudentData("className", null); return mClassName }
|
||||||
|
set(value) { profile?.putStudentData("className", value) ?: return; mClassName = value }
|
||||||
|
|
||||||
|
private var mSchoolYear: String? = null
|
||||||
|
var schoolYear: String?
|
||||||
|
get() { mSchoolYear = mSchoolYear ?: profile?.getStudentData("schoolYear", null); return mSchoolYear }
|
||||||
|
set(value) { profile?.putStudentData("schoolYear", value) ?: return; mSchoolYear = value }
|
||||||
|
|
||||||
|
private var mCurrentSemester: Int? = null
|
||||||
|
var currentSemester: Int
|
||||||
|
get() { mCurrentSemester = mCurrentSemester ?: profile?.getStudentData("currentSemester", 0); return mCurrentSemester ?: 0 }
|
||||||
|
set(value) { profile?.putStudentData("currentSemester", value) ?: return; mCurrentSemester = value }
|
||||||
|
|
||||||
|
val schoolShortName: String?
|
||||||
|
get() = studentLogin?.split('@')?.get(1)?.replace(".podlaskie.pl", "")
|
||||||
|
|
||||||
|
val loginShort: String?
|
||||||
|
get() = studentLogin?.split('@')?.get(0)
|
||||||
|
|
||||||
|
fun getSubject(name: String): Subject {
|
||||||
|
val id = name.crc32()
|
||||||
|
return subjectList.singleOrNull { it.id == id } ?: run {
|
||||||
|
val subject = Subject(profileId, id, name, name)
|
||||||
|
subjectList.put(id, subject)
|
||||||
|
subject
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getTeacher(firstName: String, lastName: String): Teacher {
|
||||||
|
val name = "$firstName $lastName".fixName()
|
||||||
|
return teacherList.singleOrNull { it.fullName == name } ?: run {
|
||||||
|
val id = name.crc32()
|
||||||
|
val teacher = Teacher(profileId, id, firstName, lastName)
|
||||||
|
teacherList.put(id, teacher)
|
||||||
|
teacher
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getTeam(name: String? = null): Team {
|
||||||
|
if (name == "cała klasa" || name == null) return teamClass ?: run {
|
||||||
|
val id = className!!.crc32()
|
||||||
|
val teamCode = "$schoolShortName:$className"
|
||||||
|
val team = Team(profileId, id, className, Team.TYPE_CLASS, teamCode, -1)
|
||||||
|
teamList.put(id, team)
|
||||||
|
return team
|
||||||
|
} else {
|
||||||
|
val id = name.crc32()
|
||||||
|
val teamCode = "$schoolShortName:$name"
|
||||||
|
val team = Team(profileId, id, name, Team.TYPE_VIRTUAL, teamCode, -1)
|
||||||
|
teamList.put(id, team)
|
||||||
|
return team
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
import pl.szczodrzynski.edziennik.App
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.PodlasieData
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.firstlogin.PodlasieFirstLogin
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.login.PodlasieLogin
|
||||||
|
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.full.AnnouncementFull
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
|
||||||
|
import pl.szczodrzynski.edziennik.utils.Utils
|
||||||
|
|
||||||
|
class Podlasie(val app: App, val profile: Profile?, val loginStore: LoginStore, val callback: EdziennikCallback) : EdziennikInterface {
|
||||||
|
companion object {
|
||||||
|
const val TAG = "Podlasie"
|
||||||
|
}
|
||||||
|
|
||||||
|
val internalErrorList = mutableListOf<Int>()
|
||||||
|
val data: DataPodlasie
|
||||||
|
|
||||||
|
init {
|
||||||
|
data = DataPodlasie(app, profile, loginStore).apply {
|
||||||
|
callback = wrapCallback(this@Podlasie.callback)
|
||||||
|
satisfyLoginMethods()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun completed() {
|
||||||
|
data.saveData()
|
||||||
|
callback.onCompleted()
|
||||||
|
}
|
||||||
|
|
||||||
|
/* _______ _ _ _ _ _
|
||||||
|
|__ __| | /\ | | (_) | | |
|
||||||
|
| | | |__ ___ / \ | | __ _ ___ _ __ _| |_| |__ _ __ ___
|
||||||
|
| | | '_ \ / _ \ / /\ \ | |/ _` |/ _ \| '__| | __| '_ \| '_ ` _ \
|
||||||
|
| | | | | | __/ / ____ \| | (_| | (_) | | | | |_| | | | | | | | |
|
||||||
|
|_| |_| |_|\___| /_/ \_\_|\__, |\___/|_| |_|\__|_| |_|_| |_| |_|
|
||||||
|
__/ |
|
||||||
|
|__*/
|
||||||
|
override fun sync(featureIds: List<Int>, viewId: Int?, onlyEndpoints: List<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}")
|
||||||
|
PodlasieLogin(data) {
|
||||||
|
PodlasieData(data) {
|
||||||
|
completed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getMessage(message: MessageFull) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun sendMessage(recipients: List<Teacher>, subject: String, text: String) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun markAllAnnouncementsAsRead() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getAnnouncement(announcement: AnnouncementFull) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getAttachment(owner: Any, attachmentId: Long, attachmentName: String) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getRecipientList() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getEvent(eventFull: EventFull) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun firstLogin() {
|
||||||
|
PodlasieFirstLogin(data) {
|
||||||
|
completed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun cancel() {
|
||||||
|
Utils.d(TAG, "Cancelled")
|
||||||
|
data.cancel()
|
||||||
|
callback.onCompleted()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun wrapCallback(callback: EdziennikCallback): EdziennikCallback {
|
||||||
|
return object : EdziennikCallback {
|
||||||
|
override fun onCompleted() {
|
||||||
|
callback.onCompleted()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onProgress(step: Float) {
|
||||||
|
callback.onProgress(step)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStartProgress(stringRes: Int) {
|
||||||
|
callback.onStartProgress(stringRes)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(apiError: ApiError) {
|
||||||
|
// TODO Error handling
|
||||||
|
when (apiError.errorCode) {
|
||||||
|
in internalErrorList -> {
|
||||||
|
// finish immediately if the same error occurs twice during the same sync
|
||||||
|
callback.onError(apiError)
|
||||||
|
}
|
||||||
|
else -> callback.onError(apiError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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))
|
||||||
|
)
|
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
import im.wangchao.mhttp.Request
|
||||||
|
import im.wangchao.mhttp.RequestParams
|
||||||
|
import im.wangchao.mhttp.Response
|
||||||
|
import im.wangchao.mhttp.callback.JsonCallbackHandler
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.*
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||||
|
import pl.szczodrzynski.edziennik.getInt
|
||||||
|
import pl.szczodrzynski.edziennik.getJsonObject
|
||||||
|
import pl.szczodrzynski.edziennik.toHexString
|
||||||
|
import pl.szczodrzynski.edziennik.utils.Utils
|
||||||
|
import java.security.MessageDigest
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
open class PodlasieApi(open val data: DataPodlasie, open val lastSync: Long?) {
|
||||||
|
companion object {
|
||||||
|
const val TAG = "PodlasieApi"
|
||||||
|
}
|
||||||
|
|
||||||
|
val profileId
|
||||||
|
get() = data.profile?.id ?: -1
|
||||||
|
|
||||||
|
val profile
|
||||||
|
get() = data.profile
|
||||||
|
|
||||||
|
fun apiGet(tag: String, endpoint: String, onSuccess: (json: JsonObject) -> Unit) {
|
||||||
|
val url = PODLASIE_API_URL + endpoint
|
||||||
|
|
||||||
|
Utils.d(tag, "Request: Podlasie/Api - $url")
|
||||||
|
|
||||||
|
if (data.apiToken == null) {
|
||||||
|
data.error(tag, ERROR_PODLASIE_API_NO_TOKEN)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val callback = object : JsonCallbackHandler() {
|
||||||
|
override fun onSuccess(json: JsonObject?, response: Response?) {
|
||||||
|
if (json == null || response == null) {
|
||||||
|
data.error(ApiError(TAG, ERROR_RESPONSE_EMPTY)
|
||||||
|
.withResponse(response))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val error = json.getJsonObject("system_message")?.getInt("code")
|
||||||
|
|
||||||
|
error?.let { code ->
|
||||||
|
when (code) {
|
||||||
|
0 -> ERROR_PODLASIE_API_DATA_MISSING
|
||||||
|
4 -> ERROR_LOGIN_PODLASIE_API_DEVICE_LIMIT
|
||||||
|
5 -> ERROR_LOGIN_PODLASIE_API_INVALID_TOKEN
|
||||||
|
200 -> null // Not an error
|
||||||
|
else -> ERROR_PODLASIE_API_OTHER
|
||||||
|
}?.let { errorCode ->
|
||||||
|
data.error(ApiError(tag, errorCode)
|
||||||
|
.withApiResponse(json)
|
||||||
|
.withResponse(response))
|
||||||
|
return@onSuccess
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
onSuccess(json)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
data.error(ApiError(tag, EXCEPTION_PODLASIE_API_REQUEST)
|
||||||
|
.withResponse(response)
|
||||||
|
.withThrowable(e)
|
||||||
|
.withApiResponse(json))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(response: Response?, throwable: Throwable?) {
|
||||||
|
data.error(ApiError(tag, ERROR_REQUEST_FAILURE)
|
||||||
|
.withResponse(response)
|
||||||
|
.withThrowable(throwable))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Request.builder()
|
||||||
|
.url(url)
|
||||||
|
.userAgent(SYSTEM_USER_AGENT)
|
||||||
|
.requestParams(RequestParams(mapOf(
|
||||||
|
"token" to data.apiToken,
|
||||||
|
"securityToken" to getSecurityToken(),
|
||||||
|
"mobileId" to data.app.deviceId,
|
||||||
|
"ver" to PODLASIE_API_VERSION
|
||||||
|
)))
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
.enqueue()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getSecurityToken(): String {
|
||||||
|
val format = SimpleDateFormat("yyyy-MM-dd HH", Locale.ENGLISH)
|
||||||
|
.also { it.timeZone = TimeZone.getTimeZone("Europe/Warsaw") }.format(System.currentTimeMillis())
|
||||||
|
val instance = MessageDigest.getInstance("SHA-256")
|
||||||
|
val digest = instance.digest("-EYlwYu8u16miVd8tT?oO7cvoUVQrQN0vr!$format".toByteArray()).toHexString()
|
||||||
|
val digest2 = instance.digest(data.apiToken!!.toByteArray()).toHexString()
|
||||||
|
return instance.digest("$digest$digest2".toByteArray()).toHexString()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data
|
||||||
|
|
||||||
|
import pl.szczodrzynski.edziennik.R
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.ENDPOINT_PODLASIE_API_MAIN
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.api.PodlasieApiMain
|
||||||
|
import pl.szczodrzynski.edziennik.utils.Utils
|
||||||
|
|
||||||
|
class PodlasieData(val data: DataPodlasie, val onSuccess: () -> Unit) {
|
||||||
|
companion object {
|
||||||
|
const val TAG = "PodlasieData"
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
nextEndpoint(onSuccess)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun nextEndpoint(onSuccess: () -> Unit) {
|
||||||
|
if (data.targetEndpointIds.isEmpty()) {
|
||||||
|
onSuccess()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (data.cancelled) {
|
||||||
|
onSuccess()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val id = data.targetEndpointIds.firstKey()
|
||||||
|
val lastSync = data.targetEndpointIds.remove(id)
|
||||||
|
useEndpoint(id, lastSync) {
|
||||||
|
data.progress(data.progressStep)
|
||||||
|
nextEndpoint(onSuccess)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun useEndpoint(endpointId: Int, lastSync: Long?, onSuccess: (endpointId: Int) -> Unit) {
|
||||||
|
Utils.d(TAG, "Using endpoint $endpointId. Last sync time = $lastSync")
|
||||||
|
when (endpointId) {
|
||||||
|
ENDPOINT_PODLASIE_API_MAIN -> {
|
||||||
|
data.startProgress(R.string.edziennik_progress_endpoint_data)
|
||||||
|
PodlasieApiMain(data, lastSync, onSuccess)
|
||||||
|
}
|
||||||
|
else -> onSuccess(endpointId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-13
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.api
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
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.getLong
|
||||||
|
import pl.szczodrzynski.edziennik.getString
|
||||||
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
|
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class PodlasieApiEvents(val data: DataPodlasie, val rows: List<JsonObject>) {
|
||||||
|
init {
|
||||||
|
rows.forEach { event ->
|
||||||
|
val id = event.getLong("ExternalId") ?: return@forEach
|
||||||
|
val date = event.getString("DateFrom")?.let { Date.fromY_m_d(it) } ?: return@forEach
|
||||||
|
val time = event.getString("DateFrom")?.let { Time.fromY_m_d_H_m_s(it) }
|
||||||
|
?: return@forEach
|
||||||
|
|
||||||
|
val name = event.getString("Name")?.replace(""", "\"") ?: ""
|
||||||
|
val description = event.getString("Description")?.replace(""", "\"") ?: ""
|
||||||
|
|
||||||
|
val type = when (event.getString("Category")?.toLowerCase(Locale.getDefault())) {
|
||||||
|
"klasówka" -> Event.TYPE_EXAM
|
||||||
|
"praca domowa" -> Event.TYPE_HOMEWORK
|
||||||
|
"wycieczka" -> Event.TYPE_EXCURSION
|
||||||
|
else -> Event.TYPE_DEFAULT
|
||||||
|
}
|
||||||
|
|
||||||
|
val teacherFirstName = event.getString("PersonEnteringDataFirstName") ?: return@forEach
|
||||||
|
val teacherLastName = event.getString("PersonEnteringDataLastName") ?: return@forEach
|
||||||
|
val teacher = data.getTeacher(teacherFirstName, teacherLastName)
|
||||||
|
|
||||||
|
val lessonList = data.db.timetableDao().getAllForDateNow(data.profileId, date)
|
||||||
|
val lesson = lessonList.firstOrNull { it.startTime == time }
|
||||||
|
|
||||||
|
val addedDate = event.getString("CreateDate")?.let { Date.fromIso(it) }
|
||||||
|
?: System.currentTimeMillis()
|
||||||
|
|
||||||
|
val eventObject = Event(
|
||||||
|
profileId = data.profileId,
|
||||||
|
id = id,
|
||||||
|
date = date,
|
||||||
|
time = time,
|
||||||
|
topic = name,
|
||||||
|
color = null,
|
||||||
|
type = type,
|
||||||
|
teacherId = teacher.id,
|
||||||
|
subjectId = lesson?.subjectId ?: -1,
|
||||||
|
teamId = data.teamClass?.id ?: -1,
|
||||||
|
addedDate = addedDate
|
||||||
|
).apply {
|
||||||
|
homeworkBody = description
|
||||||
|
}
|
||||||
|
|
||||||
|
data.eventList.add(eventObject)
|
||||||
|
data.metadataList.add(
|
||||||
|
Metadata(
|
||||||
|
data.profileId,
|
||||||
|
Metadata.TYPE_EVENT,
|
||||||
|
id,
|
||||||
|
data.profile?.empty ?: false,
|
||||||
|
data.profile?.empty ?: false
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
data.toRemove.add(DataRemoveModel.Events.future())
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-13
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.api
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
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.Grade.Companion.TYPE_SEMESTER1_FINAL
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_SEMESTER1_PROPOSED
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_SEMESTER2_FINAL
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_SEMESTER2_PROPOSED
|
||||||
|
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.getLong
|
||||||
|
import pl.szczodrzynski.edziennik.getString
|
||||||
|
|
||||||
|
class PodlasieApiFinalGrades(val data: DataPodlasie, val rows: List<JsonObject>) {
|
||||||
|
init { data.profile?.also { profile ->
|
||||||
|
rows.forEach { grade ->
|
||||||
|
val id = grade.getLong("ExternalId") ?: return@forEach
|
||||||
|
val mark = grade.getString("Mark") ?: return@forEach
|
||||||
|
val proposedMark = grade.getString("ProposedMark") ?: "0"
|
||||||
|
val name = data.app.gradesManager.getGradeNumberName(mark)
|
||||||
|
val value = data.app.gradesManager.getGradeValue(name)
|
||||||
|
val semester = grade.getString("TermShortcut")?.length ?: return@forEach
|
||||||
|
|
||||||
|
val typeName = grade.getString("Type") ?: return@forEach
|
||||||
|
val type = when (typeName) {
|
||||||
|
"S" -> if (semester == 1) TYPE_SEMESTER1_FINAL else TYPE_SEMESTER2_FINAL
|
||||||
|
"Y", "R" -> TYPE_YEAR_FINAL
|
||||||
|
else -> return@forEach
|
||||||
|
}
|
||||||
|
|
||||||
|
val subjectName = grade.getString("SchoolSubject") ?: return@forEach
|
||||||
|
val subject = data.getSubject(subjectName)
|
||||||
|
|
||||||
|
val addedDate = if (profile.empty) profile.getSemesterStart(semester).inMillis
|
||||||
|
else System.currentTimeMillis()
|
||||||
|
|
||||||
|
val gradeObject = Grade(
|
||||||
|
profileId = data.profileId,
|
||||||
|
id = id,
|
||||||
|
name = name,
|
||||||
|
type = type,
|
||||||
|
value = value,
|
||||||
|
weight = 0f,
|
||||||
|
color = -1,
|
||||||
|
category = null,
|
||||||
|
description = null,
|
||||||
|
comment = null,
|
||||||
|
semester = semester,
|
||||||
|
teacherId = -1,
|
||||||
|
subjectId = subject.id,
|
||||||
|
addedDate = addedDate
|
||||||
|
)
|
||||||
|
|
||||||
|
data.gradeList.add(gradeObject)
|
||||||
|
data.metadataList.add(
|
||||||
|
Metadata(
|
||||||
|
data.profileId,
|
||||||
|
Metadata.TYPE_GRADE,
|
||||||
|
id,
|
||||||
|
profile.empty,
|
||||||
|
profile.empty
|
||||||
|
))
|
||||||
|
|
||||||
|
if (proposedMark != "0") {
|
||||||
|
val proposedName = data.app.gradesManager.getGradeNumberName(proposedMark)
|
||||||
|
val proposedValue = data.app.gradesManager.getGradeValue(proposedName)
|
||||||
|
|
||||||
|
val proposedType = when (typeName) {
|
||||||
|
"S" -> if (semester == 1) TYPE_SEMESTER1_PROPOSED else TYPE_SEMESTER2_PROPOSED
|
||||||
|
"Y", "R" -> TYPE_YEAR_PROPOSED
|
||||||
|
else -> return@forEach
|
||||||
|
}
|
||||||
|
|
||||||
|
val proposedGradeObject = Grade(
|
||||||
|
profileId = data.profileId,
|
||||||
|
id = id * (-1),
|
||||||
|
name = proposedName,
|
||||||
|
type = proposedType,
|
||||||
|
value = proposedValue,
|
||||||
|
weight = 0f,
|
||||||
|
color = -1,
|
||||||
|
category = null,
|
||||||
|
description = null,
|
||||||
|
comment = null,
|
||||||
|
semester = semester,
|
||||||
|
teacherId = -1,
|
||||||
|
subjectId = subject.id,
|
||||||
|
addedDate = addedDate
|
||||||
|
)
|
||||||
|
|
||||||
|
data.gradeList.add(proposedGradeObject)
|
||||||
|
data.metadataList.add(
|
||||||
|
Metadata(
|
||||||
|
data.profileId,
|
||||||
|
Metadata.TYPE_GRADE,
|
||||||
|
proposedGradeObject.id,
|
||||||
|
profile.empty,
|
||||||
|
profile.empty
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.toRemove.addAll(listOf(
|
||||||
|
TYPE_SEMESTER1_FINAL,
|
||||||
|
TYPE_SEMESTER1_PROPOSED,
|
||||||
|
TYPE_SEMESTER2_FINAL,
|
||||||
|
TYPE_SEMESTER2_PROPOSED,
|
||||||
|
TYPE_YEAR_FINAL,
|
||||||
|
TYPE_YEAR_PROPOSED
|
||||||
|
).map {
|
||||||
|
DataRemoveModel.Grades.allWithType(it)
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-13
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.api
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
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.getFloat
|
||||||
|
import pl.szczodrzynski.edziennik.getInt
|
||||||
|
import pl.szczodrzynski.edziennik.getLong
|
||||||
|
import pl.szczodrzynski.edziennik.getString
|
||||||
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
|
|
||||||
|
class PodlasieApiGrades(val data: DataPodlasie, val rows: List<JsonObject>) {
|
||||||
|
init {
|
||||||
|
rows.forEach { grade ->
|
||||||
|
val id = grade.getLong("ExternalId") ?: return@forEach
|
||||||
|
val name = grade.getString("Mark") ?: return@forEach
|
||||||
|
val value = data.app.gradesManager.getGradeValue(name)
|
||||||
|
val weight = grade.getFloat("Weight") ?: 0f
|
||||||
|
val includeToAverage = grade.getInt("IncludeToAverage") != 0
|
||||||
|
val color = grade.getString("Color")?.let { Color.parseColor(it) } ?: -1
|
||||||
|
val category = grade.getString("Category") ?: ""
|
||||||
|
val comment = grade.getString("Comment") ?: ""
|
||||||
|
val semester = grade.getString("TermShortcut")?.length ?: data.currentSemester
|
||||||
|
|
||||||
|
val teacherFirstName = grade.getString("TeacherFirstName") ?: return@forEach
|
||||||
|
val teacherLastName = grade.getString("TeacherLastName") ?: return@forEach
|
||||||
|
val teacher = data.getTeacher(teacherFirstName, teacherLastName)
|
||||||
|
|
||||||
|
val subjectName = grade.getString("SchoolSubject") ?: return@forEach
|
||||||
|
val subject = data.getSubject(subjectName)
|
||||||
|
|
||||||
|
val addedDate = grade.getString("ReceivedDate")?.let { Date.fromY_m_d(it).inMillis }
|
||||||
|
?: System.currentTimeMillis()
|
||||||
|
|
||||||
|
val gradeObject = Grade(
|
||||||
|
profileId = data.profileId,
|
||||||
|
id = id,
|
||||||
|
name = name,
|
||||||
|
type = Grade.TYPE_NORMAL,
|
||||||
|
value = value,
|
||||||
|
weight = if (includeToAverage) weight else 0f,
|
||||||
|
color = color,
|
||||||
|
category = category,
|
||||||
|
description = null,
|
||||||
|
comment = comment,
|
||||||
|
semester = semester,
|
||||||
|
teacherId = teacher.id,
|
||||||
|
subjectId = subject.id,
|
||||||
|
addedDate = addedDate
|
||||||
|
)
|
||||||
|
|
||||||
|
data.gradeList.add(gradeObject)
|
||||||
|
data.metadataList.add(
|
||||||
|
Metadata(
|
||||||
|
data.profileId,
|
||||||
|
Metadata.TYPE_GRADE,
|
||||||
|
id,
|
||||||
|
data.profile?.empty ?: false,
|
||||||
|
data.profile?.empty ?: false
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
data.toRemove.add(DataRemoveModel.Grades.allWithType(Grade.TYPE_NORMAL))
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-13
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.utils.models.Date
|
||||||
|
|
||||||
|
class PodlasieApiLuckyNumber(val data: DataPodlasie, val luckyNumber: Int) {
|
||||||
|
init {
|
||||||
|
val luckyNumberObject = LuckyNumber(
|
||||||
|
profileId = data.profileId,
|
||||||
|
date = Date.getToday(),
|
||||||
|
number = luckyNumber
|
||||||
|
)
|
||||||
|
|
||||||
|
data.luckyNumberList.add(luckyNumberObject)
|
||||||
|
data.metadataList.add(
|
||||||
|
Metadata(
|
||||||
|
data.profileId,
|
||||||
|
Metadata.TYPE_LUCKY_NUMBER,
|
||||||
|
luckyNumberObject.date.value.toLong(),
|
||||||
|
true,
|
||||||
|
data.profile?.empty ?: false
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.api
|
||||||
|
|
||||||
|
import pl.szczodrzynski.edziennik.asJsonObjectList
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.PODLASIE_API_USER_ENDPOINT
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.ENDPOINT_PODLASIE_API_MAIN
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.PodlasieApi
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||||
|
import pl.szczodrzynski.edziennik.getInt
|
||||||
|
import pl.szczodrzynski.edziennik.getJsonArray
|
||||||
|
|
||||||
|
class PodlasieApiMain(override val data: DataPodlasie,
|
||||||
|
override val lastSync: Long?,
|
||||||
|
val onSuccess: (endpointId: Int) -> Unit) : PodlasieApi(data, lastSync) {
|
||||||
|
companion object {
|
||||||
|
const val TAG = "PodlasieApiTimetable"
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
apiGet(TAG, PODLASIE_API_USER_ENDPOINT) { json ->
|
||||||
|
data.getTeam() // Save the class team when it doesn't exist.
|
||||||
|
|
||||||
|
json.getInt("LuckyNumber")?.let { PodlasieApiLuckyNumber(data, it) }
|
||||||
|
json.getJsonArray("Teacher")?.asJsonObjectList()?.let { PodlasieApiTeachers(data, it) }
|
||||||
|
json.getJsonArray("Timetable")?.asJsonObjectList()?.let { PodlasieApiTimetable(data, it) }
|
||||||
|
json.getJsonArray("Marks")?.asJsonObjectList()?.let { PodlasieApiGrades(data, it) }
|
||||||
|
json.getJsonArray("MarkFinal")?.asJsonObjectList()?.let { PodlasieApiFinalGrades(data, it) }
|
||||||
|
json.getJsonArray("News")?.asJsonObjectList()?.let { PodlasieApiEvents(data, it) }
|
||||||
|
|
||||||
|
data.setSyncNext(ENDPOINT_PODLASIE_API_MAIN, SYNC_ALWAYS)
|
||||||
|
onSuccess(ENDPOINT_PODLASIE_API_MAIN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-13
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.api
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.entity.Teacher
|
||||||
|
import pl.szczodrzynski.edziennik.getInt
|
||||||
|
import pl.szczodrzynski.edziennik.getLong
|
||||||
|
import pl.szczodrzynski.edziennik.getString
|
||||||
|
|
||||||
|
class PodlasieApiTeachers(val data: DataPodlasie, val rows: List<JsonObject>) {
|
||||||
|
init {
|
||||||
|
rows.forEach { teacher ->
|
||||||
|
val id = teacher.getLong("ExternalId") ?: return@forEach
|
||||||
|
val firstName = teacher.getString("FirstName") ?: return@forEach
|
||||||
|
val lastName = teacher.getString("LastName") ?: return@forEach
|
||||||
|
val isEducator = teacher.getInt("Educator") == 1
|
||||||
|
|
||||||
|
val teacherObject = Teacher(
|
||||||
|
profileId = data.profileId,
|
||||||
|
id = id,
|
||||||
|
name = firstName,
|
||||||
|
surname = lastName,
|
||||||
|
loginId = null
|
||||||
|
)
|
||||||
|
|
||||||
|
data.teacherList.put(id, teacherObject)
|
||||||
|
|
||||||
|
val teamClass = data.teamClass
|
||||||
|
if (isEducator && teamClass != null) {
|
||||||
|
data.teamList.put(teamClass.id, teamClass.apply {
|
||||||
|
teacherId = id
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.api
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.models.DataRemoveModel
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
||||||
|
import pl.szczodrzynski.edziennik.getInt
|
||||||
|
import pl.szczodrzynski.edziennik.getString
|
||||||
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
|
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||||
|
import pl.szczodrzynski.edziennik.utils.models.Week
|
||||||
|
|
||||||
|
class PodlasieApiTimetable(val data: DataPodlasie, rows: List<JsonObject>) {
|
||||||
|
init {
|
||||||
|
val currentWeekStart = Week.getWeekStart()
|
||||||
|
|
||||||
|
if (Date.getToday().weekDay > 4) {
|
||||||
|
currentWeekStart.stepForward(0, 0, 7)
|
||||||
|
}
|
||||||
|
|
||||||
|
val getDate = data.arguments?.getString("weekStart") ?: currentWeekStart.stringY_m_d
|
||||||
|
|
||||||
|
val weekStart = Date.fromY_m_d(getDate)
|
||||||
|
val weekEnd = weekStart.clone().stepForward(0, 0, 6)
|
||||||
|
|
||||||
|
val days = mutableListOf<Int>()
|
||||||
|
var startDate: Date? = null
|
||||||
|
var endDate: Date? = null
|
||||||
|
|
||||||
|
rows.forEach { lesson ->
|
||||||
|
val date = lesson.getString("Date")?.let { Date.fromY_m_d(it) } ?: return@forEach
|
||||||
|
|
||||||
|
if ((date > weekEnd || date < weekStart) && data.profile?.empty != true) return@forEach
|
||||||
|
if (startDate == null) startDate = date.clone()
|
||||||
|
endDate = date.clone()
|
||||||
|
if (date.value !in days) days += date.value
|
||||||
|
|
||||||
|
val lessonNumber = lesson.getInt("LessonNumber") ?: return@forEach
|
||||||
|
val startTime = lesson.getString("TimeFrom")?.let { Time.fromH_m_s(it) }
|
||||||
|
?: return@forEach
|
||||||
|
val endTime = lesson.getString("TimeTo")?.let { Time.fromH_m_s(it) } ?: return@forEach
|
||||||
|
val subject = lesson.getString("SchoolSubject")?.let { data.getSubject(it) }
|
||||||
|
?: return@forEach
|
||||||
|
|
||||||
|
val teacherFirstName = lesson.getString("TeacherFirstName") ?: return@forEach
|
||||||
|
val teacherLastName = lesson.getString("TeacherLastName") ?: return@forEach
|
||||||
|
val teacher = data.getTeacher(teacherFirstName, teacherLastName)
|
||||||
|
|
||||||
|
val team = lesson.getString("Group")?.let { data.getTeam(it) } ?: return@forEach
|
||||||
|
val classroom = lesson.getString("Room")
|
||||||
|
|
||||||
|
Lesson(data.profileId, -1).also {
|
||||||
|
it.type = Lesson.TYPE_NORMAL
|
||||||
|
it.date = date
|
||||||
|
it.lessonNumber = lessonNumber
|
||||||
|
it.startTime = startTime
|
||||||
|
it.endTime = endTime
|
||||||
|
it.subjectId = subject.id
|
||||||
|
it.teacherId = teacher.id
|
||||||
|
it.teamId = team.id
|
||||||
|
it.classroom = classroom
|
||||||
|
|
||||||
|
it.id = it.buildId()
|
||||||
|
data.lessonList += it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startDate != null && endDate != null) {
|
||||||
|
if (weekEnd > endDate!!) endDate = weekEnd
|
||||||
|
|
||||||
|
while (startDate!! <= endDate!!) {
|
||||||
|
if (startDate!!.value !in days) {
|
||||||
|
val lessonDate = startDate!!.clone()
|
||||||
|
data.lessonList += Lesson(data.profileId, lessonDate.value.toLong()).apply {
|
||||||
|
type = Lesson.TYPE_NO_LESSONS
|
||||||
|
date = lessonDate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
startDate!!.stepForward(0, 0, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.toRemove.add(DataRemoveModel.Timetable.between(weekStart, weekEnd))
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.firstlogin
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus
|
||||||
|
import pl.szczodrzynski.edziennik.*
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_PODLASIE
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.PODLASIE_API_USER_ENDPOINT
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||||
|
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
|
||||||
|
|
||||||
|
class PodlasieFirstLogin(val data: DataPodlasie, val onSuccess: () -> Unit) {
|
||||||
|
companion object {
|
||||||
|
const val TAG = "PodlasieFirstLogin"
|
||||||
|
}
|
||||||
|
|
||||||
|
private val api = PodlasieApi(data, null)
|
||||||
|
|
||||||
|
init {
|
||||||
|
val loginStoreId = data.loginStore.id
|
||||||
|
val loginStoreType = LOGIN_TYPE_PODLASIE
|
||||||
|
|
||||||
|
PodlasieLoginApi(data) {
|
||||||
|
api.apiGet(TAG, PODLASIE_API_USER_ENDPOINT) { json ->
|
||||||
|
val uuid = json.getString("Uuid")
|
||||||
|
val login = json.getString("Login")
|
||||||
|
val firstName = json.getString("FirstName")
|
||||||
|
val lastName = json.getString("LastName")
|
||||||
|
val studentNameLong = "$firstName $lastName".fixName()
|
||||||
|
val studentNameShort = studentNameLong.getShortName()
|
||||||
|
val schoolName = json.getString("SchoolName")
|
||||||
|
val className = json.getString("SchoolClass")
|
||||||
|
val schoolYear = json.getString("ActualSchoolYear")?.replace(' ', '/')
|
||||||
|
val semester = json.getString("ActualTermShortcut")?.length
|
||||||
|
val apiUrl = json.getString("URL")
|
||||||
|
|
||||||
|
val profile = Profile(
|
||||||
|
loginStoreId,
|
||||||
|
loginStoreId,
|
||||||
|
loginStoreType,
|
||||||
|
studentNameLong,
|
||||||
|
login,
|
||||||
|
studentNameLong,
|
||||||
|
studentNameShort,
|
||||||
|
null
|
||||||
|
).apply {
|
||||||
|
studentData["studentId"] = uuid
|
||||||
|
studentData["studentLogin"] = login
|
||||||
|
studentData["schoolName"] = schoolName
|
||||||
|
studentData["className"] = className
|
||||||
|
studentData["schoolYear"] = schoolYear
|
||||||
|
studentData["currentSemester"] = semester ?: 1
|
||||||
|
studentData["apiUrl"] = apiUrl
|
||||||
|
|
||||||
|
schoolYear?.split('/')?.get(0)?.toInt()?.let {
|
||||||
|
studentSchoolYearStart = it
|
||||||
|
}
|
||||||
|
studentClassName = className
|
||||||
|
}
|
||||||
|
|
||||||
|
EventBus.getDefault().postSticky(FirstLoginFinishedEvent(listOf(profile), data.loginStore))
|
||||||
|
onSuccess()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.utils.Utils
|
||||||
|
|
||||||
|
class PodlasieLogin(val data: DataPodlasie, val onSuccess: () -> Unit) {
|
||||||
|
companion object {
|
||||||
|
const val TAG = "PodlasieLogin"
|
||||||
|
}
|
||||||
|
|
||||||
|
private var cancelled = false
|
||||||
|
|
||||||
|
init {
|
||||||
|
nextLoginMethod(onSuccess)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun nextLoginMethod(onSuccess: () -> Unit) {
|
||||||
|
if (data.targetLoginMethodIds.isEmpty()) {
|
||||||
|
onSuccess()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (cancelled) {
|
||||||
|
onSuccess()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
useLoginMethod(data.targetLoginMethodIds.removeAt(0)) { usedMethodId ->
|
||||||
|
data.progress(data.progressStep)
|
||||||
|
if (usedMethodId != -1)
|
||||||
|
data.loginMethods.add(usedMethodId)
|
||||||
|
nextLoginMethod(onSuccess)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun useLoginMethod(loginMethodId: Int, onSuccess: (usedMethodId: Int) -> Unit) {
|
||||||
|
// this should never be true
|
||||||
|
if (data.loginMethods.contains(loginMethodId)) {
|
||||||
|
onSuccess(-1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Utils.d(TAG, "Using login method $loginMethodId")
|
||||||
|
when (loginMethodId) {
|
||||||
|
LOGIN_METHOD_PODLASIE_API -> {
|
||||||
|
data.startProgress(R.string.edziennik_progress_login_podlasie_api)
|
||||||
|
PodlasieLoginApi(data) { onSuccess(loginMethodId) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.login
|
||||||
|
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.ERROR_LOGIN_DATA_MISSING
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||||
|
|
||||||
|
class PodlasieLoginApi(val data: DataPodlasie, val onSuccess: () -> Unit) {
|
||||||
|
companion object {
|
||||||
|
const val TAG = "PodlasieLoginApi"
|
||||||
|
}
|
||||||
|
|
||||||
|
init { run {
|
||||||
|
if (data.isApiLoginValid()) {
|
||||||
|
onSuccess()
|
||||||
|
} else {
|
||||||
|
data.error(ApiError(TAG, ERROR_LOGIN_DATA_MISSING))
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
}
|
@ -53,12 +53,15 @@ open class DataRemoveModel {
|
|||||||
fun futureExceptType(exceptType: Long) = Events(null, exceptType, null)
|
fun futureExceptType(exceptType: Long) = Events(null, exceptType, null)
|
||||||
fun futureExceptTypes(exceptTypes: List<Long>) = Events(null, null, exceptTypes)
|
fun futureExceptTypes(exceptTypes: List<Long>) = Events(null, null, exceptTypes)
|
||||||
fun futureWithType(type: Long) = Events(type, null, null)
|
fun futureWithType(type: Long) = Events(type, null, null)
|
||||||
|
fun future() = Events(null, null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun commit(profileId: Int, dao: EventDao) {
|
fun commit(profileId: Int, dao: EventDao) {
|
||||||
type?.let { dao.dontKeepFutureWithType(profileId, Date.getToday(), it) }
|
type?.let { dao.dontKeepFutureWithType(profileId, Date.getToday(), it) }
|
||||||
exceptType?.let { dao.dontKeepFutureExceptType(profileId, Date.getToday(), it) }
|
exceptType?.let { dao.dontKeepFutureExceptType(profileId, Date.getToday(), it) }
|
||||||
exceptTypes?.let { dao.dontKeepFutureExceptTypes(profileId, Date.getToday(), it) }
|
exceptTypes?.let { dao.dontKeepFutureExceptTypes(profileId, Date.getToday(), it) }
|
||||||
|
if (type == null && exceptType == null && exceptTypes == null)
|
||||||
|
dao.dontKeepFuture(profileId, Date.getToday())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +114,9 @@ abstract class EventDao : BaseDao<Event, EventFull> {
|
|||||||
" AND " + filter))
|
" AND " + filter))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Query("UPDATE events SET keep = 0 WHERE profileId = :profileId AND eventAddedManually = 0 AND eventDate >= :todayDate")
|
||||||
|
abstract fun dontKeepFuture(profileId: Int, todayDate: Date)
|
||||||
|
|
||||||
@Query("UPDATE events SET keep = 0 WHERE profileId = :profileId AND eventAddedManually = 0 AND eventDate >= :todayDate AND eventType = :type")
|
@Query("UPDATE events SET keep = 0 WHERE profileId = :profileId AND eventAddedManually = 0 AND eventDate >= :todayDate AND eventType = :type")
|
||||||
abstract fun dontKeepFutureWithType(profileId: Int, todayDate: Date, type: Long)
|
abstract fun dontKeepFutureWithType(profileId: Int, todayDate: Date, type: Long)
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import com.google.gson.JsonObject
|
|||||||
import pl.droidsonroids.gif.GifDrawable
|
import pl.droidsonroids.gif.GifDrawable
|
||||||
import pl.szczodrzynski.edziennik.*
|
import pl.szczodrzynski.edziennik.*
|
||||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_EDUDZIENNIK
|
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_EDUDZIENNIK
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_PODLASIE
|
||||||
import pl.szczodrzynski.edziennik.utils.ProfileImageHolder
|
import pl.szczodrzynski.edziennik.utils.ProfileImageHolder
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
import pl.szczodrzynski.navlib.ImageHolder
|
import pl.szczodrzynski.navlib.ImageHolder
|
||||||
@ -175,6 +176,12 @@ open class Profile(
|
|||||||
MainActivity.DRAWER_ITEM_ATTENDANCE,
|
MainActivity.DRAWER_ITEM_ATTENDANCE,
|
||||||
MainActivity.DRAWER_ITEM_ANNOUNCEMENTS
|
MainActivity.DRAWER_ITEM_ANNOUNCEMENTS
|
||||||
)
|
)
|
||||||
|
LOGIN_TYPE_PODLASIE -> listOf(
|
||||||
|
MainActivity.DRAWER_ITEM_TIMETABLE,
|
||||||
|
MainActivity.DRAWER_ITEM_AGENDA,
|
||||||
|
MainActivity.DRAWER_ITEM_GRADES,
|
||||||
|
MainActivity.DRAWER_ITEM_HOMEWORK
|
||||||
|
)
|
||||||
else -> listOf(
|
else -> listOf(
|
||||||
MainActivity.DRAWER_ITEM_TIMETABLE,
|
MainActivity.DRAWER_ITEM_TIMETABLE,
|
||||||
MainActivity.DRAWER_ITEM_AGENDA,
|
MainActivity.DRAWER_ITEM_AGENDA,
|
||||||
|
@ -333,6 +333,34 @@ object LoginInfo {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
),
|
||||||
|
Register(
|
||||||
|
loginType = LOGIN_TYPE_PODLASIE,
|
||||||
|
internalName = "podlasie",
|
||||||
|
registerName = R.string.login_type_podlasie,
|
||||||
|
registerLogo = R.drawable.login_logo_podlasie,
|
||||||
|
loginModes = listOf(
|
||||||
|
Mode(
|
||||||
|
loginMode = LOGIN_MODE_PODLASIE_API,
|
||||||
|
name = R.string.login_mode_podlasie_api,
|
||||||
|
icon = R.drawable.login_mode_podlasie_api,
|
||||||
|
guideText = R.string.login_mode_podlasie_api_guide,
|
||||||
|
credentials = listOf(
|
||||||
|
Credential(
|
||||||
|
keyName = "apiToken",
|
||||||
|
name = R.string.login_hint_token,
|
||||||
|
icon = CommunityMaterial.Icon2.cmd_lock_outline,
|
||||||
|
emptyText = R.string.login_error_no_token,
|
||||||
|
invalidText = R.string.login_error_incorrect_token,
|
||||||
|
errorCodes = mapOf(),
|
||||||
|
isRequired = true,
|
||||||
|
validationRegex = "[a-zA-Z0-9]{10}",
|
||||||
|
caseMode = Credential.CaseMode.UNCHANGED
|
||||||
|
)
|
||||||
|
),
|
||||||
|
errorCodes = mapOf()
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
) }
|
) }
|
||||||
|
|
||||||
|
@ -208,6 +208,30 @@ class GradesManager(val app: App) : CoroutineScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getGradeNumberName(name: String): String {
|
||||||
|
return when(name.toLowerCase()){
|
||||||
|
"niedostateczny", "f" -> "1"
|
||||||
|
"niedostateczny plus", "f+" -> "1+"
|
||||||
|
"niedostateczny minus", "f-" -> "1-"
|
||||||
|
"dopuszczający", "e" -> "2"
|
||||||
|
"dopuszczający plus", "e+" -> "2+"
|
||||||
|
"dopuszczający minus", "e-" -> "2-"
|
||||||
|
"dostateczny", "d" -> "3"
|
||||||
|
"dostateczny plus", "d+" -> "3+"
|
||||||
|
"dostateczny minus", "d-" -> "3-"
|
||||||
|
"dobry", "c" -> "4"
|
||||||
|
"dobry plus", "c+" -> "4+"
|
||||||
|
"dobry minus", "c-" -> "4-"
|
||||||
|
"bardzo dobry", "b" -> "5"
|
||||||
|
"bardzo dobry plus", "b+" -> "5+"
|
||||||
|
"bardzo dobry minus", "b-" -> "5-"
|
||||||
|
"celujący", "a" -> "6"
|
||||||
|
"celujący plus", "a+" -> "6+"
|
||||||
|
"celujący minus", "a-" -> "6-"
|
||||||
|
else -> name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* _ _ _____ _____ _ __ _
|
/* _ _ _____ _____ _ __ _
|
||||||
| | | |_ _| / ____| (_)/ _(_)
|
| | | |_ _| / ____| (_)/ _(_)
|
||||||
| | | | | | | (___ _ __ ___ ___ _| |_ _ ___
|
| | | | | | | (___ _ __ ___ ___ _| |_ _ ___
|
||||||
|
@ -49,6 +49,16 @@ public class Time implements Comparable<Time> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Time fromY_m_d_H_m_s(String dateTime)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return new Time(Integer.parseInt(dateTime.substring(11, 13)), Integer.parseInt(dateTime.substring(14, 16)), Integer.parseInt(dateTime.substring(17, 19)));
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
return new Time(0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public long combineWith(Date date) {
|
public long combineWith(Date date) {
|
||||||
if (date == null) {
|
if (date == null) {
|
||||||
return getInMillis();
|
return getInMillis();
|
||||||
|
BIN
app/src/main/res/drawable-nodpi/login_logo_podlasie.png
Normal file
BIN
app/src/main/res/drawable-nodpi/login_logo_podlasie.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
BIN
app/src/main/res/drawable-xhdpi/login_mode_podlasie_api.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/login_mode_podlasie_api.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
@ -160,6 +160,12 @@
|
|||||||
<string name="error_522" translatable="false">ERROR_EDUDZIENNIK_WEB_SESSION_EXPIRED</string>
|
<string name="error_522" translatable="false">ERROR_EDUDZIENNIK_WEB_SESSION_EXPIRED</string>
|
||||||
<string name="error_530" translatable="false">ERROR_EDUDZIENNIK_WEB_TEAM_MISSING</string>
|
<string name="error_530" translatable="false">ERROR_EDUDZIENNIK_WEB_TEAM_MISSING</string>
|
||||||
|
|
||||||
|
<string name="error_601" translatable="false">ERROR_LOGIN_PODLASIE_API_INVALID_TOKEN</string>
|
||||||
|
<string name="error_602" translatable="false">ERROR_LOGIN_PODLASIE_API_DEVICE_LIMIT</string>
|
||||||
|
<string name="error_630" translatable="false">ERROR_PODLASIE_API_NO_TOKEN</string>
|
||||||
|
<string name="error_631" translatable="false">ERROR_PODLASIE_API_OTHER</string>
|
||||||
|
<string name="error_632" translatable="false">ERROR_PODLASIE_API_DATA_MISSING</string>
|
||||||
|
|
||||||
<string name="error_801" translatable="false">ERROR_TEMPLATE_WEB_OTHER</string>
|
<string name="error_801" translatable="false">ERROR_TEMPLATE_WEB_OTHER</string>
|
||||||
|
|
||||||
<string name="error_900" translatable="false">EXCEPTION_API_TASK</string>
|
<string name="error_900" translatable="false">EXCEPTION_API_TASK</string>
|
||||||
@ -180,6 +186,9 @@
|
|||||||
<string name="error_920" translatable="false">EXCEPTION_EDUDZIENNIK_WEB_REQUEST</string>
|
<string name="error_920" translatable="false">EXCEPTION_EDUDZIENNIK_WEB_REQUEST</string>
|
||||||
<string name="error_921" translatable="false">EXCEPTION_EDUDZIENNIK_FILE_REQUEST</string>
|
<string name="error_921" translatable="false">EXCEPTION_EDUDZIENNIK_FILE_REQUEST</string>
|
||||||
<string name="error_930" translatable="false">ERROR_ONEDRIVE_DOWNLOAD</string>
|
<string name="error_930" translatable="false">ERROR_ONEDRIVE_DOWNLOAD</string>
|
||||||
|
<string name="error_931" translatable="false">EXCEPTION_VULCAN_WEB_LOGIN</string>
|
||||||
|
<string name="error_932" translatable="false">EXCEPTION_VULCAN_WEB_REQUEST</string>
|
||||||
|
<string name="error_940" translatable="false">EXCEPTION_PODLASIE_API_REQUEST</string>
|
||||||
|
|
||||||
<string name="error_1201" translatable="false">LOGIN_NO_ARGUMENTS</string>
|
<string name="error_1201" translatable="false">LOGIN_NO_ARGUMENTS</string>
|
||||||
|
|
||||||
@ -339,6 +348,12 @@
|
|||||||
<string name="error_522_reason">Sesja wygasła</string>
|
<string name="error_522_reason">Sesja wygasła</string>
|
||||||
<string name="error_530_reason">Nie można pobrać informacji o klasie i szkole</string>
|
<string name="error_530_reason">Nie można pobrać informacji o klasie i szkole</string>
|
||||||
|
|
||||||
|
<string name="error_601_reason">Nieprawidłowy token</string>
|
||||||
|
<string name="error_602_reason">Przekroczono maksymalną liczbę urządzeń (5)</string>
|
||||||
|
<string name="error_630_reason">ERROR_PODLASIE_API_NO_TOKEN</string>
|
||||||
|
<string name="error_631_reason">ERROR_PODLASIE_API_OTHER</string>
|
||||||
|
<string name="error_632_reason">Brak danych. Zgłoś błąd programiście.</string>
|
||||||
|
|
||||||
<string name="error_801_reason">ERROR_TEMPLATE_WEB_OTHER</string>
|
<string name="error_801_reason">ERROR_TEMPLATE_WEB_OTHER</string>
|
||||||
|
|
||||||
<string name="error_900_reason">Błąd synchronizacji. Upewnij się, że masz połączenie z internetem, a następnie zgłoś błąd.</string>
|
<string name="error_900_reason">Błąd synchronizacji. Upewnij się, że masz połączenie z internetem, a następnie zgłoś błąd.</string>
|
||||||
@ -359,6 +374,9 @@
|
|||||||
<string name="error_920_reason">Wystąpił błąd</string>
|
<string name="error_920_reason">Wystąpił błąd</string>
|
||||||
<string name="error_921_reason">Wystąpił błąd podczas pobierania pliku</string>
|
<string name="error_921_reason">Wystąpił błąd podczas pobierania pliku</string>
|
||||||
<string name="error_930_reason">Nie udało się pobrać pliku z OneDrive</string>
|
<string name="error_930_reason">Nie udało się pobrać pliku z OneDrive</string>
|
||||||
|
<string name="error_931_reason">EXCEPTION_VULCAN_WEB_LOGIN</string>
|
||||||
|
<string name="error_932_reason">EXCEPTION_VULCAN_WEB_REQUEST</string>
|
||||||
|
<string name="error_940_reason">Zgłoś błąd: wyjątek w API PPE</string>
|
||||||
|
|
||||||
<string name="error_1201_reason">Nie podano parametrów</string>
|
<string name="error_1201_reason">Nie podano parametrów</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1352,4 +1352,8 @@
|
|||||||
<string name="login_mode_edudziennik_web">Zaloguj używając e-maila i hasła</string>
|
<string name="login_mode_edudziennik_web">Zaloguj używając e-maila i hasła</string>
|
||||||
<string name="login_mode_edudziennik_web_hint">Użyj danych, które podajesz na stronie internetowej e-dziennika</string>
|
<string name="login_mode_edudziennik_web_hint">Użyj danych, które podajesz na stronie internetowej e-dziennika</string>
|
||||||
<string name="login_mode_edudziennik_web_guide">Podaj adres e-mail i hasło, których używasz do logowania w przeglądarce na stronie EduDziennika.</string>
|
<string name="login_mode_edudziennik_web_guide">Podaj adres e-mail i hasło, których używasz do logowania w przeglądarce na stronie EduDziennika.</string>
|
||||||
|
<string name="login_type_podlasie">Podlaska Platforma Edukacyjna</string>
|
||||||
|
<string name="login_mode_podlasie_api">Zaloguj używając tokenu</string>
|
||||||
|
<string name="login_mode_podlasie_api_guide">Podaj token aplikacji mobilnej.</string>
|
||||||
|
<string name="edziennik_progress_login_podlasie_api">Logowanie do PPE…</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user