applying the password character limit to the keyboard done action
This commit is contained in:
parent
e6df2b39b4
commit
2dae13f6c8
@ -75,7 +75,11 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu
|
|||||||
setupSubmitButton()
|
setupSubmitButton()
|
||||||
views.createAccountRoot.realignPercentagesToParent()
|
views.createAccountRoot.realignPercentagesToParent()
|
||||||
views.editServerButton.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.EditServerSelection)) }
|
views.editServerButton.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.EditServerSelection)) }
|
||||||
views.createAccountPasswordInput.setOnImeDoneListener { submit() }
|
views.createAccountPasswordInput.setOnImeDoneListener {
|
||||||
|
if (canSubmit(views.createAccountInput.content(), views.createAccountPasswordInput.content())) {
|
||||||
|
submit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
views.createAccountInput.onTextChange(viewLifecycleOwner) {
|
views.createAccountInput.onTextChange(viewLifecycleOwner) {
|
||||||
viewModel.handle(OnboardingAction.ResetSelectedRegistrationUserName)
|
viewModel.handle(OnboardingAction.ResetSelectedRegistrationUserName)
|
||||||
@ -87,15 +91,19 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun canSubmit(account: CharSequence, password: CharSequence): Boolean {
|
||||||
|
val accountIsValid = account.isNotEmpty()
|
||||||
|
val passwordIsValid = password.length >= MINIMUM_PASSWORD_LENGTH
|
||||||
|
return accountIsValid && passwordIsValid
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupSubmitButton() {
|
private fun setupSubmitButton() {
|
||||||
views.createAccountSubmit.setOnClickListener { submit() }
|
views.createAccountSubmit.setOnClickListener { submit() }
|
||||||
views.createAccountInput.clearErrorOnChange(viewLifecycleOwner)
|
views.createAccountInput.clearErrorOnChange(viewLifecycleOwner)
|
||||||
views.createAccountPasswordInput.clearErrorOnChange(viewLifecycleOwner)
|
views.createAccountPasswordInput.clearErrorOnChange(viewLifecycleOwner)
|
||||||
|
|
||||||
combine(views.createAccountInput.editText().textChanges(), views.createAccountPasswordInput.editText().textChanges()) { account, password ->
|
combine(views.createAccountInput.editText().textChanges(), views.createAccountPasswordInput.editText().textChanges()) { account, password ->
|
||||||
val accountIsValid = account.isNotEmpty()
|
views.createAccountSubmit.isEnabled = canSubmit(account, password)
|
||||||
val passwordIsValid = password.length >= MINIMUM_PASSWORD_LENGTH
|
|
||||||
views.createAccountSubmit.isEnabled = accountIsValid && passwordIsValid
|
|
||||||
}.launchIn(viewLifecycleOwner.lifecycleScope)
|
}.launchIn(viewLifecycleOwner.lifecycleScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user