mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-18 21:16:48 -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
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Patterns
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -64,21 +65,36 @@ class LoginSupportDialog : BaseDialogFragment<DialogLoginSupportBinding>() {
|
||||
error = null
|
||||
}
|
||||
}
|
||||
dialogLoginSupportSubmit.setOnClickListener {
|
||||
if (dialogLoginSupportSchoolInput.text.isNullOrBlank()) {
|
||||
with(dialogLoginSupportSchoolLayout) {
|
||||
isErrorEnabled = true
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
} else {
|
||||
onSubmitClick()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
dialogLoginSupportSubmit.setOnClickListener { 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) {
|
||||
context?.openEmailClient(
|
||||
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_symbol_enter">Enter a different symbol</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_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_placeholder">Np. \"Ostatnio zmieniłem szkołę i…\" albo \"Jestem rodzicem i nie widzę drugiego dziecka…\"</string>
|
||||
<string name="login_support_submit">Submit</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user