Skip to content

Commit

Permalink
Require username and password to be set when auth type is not NONE
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbakker committed Oct 19, 2024
1 parent 39210f4 commit f64c7f2
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.widget.Toast
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.children
import androidx.core.view.isVisible
import androidx.core.widget.doAfterTextChanged
import androidx.databinding.BindingAdapter
import androidx.databinding.DataBindingUtil
Expand Down Expand Up @@ -82,6 +83,7 @@ class AccountFragment : Fragment() {
if (it.authType == Account.AuthType.NONE) {
it.username = null
it.password = null
binding.invalidateAll()
}
}
updateUserPassVisibility()
Expand Down Expand Up @@ -235,6 +237,26 @@ class AccountFragment : Fragment() {
}
}

if (binding.textLayoutUsername.isVisible && binding.textUsername.text.toString().isBlank()) {
getInputLayout(binding.textUsername).error = getString(R.string.error_field_required)
res = false
} else {
getInputLayout(binding.textUsername).let {
it.error = null
it.isErrorEnabled = false
}
}

if (binding.textLayoutPassword.isVisible && binding.textPassword.text.toString().isBlank()) {
getInputLayout(binding.textPassword).error = getString(R.string.error_field_required)
res = false
} else {
getInputLayout(binding.textPassword).let {
it.error = null
it.isErrorEnabled = false
}
}

try {
val url = binding.textUrl.text.toString().toHttpUrl()
if (clientCert && !url.isHttps) {
Expand Down

0 comments on commit f64c7f2

Please sign in to comment.