From bdfc4ad8a7d70a0f0853d149b932d5858ef9e1d8 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 14 Nov 2019 10:23:48 +0100 Subject: [PATCH] Login screens: splash screen --- .../features/login/AbstractLoginFragment.kt | 40 ++++++ .../riotx/features/login/LoginActivity.kt | 3 +- .../riotx/features/login/LoginFragment.kt | 8 +- .../riotx/features/login/LoginNavigation.kt | 3 +- .../features/login/LoginSplashFragment.kt | 34 +++++ .../main/res/layout/fragment_login_splash.xml | 126 ++++++++++++++++++ vector/src/main/res/values/strings_riotX.xml | 5 + 7 files changed, 210 insertions(+), 9 deletions(-) create mode 100644 vector/src/main/java/im/vector/riotx/features/login/AbstractLoginFragment.kt create mode 100644 vector/src/main/java/im/vector/riotx/features/login/LoginSplashFragment.kt create mode 100644 vector/src/main/res/layout/fragment_login_splash.xml diff --git a/vector/src/main/java/im/vector/riotx/features/login/AbstractLoginFragment.kt b/vector/src/main/java/im/vector/riotx/features/login/AbstractLoginFragment.kt new file mode 100644 index 0000000000..25472fa9a1 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/login/AbstractLoginFragment.kt @@ -0,0 +1,40 @@ +/* + * 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 androidx.annotation.CallSuper +import com.airbnb.mvrx.activityViewModel +import im.vector.riotx.core.platform.VectorBaseFragment + +/** + * Parent Fragment for all the login/registration screens + */ +abstract class AbstractLoginFragment() : VectorBaseFragment() { + + protected val viewModel: LoginViewModel by activityViewModel() + protected lateinit var loginSharedActionViewModel: LoginSharedActionViewModel + + @CallSuper + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + loginSharedActionViewModel = activityViewModelProvider.get(LoginSharedActionViewModel::class.java) + } + +} 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 4e5b5621ce..d371b459eb 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 @@ -45,7 +45,7 @@ class LoginActivity : VectorBaseActivity() { override fun initUiAndData() { if (isFirstCreation()) { - addFragment(R.id.simpleFragmentContainer, LoginFragment::class.java) + addFragment(R.id.simpleFragmentContainer, LoginSplashFragment::class.java) } // Get config extra @@ -58,6 +58,7 @@ 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) } diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginFragment.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginFragment.kt index aa9aabe5dd..4f918baa8a 100644 --- a/vector/src/main/java/im/vector/riotx/features/login/LoginFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginFragment.kt @@ -28,7 +28,6 @@ import com.jakewharton.rxbinding3.widget.textChanges import im.vector.riotx.R import im.vector.riotx.core.extensions.setTextWithColoredPart import im.vector.riotx.core.extensions.showPassword -import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.utils.openUrlInExternalBrowser import im.vector.riotx.features.homeserver.ServerUrlsRepository import io.reactivex.Observable @@ -41,10 +40,7 @@ import javax.inject.Inject * What can be improved: * - When filtering more (when entering new chars), we could filter on result we already have, during the new server request, to avoid empty screen effect */ -class LoginFragment @Inject constructor() : VectorBaseFragment() { - - private val viewModel: LoginViewModel by activityViewModel() - private lateinit var loginSharedActionViewModel: LoginSharedActionViewModel +class LoginFragment @Inject constructor() : AbstractLoginFragment() { private var passwordShown = false @@ -53,8 +49,6 @@ class LoginFragment @Inject constructor() : VectorBaseFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - loginSharedActionViewModel = activityViewModelProvider.get(LoginSharedActionViewModel::class.java) - setupNotice() setupAuthButton() setupPasswordReveal() 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 c9de4695f9..28d583a749 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 @@ -18,8 +18,9 @@ package im.vector.riotx.features.login import im.vector.riotx.core.platform.VectorSharedAction -// Supported navigation actions for this Activity +// Supported navigation actions for LoginActivity sealed class LoginNavigation : VectorSharedAction { + object OpenServerSelection : LoginNavigation() object OpenSsoLoginFallback : LoginNavigation() object GoBack : LoginNavigation() } diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginSplashFragment.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginSplashFragment.kt new file mode 100644 index 0000000000..672502a167 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginSplashFragment.kt @@ -0,0 +1,34 @@ +/* + * 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 butterknife.OnClick +import im.vector.riotx.R +import javax.inject.Inject + +/** + * + */ +class LoginSplashFragment @Inject constructor() : AbstractLoginFragment() { + + override fun getLayoutResId() = R.layout.fragment_login_splash + + @OnClick(R.id.loginSplashSubmit) + fun getStarted() { + loginSharedActionViewModel.post(LoginNavigation.OpenServerSelection) + } +} diff --git a/vector/src/main/res/layout/fragment_login_splash.xml b/vector/src/main/res/layout/fragment_login_splash.xml new file mode 100644 index 0000000000..fd40e0bca3 --- /dev/null +++ b/vector/src/main/res/layout/fragment_login_splash.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index 8d8be693e1..4e7143fa56 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -23,5 +23,10 @@ %1$s made the room public to whoever knows the link. %1$s made the room invite only. + Liberate your communication + Chat with people directly or in groups + Keep conversations private with encryption + Extend & customise your experience + Get started