forked from github/szkolny
[API/Edudziennik] Add userCode
This commit is contained in:
parent
e04b519e9b
commit
f40cd7f26c
@ -75,6 +75,11 @@ class DataEdudziennik(app: App, profile: Profile?, loginStore: LoginStore) : Dat
|
|||||||
| | | | __| '_ \ / _ \ '__|
|
| | | | __| '_ \ / _ \ '__|
|
||||||
| |__| | |_| | | | __/ |
|
| |__| | |_| | | | __/ |
|
||||||
\____/ \__|_| |_|\___|*/
|
\____/ \__|_| |_|\___|*/
|
||||||
|
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 mTimetableNotPublic: Boolean? = null
|
private var mTimetableNotPublic: Boolean? = null
|
||||||
var timetableNotPublic: Boolean
|
var timetableNotPublic: Boolean
|
||||||
get() { mTimetableNotPublic = mTimetableNotPublic ?: profile?.getStudentData("timetableNotPublic", false); return mTimetableNotPublic ?: false }
|
get() { mTimetableNotPublic = mTimetableNotPublic ?: profile?.getStudentData("timetableNotPublic", false); return mTimetableNotPublic ?: false }
|
||||||
|
@ -20,21 +20,24 @@ class EdudziennikWebStartInfo(val data: DataEdudziennik, val text: String) {
|
|||||||
|
|
||||||
init { run {
|
init { run {
|
||||||
val schoolId = Regexes.EDUDZIENNIK_SCHOOL_DETAIL_ID.find(text)?.get(1)?.trim()
|
val schoolId = Regexes.EDUDZIENNIK_SCHOOL_DETAIL_ID.find(text)?.get(1)?.trim()
|
||||||
val schoolName = Regexes.EDUDZIENNIK_SCHOOL_DETAIL_NAME.find(text)?.get(1)?.trim()
|
val schoolLongName = Regexes.EDUDZIENNIK_SCHOOL_DETAIL_NAME.find(text)?.get(1)?.trim()
|
||||||
data.schoolId = schoolId
|
data.schoolId = schoolId
|
||||||
|
|
||||||
val classId = Regexes.EDUDZIENNIK_CLASS_DETAIL_ID.find(text)?.get(1)?.trim()
|
val classId = Regexes.EDUDZIENNIK_CLASS_DETAIL_ID.find(text)?.get(1)?.trim()
|
||||||
val className = Regexes.EDUDZIENNIK_CLASS_DETAIL_NAME.find(text)?.get(1)?.trim()
|
val className = Regexes.EDUDZIENNIK_CLASS_DETAIL_NAME.find(text)?.get(1)?.trim()
|
||||||
data.classId = classId
|
data.classId = classId
|
||||||
|
|
||||||
if (classId == null || className == null || schoolId == null || schoolName == null) {
|
if (classId == null || className == null || schoolId == null || schoolLongName == null) {
|
||||||
data.error(ApiError(TAG, ERROR_EDUDZIENNIK_WEB_TEAM_MISSING)
|
data.error(ApiError(TAG, ERROR_EDUDZIENNIK_WEB_TEAM_MISSING)
|
||||||
.withApiResponse(text))
|
.withApiResponse(text))
|
||||||
return@run
|
return@run
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val schoolName = schoolId.crc32().toString() + schoolLongName.firstLettersName + "_edu"
|
||||||
|
data.schoolName = schoolName
|
||||||
|
|
||||||
val teamId = classId.crc32()
|
val teamId = classId.crc32()
|
||||||
val teamCode = schoolId.crc32().toString() + schoolName.firstLettersName + "_edu:" + className
|
val teamCode = "$schoolName:$className"
|
||||||
|
|
||||||
val teamObject = Team(
|
val teamObject = Team(
|
||||||
data.profileId,
|
data.profileId,
|
||||||
|
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_GRADES
|
|||||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_HOMEWORK
|
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_MESSAGES
|
||||||
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_TIMETABLE
|
import pl.szczodrzynski.edziennik.MainActivity.Companion.DRAWER_ITEM_TIMETABLE
|
||||||
|
import pl.szczodrzynski.edziennik.crc32
|
||||||
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_EDUDZIENNIK
|
import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_EDUDZIENNIK
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore
|
import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore.*
|
import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore.*
|
||||||
@ -36,6 +37,7 @@ class ProfileFull : Profile {
|
|||||||
LOGIN_TYPE_LIBRUS -> getStudentData("schoolName", "LIBRUS_UN") + ":" + getStudentData("accountLogin", "LIBRUS_LOGIN_UN")
|
LOGIN_TYPE_LIBRUS -> getStudentData("schoolName", "LIBRUS_UN") + ":" + getStudentData("accountLogin", "LIBRUS_LOGIN_UN")
|
||||||
LOGIN_TYPE_IUCZNIOWIE -> getLoginData("schoolName", "IUCZNIOWIE_UN") + ":" + getLoginData("username", "IUCZNIOWIE_UN") + ":" + getStudentData("registerId", -1)
|
LOGIN_TYPE_IUCZNIOWIE -> getLoginData("schoolName", "IUCZNIOWIE_UN") + ":" + getLoginData("username", "IUCZNIOWIE_UN") + ":" + getStudentData("registerId", -1)
|
||||||
LOGIN_TYPE_VULCAN -> getStudentData("schoolName", "VULCAN_UN") + ":" + getStudentData("studentId", -1)
|
LOGIN_TYPE_VULCAN -> getStudentData("schoolName", "VULCAN_UN") + ":" + getStudentData("studentId", -1)
|
||||||
|
LOGIN_TYPE_EDUDZIENNIK -> getStudentData("schoolName", "EDU_UN") + ":" + getLoginData("email", "EDU_UN") + ":" + getStudentData("studentId", null)?.crc32()
|
||||||
LOGIN_TYPE_DEMO -> getLoginData("serverName", "DEMO_UN") + ":" + getLoginData("username", "DEMO_UN") + ":" + getStudentData("studentId", -1)
|
LOGIN_TYPE_DEMO -> getLoginData("serverName", "DEMO_UN") + ":" + getLoginData("username", "DEMO_UN") + ":" + getStudentData("studentId", -1)
|
||||||
else -> "TYPE_UNKNOWN"
|
else -> "TYPE_UNKNOWN"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user