mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 00:06:46 -06:00
Add negative e-mail validation in school input on support dialog (#2315)
This commit is contained in:
parent
d1d665bbdf
commit
c04b3e40d2
@ -1,6 +1,7 @@
|
|||||||
package io.github.wulkanowy.ui.modules.login.support
|
package io.github.wulkanowy.ui.modules.login.support
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Patterns
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@ -64,21 +65,36 @@ class LoginSupportDialog : BaseDialogFragment<DialogLoginSupportBinding>() {
|
|||||||
error = null
|
error = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dialogLoginSupportSubmit.setOnClickListener {
|
dialogLoginSupportSubmit.setOnClickListener { onSubmitClick() }
|
||||||
if (dialogLoginSupportSchoolInput.text.isNullOrBlank()) {
|
|
||||||
with(dialogLoginSupportSchoolLayout) {
|
|
||||||
isErrorEnabled = true
|
|
||||||
error = getString(R.string.error_field_required)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
onSubmitClick()
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onSubmitClick() {
|
private fun onSubmitClick() {
|
||||||
|
when {
|
||||||
|
binding.dialogLoginSupportSchoolInput.text.isNullOrBlank() -> {
|
||||||
|
with(binding.dialogLoginSupportSchoolLayout) {
|
||||||
|
isErrorEnabled = true
|
||||||
|
error = getString(R.string.error_field_required)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Patterns.EMAIL_ADDRESS.matcher(
|
||||||
|
binding.dialogLoginSupportSchoolInput.text.toString()
|
||||||
|
).matches() -> {
|
||||||
|
with(binding.dialogLoginSupportSchoolLayout) {
|
||||||
|
isErrorEnabled = true
|
||||||
|
error = getString(R.string.login_support_school_invalid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
openEmailClientWithFilledTemplate()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun openEmailClientWithFilledTemplate() {
|
||||||
with(binding) {
|
with(binding) {
|
||||||
context?.openEmailClient(
|
context?.openEmailClient(
|
||||||
chooserTitle = requireContext().getString(R.string.login_email_intent_title),
|
chooserTitle = requireContext().getString(R.string.login_email_intent_title),
|
||||||
|
@ -87,8 +87,9 @@
|
|||||||
<string name="login_no_active_student">No active students found</string>
|
<string name="login_no_active_student">No active students found</string>
|
||||||
<string name="login_symbol_enter">Enter a different symbol</string>
|
<string name="login_symbol_enter">Enter a different symbol</string>
|
||||||
<string name="login_support_title">Get help</string>
|
<string name="login_support_title">Get help</string>
|
||||||
<string name="login_support_school_hint">Full school name (required)</string>
|
<string name="login_support_school_hint">Full school name with the town (required)</string>
|
||||||
<string name="login_support_school_placeholder">Np. ZSTiO Jarosław lub SP nr 99 w Łodzi</string>
|
<string name="login_support_school_placeholder">Np. ZSTiO Jarosław lub SP nr 99 w Łodzi</string>
|
||||||
|
<string name="login_support_school_invalid">Enter correct name of the school</string>
|
||||||
<string name="login_support_additional_hint">Additional information in Polish (optional)</string>
|
<string name="login_support_additional_hint">Additional information in Polish (optional)</string>
|
||||||
<string name="login_support_additional_placeholder">Np. \"Ostatnio zmieniłem szkołę i…\" albo \"Jestem rodzicem i nie widzę drugiego dziecka…\"</string>
|
<string name="login_support_additional_placeholder">Np. \"Ostatnio zmieniłem szkołę i…\" albo \"Jestem rodzicem i nie widzę drugiego dziecka…\"</string>
|
||||||
<string name="login_support_submit">Submit</string>
|
<string name="login_support_submit">Submit</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user