diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedFragment.kt
index 99090902..aaea31ec 100644
--- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedFragment.kt
+++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedFragment.kt
@@ -146,6 +146,20 @@ class LoginAdvancedFragment : BaseFragment(), LoginAdvancedView {
}
}
+ override fun setErrorLoginRequired() {
+ with(loginFormUsernameLayout) {
+ requestFocus()
+ error = getString(R.string.login_invalid_login)
+ }
+ }
+
+ override fun setErrorEmailRequired() {
+ with(loginFormUsernameLayout) {
+ requestFocus()
+ error = getString(R.string.login_invalid_email)
+ }
+ }
+
override fun setErrorPassRequired(focus: Boolean) {
with(loginFormPassLayout) {
if (focus) requestFocus()
diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedPresenter.kt
index 212f7b67..3a0d4a0d 100644
--- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedPresenter.kt
+++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedPresenter.kt
@@ -173,6 +173,8 @@ class LoginAdvancedPresenter @Inject constructor(
val login = view?.formUsernameValue.orEmpty()
val password = view?.formPassValue.orEmpty()
+ val host = view?.formHostValue.orEmpty()
+
val pin = view?.formPinValue.orEmpty()
val symbol = view?.formSymbolValue.orEmpty()
val token = view?.formTokenValue.orEmpty()
@@ -196,26 +198,20 @@ class LoginAdvancedPresenter @Inject constructor(
isCorrect = false
}
}
- Sdk.Mode.SCRAPPER -> {
+ Sdk.Mode.HYBRID, Sdk.Mode.SCRAPPER -> {
if (login.isEmpty()) {
view?.setErrorUsernameRequired()
isCorrect = false
- }
+ } else {
+ if ("@" in login && "standard" !in host) {
+ view?.setErrorLoginRequired()
+ isCorrect = false
+ }
- if (password.isEmpty()) {
- view?.setErrorPassRequired(focus = isCorrect)
- isCorrect = false
- }
-
- if (password.length < 6 && password.isNotEmpty()) {
- view?.setErrorPassInvalid(focus = isCorrect)
- isCorrect = false
- }
- }
- Sdk.Mode.HYBRID -> {
- if (login.isEmpty()) {
- view?.setErrorUsernameRequired()
- isCorrect = false
+ if ("@" !in login && "standard" in host) {
+ view?.setErrorEmailRequired()
+ isCorrect = false
+ }
}
if (password.isEmpty()) {
diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedView.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedView.kt
index eb280235..36c9a93f 100644
--- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedView.kt
+++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedView.kt
@@ -41,6 +41,10 @@ interface LoginAdvancedView : BaseView {
fun setErrorUsernameRequired()
+ fun setErrorLoginRequired()
+
+ fun setErrorEmailRequired()
+
fun setErrorPassRequired(focus: Boolean)
fun setErrorPassInvalid(focus: Boolean)
diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt
index 67e8a740..b79da3cc 100644
--- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt
+++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt
@@ -121,6 +121,20 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
}
}
+ override fun setErrorLoginRequired() {
+ with(loginFormUsernameLayout) {
+ requestFocus()
+ error = getString(R.string.login_invalid_login)
+ }
+ }
+
+ override fun setErrorEmailRequired() {
+ with(loginFormUsernameLayout) {
+ requestFocus()
+ error = getString(R.string.login_invalid_email)
+ }
+ }
+
override fun setErrorSymbolRequired(focus: Boolean) {
with(loginFormSymbolLayout) {
if (focus) requestFocus()
diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt
index 6d429285..3ed40539 100644
--- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt
+++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt
@@ -131,6 +131,16 @@ class LoginFormPresenter @Inject constructor(
if (login.isEmpty()) {
view?.setErrorUsernameRequired()
isCorrect = false
+ } else {
+ if ("@" in login && "standard" !in host) {
+ view?.setErrorLoginRequired()
+ isCorrect = false
+ }
+
+ if ("@" !in login && "standard" in host) {
+ view?.setErrorEmailRequired()
+ isCorrect = false
+ }
}
if (password.isEmpty()) {
diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormView.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormView.kt
index 4a570f5c..80cf5844 100644
--- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormView.kt
+++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormView.kt
@@ -31,6 +31,10 @@ interface LoginFormView : BaseView {
fun setErrorUsernameRequired()
+ fun setErrorLoginRequired()
+
+ fun setErrorEmailRequired()
+
fun setErrorSymbolRequired(focus: Boolean)
fun setErrorPassRequired(focus: Boolean)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 9d14bb56..87c90654 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -48,6 +48,7 @@
Ungültige token
Token ist nicht mehr gültig
Ungültige email
+ Ungültige login
Ungültige symbol
Student nicht gefunden. Überprüfen Sie das Symbol
Dieses Datenfeld ist erforderlich
diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml
index af35109f..c80137b1 100644
--- a/app/src/main/res/values-pl/strings.xml
+++ b/app/src/main/res/values-pl/strings.xml
@@ -49,6 +49,7 @@
Nieprawidłowy token
Token stracił ważność
Niepoprawny adres email
+ Niepoprawny login
Niepoprawny symbol
Nie znaleziono ucznia. Sprawdź symbol
To pole jest wymagane
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 5ff83d3e..e5530400 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -49,6 +49,7 @@
Недействительный token
Токен просрочен
Неверный адрес электронной почты
+ Неправильный логин
Недействительный symbol
Не удалось найти ученика. Пожалуйста, проверьте \"symbol\"
Это поле обязательно
diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml
index 47b06ca3..cd1c3b5d 100644
--- a/app/src/main/res/values-uk/strings.xml
+++ b/app/src/main/res/values-uk/strings.xml
@@ -49,6 +49,7 @@
Недійсний PIN
Недійсний token
Недійсна адреса електронної пошти
+ Невірний логін
Токен протермінований
Недійсний symbol
Не вдалося знайти учня. Будь ласка, перевірте \"symbol\"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 21ee8bed..30cc086d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -50,6 +50,7 @@
Invalid token
Token expired
Invalid email
+ Invalid login
Invalid symbol
Student not found. Check the symbol
This field is required
diff --git a/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt b/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt
index 05b543f1..779a605f 100644
--- a/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt
+++ b/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt
@@ -52,7 +52,7 @@ class LoginFormPresenterTest {
fun emptyNicknameLoginTest() {
`when`(loginFormView.formUsernameValue).thenReturn("")
`when`(loginFormView.formPassValue).thenReturn("test123")
- `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf")
+ `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf/?standard")
presenter.onSignInClick()
verify(loginFormView).setErrorUsernameRequired()
@@ -64,7 +64,7 @@ class LoginFormPresenterTest {
fun emptyPassLoginTest() {
`when`(loginFormView.formUsernameValue).thenReturn("@")
`when`(loginFormView.formPassValue).thenReturn("")
- `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf")
+ `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf/?standard")
presenter.onSignInClick()
verify(loginFormView, never()).setErrorUsernameRequired()
@@ -76,7 +76,7 @@ class LoginFormPresenterTest {
fun invalidPassLoginTest() {
`when`(loginFormView.formUsernameValue).thenReturn("@")
`when`(loginFormView.formPassValue).thenReturn("123")
- `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf")
+ `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf/?standard")
presenter.onSignInClick()
verify(loginFormView, never()).setErrorUsernameRequired()
@@ -86,12 +86,12 @@ class LoginFormPresenterTest {
@Test
fun loginTest() {
- val studentTest = Student(email = "test@", password = "123", scrapperBaseUrl = "https://fakelog.cf", loginType = "AUTO", studentName = "", schoolSymbol = "", schoolName = "", studentId = 0, classId = 1, isCurrent = false, symbol = "", registrationDate = now(), className = "", mobileBaseUrl = "", privateKey = "", certificateKey = "", loginMode = "", userLoginId = 0, schoolShortName = "", isParent = false)
+ val studentTest = Student(email = "test@", password = "123", scrapperBaseUrl = "https://fakelog.cf/", loginType = "AUTO", studentName = "", schoolSymbol = "", schoolName = "", studentId = 0, classId = 1, isCurrent = false, symbol = "", registrationDate = now(), className = "", mobileBaseUrl = "", privateKey = "", certificateKey = "", loginMode = "", userLoginId = 0, schoolShortName = "", isParent = false)
doReturn(Single.just(listOf(studentTest))).`when`(repository).getStudentsScrapper(anyString(), anyString(), anyString(), anyString())
`when`(loginFormView.formUsernameValue).thenReturn("@")
`when`(loginFormView.formPassValue).thenReturn("123456")
- `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf")
+ `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf/?standard")
`when`(loginFormView.formSymbolValue).thenReturn("Default")
`when`(loginFormView.formHostSymbol).thenReturn("Default")
presenter.onSignInClick()
@@ -109,7 +109,7 @@ class LoginFormPresenterTest {
.`when`(repository).getStudentsScrapper(anyString(), anyString(), anyString(), anyString())
`when`(loginFormView.formUsernameValue).thenReturn("@")
`when`(loginFormView.formPassValue).thenReturn("123456")
- `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf")
+ `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf/?standard")
`when`(loginFormView.formSymbolValue).thenReturn("Default")
`when`(loginFormView.formHostSymbol).thenReturn("Default")
presenter.onSignInClick()
@@ -127,7 +127,7 @@ class LoginFormPresenterTest {
.`when`(repository).getStudentsScrapper(anyString(), anyString(), anyString(), anyString())
`when`(loginFormView.formUsernameValue).thenReturn("@")
`when`(loginFormView.formPassValue).thenReturn("123456")
- `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf")
+ `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf/?standard")
`when`(loginFormView.formSymbolValue).thenReturn("Default")
`when`(loginFormView.formHostSymbol).thenReturn("Default")
presenter.onSignInClick()
@@ -146,7 +146,7 @@ class LoginFormPresenterTest {
doReturn(Single.error>(testException)).`when`(repository).getStudentsScrapper(anyString(), anyString(), anyString(), anyString())
`when`(loginFormView.formUsernameValue).thenReturn("@")
`when`(loginFormView.formPassValue).thenReturn("123456")
- `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf")
+ `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf/?standard")
`when`(loginFormView.formSymbolValue).thenReturn("Default")
`when`(loginFormView.formHostSymbol).thenReturn("Default")
presenter.onSignInClick()