Merge pull request #6741 from vector-im/feature/adm/focus-errors
FTUE - Focus errors showing on wrong page
This commit is contained in:
commit
81897a179e
|
@ -0,0 +1 @@
|
||||||
|
Fixes onboarding login/account creation errors showing after navigation
|
|
@ -78,10 +78,14 @@ fun TextInputLayout.setOnImeDoneListener(action: () -> Unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun TextInputLayout.setOnFocusLostListener(action: () -> Unit) {
|
/**
|
||||||
|
* Set a listener for when the input has lost focus, such as moving to the another input field.
|
||||||
|
* The listener is only called when the view is in a resumed state to avoid triggers when exiting a screen.
|
||||||
|
*/
|
||||||
|
fun TextInputLayout.setOnFocusLostListener(lifecycleOwner: LifecycleOwner, action: () -> Unit) {
|
||||||
editText().setOnFocusChangeListener { _, hasFocus ->
|
editText().setOnFocusChangeListener { _, hasFocus ->
|
||||||
when (hasFocus) {
|
when (hasFocus) {
|
||||||
false -> action()
|
false -> lifecycleOwner.lifecycleScope.launchWhenResumed { action() }
|
||||||
else -> {
|
else -> {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,9 @@ class FtueAuthCombinedLoginFragment @Inject constructor(
|
||||||
views.loginRoot.realignPercentagesToParent()
|
views.loginRoot.realignPercentagesToParent()
|
||||||
views.editServerButton.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.EditServerSelection)) }
|
views.editServerButton.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.EditServerSelection)) }
|
||||||
views.loginPasswordInput.setOnImeDoneListener { submit() }
|
views.loginPasswordInput.setOnImeDoneListener { submit() }
|
||||||
views.loginInput.setOnFocusLostListener { viewModel.handle(OnboardingAction.UserNameEnteredAction.Login(views.loginInput.content())) }
|
views.loginInput.setOnFocusLostListener(viewLifecycleOwner) {
|
||||||
|
viewModel.handle(OnboardingAction.UserNameEnteredAction.Login(views.loginInput.content()))
|
||||||
|
}
|
||||||
views.loginForgotPassword.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnForgetPasswordClicked)) }
|
views.loginForgotPassword.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnForgetPasswordClicked)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu
|
||||||
views.createAccountEntryFooter.text = ""
|
views.createAccountEntryFooter.text = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
views.createAccountInput.setOnFocusLostListener {
|
views.createAccountInput.setOnFocusLostListener(viewLifecycleOwner) {
|
||||||
viewModel.handle(OnboardingAction.UserNameEnteredAction.Registration(views.createAccountInput.content()))
|
viewModel.handle(OnboardingAction.UserNameEnteredAction.Registration(views.createAccountInput.content()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,7 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/serverSelectionSpacing">
|
app:layout_constraintTop_toBottomOf="@id/serverSelectionSpacing">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/loginEditText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:imeOptions="actionNext"
|
android:imeOptions="actionNext"
|
||||||
|
@ -176,6 +177,7 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/entrySpacing">
|
app:layout_constraintTop_toBottomOf="@id/entrySpacing">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/loginPasswordEditText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:imeOptions="actionDone"
|
android:imeOptions="actionDone"
|
||||||
|
|
|
@ -145,6 +145,7 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/serverSelectionSpacing">
|
app:layout_constraintTop_toBottomOf="@id/serverSelectionSpacing">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/createAccountEditText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:imeOptions="actionNext"
|
android:imeOptions="actionNext"
|
||||||
|
@ -186,6 +187,7 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/entrySpacing">
|
app:layout_constraintTop_toBottomOf="@id/entrySpacing">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/createAccountPassword"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:imeOptions="actionDone"
|
android:imeOptions="actionDone"
|
||||||
|
|
Loading…
Reference in New Issue