mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-24 14:58:59 +03:00
Simplify the server selection screen: remove the "Continue" button
This commit is contained in:
parent
b853397c0a
commit
2a68c8d08b
9 changed files with 29 additions and 55 deletions
vector/src/main
|
@ -235,6 +235,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarConfigurable {
|
||||||
ServerType.Other -> addFragmentToBackstack(R.id.loginFragmentContainer,
|
ServerType.Other -> addFragmentToBackstack(R.id.loginFragmentContainer,
|
||||||
LoginServerUrlFormFragment::class.java,
|
LoginServerUrlFormFragment::class.java,
|
||||||
option = commonOption)
|
option = commonOption)
|
||||||
|
ServerType.Unknown -> Unit /* Should not happen */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,7 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {
|
||||||
loginTitle.text = getString(resId, state.homeServerUrl.toReducedUrl())
|
loginTitle.text = getString(resId, state.homeServerUrl.toReducedUrl())
|
||||||
loginNotice.text = getString(R.string.login_server_other_text)
|
loginNotice.text = getString(R.string.login_server_other_text)
|
||||||
}
|
}
|
||||||
|
ServerType.Unknown -> Unit /* Should not happen */
|
||||||
}
|
}
|
||||||
loginPasswordNotice.isVisible = false
|
loginPasswordNotice.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package im.vector.riotx.features.login
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import butterknife.OnClick
|
import butterknife.OnClick
|
||||||
import com.airbnb.mvrx.withState
|
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.utils.openUrlInChromeCustomTab
|
import im.vector.riotx.core.utils.openUrlInChromeCustomTab
|
||||||
import kotlinx.android.synthetic.main.fragment_login_server_selection.*
|
import kotlinx.android.synthetic.main.fragment_login_server_selection.*
|
||||||
|
@ -40,11 +39,7 @@ class LoginServerSelectionFragment @Inject constructor() : AbstractLoginFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSelectedChoice(state: LoginViewState) {
|
private fun updateSelectedChoice(state: LoginViewState) {
|
||||||
state.serverType.let {
|
loginServerChoiceMatrixOrg.isChecked = state.serverType == ServerType.MatrixOrg
|
||||||
loginServerChoiceMatrixOrg.isChecked = it == ServerType.MatrixOrg
|
|
||||||
loginServerChoiceModular.isChecked = it == ServerType.Modular
|
|
||||||
loginServerChoiceOther.isChecked = it == ServerType.Other
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initTextViews() {
|
private fun initTextViews() {
|
||||||
|
@ -61,43 +56,18 @@ class LoginServerSelectionFragment @Inject constructor() : AbstractLoginFragment
|
||||||
|
|
||||||
@OnClick(R.id.loginServerChoiceMatrixOrg)
|
@OnClick(R.id.loginServerChoiceMatrixOrg)
|
||||||
fun selectMatrixOrg() {
|
fun selectMatrixOrg() {
|
||||||
if (loginServerChoiceMatrixOrg.isChecked) {
|
|
||||||
// Consider this is a submit
|
|
||||||
submit()
|
|
||||||
} else {
|
|
||||||
loginViewModel.handle(LoginAction.UpdateServerType(ServerType.MatrixOrg))
|
loginViewModel.handle(LoginAction.UpdateServerType(ServerType.MatrixOrg))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.loginServerChoiceModular)
|
@OnClick(R.id.loginServerChoiceModular)
|
||||||
fun selectModular() {
|
fun selectModular() {
|
||||||
if (loginServerChoiceModular.isChecked) {
|
|
||||||
// Consider this is a submit
|
|
||||||
submit()
|
|
||||||
} else {
|
|
||||||
loginViewModel.handle(LoginAction.UpdateServerType(ServerType.Modular))
|
loginViewModel.handle(LoginAction.UpdateServerType(ServerType.Modular))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.loginServerChoiceOther)
|
@OnClick(R.id.loginServerChoiceOther)
|
||||||
fun selectOther() {
|
fun selectOther() {
|
||||||
if (loginServerChoiceOther.isChecked) {
|
|
||||||
// Consider this is a submit
|
|
||||||
submit()
|
|
||||||
} else {
|
|
||||||
loginViewModel.handle(LoginAction.UpdateServerType(ServerType.Other))
|
loginViewModel.handle(LoginAction.UpdateServerType(ServerType.Other))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.loginServerSubmit)
|
|
||||||
fun submit() = withState(loginViewModel) { state ->
|
|
||||||
if (state.serverType == ServerType.MatrixOrg) {
|
|
||||||
// Request login flow here
|
|
||||||
loginViewModel.handle(LoginAction.UpdateHomeServer(getString(R.string.matrix_org_server_url)))
|
|
||||||
} else {
|
|
||||||
loginViewModel.handle(LoginAction.PostViewEvent(LoginViewEvents.OnServerSelectionDone))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.loginServerIKnowMyIdSubmit)
|
@OnClick(R.id.loginServerIKnowMyIdSubmit)
|
||||||
fun loginWithMatrixId() {
|
fun loginWithMatrixId() {
|
||||||
|
|
|
@ -49,6 +49,7 @@ open class LoginSignUpSignInSelectionFragment @Inject constructor() : AbstractLo
|
||||||
loginSignupSigninTitle.text = getString(R.string.login_server_other_title)
|
loginSignupSigninTitle.text = getString(R.string.login_server_other_title)
|
||||||
loginSignupSigninText.text = getString(R.string.login_connect_to, state.homeServerUrl.toReducedUrl())
|
loginSignupSigninText.text = getString(R.string.login_connect_to, state.homeServerUrl.toReducedUrl())
|
||||||
}
|
}
|
||||||
|
ServerType.Unknown -> Unit /* Should not happen */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -321,7 +321,7 @@ class LoginViewModel @AssistedInject constructor(
|
||||||
LoginAction.ResetHomeServerType -> {
|
LoginAction.ResetHomeServerType -> {
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
serverType = ServerType.MatrixOrg
|
serverType = ServerType.Unknown
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -390,6 +390,15 @@ class LoginViewModel @AssistedInject constructor(
|
||||||
serverType = action.serverType
|
serverType = action.serverType
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
when (action.serverType) {
|
||||||
|
ServerType.Unknown -> Unit /* Should not happen */
|
||||||
|
ServerType.MatrixOrg ->
|
||||||
|
// Request login flow here
|
||||||
|
handle(LoginAction.UpdateHomeServer(stringProvider.getString(R.string.matrix_org_server_url)))
|
||||||
|
ServerType.Modular,
|
||||||
|
ServerType.Other -> _viewEvents.post(LoginViewEvents.OnServerSelectionDone)
|
||||||
|
}.exhaustive
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleInitWith(action: LoginAction.InitWith) {
|
private fun handleInitWith(action: LoginAction.InitWith) {
|
||||||
|
@ -682,7 +691,9 @@ class LoginViewModel @AssistedInject constructor(
|
||||||
_viewEvents.post(LoginViewEvents.Failure(failure))
|
_viewEvents.post(LoginViewEvents.Failure(failure))
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
asyncHomeServerLoginFlowRequest = Uninitialized
|
asyncHomeServerLoginFlowRequest = Uninitialized,
|
||||||
|
// If we were trying to retrieve matrix.org login flow, also reset the serverType
|
||||||
|
serverType = if (serverType == ServerType.MatrixOrg) ServerType.Unknown else serverType
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ data class LoginViewState(
|
||||||
|
|
||||||
// User choices
|
// User choices
|
||||||
@PersistState
|
@PersistState
|
||||||
val serverType: ServerType = ServerType.MatrixOrg,
|
val serverType: ServerType = ServerType.Unknown,
|
||||||
@PersistState
|
@PersistState
|
||||||
val signMode: SignMode = SignMode.Unknown,
|
val signMode: SignMode = SignMode.Unknown,
|
||||||
@PersistState
|
@PersistState
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package im.vector.riotx.features.login
|
package im.vector.riotx.features.login
|
||||||
|
|
||||||
enum class ServerType {
|
enum class ServerType {
|
||||||
|
Unknown,
|
||||||
MatrixOrg,
|
MatrixOrg,
|
||||||
Modular,
|
Modular,
|
||||||
Other
|
Other
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item android:drawable="@drawable/bg_login_server_checked" android:state_checked="true" />
|
<item android:drawable="@drawable/bg_login_server_checked" android:state_checked="true" />
|
||||||
|
<item android:drawable="@drawable/bg_login_server_checked" android:state_pressed="true" />
|
||||||
|
|
||||||
<item android:drawable="@drawable/bg_login_server" />
|
<item android:drawable="@drawable/bg_login_server" />
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/loginServerTitle" />
|
app:layout_constraintTop_toBottomOf="@+id/loginServerTitle" />
|
||||||
|
|
||||||
|
<!-- Use a CheckableConstraintLayout to keep the pressed state when retrieving login flow -->
|
||||||
<im.vector.riotx.core.platform.CheckableConstraintLayout
|
<im.vector.riotx.core.platform.CheckableConstraintLayout
|
||||||
android:id="@+id/loginServerChoiceMatrixOrg"
|
android:id="@+id/loginServerChoiceMatrixOrg"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -84,7 +85,7 @@
|
||||||
|
|
||||||
</im.vector.riotx.core.platform.CheckableConstraintLayout>
|
</im.vector.riotx.core.platform.CheckableConstraintLayout>
|
||||||
|
|
||||||
<im.vector.riotx.core.platform.CheckableConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/loginServerChoiceModular"
|
android:id="@+id/loginServerChoiceModular"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -135,9 +136,9 @@
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@+id/loginServerChoiceModularText" />
|
app:layout_constraintTop_toTopOf="@+id/loginServerChoiceModularText" />
|
||||||
|
|
||||||
</im.vector.riotx.core.platform.CheckableConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<im.vector.riotx.core.platform.CheckableConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/loginServerChoiceOther"
|
android:id="@+id/loginServerChoiceOther"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -178,20 +179,7 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/loginServerChoiceOtherTitle" />
|
app:layout_constraintTop_toBottomOf="@+id/loginServerChoiceOtherTitle" />
|
||||||
|
|
||||||
</im.vector.riotx.core.platform.CheckableConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/loginServerSubmit"
|
|
||||||
style="@style/Style.Vector.Login.Button"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:text="@string/login_continue"
|
|
||||||
android:transitionName="loginSubmitTransition"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/loginServerIKnowMyIdSubmit"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/loginServerChoiceOther" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/loginServerIKnowMyIdSubmit"
|
android:id="@+id/loginServerIKnowMyIdSubmit"
|
||||||
|
@ -204,7 +192,7 @@
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/loginServerSubmit" />
|
app:layout_constraintTop_toBottomOf="@+id/loginServerChoiceOther" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue