styling the captcha wth the update designs

This commit is contained in:
Adam Brown 2022-04-06 11:44:50 +01:00
parent 863b4b810f
commit f4747aa069
4 changed files with 117 additions and 38 deletions

View file

@ -16,6 +16,7 @@
package im.vector.app.features.onboarding.ftueauth
import android.os.Parcelable
import android.view.LayoutInflater
import android.view.ViewGroup
import com.airbnb.mvrx.args
@ -23,8 +24,14 @@ import im.vector.app.databinding.FragmentFtueLoginCaptchaBinding
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
*/

View file

@ -28,7 +28,7 @@ import kotlinx.parcelize.Parcelize
import javax.inject.Inject
@Parcelize
data class FtueAuthCaptchaFragmentArgument(
data class FtueAuthLegacyStyleCaptchaFragmentArgument(
val siteKey: String
) : Parcelable
@ -39,7 +39,7 @@ class FtueAuthLegacyStyleCaptchaFragment @Inject constructor(
private val captchaWebview: CaptchaWebview
) : AbstractFtueAuthFragment<FragmentLoginCaptchaBinding>() {
private val params: FtueAuthCaptchaFragmentArgument by args()
private val params: FtueAuthLegacyStyleCaptchaFragmentArgument by args()
private var isWebViewLoaded = false
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginCaptchaBinding {

View file

@ -382,13 +382,7 @@ class FtueAuthVariant(
supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
when (stage) {
is Stage.ReCaptcha -> activity.addFragmentToBackstack(
views.loginFragmentContainer,
FtueAuthLegacyStyleCaptchaFragment::class.java,
FtueAuthCaptchaFragmentArgument(stage.publicKey),
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
option = commonOption
)
is Stage.ReCaptcha -> onCaptcha(stage)
is Stage.Email -> activity.addFragmentToBackstack(
views.loginFragmentContainer,
FtueAuthGenericTextInputFormFragment::class.java,
@ -414,6 +408,25 @@ class FtueAuthVariant(
}
}
private fun onCaptcha(stage: Stage.ReCaptcha) {
when {
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> activity.addFragmentToBackstack(
views.loginFragmentContainer,
FtueAuthCaptchaFragment::class.java,
FtueAuthCaptchaFragmentArgument(stage.publicKey),
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
option = commonOption
)
else -> activity.addFragmentToBackstack(
views.loginFragmentContainer,
FtueAuthLegacyStyleCaptchaFragment::class.java,
FtueAuthLegacyStyleCaptchaFragmentArgument(stage.publicKey),
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
option = commonOption
)
}
}
private fun onAccountSignedIn() {
navigateToHome(createdAccount = false)
}

View file

@ -1,50 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/captchaRoot"
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"
<androidx.constraintlayout.widget.Guideline
android:id="@+id/captchaGutterStart"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp">
app:layout_constraintGuide_percent="@dimen/ftue_auth_gutter_start_percent" />
<ImageView
style="@style/LoginLogo"
android:layout_marginBottom="8dp"
tools:ignore="ContentDescription" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/captchaGutterEnd"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintGuide_percent="@dimen/ftue_auth_gutter_end_percent" />
<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" />
<Space
android:id="@+id/headerSpacing"
android:layout_width="match_parent"
android:layout_height="52dp"
app:layout_constraintBottom_toTopOf="@id/captchaHeaderIcon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0"
app:layout_constraintVertical_chainStyle="packed" />
<!-- 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" />
<ImageView
android:id="@+id/captchaHeaderIcon"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:background="@drawable/circle"
android:backgroundTint="?colorSecondary"
android:contentDescription="@null"
android:src="@drawable/ic_user_fg"
app:layout_constraintBottom_toTopOf="@id/captchaHeaderTitle"
app:layout_constraintEnd_toEndOf="@id/captchaGutterEnd"
app:layout_constraintHeight_percent="0.10"
app:layout_constraintStart_toStartOf="@id/captchaGutterStart"
app:layout_constraintTop_toBottomOf="@id/headerSpacing"
app:tint="@color/palette_white" />
</LinearLayout>
<TextView
android:id="@+id/captchaHeaderTitle"
style="@style/Widget.Vector.TextView.Title.Medium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/ftue_auth_create_account_title"
android:textColor="?vctr_content_primary"
app:layout_constraintBottom_toTopOf="@id/captchaHeaderSubtitle"
app:layout_constraintEnd_toEndOf="@id/captchaGutterEnd"
app:layout_constraintStart_toStartOf="@id/captchaGutterStart"
app:layout_constraintTop_toBottomOf="@id/captchaHeaderIcon" />
<TextView
android:id="@+id/captchaHeaderSubtitle"
style="@style/Widget.Vector.TextView.Subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:text="@string/auth_recaptcha_message"
android:textColor="?vctr_content_secondary"
app:layout_constraintBottom_toTopOf="@id/titleContentSpacing"
app:layout_constraintEnd_toEndOf="@id/captchaGutterEnd"
app:layout_constraintStart_toStartOf="@id/captchaGutterStart"
app:layout_constraintTop_toBottomOf="@id/captchaHeaderTitle" />
<Space
android:id="@+id/titleContentSpacing"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/loginCaptchaWevView"
app:layout_constraintHeight_percent="0.03"
app:layout_constraintTop_toBottomOf="@id/captchaHeaderSubtitle" />
<!-- contentDescription does not work on WebView? -->
<WebView
android:id="@+id/loginCaptchaWevView"
android:layout_width="0dp"
android:layout_height="0dp"
android:contentDescription="@string/login_a11y_captcha_container"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/captchaGutterEnd"
app:layout_constraintStart_toStartOf="@id/captchaGutterStart"
app:layout_constraintTop_toBottomOf="@id/titleContentSpacing" />
<ProgressBar
android:id="@+id/loginCaptchaProgress"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/captchaGutterEnd"
app:layout_constraintStart_toStartOf="@id/captchaGutterStart"
app:layout_constraintTop_toBottomOf="@id/headerSpacing"
tools:ignore="UnknownId,NotSibling" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>