mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Fix infinite focus on HS field
This commit is contained in:
parent
e04bf31faa
commit
47e3797b7e
3 changed files with 24 additions and 4 deletions
|
@ -18,6 +18,7 @@ package im.vector.riotx.features.login
|
|||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.transition.TransitionManager
|
||||
|
@ -68,12 +69,19 @@ class LoginFragment : VectorBaseFragment() {
|
|||
homeServerField.focusChanges()
|
||||
.subscribe {
|
||||
if (!it) {
|
||||
// TODO Also when clicking on button?
|
||||
viewModel.handle(LoginActions.UpdateHomeServer(homeServerField.text.toString()))
|
||||
}
|
||||
}
|
||||
.disposeOnDestroy()
|
||||
|
||||
homeServerField.setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
viewModel.handle(LoginActions.UpdateHomeServer(homeServerField.text.toString()))
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
return@setOnEditorActionListener false
|
||||
}
|
||||
|
||||
val initHsUrl = viewModel.getInitialHomeServerUrl()
|
||||
if (initHsUrl != null) {
|
||||
homeServerField.setText(initHsUrl)
|
||||
|
@ -170,6 +178,10 @@ class LoginFragment : VectorBaseFragment() {
|
|||
passwordContainer.isVisible = true
|
||||
authenticateButton.isVisible = true
|
||||
authenticateButtonSso.isVisible = false
|
||||
if (loginField.text.isNullOrBlank() && passwordField.text.isNullOrBlank()) {
|
||||
//Jump focus to login
|
||||
loginField.requestFocus()
|
||||
}
|
||||
}
|
||||
LoginMode.Sso -> {
|
||||
loginField.isVisible = false
|
||||
|
|
|
@ -137,16 +137,23 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
|
|||
}
|
||||
|
||||
|
||||
private fun handleUpdateHomeserver(action: LoginActions.UpdateHomeServer) {
|
||||
currentTask?.cancel()
|
||||
private fun handleUpdateHomeserver(action: LoginActions.UpdateHomeServer) = withState { state ->
|
||||
|
||||
var newConfig : HomeServerConnectionConfig? = null
|
||||
Try {
|
||||
val homeServerUri = action.homeServerUrl
|
||||
homeServerConnectionConfig = HomeServerConnectionConfig.Builder()
|
||||
newConfig = HomeServerConnectionConfig.Builder()
|
||||
.withHomeServerUri(homeServerUri)
|
||||
.build()
|
||||
}
|
||||
|
||||
//Do not retry if we already have flows for this config -> causes infinite focus loop
|
||||
if (newConfig?.homeServerUri?.toString() == homeServerConnectionConfig?.homeServerUri?.toString()
|
||||
&& state.asyncHomeServerLoginFlowRequest is Success) return@withState
|
||||
|
||||
currentTask?.cancel()
|
||||
homeServerConnectionConfig = newConfig
|
||||
|
||||
val homeServerConnectionConfigFinal = homeServerConnectionConfig
|
||||
|
||||
if (homeServerConnectionConfigFinal == null) {
|
||||
|
|
|
@ -104,6 +104,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textUri"
|
||||
android:imeOptions="actionDone"
|
||||
android:maxLines="1" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
|
Loading…
Reference in a new issue