Fix some errors

This commit is contained in:
Benoit Marty 2019-11-21 15:52:12 +01:00
parent 9af8355c07
commit edb65f1787
4 changed files with 32 additions and 19 deletions

View File

@ -0,0 +1,20 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.riotx.features.login
// TODO Check the link with Nad
const val MODULAR_LINK = "https://modular.im/?utm_source=riot-web&utm_medium=web&utm_campaign=riot-web-authentication"

View File

@ -191,9 +191,8 @@ class LoginFragment @Inject constructor(
renderPasswordField() renderPasswordField()
} }
is Fail -> { is Fail -> {
// TODO This does not work, we want the error to be on without text. Fix that // Trick to display the error without text.
loginFieldTil.error = "" loginFieldTil.error = " "
// TODO Handle error text properly
passwordFieldTil.error = errorFormatter.toHumanReadable(state.asyncLoginAction.error) passwordFieldTil.error = errorFormatter.toHumanReadable(state.asyncLoginAction.error)
} }
// Success is handled by the LoginActivity // Success is handled by the LoginActivity

View File

@ -68,13 +68,14 @@ class LoginServerSelectionFragment @Inject constructor(
loginServerChoiceModularLearnMore.text = span { loginServerChoiceModularLearnMore.text = span {
text = getString(R.string.login_server_modular_learn_more) text = getString(R.string.login_server_modular_learn_more)
textDecorationLine = "underline" textDecorationLine = "underline"
onClick = {
// TODO this does not work
openUrlInExternalBrowser(requireActivity(), "https://example.org")
}
} }
} }
@OnClick(R.id.loginServerChoiceModularLearnMore)
fun learMore() {
openUrlInExternalBrowser(requireActivity(), MODULAR_LINK)
}
@OnClick(R.id.loginServerChoiceMatrixOrg) @OnClick(R.id.loginServerChoiceMatrixOrg)
fun selectMatrixOrg() { fun selectMatrixOrg() {
if (loginServerChoiceMatrixOrg.isChecked) { if (loginServerChoiceMatrixOrg.isChecked) {

View File

@ -50,15 +50,10 @@ class LoginServerUrlFormFragment @Inject constructor(
} }
private fun setupHomeServerField() { private fun setupHomeServerField() {
// TODO Import code from Riot to clear error on TIL
loginServerUrlFormHomeServerUrl.textChanges() loginServerUrlFormHomeServerUrl.textChanges()
.subscribe( .subscribe {
{ loginServerUrlFormHomeServerUrlTil.error = null
loginServerUrlFormHomeServerUrlTil.error = null }
},
{
// Ignore error
})
.disposeOnDestroyView() .disposeOnDestroyView()
loginServerUrlFormHomeServerUrl.setOnEditorActionListener { _, actionId, _ -> loginServerUrlFormHomeServerUrl.setOnEditorActionListener { _, actionId, _ ->
@ -88,14 +83,13 @@ class LoginServerUrlFormFragment @Inject constructor(
loginServerUrlFormHomeServerUrlTil.hint = getText(R.string.login_server_url_form_other_hint) loginServerUrlFormHomeServerUrlTil.hint = getText(R.string.login_server_url_form_other_hint)
loginServerUrlFormNotice.text = getString(R.string.login_server_url_form_other_notice) loginServerUrlFormNotice.text = getString(R.string.login_server_url_form_other_notice)
} }
else -> error("This fragment should not be display in matrix.org mode") else -> error("This fragment should not be displayed in matrix.org mode")
} }
} }
@OnClick(R.id.loginServerUrlFormLearnMore) @OnClick(R.id.loginServerUrlFormLearnMore)
fun learMore() { fun learMore() {
// TODO openUrlInExternalBrowser(requireActivity(), MODULAR_LINK)
openUrlInExternalBrowser(requireActivity(), "https://example.org")
} }
override fun resetViewModel() { override fun resetViewModel() {
@ -134,7 +128,6 @@ class LoginServerUrlFormFragment @Inject constructor(
override fun invalidate() = withState(loginViewModel) { state -> override fun invalidate() = withState(loginViewModel) { state ->
when (state.asyncHomeServerLoginFlowRequest) { when (state.asyncHomeServerLoginFlowRequest) {
is Fail -> { is Fail -> {
// TODO Error text is not correct
loginServerUrlFormHomeServerUrlTil.error = errorFormatter.toHumanReadable(state.asyncHomeServerLoginFlowRequest.error) loginServerUrlFormHomeServerUrlTil.error = errorFormatter.toHumanReadable(state.asyncHomeServerLoginFlowRequest.error)
} }
is Success -> { is Success -> {