Commit b7a727f2 authored by Wilko Manger's avatar Wilko Manger

Fix next button staying disable on wrong username

parent 00fe8b78
Pipeline #272 passed with stages
in 3 minutes and 49 seconds
......@@ -21,6 +21,9 @@ package im.pattle.app.ui.start.phase.identity
import android.net.Uri
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.text.method.KeyListener
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -45,6 +48,9 @@ class UsernameFragment : StartBaseFragment() {
override val onKeyboardCompleteAction: () -> Unit = { next() }
// Must change username because the current
var wrongUsername: String? = null
override fun onCreateView(inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?)
......@@ -59,6 +65,27 @@ class UsernameFragment : StartBaseFragment() {
view.usernameInputEditText
.setOnEditorActionListener(onEditorActionListener)
view.usernameInputEditText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?,
start: Int,
count: Int,
after: Int) { }
override fun onTextChanged(s: CharSequence?,
start: Int,
before: Int,
count: Int) { }
override fun afterTextChanged(s: Editable?) {
if (s.toString() != wrongUsername) {
// TODO: Check whether the new username is valid before
// enabling the next button again
view.nextButton.isEnabled = true
}
}
})
view.nextButton.onClick {
next()
}
......@@ -106,6 +133,7 @@ class UsernameFragment : StartBaseFragment() {
if (usernameRegex.matchEntire(username) == null) {
setError(getString(R.string.start_username_error_invalid_username))
wrongUsername = username
return
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment