duplicating the captcha fragment to style separately for the combined register flow
This commit is contained in:
parent
81a325b769
commit
863b4b810f
|
@ -102,6 +102,7 @@ import im.vector.app.features.onboarding.ftueauth.FtueAuthCaptchaFragment
|
||||||
import im.vector.app.features.onboarding.ftueauth.FtueAuthChooseDisplayNameFragment
|
import im.vector.app.features.onboarding.ftueauth.FtueAuthChooseDisplayNameFragment
|
||||||
import im.vector.app.features.onboarding.ftueauth.FtueAuthChooseProfilePictureFragment
|
import im.vector.app.features.onboarding.ftueauth.FtueAuthChooseProfilePictureFragment
|
||||||
import im.vector.app.features.onboarding.ftueauth.FtueAuthGenericTextInputFormFragment
|
import im.vector.app.features.onboarding.ftueauth.FtueAuthGenericTextInputFormFragment
|
||||||
|
import im.vector.app.features.onboarding.ftueauth.FtueAuthLegacyStyleCaptchaFragment
|
||||||
import im.vector.app.features.onboarding.ftueauth.FtueAuthLoginFragment
|
import im.vector.app.features.onboarding.ftueauth.FtueAuthLoginFragment
|
||||||
import im.vector.app.features.onboarding.ftueauth.FtueAuthPersonalizationCompleteFragment
|
import im.vector.app.features.onboarding.ftueauth.FtueAuthPersonalizationCompleteFragment
|
||||||
import im.vector.app.features.onboarding.ftueauth.FtueAuthResetPasswordFragment
|
import im.vector.app.features.onboarding.ftueauth.FtueAuthResetPasswordFragment
|
||||||
|
@ -407,6 +408,11 @@ interface FragmentModule {
|
||||||
@FragmentKey(LoginWaitForEmailFragment2::class)
|
@FragmentKey(LoginWaitForEmailFragment2::class)
|
||||||
fun bindLoginWaitForEmailFragment2(fragment: LoginWaitForEmailFragment2): Fragment
|
fun bindLoginWaitForEmailFragment2(fragment: LoginWaitForEmailFragment2): Fragment
|
||||||
|
|
||||||
|
@Binds
|
||||||
|
@IntoMap
|
||||||
|
@FragmentKey(FtueAuthLegacyStyleCaptchaFragment::class)
|
||||||
|
fun bindFtueAuthLegacyStyleCaptchaFragment(fragment: FtueAuthLegacyStyleCaptchaFragment): Fragment
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@IntoMap
|
@IntoMap
|
||||||
@FragmentKey(FtueAuthCaptchaFragment::class)
|
@FragmentKey(FtueAuthCaptchaFragment::class)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2022 New Vector Ltd
|
* Copyright (c) 2022 New Vector Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,37 +16,29 @@
|
||||||
|
|
||||||
package im.vector.app.features.onboarding.ftueauth
|
package im.vector.app.features.onboarding.ftueauth
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.airbnb.mvrx.args
|
import com.airbnb.mvrx.args
|
||||||
import im.vector.app.databinding.FragmentLoginCaptchaBinding
|
import im.vector.app.databinding.FragmentFtueLoginCaptchaBinding
|
||||||
import im.vector.app.features.onboarding.OnboardingAction
|
import im.vector.app.features.onboarding.OnboardingAction
|
||||||
import im.vector.app.features.onboarding.OnboardingViewState
|
import im.vector.app.features.onboarding.OnboardingViewState
|
||||||
import im.vector.app.features.onboarding.RegisterAction
|
import im.vector.app.features.onboarding.RegisterAction
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
data class FtueAuthCaptchaFragmentArgument(
|
|
||||||
val siteKey: String
|
|
||||||
) : Parcelable
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this screen, the user is asked to confirm they are not a robot
|
* In this screen, the user is asked to confirm they are not a robot
|
||||||
*/
|
*/
|
||||||
class FtueAuthCaptchaFragment @Inject constructor(
|
class FtueAuthCaptchaFragment @Inject constructor(
|
||||||
private val captchaWebview: CaptchaWebview
|
private val captchaWebview: CaptchaWebview
|
||||||
) : AbstractFtueAuthFragment<FragmentLoginCaptchaBinding>() {
|
) : AbstractFtueAuthFragment<FragmentFtueLoginCaptchaBinding>() {
|
||||||
|
|
||||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginCaptchaBinding {
|
|
||||||
return FragmentLoginCaptchaBinding.inflate(inflater, container, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val params: FtueAuthCaptchaFragmentArgument by args()
|
private val params: FtueAuthCaptchaFragmentArgument by args()
|
||||||
|
|
||||||
private var isWebViewLoaded = false
|
private var isWebViewLoaded = false
|
||||||
|
|
||||||
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueLoginCaptchaBinding {
|
||||||
|
return FragmentFtueLoginCaptchaBinding.inflate(inflater, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
override fun resetViewModel() {
|
override fun resetViewModel() {
|
||||||
viewModel.handle(OnboardingAction.ResetAuthenticationAttempt)
|
viewModel.handle(OnboardingAction.ResetAuthenticationAttempt)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ import im.vector.app.core.extensions.hideKeyboard
|
||||||
import im.vector.app.core.extensions.hidePassword
|
import im.vector.app.core.extensions.hidePassword
|
||||||
import im.vector.app.core.extensions.realignPercentagesToParent
|
import im.vector.app.core.extensions.realignPercentagesToParent
|
||||||
import im.vector.app.core.extensions.toReducedUrl
|
import im.vector.app.core.extensions.toReducedUrl
|
||||||
import im.vector.app.databinding.FragmentFtueSignUpCombinedBinding
|
import im.vector.app.databinding.FragmentFtueCombinedRegisterBinding
|
||||||
import im.vector.app.features.login.LoginMode
|
import im.vector.app.features.login.LoginMode
|
||||||
import im.vector.app.features.login.SSORedirectRouterActivity
|
import im.vector.app.features.login.SSORedirectRouterActivity
|
||||||
import im.vector.app.features.login.SocialLoginButtonsView
|
import im.vector.app.features.login.SocialLoginButtonsView
|
||||||
|
@ -56,10 +56,10 @@ import org.matrix.android.sdk.api.failure.isUsernameInUse
|
||||||
import org.matrix.android.sdk.api.failure.isWeakPassword
|
import org.matrix.android.sdk.api.failure.isWeakPassword
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAuthFragment<FragmentFtueSignUpCombinedBinding>() {
|
class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAuthFragment<FragmentFtueCombinedRegisterBinding>() {
|
||||||
|
|
||||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueSignUpCombinedBinding {
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueCombinedRegisterBinding {
|
||||||
return FragmentFtueSignUpCombinedBinding.inflate(inflater, container, false)
|
return FragmentFtueCombinedRegisterBinding.inflate(inflater, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2022 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.app.features.onboarding.ftueauth
|
||||||
|
|
||||||
|
import android.os.Parcelable
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.airbnb.mvrx.args
|
||||||
|
import im.vector.app.databinding.FragmentLoginCaptchaBinding
|
||||||
|
import im.vector.app.features.onboarding.OnboardingAction
|
||||||
|
import im.vector.app.features.onboarding.OnboardingViewState
|
||||||
|
import im.vector.app.features.onboarding.RegisterAction
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data class FtueAuthCaptchaFragmentArgument(
|
||||||
|
val siteKey: String
|
||||||
|
) : Parcelable
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In this screen, the user is asked to confirm they are not a robot
|
||||||
|
*/
|
||||||
|
class FtueAuthLegacyStyleCaptchaFragment @Inject constructor(
|
||||||
|
private val captchaWebview: CaptchaWebview
|
||||||
|
) : AbstractFtueAuthFragment<FragmentLoginCaptchaBinding>() {
|
||||||
|
|
||||||
|
private val params: FtueAuthCaptchaFragmentArgument by args()
|
||||||
|
private var isWebViewLoaded = false
|
||||||
|
|
||||||
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginCaptchaBinding {
|
||||||
|
return FragmentLoginCaptchaBinding.inflate(inflater, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resetViewModel() {
|
||||||
|
viewModel.handle(OnboardingAction.ResetAuthenticationAttempt)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateWithState(state: OnboardingViewState) {
|
||||||
|
if (!isWebViewLoaded) {
|
||||||
|
captchaWebview.setupWebView(this, views.loginCaptchaWevView, views.loginCaptchaProgress, params.siteKey, state) {
|
||||||
|
viewModel.handle(OnboardingAction.PostRegisterAction(RegisterAction.CaptchaDone(it)))
|
||||||
|
}
|
||||||
|
isWebViewLoaded = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -384,7 +384,7 @@ class FtueAuthVariant(
|
||||||
when (stage) {
|
when (stage) {
|
||||||
is Stage.ReCaptcha -> activity.addFragmentToBackstack(
|
is Stage.ReCaptcha -> activity.addFragmentToBackstack(
|
||||||
views.loginFragmentContainer,
|
views.loginFragmentContainer,
|
||||||
FtueAuthCaptchaFragment::class.java,
|
FtueAuthLegacyStyleCaptchaFragment::class.java,
|
||||||
FtueAuthCaptchaFragmentArgument(stage.publicKey),
|
FtueAuthCaptchaFragmentArgument(stage.publicKey),
|
||||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
||||||
option = commonOption
|
option = commonOption
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:colorBackground">
|
||||||
|
|
||||||
|
<!-- No scroll view in the screen, but use the style -->
|
||||||
|
<LinearLayout
|
||||||
|
style="@style/LoginFormScrollView"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
style="@style/LoginLogo"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/loginCaptchaNotice"
|
||||||
|
style="@style/Widget.Vector.TextView.Caption"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="@string/auth_recaptcha_message"
|
||||||
|
android:textColor="?vctr_content_secondary" />
|
||||||
|
|
||||||
|
<!-- contentDescription does not work on WebView? -->
|
||||||
|
<WebView
|
||||||
|
android:id="@+id/loginCaptchaWevView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:contentDescription="@string/login_a11y_captcha_container" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/loginCaptchaProgress"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
tools:ignore="UnknownId,NotSibling" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
Loading…
Reference in New Issue