Login screens: signup signin selection

This commit is contained in:
Benoit Marty 2019-11-14 13:16:01 +01:00
parent fa6a9cab7e
commit da8d6fb4f4
13 changed files with 238 additions and 3 deletions

View file

@ -17,6 +17,8 @@
<w>msisdn</w>
<w>pbkdf</w>
<w>pkcs</w>
<w>signin</w>
<w>signup</w>
</words>
</dictionary>
</component>

View file

@ -25,4 +25,5 @@ sealed class LoginAction : VectorViewModelAction {
data class SsoLoginSuccess(val credentials: Credentials) : LoginAction()
data class InitWith(val loginConfig: LoginConfig) : LoginAction()
data class UpdateServerType(val serverType: ServerType) : LoginAction()
data class UpdateSignMode(val signMode: SignMode) : LoginAction()
}

View file

@ -61,6 +61,7 @@ class LoginActivity : VectorBaseActivity() {
when (it) {
is LoginNavigation.OpenServerSelection -> addFragmentToBackstack(R.id.simpleFragmentContainer, LoginServerSelectionFragment::class.java)
is LoginNavigation.OnServerSelectionDone -> onServerSelectionDone()
is LoginNavigation.OnSignModeSelected -> onSignModeSelected()
is LoginNavigation.OpenSsoLoginFallback -> addFragmentToBackstack(R.id.simpleFragmentContainer, LoginSsoFallbackFragment::class.java)
is LoginNavigation.GoBack -> supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
}
@ -76,11 +77,15 @@ class LoginActivity : VectorBaseActivity() {
}
}
private fun onSignModeSelected() {
// TODO
}
private fun onServerSelectionDone() = withState(loginViewModel) {
when (it.serverType) {
ServerType.MatrixOrg -> addFragmentToBackstack(R.id.simpleFragmentContainer, LoginSignUpSignInSelectionFragment::class.java)
ServerType.Modular,
ServerType.Other -> addFragmentToBackstack(R.id.simpleFragmentContainer, LoginEnterHomeServerFragment::class.java)
ServerType.Other -> Unit // TODO addFragmentToBackstack(R.id.simpleFragmentContainer, LoginEnterHomeServerFragment::class.java)
}
}

View file

@ -22,6 +22,7 @@ import im.vector.riotx.core.platform.VectorSharedAction
sealed class LoginNavigation : VectorSharedAction {
object OpenServerSelection : LoginNavigation()
object OnServerSelectionDone : LoginNavigation()
object OnSignModeSelected : LoginNavigation()
object OpenSsoLoginFallback : LoginNavigation()
object GoBack : LoginNavigation()
}

View file

@ -0,0 +1,70 @@
/*
* 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
import androidx.core.view.isVisible
import butterknife.OnClick
import com.airbnb.mvrx.withState
import im.vector.riotx.R
import kotlinx.android.synthetic.main.fragment_login_signup_signin_selection.*
import javax.inject.Inject
/**
*
*/
class LoginSignUpSignInSelectionFragment @Inject constructor() : AbstractLoginFragment() {
override fun getLayoutResId() = R.layout.fragment_login_signup_signin_selection
private fun updateViews(serverType: ServerType) {
when (serverType) {
ServerType.MatrixOrg -> {
loginSignupSigninServerIcon.setImageResource(R.drawable.ic_logo_matrix_org)
loginSignupSigninServerIcon.isVisible = true
loginSignupSigninTitle.text = getString(R.string.login_connect_to, "matrix.org")
loginSignupSigninText.text = getString(R.string.login_server_matrix_org_text)
}
ServerType.Modular -> {
loginSignupSigninServerIcon.setImageResource(R.drawable.ic_logo_modular)
loginSignupSigninServerIcon.isVisible = true
loginSignupSigninTitle.text = getString(R.string.login_connect_to, "TODO MODULAR NAME")
loginSignupSigninText.text = "TODO MODULAR URL"
}
ServerType.Other -> {
loginSignupSigninServerIcon.isVisible = false
loginSignupSigninTitle.text = getString(R.string.login_server_other_title)
loginSignupSigninText.text = "TODO SERVER URL"
}
}
}
@OnClick(R.id.loginSignupSigninSignUp)
fun signUp() {
viewModel.handle(LoginAction.UpdateSignMode(SignMode.SignUp))
loginSharedActionViewModel.post(LoginNavigation.OnSignModeSelected)
}
@OnClick(R.id.loginSignupSigninSignIn)
fun signIn() {
viewModel.handle(LoginAction.UpdateSignMode(SignMode.SignIn))
loginSharedActionViewModel.post(LoginNavigation.OnSignModeSelected)
}
override fun invalidate() = withState(viewModel) {
updateViews(it.serverType)
}
}

