From 5f6c8eebcf6b52334894cffcea29262dcc01bc2d Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Thu, 6 Oct 2022 12:16:24 +0300 Subject: [PATCH] Navigate to the instructions screen. --- .../src/main/res/values/strings.xml | 1 + .../features/login/qr/QrCodeLoginActivity.kt | 19 +++++++++++++++++++ .../features/navigation/DefaultNavigator.kt | 10 ++++++++++ .../app/features/navigation/Navigator.kt | 6 ++++++ .../ftueauth/FtueAuthCombinedLoginFragment.kt | 3 +++ .../layout/fragment_ftue_combined_login.xml | 17 ++++++++++++++--- .../fragment_qr_code_login_instructions.xml | 3 ++- 7 files changed, 55 insertions(+), 4 deletions(-) diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 5099b70c1d..25daadb453 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -2168,6 +2168,7 @@ If you don’t know your password, go back to reset it. This is not a valid user identifier. Expected format: \'@user:homeserver.org\' Unable to find a valid homeserver. Please check your identifier + Sign in with QR code Seen by diff --git a/vector/src/main/java/im/vector/app/features/login/qr/QrCodeLoginActivity.kt b/vector/src/main/java/im/vector/app/features/login/qr/QrCodeLoginActivity.kt index e0a5d244e1..bef9d5a040 100644 --- a/vector/src/main/java/im/vector/app/features/login/qr/QrCodeLoginActivity.kt +++ b/vector/src/main/java/im/vector/app/features/login/qr/QrCodeLoginActivity.kt @@ -18,12 +18,31 @@ package im.vector.app.features.login.qr import android.content.Context import android.content.Intent +import android.os.Bundle +import android.view.View import dagger.hilt.android.AndroidEntryPoint +import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.SimpleFragmentActivity @AndroidEntryPoint class QrCodeLoginActivity : SimpleFragmentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + views.toolbar.visibility = View.GONE + + val qrCodeLoginArgs: QrCodeLoginArgs? = intent?.extras?.getParcelable(EXTRA_QR_CODE_LOGIN_ARGS) + if (isFirstCreation()) { + if (qrCodeLoginArgs?.loginType == QrCodeLoginType.LOGIN) { + addFragment( + views.container, + QrCodeLoginInstructionsFragment::class.java, + qrCodeLoginArgs + ) + } + } + } + companion object { private const val EXTRA_QR_CODE_LOGIN_ARGS = "EXTRA_QR_CODE_LOGIN_ARGS" diff --git a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt index 53ed307da9..3970af385e 100644 --- a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt +++ b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt @@ -70,6 +70,8 @@ import im.vector.app.features.location.live.map.LiveLocationMapViewActivity import im.vector.app.features.location.live.map.LiveLocationMapViewArgs import im.vector.app.features.login.LoginActivity import im.vector.app.features.login.LoginConfig +import im.vector.app.features.login.qr.QrCodeLoginActivity +import im.vector.app.features.login.qr.QrCodeLoginArgs import im.vector.app.features.matrixto.MatrixToBottomSheet import im.vector.app.features.matrixto.OriginOfMatrixTo import im.vector.app.features.media.AttachmentData @@ -604,6 +606,14 @@ class DefaultNavigator @Inject constructor( activityResultLauncher.launch(screenCaptureIntent) } + override fun openLoginWithQrCode(context: Context, qrCodeLoginArgs: QrCodeLoginArgs) { + QrCodeLoginActivity + .getIntent(context, qrCodeLoginArgs) + .also { + context.startActivity(it) + } + } + private fun Intent.start(context: Context) { context.startActivity(this) } diff --git a/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt b/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt index 3521a02775..1d67f883a3 100644 --- a/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt +++ b/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt @@ -31,6 +31,7 @@ import im.vector.app.features.home.room.threads.arguments.ThreadTimelineArgs import im.vector.app.features.location.LocationData import im.vector.app.features.location.LocationSharingMode import im.vector.app.features.login.LoginConfig +import im.vector.app.features.login.qr.QrCodeLoginArgs import im.vector.app.features.matrixto.OriginOfMatrixTo import im.vector.app.features.media.AttachmentData import im.vector.app.features.pin.PinMode @@ -201,4 +202,9 @@ interface Navigator { screenCaptureIntent: Intent, activityResultLauncher: ActivityResultLauncher ) + + fun openLoginWithQrCode( + context: Context, + qrCodeLoginArgs: QrCodeLoginArgs, + ) } diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt index 6877810f0a..301e41be4b 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt @@ -40,6 +40,8 @@ import im.vector.app.features.login.LoginMode import im.vector.app.features.login.SSORedirectRouterActivity import im.vector.app.features.login.SocialLoginButtonsView import im.vector.app.features.login.SsoState +import im.vector.app.features.login.qr.QrCodeLoginArgs +import im.vector.app.features.login.qr.QrCodeLoginType import im.vector.app.features.login.render import im.vector.app.features.onboarding.OnboardingAction import im.vector.app.features.onboarding.OnboardingViewEvents @@ -70,6 +72,7 @@ class FtueAuthCombinedLoginFragment : viewModel.handle(OnboardingAction.UserNameEnteredAction.Login(views.loginInput.content())) } views.loginForgotPassword.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnForgetPasswordClicked)) } + views.loginWithQrCode.debouncedClicks { navigator.openLoginWithQrCode(requireActivity(), QrCodeLoginArgs(loginType = QrCodeLoginType.LOGIN)) } } private fun setupSubmitButton() { diff --git a/vector/src/main/res/layout/fragment_ftue_combined_login.xml b/vector/src/main/res/layout/fragment_ftue_combined_login.xml index 12943b4dc0..5440fcba15 100644 --- a/vector/src/main/res/layout/fragment_ftue_combined_login.xml +++ b/vector/src/main/res/layout/fragment_ftue_combined_login.xml @@ -194,9 +194,9 @@ android:text="@string/ftue_auth_forgot_password" android:textAllCaps="true" android:textColor="?colorSecondary" - app:layout_constraintHorizontal_bias="1" app:layout_constraintBottom_toTopOf="@id/actionSpacing" app:layout_constraintEnd_toEndOf="@id/loginGutterEnd" + app:layout_constraintHorizontal_bias="1" app:layout_constraintStart_toStartOf="@id/loginGutterStart" app:layout_constraintTop_toBottomOf="@id/loginPasswordInput" /> @@ -220,6 +220,17 @@ app:layout_constraintStart_toStartOf="@id/loginGutterStart" app:layout_constraintTop_toBottomOf="@id/actionSpacing" /> +