Temporary fix to show error when user is creating an account on matrix.org with userId containing only digits (#1410)

This commit is contained in:
Benoit Marty 2020-05-27 16:12:06 +02:00
parent 55bd346cb2
commit 0fd50892af
3 changed files with 10 additions and 3 deletions

View file

@ -1,9 +1,6 @@
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173"> <code_scheme name="Project" version="173">
<option name="RIGHT_MARGIN" value="160" /> <option name="RIGHT_MARGIN" value="160" />
<AndroidXmlCodeStyleSettings>
<option name="ARRANGEMENT_SETTINGS_MIGRATED_TO_191" value="true" />
</AndroidXmlCodeStyleSettings>
<JetCodeStyleSettings> <JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS"> <option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value> <value>

View file

@ -11,6 +11,7 @@ Improvements 🙌:
Bugfix 🐛: Bugfix 🐛:
- Switch theme is not fully taken into account without restarting the app - Switch theme is not fully taken into account without restarting the app
- Temporary fix to show error when user is creating an account on matrix.org with userId containing only digits (#1410)
Translations 🗣: Translations 🗣:
- -

View file

@ -21,6 +21,7 @@ import android.os.Bundle
import android.view.View import android.view.View
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import androidx.autofill.HintConstants import androidx.autofill.HintConstants
import androidx.core.text.isDigitsOnly
import androidx.core.view.isVisible import androidx.core.view.isVisible
import butterknife.OnClick import butterknife.OnClick
import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Fail
@ -53,6 +54,9 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {
private var passwordShown = false private var passwordShown = false
private var isSignupMode = false private var isSignupMode = false
// Temporary patch for https://github.com/vector-im/riotX-android/issues/1410,
// waiting for https://github.com/matrix-org/synapse/issues/7576
private var isNumericOnlyUserIdForbidden = false
override fun getLayoutResId() = R.layout.fragment_login override fun getLayoutResId() = R.layout.fragment_login
@ -101,6 +105,10 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {
loginFieldTil.error = getString(if (isSignupMode) R.string.error_empty_field_choose_user_name else R.string.error_empty_field_enter_user_name) loginFieldTil.error = getString(if (isSignupMode) R.string.error_empty_field_choose_user_name else R.string.error_empty_field_enter_user_name)
error++ error++
} }
if (isSignupMode && isNumericOnlyUserIdForbidden && login.isDigitsOnly()) {
loginFieldTil.error = "The homeserver does not accept username with only digits."
error++
}
if (password.isEmpty()) { if (password.isEmpty()) {
passwordFieldTil.error = getString(if (isSignupMode) R.string.error_empty_field_choose_password else R.string.error_empty_field_your_password) passwordFieldTil.error = getString(if (isSignupMode) R.string.error_empty_field_choose_password else R.string.error_empty_field_your_password)
error++ error++
@ -227,6 +235,7 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {
override fun updateWithState(state: LoginViewState) { override fun updateWithState(state: LoginViewState) {
isSignupMode = state.signMode == SignMode.SignUp isSignupMode = state.signMode == SignMode.SignUp
isNumericOnlyUserIdForbidden = state.serverType == ServerType.MatrixOrg
setupUi(state) setupUi(state)
setupAutoFill(state) setupAutoFill(state)