diff --git a/.idea/dictionaries/bmarty.xml b/.idea/dictionaries/bmarty.xml index 784e5c1182..7c9f6489ee 100644 --- a/.idea/dictionaries/bmarty.xml +++ b/.idea/dictionaries/bmarty.xml @@ -3,6 +3,7 @@ backstack bytearray + checkables ciphertext coroutine decryptor diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginAction.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginAction.kt index 63d19ea148..8192d26a30 100644 --- a/vector/src/main/java/im/vector/riotx/features/login/LoginAction.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginAction.kt @@ -24,4 +24,5 @@ sealed class LoginAction : VectorViewModelAction { data class Login(val login: String, val password: String) : LoginAction() data class SsoLoginSuccess(val credentials: Credentials) : LoginAction() data class InitWith(val loginConfig: LoginConfig) : LoginAction() + data class UpdateServerType(val serverType: ServerType) : LoginAction() } diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginActivity.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginActivity.kt index d371b459eb..ecf3fa45e2 100644 --- a/vector/src/main/java/im/vector/riotx/features/login/LoginActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginActivity.kt @@ -21,6 +21,7 @@ import android.content.Intent import androidx.fragment.app.FragmentManager import com.airbnb.mvrx.Success import com.airbnb.mvrx.viewModel +import com.airbnb.mvrx.withState import im.vector.riotx.R import im.vector.riotx.core.di.ScreenComponent import im.vector.riotx.core.extensions.addFragment @@ -58,9 +59,10 @@ class LoginActivity : VectorBaseActivity() { loginSharedActionViewModel.observe() .subscribe { when (it) { - is LoginNavigation.OpenServerSelection -> addFragmentToBackstack(R.id.simpleFragmentContainer, LoginFragment::class.java) - is LoginNavigation.OpenSsoLoginFallback -> addFragmentToBackstack(R.id.simpleFragmentContainer, LoginSsoFallbackFragment::class.java) - is LoginNavigation.GoBack -> supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE) + is LoginNavigation.OpenServerSelection -> addFragmentToBackstack(R.id.simpleFragmentContainer, LoginServerSelectionFragment::class.java) + is LoginNavigation.OnServerSelectionDone -> onServerSelectionDone() + is LoginNavigation.OpenSsoLoginFallback -> addFragmentToBackstack(R.id.simpleFragmentContainer, LoginSsoFallbackFragment::class.java) + is LoginNavigation.GoBack -> supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE) } } .disposeOnDestroy() @@ -74,6 +76,14 @@ class LoginActivity : VectorBaseActivity() { } } + 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) + } + } + override fun onResume() { super.onResume() diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginNavigation.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginNavigation.kt index 28d583a749..46a6c213d5 100644 --- a/vector/src/main/java/im/vector/riotx/features/login/LoginNavigation.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginNavigation.kt @@ -21,6 +21,7 @@ import im.vector.riotx.core.platform.VectorSharedAction // Supported navigation actions for LoginActivity sealed class LoginNavigation : VectorSharedAction { object OpenServerSelection : LoginNavigation() + object OnServerSelectionDone : LoginNavigation() object OpenSsoLoginFallback : LoginNavigation() object GoBack : LoginNavigation() } diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginServerSelectionFragment.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginServerSelectionFragment.kt new file mode 100644 index 0000000000..011100a6f5 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginServerSelectionFragment.kt @@ -0,0 +1,81 @@ +/* + * 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 android.os.Bundle +import android.view.View +import butterknife.OnClick +import com.airbnb.mvrx.withState +import im.vector.riotx.R +import kotlinx.android.synthetic.main.fragment_login_server_selection.* +import me.gujun.android.span.span +import javax.inject.Inject + +/** + * + */ +class LoginServerSelectionFragment @Inject constructor() : AbstractLoginFragment() { + + override fun getLayoutResId() = R.layout.fragment_login_server_selection + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + initTextViews() + } + + private fun updateSelectedChoice(serverType: ServerType) { + loginServerChoiceMatrixOrg.isChecked = serverType == ServerType.MatrixOrg + loginServerChoiceModular.isChecked = serverType == ServerType.Modular + loginServerChoiceOther.isChecked = serverType == ServerType.Other + } + + private fun initTextViews() { + loginServerChoiceModularLearnMore.text = span { + text = getString(R.string.login_server_modular_learn_more) + textDecorationLine = "underline" + onClick = { + // TODO + } + } + + } + + @OnClick(R.id.loginServerChoiceMatrixOrg) + fun selectMatrixOrg() { + viewModel.handle(LoginAction.UpdateServerType(ServerType.MatrixOrg)) + } + + @OnClick(R.id.loginServerChoiceModular) + fun selectModular() { + viewModel.handle(LoginAction.UpdateServerType(ServerType.Modular)) + } + + @OnClick(R.id.loginServerChoiceOther) + fun selectOther() { + viewModel.handle(LoginAction.UpdateServerType(ServerType.Other)) + } + + @OnClick(R.id.loginServerSubmit) + fun submit() { + loginSharedActionViewModel.post(LoginNavigation.OnServerSelectionDone) + } + + override fun invalidate() = withState(viewModel) { + updateSelectedChoice(it.serverType) + } +} diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt index b3d7e56029..a596603bc6 100644 --- a/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt @@ -62,6 +62,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi override fun handle(action: LoginAction) { when (action) { + is LoginAction.UpdateServerType -> handleUpdateServerType(action) is LoginAction.InitWith -> handleInitWith(action) is LoginAction.UpdateHomeServer -> handleUpdateHomeserver(action) is LoginAction.Login -> handleLogin(action) @@ -69,6 +70,14 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi } } + private fun handleUpdateServerType(action: LoginAction.UpdateServerType) { + setState { + copy( + serverType = action.serverType + ) + } + } + private fun handleInitWith(action: LoginAction.InitWith) { loginConfig = action.loginConfig } diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginViewState.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginViewState.kt index 0cc0476254..5c00614b09 100644 --- a/vector/src/main/java/im/vector/riotx/features/login/LoginViewState.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginViewState.kt @@ -21,6 +21,7 @@ import com.airbnb.mvrx.MvRxState import com.airbnb.mvrx.Uninitialized data class LoginViewState( + val serverType: ServerType = ServerType.MatrixOrg, val asyncLoginAction: Async = Uninitialized, val asyncHomeServerLoginFlowRequest: Async = Uninitialized ) : MvRxState diff --git a/vector/src/main/java/im/vector/riotx/features/login/ServerType.kt b/vector/src/main/java/im/vector/riotx/features/login/ServerType.kt new file mode 100644 index 0000000000..4c7007c137 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/login/ServerType.kt @@ -0,0 +1,23 @@ +/* + * 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 ServerType { + MatrixOrg, + Modular, + Other +} diff --git a/vector/src/main/res/drawable/bg_login_server.xml b/vector/src/main/res/drawable/bg_login_server.xml new file mode 100644 index 0000000000..5aecd26292 --- /dev/null +++ b/vector/src/main/res/drawable/bg_login_server.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/bg_login_server_checked.xml b/vector/src/main/res/drawable/bg_login_server_checked.xml new file mode 100644 index 0000000000..1aea622462 --- /dev/null +++ b/vector/src/main/res/drawable/bg_login_server_checked.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/bg_login_server_selector.xml b/vector/src/main/res/drawable/bg_login_server_selector.xml new file mode 100644 index 0000000000..57be1e5d54 --- /dev/null +++ b/vector/src/main/res/drawable/bg_login_server_selector.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/ic_logo_modular.xml b/vector/src/main/res/drawable/ic_logo_modular.xml new file mode 100644 index 0000000000..c95ee66b86 --- /dev/null +++ b/vector/src/main/res/drawable/ic_logo_modular.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/vector/src/main/res/layout/fragment_login_server_selection.xml b/vector/src/main/res/layout/fragment_login_server_selection.xml new file mode 100644 index 0000000000..58bc682d2a --- /dev/null +++ b/vector/src/main/res/layout/fragment_login_server_selection.xml @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vector/src/main/res/layout/fragment_login_splash.xml b/vector/src/main/res/layout/fragment_login_splash.xml index fd40e0bca3..5c025ef57b 100644 --- a/vector/src/main/res/layout/fragment_login_splash.xml +++ b/vector/src/main/res/layout/fragment_login_splash.xml @@ -25,9 +25,7 @@ android:layout_height="wrap_content" android:layout_marginTop="48dp" android:text="@string/login_splash_title" - android:textColor="?riotx_text_primary" - android:textSize="20sp" - android:textStyle="bold" + android:textAppearance="@style/TextAppearance.Vector.Login.Title" app:layout_constraintBottom_toTopOf="@+id/loginSplashText1" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/loginSplashLogo" /> @@ -51,8 +49,7 @@ android:layout_marginTop="32dp" android:gravity="start" android:text="@string/login_splash_text1" - android:textColor="?vctr_notice_secondary" - android:textSize="16sp" + android:textAppearance="@style/TextAppearance.Vector.Login.Text" app:layout_constraintBottom_toTopOf="@+id/loginSplashText2" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/loginSplashPicto1" @@ -76,8 +73,7 @@ android:layout_marginTop="16dp" android:gravity="start" android:text="@string/login_splash_text2" - android:textColor="?vctr_notice_secondary" - android:textSize="16sp" + android:textAppearance="@style/TextAppearance.Vector.Login.Text" app:layout_constraintBottom_toTopOf="@id/loginSplashText3" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/loginSplashPicto2" @@ -100,9 +96,8 @@ android:layout_marginStart="12dp" android:layout_marginTop="16dp" android:gravity="start" - android:text="@string/login_splash_text1" - android:textColor="?vctr_notice_secondary" - android:textSize="16sp" + android:text="@string/login_splash_text3" + android:textAppearance="@style/TextAppearance.Vector.Login.Text" app:layout_constraintBottom_toTopOf="@+id/loginSplashSubmit" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/loginSplashPicto3" @@ -110,7 +105,7 @@ Extend & customise your experience Get started + Select a server + Just like email, accounts have one home, although you can talk to anyone + Join millions free on the largest public server + Premium hosting for organisations + Learn more + Other + Custom & advanced settings + Continue + + diff --git a/vector/src/main/res/values/styles_login.xml b/vector/src/main/res/values/styles_login.xml new file mode 100644 index 0000000000..ffcd5bc29e --- /dev/null +++ b/vector/src/main/res/values/styles_login.xml @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/values/text_appearances.xml b/vector/src/main/res/values/text_appearances.xml index 606aef6511..6c2a71631d 100644 --- a/vector/src/main/res/values/text_appearances.xml +++ b/vector/src/main/res/values/text_appearances.xml @@ -37,4 +37,23 @@ ?riotx_text_secondary + + + + + + \ No newline at end of file