forked from github/wulkanowy-mirror
Add register variant auto-matching based on email (#1041)
This commit is contained in:
parent
6ca5e11371
commit
67cef0f6d9
@ -142,7 +142,7 @@ configurations.all {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "io.github.wulkanowy:sdk:bcf6b53"
|
||||
implementation "io.github.wulkanowy:sdk:50c049ef"
|
||||
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
|
||||
|
||||
|
@ -14,7 +14,7 @@ class TimetableRemote @Inject constructor(private val sdk: Sdk) {
|
||||
|
||||
suspend fun getTimetable(student: Student, semester: Semester, startDate: LocalDate, endDate: LocalDate): List<Timetable> {
|
||||
return sdk.init(student).switchDiary(semester.diaryId, semester.schoolYear)
|
||||
.getTimetable(startDate, endDate)
|
||||
.getTimetable(startDate, endDate).first
|
||||
.map {
|
||||
Timetable(
|
||||
studentId = semester.studentId,
|
||||
|
@ -89,6 +89,8 @@ class LoginFormFragment : BaseFragment<FragmentLoginFormBinding>(R.layout.fragme
|
||||
}
|
||||
}
|
||||
|
||||
override fun getHostsValues(): List<String> = hostValues.toList()
|
||||
|
||||
override fun setCredentials(username: String, pass: String) {
|
||||
with(binding) {
|
||||
loginFormUsername.setText(username)
|
||||
@ -96,6 +98,12 @@ class LoginFormFragment : BaseFragment<FragmentLoginFormBinding>(R.layout.fragme
|
||||
}
|
||||
}
|
||||
|
||||
override fun setHost(host: String) {
|
||||
binding.loginFormHost.setText(
|
||||
hostKeys.getOrNull(hostValues.indexOf(host)).orEmpty()
|
||||
)
|
||||
}
|
||||
|
||||
override fun setUsernameLabel(label: String) {
|
||||
binding.loginFormUsernameLayout.hint = label
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.github.wulkanowy.ui.modules.login.form
|
||||
|
||||
import androidx.core.net.toUri
|
||||
import io.github.wulkanowy.data.Status
|
||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
@ -56,7 +57,7 @@ class LoginFormPresenter @Inject constructor(
|
||||
|
||||
fun updateUsernameLabel() {
|
||||
view?.run {
|
||||
setUsernameLabel(if ("standard" in formHostValue) emailLabel else nicknameLabel)
|
||||
setUsernameLabel(if ("login" in formHostValue) nicknameLabel else emailLabel)
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,6 +67,16 @@ class LoginFormPresenter @Inject constructor(
|
||||
|
||||
fun onUsernameTextChanged() {
|
||||
view?.clearUsernameError()
|
||||
|
||||
val username = view?.formUsernameValue.orEmpty().trim()
|
||||
if ("@" in username && "@vulcan" !in username) {
|
||||
val hosts = view?.getHostsValues().orEmpty().map { it.toUri().host to it }.toMap()
|
||||
val usernameHost = username.substringAfter("@")
|
||||
|
||||
hosts[usernameHost]?.let {
|
||||
view?.setHost(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onSignInClick() {
|
||||
@ -135,12 +146,12 @@ class LoginFormPresenter @Inject constructor(
|
||||
view?.setErrorUsernameRequired()
|
||||
isCorrect = false
|
||||
} else {
|
||||
if ("@" in login && "standard" !in host) {
|
||||
if ("@" in login && "login" in host) {
|
||||
view?.setErrorLoginRequired()
|
||||
isCorrect = false
|
||||
}
|
||||
|
||||
if ("@" !in login && "standard" in host) {
|
||||
if ("@" !in login && "email" in host) {
|
||||
view?.setErrorEmailRequired()
|
||||
isCorrect = false
|
||||
}
|
||||
|
@ -19,8 +19,12 @@ interface LoginFormView : BaseView {
|
||||
|
||||
val emailLabel: String
|
||||
|
||||
fun getHostsValues(): List<String>
|
||||
|
||||
fun setCredentials(username: String, pass: String)
|
||||
|
||||
fun setHost(host: String)
|
||||
|
||||
fun setUsernameLabel(label: String)
|
||||
|
||||
fun setErrorUsernameRequired()
|
||||
|
@ -22,25 +22,25 @@
|
||||
<item>Fakelog</item>
|
||||
</string-array>
|
||||
<string-array name="hosts_values">
|
||||
<item>https://vulcan.net.pl/?standard</item>
|
||||
<item>https://vulcan.net.pl/?email</item>
|
||||
<item>https://eszkola.opolskie.pl</item>
|
||||
<item>https://edu.gdansk.pl</item>
|
||||
<item>https://edu.lublin.eu</item>
|
||||
<item>https://umt.tarnow.pl</item>
|
||||
<item>https://resman.pl</item>
|
||||
<item>https://eduportal.koszalin.pl</item>
|
||||
<item>https://vulcan.net.pl/</item>
|
||||
<item>https://vulcan.net.pl/</item>
|
||||
<item>https://vulcan.net.pl/</item>
|
||||
<item>https://vulcan.net.pl/</item>
|
||||
<item>https://vulcan.net.pl/</item>
|
||||
<item>https://vulcan.net.pl/</item>
|
||||
<item>https://vulcan.net.pl/</item>
|
||||
<item>https://vulcan.net.pl/</item>
|
||||
<item>https://vulcan.net.pl/</item>
|
||||
<item>https://vulcan.net.pl/</item>
|
||||
<item>https://vulcan.net.pl/</item>
|
||||
<item>http://fakelog.tk/?standard</item>
|
||||
<item>https://vulcan.net.pl/?login</item>
|
||||
<item>https://vulcan.net.pl/?login</item>
|
||||
<item>https://vulcan.net.pl/?login</item>
|
||||
<item>https://vulcan.net.pl/?login</item>
|
||||
<item>https://vulcan.net.pl/?login</item>
|
||||
<item>https://vulcan.net.pl/?login</item>
|
||||
<item>https://vulcan.net.pl/?login</item>
|
||||
<item>https://vulcan.net.pl/?login</item>
|
||||
<item>https://vulcan.net.pl/?login</item>
|
||||
<item>https://vulcan.net.pl/?login</item>
|
||||
<item>https://vulcan.net.pl/?login</item>
|
||||
<item>http://fakelog.cf/?email</item>
|
||||
</string-array>
|
||||
<string-array name="hosts_symbols">
|
||||
<item>Default</item>
|
||||
|
@ -39,10 +39,10 @@ class TimetableRemoteTest {
|
||||
of(2018, 9, 10),
|
||||
of(2018, 9, 15)
|
||||
)
|
||||
} returns listOf(
|
||||
} returns (listOf(
|
||||
getTimetable(of(2018, 9, 10)),
|
||||
getTimetable(of(2018, 9, 17))
|
||||
)
|
||||
) to emptyList())
|
||||
|
||||
every { semesterMock.studentId } returns 1
|
||||
every { semesterMock.diaryId } returns 1
|
||||
|
Loading…
Reference in New Issue
Block a user