mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 17:12:44 +01:00
Login improvements (#1645)
This commit is contained in:
parent
39327ff3ea
commit
981d6d559c
@ -205,7 +205,7 @@ class LoginAdvancedFragment :
|
||||
override fun setErrorPassIncorrect(message: String?) {
|
||||
with(binding.loginFormPassLayout) {
|
||||
requestFocus()
|
||||
error = message ?: getString(R.string.login_incorrect_password)
|
||||
error = message ?: getString(R.string.login_incorrect_password_default)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,12 +152,11 @@ class LoginFormFragment : BaseFragment<FragmentLoginFormBinding>(R.layout.fragme
|
||||
}
|
||||
|
||||
override fun setErrorPassIncorrect(message: String?) {
|
||||
val error = message ?: getString(R.string.login_incorrect_password_default)
|
||||
|
||||
with(binding) {
|
||||
loginFormUsernameLayout.error = " "
|
||||
loginFormPassLayout.error = " "
|
||||
loginFormErrorBox.text = getString(R.string.login_incorrect_password, error)
|
||||
loginFormHostLayout.error = " "
|
||||
loginFormErrorBox.text = message ?: getString(R.string.login_incorrect_password_default)
|
||||
loginFormErrorBox.isVisible = true
|
||||
}
|
||||
}
|
||||
@ -178,6 +177,11 @@ class LoginFormFragment : BaseFragment<FragmentLoginFormBinding>(R.layout.fragme
|
||||
binding.loginFormErrorBox.isVisible = false
|
||||
}
|
||||
|
||||
override fun clearHostError() {
|
||||
binding.loginFormHostLayout.error = null
|
||||
binding.loginFormErrorBox.isVisible = false
|
||||
}
|
||||
|
||||
override fun showSoftKeyboard() {
|
||||
activity?.showSoftInput()
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class LoginFormPresenter @Inject constructor(
|
||||
showVersion()
|
||||
|
||||
loginErrorHandler.onBadCredentials = {
|
||||
setErrorPassIncorrect(it)
|
||||
setErrorPassIncorrect(it.takeIf { !it.isNullOrBlank() })
|
||||
showSoftKeyboard()
|
||||
Timber.i("Entered wrong username or password")
|
||||
}
|
||||
@ -49,6 +49,7 @@ class LoginFormPresenter @Inject constructor(
|
||||
view?.apply {
|
||||
clearPassError()
|
||||
clearUsernameError()
|
||||
clearHostError()
|
||||
if (formHostValue.contains("fakelog")) {
|
||||
setCredentials("jan@fakelog.cf", "jan123")
|
||||
}
|
||||
@ -75,7 +76,10 @@ class LoginFormPresenter @Inject constructor(
|
||||
val usernameHost = username.substringAfter("@")
|
||||
|
||||
hosts[usernameHost]?.let {
|
||||
view?.setHost(it)
|
||||
view?.run {
|
||||
setHost(it)
|
||||
clearHostError()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ interface LoginFormView : BaseView {
|
||||
|
||||
fun clearPassError()
|
||||
|
||||
fun clearHostError()
|
||||
|
||||
fun showSoftKeyboard()
|
||||
|
||||
fun hideSoftKeyboard()
|
||||
|
@ -7,6 +7,7 @@ import android.view.View.VISIBLE
|
||||
import android.view.inputmethod.EditorInfo.IME_ACTION_DONE
|
||||
import android.view.inputmethod.EditorInfo.IME_NULL
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.core.text.parseAsHtml
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.github.wulkanowy.R
|
||||
@ -58,7 +59,13 @@ class LoginSymbolFragment :
|
||||
setOnEditorActionListener { _, id, _ ->
|
||||
if (id == IME_ACTION_DONE || id == IME_NULL) loginSymbolSignIn.callOnClick() else false
|
||||
}
|
||||
setAdapter(ArrayAdapter(context, android.R.layout.simple_list_item_1, resources.getStringArray(R.array.symbols_values)))
|
||||
setAdapter(
|
||||
ArrayAdapter(
|
||||
context,
|
||||
android.R.layout.simple_list_item_1,
|
||||
resources.getStringArray(R.array.symbols_values)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,6 +74,10 @@ class LoginSymbolFragment :
|
||||
presenter.onParentInitSymbolView(loginData)
|
||||
}
|
||||
|
||||
override fun setLoginToHeading(login: String) {
|
||||
binding.loginSymbolHeader.text = getString(R.string.login_header_symbol, login).parseAsHtml()
|
||||
}
|
||||
|
||||
override fun setErrorSymbolIncorrect() {
|
||||
binding.loginSymbolNameLayout.apply {
|
||||
requestFocus()
|
||||
@ -127,7 +138,10 @@ class LoginSymbolFragment :
|
||||
}
|
||||
|
||||
override fun openFaqPage() {
|
||||
context?.openInternetBrowser("https://wulkanowy.github.io/czesto-zadawane-pytania/co-to-jest-symbol", ::showMessage)
|
||||
context?.openInternetBrowser(
|
||||
"https://wulkanowy.github.io/czesto-zadawane-pytania/co-to-jest-symbol",
|
||||
::showMessage
|
||||
)
|
||||
}
|
||||
|
||||
override fun openEmail(host: String, lastError: String) {
|
||||
@ -135,7 +149,8 @@ class LoginSymbolFragment :
|
||||
chooserTitle = requireContext().getString(R.string.login_email_intent_title),
|
||||
email = "wulkanowyinc@gmail.com",
|
||||
subject = requireContext().getString(R.string.login_email_subject),
|
||||
body = requireContext().getString(R.string.login_email_text,
|
||||
body = requireContext().getString(
|
||||
R.string.login_email_text,
|
||||
"${appInfo.systemManufacturer} ${appInfo.systemModel}",
|
||||
appInfo.systemVersion.toString(),
|
||||
appInfo.versionName,
|
||||
|
@ -32,6 +32,16 @@ class LoginSymbolPresenter @Inject constructor(
|
||||
}
|
||||
if (savedLoginData is Triple<*, *, *>) {
|
||||
loginData = savedLoginData as Triple<String, String, String>
|
||||
view.setLoginToHeading(requireNotNull(loginData?.first))
|
||||
}
|
||||
}
|
||||
|
||||
fun onParentInitSymbolView(loginData: Triple<String, String, String>) {
|
||||
this.loginData = loginData
|
||||
view?.apply {
|
||||
setLoginToHeading(loginData.first)
|
||||
clearAndFocusSymbol()
|
||||
showSoftKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +57,14 @@ class LoginSymbolPresenter @Inject constructor(
|
||||
return
|
||||
}
|
||||
|
||||
flowWithResource { studentRepository.getStudentsScrapper(loginData!!.first, loginData!!.second, loginData!!.third, symbol) }.onEach {
|
||||
flowWithResource {
|
||||
studentRepository.getStudentsScrapper(
|
||||
email = loginData!!.first,
|
||||
password = loginData!!.second,
|
||||
scrapperBaseUrl = loginData!!.third,
|
||||
symbol = symbol,
|
||||
)
|
||||
}.onEach {
|
||||
when (it.status) {
|
||||
Status.LOADING -> view?.run {
|
||||
Timber.i("Login with symbol started")
|
||||
@ -98,14 +115,6 @@ class LoginSymbolPresenter @Inject constructor(
|
||||
}.launch("login")
|
||||
}
|
||||
|
||||
fun onParentInitSymbolView(loginData: Triple<String, String, String>) {
|
||||
this.loginData = loginData
|
||||
view?.apply {
|
||||
clearAndFocusSymbol()
|
||||
showSoftKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
fun onFaqClick() {
|
||||
view?.openFaqPage()
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ interface LoginSymbolView : BaseView {
|
||||
|
||||
fun initView()
|
||||
|
||||
fun setLoginToHeading(login: String)
|
||||
|
||||
fun setErrorSymbolIncorrect()
|
||||
|
||||
fun setErrorSymbolRequire()
|
||||
|
@ -30,7 +30,7 @@
|
||||
<string name="grade_subtitle">Semestr %1$d, %2$d/%3$d</string>
|
||||
<!--Login-->
|
||||
<string name="login_header_default">Přihlaste se pomocí studentského nebo rodičovského účtu</string>
|
||||
<string name="login_header_symbol">Zadejte symbol ze stránky deníku</string>
|
||||
<string name="login_header_symbol">Zadejte symbol ze stránky deníku: <b>%1$s</b></string>
|
||||
<string name="login_nickname_hint">Uživatelské jméno</string>
|
||||
<string name="login_email_hint">Email</string>
|
||||
<string name="login_login_pesel_email_hint">Přihlášení, číslo PESEL nebo e-mail</string>
|
||||
|
@ -30,7 +30,7 @@
|
||||
<string name="grade_subtitle">Semester %1$d, %2$d/%3$d</string>
|
||||
<!--Login-->
|
||||
<string name="login_header_default">Melden Sie sich mit dem Studenten- oder Elternkonto an</string>
|
||||
<string name="login_header_symbol">Geben Sie das Symbol von der Registerseite ein</string>
|
||||
<string name="login_header_symbol">Geben Sie das Symbol von der Registerseite ein: <b>%1$s</b></string>
|
||||
<string name="login_nickname_hint">Benutzername</string>
|
||||
<string name="login_email_hint">Email</string>
|
||||
<string name="login_login_pesel_email_hint">Anmeldung, PESEL oder e-mail</string>
|
||||
|
@ -30,7 +30,7 @@
|
||||
<string name="grade_subtitle">Semestr %1$d, %2$d/%3$d</string>
|
||||
<!--Login-->
|
||||
<string name="login_header_default">Zaloguj się za pomocą konta ucznia lub rodzica</string>
|
||||
<string name="login_header_symbol">Podaj symbol ze strony dziennika</string>
|
||||
<string name="login_header_symbol">Podaj symbol ze strony dziennika dla konta: <b>%1$s</b></string>
|
||||
<string name="login_nickname_hint">Nazwa użytkownika</string>
|
||||
<string name="login_email_hint">Adres e-mail</string>
|
||||
<string name="login_login_pesel_email_hint">Login, PESEL lub adres e-mail</string>
|
||||
|
@ -30,7 +30,7 @@
|
||||
<string name="grade_subtitle">%1$d семестр, %2$d/%3$d</string>
|
||||
<!--Login-->
|
||||
<string name="login_header_default">Авторизируйтесь при помощи аккаунта ученика или родителя</string>
|
||||
<string name="login_header_symbol">Введите символ со страницы регистрации</string>
|
||||
<string name="login_header_symbol">Введите символ со страницы регистрации: <b>%1$s</b></string>
|
||||
<string name="login_nickname_hint">Имя пользователя</string>
|
||||
<string name="login_email_hint">Электронная почта</string>
|
||||
<string name="login_login_pesel_email_hint">Логин, PESEL или электронная почта</string>
|
||||
|
@ -30,7 +30,7 @@
|
||||
<string name="grade_subtitle">Semester %1$d, %2$d/%3$d</string>
|
||||
<!--Login-->
|
||||
<string name="login_header_default">Prihláste sa pomocou študentského alebo rodičovského konta</string>
|
||||
<string name="login_header_symbol">Zadajte symbol zo stránky denníka</string>
|
||||
<string name="login_header_symbol">Zadajte symbol zo stránky denníka: <b>%1$s</b></string>
|
||||
<string name="login_nickname_hint">Užívateľské meno</string>
|
||||
<string name="login_email_hint">Email</string>
|
||||
<string name="login_login_pesel_email_hint">Prihlásenie, číslo PESEL alebo e-mail</string>
|
||||
|
@ -30,7 +30,7 @@
|
||||
<string name="grade_subtitle">%1$d семестр, %2$d/%3$d</string>
|
||||
<!--Login-->
|
||||
<string name="login_header_default">Авторизуйтеся за допомогою аккаунта учня або батьків</string>
|
||||
<string name="login_header_symbol">Введіть символ зі сторінки реєстру</string>
|
||||
<string name="login_header_symbol">Введіть символ зі сторінки реєстру: <b>%1$s</b></string>
|
||||
<string name="login_nickname_hint">Ім\'я користувача</string>
|
||||
<string name="login_email_hint">Електронна пошта</string>
|
||||
<string name="login_login_pesel_email_hint">Логін, PESEL або електронна пошта</string>
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
<!--Login-->
|
||||
<string name="login_header_default">Sign in with the student or parent account</string>
|
||||
<string name="login_header_symbol">Enter the symbol from the register page</string>
|
||||
<string name="login_header_symbol">Enter the symbol from the register page for account: <b>%1$s</b></string>
|
||||
<string name="login_nickname_hint">Username</string>
|
||||
<string name="login_email_hint">Email</string>
|
||||
<string name="login_login_pesel_email_hint">Login, PESEL or e-mail</string>
|
||||
@ -71,7 +71,7 @@
|
||||
<string name="login_contact_discord">Discord</string>
|
||||
<string name="login_email_intent_title">Send email</string>
|
||||
<string name="login_email_subject" translatable="false">Zgłoszenie: Problemy z logowaniem</string>
|
||||
<string name="login_email_text" translatable="false">Informacje o aplikacji:\n\nUrządzenie: %1$s\nWersja SDK: %2$s\nWersja aplikacji: %3$s\nDodatkowe informacje: %4$s\nOstatni błąd: %5$s\n\nOpis problemu (pełna nazwa szkoły, klasa ucznia): </string>
|
||||
<string name="login_email_text" translatable="false">Informacje o aplikacji:\n\nUrządzenie: %1$s\nWersja SDK: %2$s\nWersja aplikacji: %3$s\nDodatkowe informacje: %4$s\nOstatni błąd: %5$s\n\nPełna nazwa szkoły i klasa ucznia: </string>
|
||||
<string name="login_recover_warning">Make sure you select the correct UONET+ register variation!</string>
|
||||
<string name="login_recover_button">I forgot my password</string>
|
||||
<string name="login_recover_title">Recover your account</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user