View file

@ -63,6 +63,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
override fun handle(action: LoginAction) {
when (action) {
is LoginAction.UpdateServerType -> handleUpdateServerType(action)
is LoginAction.UpdateSignMode -> handleUpdateSignMode(action)
is LoginAction.InitWith -> handleInitWith(action)
is LoginAction.UpdateHomeServer -> handleUpdateHomeserver(action)
is LoginAction.Login -> handleLogin(action)
@ -70,6 +71,14 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
}
}
private fun handleUpdateSignMode(action: LoginAction.UpdateSignMode) {
setState {
copy(
signMode = action.signMode
)
}
}
private fun handleUpdateServerType(action: LoginAction.UpdateServerType) {
setState {
copy(

View file

@ -22,6 +22,7 @@ import com.airbnb.mvrx.Uninitialized
data class LoginViewState(
val serverType: ServerType = ServerType.MatrixOrg,
val signMode: SignMode = SignMode.SignUp,
val asyncLoginAction: Async<Unit> = Uninitialized,
val asyncHomeServerLoginFlowRequest: Async<LoginMode> = Uninitialized
) : MvRxState

View file

@ -0,0 +1,24 @@
/*
* 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
enum class SignMode {
// Account creation
SignUp,
// Login
SignIn
}

View file

@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="74dp"
android:height="20dp"
android:viewportWidth="74"
android:viewportHeight="20">
<path
android:pathData="M0.638,0.57v18.85h1.355v0.451H0.117V0.117h1.876V0.57zM5.861,6.545V7.5h0.028c0.254,-0.363 0.56,-0.645 0.919,-0.845 0.359,-0.2 0.77,-0.3 1.233,-0.3 0.444,0 0.85,0.087 1.219,0.26 0.367,0.172 0.647,0.476 0.837,0.912 0.209,-0.308 0.493,-0.581 0.852,-0.817 0.358,-0.236 0.783,-0.355 1.273,-0.355 0.372,0 0.717,0.046 1.035,0.137 0.318,0.09 0.59,0.236 0.817,0.436 0.227,0.2 0.404,0.461 0.532,0.783 0.127,0.323 0.19,0.711 0.19,1.166v4.714h-1.934V9.598c0,-0.236 -0.009,-0.46 -0.027,-0.668a1.423,1.423 0,0 0,-0.15 -0.545,0.91 0.91,0 0,0 -0.36,-0.368c-0.16,-0.09 -0.375,-0.136 -0.648,-0.136 -0.272,0 -0.492,0.052 -0.66,0.156 -0.169,0.105 -0.3,0.241 -0.395,0.41a1.638,1.638 0,0 0,-0.191 0.572c-0.032,0.213 -0.048,0.429 -0.048,0.647v3.924H8.45V9.64c0,-0.21 -0.004,-0.416 -0.013,-0.62a1.743,1.743 0,0 0,-0.116 -0.566,0.872 0.872,0 0,0 -0.34,-0.416c-0.16,-0.104 -0.393,-0.156 -0.702,-0.156 -0.091,0 -0.211,0.02 -0.361,0.061a1.2,1.2 0,0 0,-0.436 0.232c-0.14,0.113 -0.26,0.277 -0.36,0.49 -0.1,0.214 -0.15,0.493 -0.15,0.838v4.088H4.035V6.545h1.825z"
android:fillColor="#2E2F32"
android:fillType="evenOdd"/>
<path
android:pathData="M16.036,7.58c0.2,-0.299 0.454,-0.54 0.762,-0.721a3.322,3.322 0,0 1,1.042 -0.389,5.928 5.928,0 0,1 1.165,-0.116c0.354,0 0.712,0.025 1.076,0.075 0.363,0.05 0.694,0.148 0.994,0.293 0.3,0.146 0.545,0.348 0.735,0.607 0.191,0.259 0.286,0.602 0.286,1.029v3.665c0,0.318 0.019,0.622 0.055,0.913 0.036,0.29 0.1,0.509 0.19,0.654h-1.96a2.738,2.738 0,0 1,-0.137 -0.681c-0.309,0.318 -0.672,0.54 -1.09,0.668 -0.417,0.126 -0.844,0.19 -1.28,0.19 -0.336,0 -0.65,-0.04 -0.94,-0.122a2.147,2.147 0,0 1,-0.762 -0.382,1.773 1.773,0 0,1 -0.511,-0.654 2.213,2.213 0,0 1,-0.184 -0.94c0,-0.4 0.07,-0.73 0.211,-0.988 0.14,-0.259 0.322,-0.466 0.545,-0.62 0.222,-0.155 0.477,-0.27 0.763,-0.348 0.286,-0.077 0.574,-0.138 0.865,-0.184 0.29,-0.045 0.576,-0.081 0.858,-0.108a5.17,5.17 0,0 0,0.749 -0.123c0.218,-0.055 0.39,-0.134 0.517,-0.239 0.127,-0.104 0.186,-0.256 0.177,-0.456 0,-0.209 -0.034,-0.375 -0.102,-0.498a0.752,0.752 0,0 0,-0.272 -0.286,1.075 1.075,0 0,0 -0.395,-0.136 3.275,3.275 0,0 0,-0.484 -0.034c-0.38,0 -0.68,0.082 -0.898,0.245 -0.218,0.164 -0.346,0.436 -0.382,0.818h-1.934c0.027,-0.454 0.14,-0.831 0.34,-1.131zM19.856,10.313c-0.123,0.04 -0.254,0.075 -0.395,0.102a5.99,5.99 0,0 1,-0.443 0.068,8.25 8.25,0 0,0 -0.463,0.068 3.475,3.475 0,0 0,-0.429 0.11c-0.14,0.045 -0.263,0.106 -0.367,0.183a0.875,0.875 0,0 0,-0.253 0.293,0.943 0.943,0 0,0 -0.095,0.45c0,0.173 0.032,0.318 0.095,0.436a0.73,0.73 0,0 0,0.26 0.28c0.108,0.067 0.235,0.115 0.38,0.142 0.146,0.028 0.296,0.041 0.45,0.041 0.381,0 0.676,-0.063 0.886,-0.19 0.208,-0.127 0.362,-0.28 0.463,-0.457 0.1,-0.177 0.16,-0.356 0.183,-0.538 0.023,-0.182 0.034,-0.327 0.034,-0.436v-0.722a0.866,0.866 0,0 1,-0.306 0.17z"
android:fillColor="#2E2F32"
android:fillType="nonZero"/>
<path
android:pathData="M27.19,6.545V7.84h-1.416v3.488c0,0.327 0.054,0.545 0.163,0.654 0.109,0.11 0.327,0.164 0.654,0.164 0.109,0 0.213,-0.005 0.313,-0.014 0.1,-0.009 0.195,-0.023 0.286,-0.04v1.498a4.635,4.635 0,0 1,-0.545 0.055c-0.2,0.008 -0.395,0.013 -0.585,0.013 -0.3,0 -0.584,-0.02 -0.852,-0.061a2,2 0,0 1,-0.708 -0.239,1.26 1.26,0 0,1 -0.483,-0.504c-0.118,-0.218 -0.177,-0.504 -0.177,-0.858V7.84h-1.172V6.545h1.172V4.433h1.934v2.112h1.416zM29.955,6.545v1.308h0.027a2.415,2.415 0,0 1,0.899 -1.083c0.2,-0.132 0.413,-0.234 0.64,-0.307a2.31,2.31 0,0 1,0.708 -0.109c0.128,0 0.268,0.023 0.423,0.069V8.22c-0.091,-0.018 -0.2,-0.034 -0.327,-0.047a3.445,3.445 0,0 0,-0.368 -0.02c-0.354,0 -0.654,0.058 -0.899,0.176s-0.442,0.28 -0.592,0.484a1.94,1.94 0,0 0,-0.32 0.715,3.9 3.9,0 0,0 -0.096,0.886v3.175h-1.934V6.545h1.839z"
android:fillColor="#2E2F32"
android:fillType="evenOdd"/>
<path
android:pathData="M33.469,5.455L33.469,3.861h1.934v1.594h-1.934zM35.403,6.545v7.045h-1.934L33.469,6.545h1.934z"
android:fillColor="#2E2F32"
android:fillType="nonZero"/>
<path
android:pathData="M36.41,6.545h2.207l1.24,1.84 1.225,-1.84h2.139l-2.316,3.298 2.602,3.747H41.3l-1.47,-2.22 -1.472,2.22h-2.165l2.533,-3.706zM72.535,19.42V0.57h-1.356V0.117h1.876v19.754H71.18v-0.452z"
android:fillColor="#2E2F32"
android:fillType="evenOdd"/>
<path
android:pathData="M45.454,11.292v2.072h2.112v-2.072zM52.49,6.22c0.548,0 1.043,0.087 1.487,0.262 0.444,0.175 0.823,0.421 1.137,0.74 0.314,0.318 0.556,0.704 0.727,1.157 0.17,0.453 0.255,0.957 0.255,1.513 0,0.556 -0.085,1.059 -0.255,1.507 -0.17,0.449 -0.413,0.832 -0.727,1.15a3.166,3.166 0,0 1,-1.137 0.734,4.12 4.12,0 0,1 -1.487,0.256c-0.547,0 -1.04,-0.086 -1.48,-0.256a3.178,3.178 0,0 1,-1.13 -0.733,3.269 3.269,0 0,1 -0.726,-1.15 4.215,4.215 0,0 1,-0.256 -1.508c0,-0.556 0.085,-1.06 0.256,-1.513 0.17,-0.453 0.412,-0.839 0.726,-1.157 0.314,-0.319 0.69,-0.565 1.13,-0.74 0.44,-0.175 0.933,-0.263 1.48,-0.263zM52.49,7.659c-0.322,0 -0.592,0.065 -0.807,0.195a1.55,1.55 0,0 0,-0.518 0.505c-0.13,0.206 -0.222,0.444 -0.276,0.713a4.175,4.175 0,0 0,0 1.634c0.054,0.265 0.146,0.503 0.276,0.713 0.13,0.211 0.303,0.38 0.518,0.505 0.215,0.126 0.485,0.188 0.807,0.188 0.323,0 0.595,-0.062 0.814,-0.188 0.22,-0.126 0.395,-0.294 0.525,-0.505 0.13,-0.21 0.222,-0.448 0.276,-0.713a4.175,4.175 0,0 0,0 -1.635,2.094 2.094,0 0,0 -0.276,-0.712 1.53,1.53 0,0 0,-0.525 -0.505c-0.22,-0.13 -0.49,-0.195 -0.814,-0.195zM57.334,6.408v6.956h1.91v-3.135c0,-0.314 0.032,-0.606 0.095,-0.875s0.168,-0.504 0.316,-0.706c0.148,-0.202 0.343,-0.361 0.585,-0.478 0.242,-0.116 0.538,-0.175 0.888,-0.175a3.67,3.67 0,0 1,0.686 0.067L61.814,6.288a1.49,1.49 0,0 0,-0.417 -0.068c-0.242,0 -0.475,0.036 -0.7,0.108a2.564,2.564 0,0 0,-0.632 0.303,2.38 2.38,0 0,0 -0.888,1.07h-0.027L59.15,6.407h-1.816zM64.963,6.22c0.457,0 0.859,0.084 1.204,0.255 0.345,0.17 0.635,0.457 0.868,0.861h0.027v-0.928h1.816v6.512c0,0.278 -0.038,0.596 -0.114,0.955 -0.077,0.359 -0.24,0.693 -0.491,1.002 -0.252,0.31 -0.615,0.572 -1.09,0.787 -0.476,0.216 -1.112,0.323 -1.91,0.323a4.45,4.45 0,0 1,-1.043 -0.128,3.312 3.312,0 0,1 -0.97,-0.396 2.38,2.38 0,0 1,-0.726 -0.693,2.009 2.009,0 0,1 -0.33,-1.016h1.898c0.09,0.359 0.264,0.608 0.524,0.747s0.561,0.208 0.902,0.208c0.538,0 0.93,-0.161 1.177,-0.484 0.247,-0.323 0.366,-0.731 0.357,-1.225v-0.915h-0.027c-0.206,0.368 -0.5,0.64 -0.881,0.814a2.854,2.854 0,0 1,-1.205 0.263c-0.52,0 -0.968,-0.092 -1.345,-0.276a2.553,2.553 0,0 1,-0.928 -0.753,3.143 3.143,0 0,1 -0.532,-1.117 5.294,5.294 0,0 1,-0.168 -1.352c0,-0.449 0.065,-0.882 0.195,-1.299 0.13,-0.417 0.32,-0.785 0.572,-1.103 0.251,-0.318 0.563,-0.572 0.935,-0.76 0.372,-0.189 0.8,-0.283 1.285,-0.283zM65.433,7.659c-0.268,0 -0.5,0.054 -0.692,0.161a1.457,1.457 0,0 0,-0.485 0.438c-0.13,0.184 -0.224,0.394 -0.282,0.632a3.124,3.124 0,0 0,-0.088 0.747c0,0.25 0.025,0.5 0.074,0.746 0.05,0.247 0.135,0.47 0.256,0.666 0.121,0.198 0.28,0.36 0.478,0.485 0.197,0.125 0.444,0.188 0.74,0.188 0.269,0 0.507,-0.054 0.713,-0.161 0.206,-0.108 0.377,-0.251 0.511,-0.43 0.135,-0.18 0.236,-0.384 0.303,-0.613 0.067,-0.229 0.1,-0.469 0.1,-0.72 0,-0.287 -0.026,-0.558 -0.08,-0.814a2.034,2.034 0,0 0,-0.27 -0.68,1.393 1.393,0 0,0 -0.497,-0.47c-0.206,-0.117 -0.466,-0.175 -0.78,-0.175z"
android:fillColor="#2E2F32"
android:fillType="nonZero"/>
</vector>

View file

@ -57,12 +57,11 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/loginServerText">
<!-- TODO Icon -->
<ImageView
android:id="@+id/loginServerChoiceMatrixOrgIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_settings_x"
android:src="@drawable/ic_logo_matrix_org"
app:layout_constraintBottom_toTopOf="@+id/loginServerChoiceMatrixOrgText"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

View file

@ -0,0 +1,86 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="36dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="36dp"
android:layout_marginBottom="32dp">
<ImageView
android:id="@+id/loginSignupSigninLogo"
style="@style/LoginTopIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/loginSignupSigninServerIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="172dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/loginSignupSigninLogo"
app:layout_goneMarginTop="172dp"
tools:src="@drawable/ic_logo_matrix_org" />
<TextView
android:id="@+id/loginSignupSigninTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="27dp"
android:textAppearance="@style/TextAppearance.Vector.Login.Title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/loginSignupSigninServerIcon"
tools:text="@string/login_connect_to" />
<TextView
android:id="@+id/loginSignupSigninText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="27dp"
android:gravity="start"
android:textAppearance="@style/TextAppearance.Vector.Login.Text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/loginSignupSigninTitle"
tools:text="@string/login_server_matrix_org_text" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/loginSignupSigninSignUp"
style="@style/Style.Vector.Login.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="38dp"
android:text="@string/login_signup"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/loginSignupSigninText" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/loginSignupSigninSignIn"
style="@style/Style.Vector.Login.Button.Wired"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:text="@string/login_signin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/loginSignupSigninSignUp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -38,5 +38,8 @@
<string name="login_server_other_text">Custom &amp; advanced settings</string>
<string name="login_server_submit">Continue</string>
<string name="login_connect_to">Connect to %1$s</string>
<string name="login_signup">Sign Up</string>
<string name="login_signin">Sign In</string>
</resources>

View file

@ -11,4 +11,8 @@
<item name="android:textAllCaps">false</item>
</style>
<style name="Style.Vector.Login.Button.Wired" parent="VectorButtonStyleFlat">
<item name="android:textAllCaps">false</item>
</style>
</resources>