diff --git a/vector/src/main/java/im/vector/app/features/login/terms/PolicyController.kt b/vector/src/main/java/im/vector/app/features/login/terms/PolicyController.kt index 405f7b09c5..42c39efdac 100644 --- a/vector/src/main/java/im/vector/app/features/login/terms/PolicyController.kt +++ b/vector/src/main/java/im/vector/app/features/login/terms/PolicyController.kt @@ -24,6 +24,7 @@ class PolicyController @Inject constructor() : TypedEpoxyController) { @@ -32,6 +33,7 @@ class PolicyController @Inject constructor() : TypedEpoxyController() { @EpoxyAttribute var subtitle: String? = null + @EpoxyAttribute + var horizontalPadding: Int? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var checkChangeListener: CompoundButton.OnCheckedChangeListener? = null @@ -47,6 +50,12 @@ abstract class PolicyItem : EpoxyModelWithHolder() { override fun bind(holder: Holder) { super.bind(holder) holder.let { + it.view.setPadding( + horizontalPadding ?: it.view.paddingLeft, + it.view.paddingTop, + horizontalPadding ?: it.view.paddingRight, + it.view.paddingBottom + ) it.checkbox.isChecked = checked it.checkbox.setOnCheckedChangeListener(checkChangeListener) it.title.text = title diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/terms/FtueAuthTermsFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/terms/FtueAuthTermsFragment.kt index 0ba84e32c8..877a85126a 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/terms/FtueAuthTermsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/terms/FtueAuthTermsFragment.kt @@ -20,7 +20,10 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.view.doOnLayout import com.airbnb.mvrx.args +import im.vector.app.R import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.configureWith import im.vector.app.core.extensions.toReducedUrl @@ -35,6 +38,7 @@ import im.vector.app.features.onboarding.RegisterAction import im.vector.app.features.onboarding.ftueauth.AbstractFtueAuthFragment import org.matrix.android.sdk.internal.auth.registration.LocalizedFlowDataLoginTerms import javax.inject.Inject +import kotlin.math.roundToInt /** * LoginTermsFragment displays the list of policies the user has to accept @@ -54,24 +58,24 @@ class FtueAuthTermsFragment @Inject constructor( override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - setupViews() - views.loginTermsPolicyList.configureWith(policyController, hasFixedSize = false) - policyController.listener = this - val list = ArrayList() - params.localizedFlowDataLoginTerms .forEach { list.add(LocalizedFlowDataLoginTermsChecked(it)) } - loginTermsViewState = LoginTermsViewState(list) } private fun setupViews() { views.displayNameSubmit.setOnClickListener { submit() } views.loginTermsPolicyList.setHasFixedSize(false) + views.loginTermsPolicyList.configureWith(policyController, hasFixedSize = false, dividerDrawable = R.drawable.divider_horizontal) + views.displayNameGutterStart.doOnLayout { + val gutterSize = views.contentRoot.width * (views.displayNameGutterStart.layoutParams as ConstraintLayout.LayoutParams).guidePercent + policyController.horizontalPadding = gutterSize.roundToInt() + } + policyController.listener = this } override fun onDestroyView() { diff --git a/vector/src/main/res/layout/fragment_login_terms.xml b/vector/src/main/res/layout/fragment_login_terms.xml index a0af01eda8..51facb0d81 100644 --- a/vector/src/main/res/layout/fragment_login_terms.xml +++ b/vector/src/main/res/layout/fragment_login_terms.xml @@ -48,6 +48,8 @@ android:layout_height="0dp" android:layout_marginTop="10dp" android:layout_marginBottom="16dp" + android:paddingStart="16dp" + android:paddingEnd="16dp" app:layout_constraintBottom_toTopOf="@id/loginTermsSubmit" app:layout_constraintTop_toBottomOf="@id/loginTermsNotice" tools:listitem="@layout/item_policy" /> diff --git a/vector/src/main/res/layout/fragment_login_terms_2.xml b/vector/src/main/res/layout/fragment_login_terms_2.xml index a64ec08184..18b7df3880 100644 --- a/vector/src/main/res/layout/fragment_login_terms_2.xml +++ b/vector/src/main/res/layout/fragment_login_terms_2.xml @@ -52,6 +52,8 @@ android:layout_height="0dp" android:layout_marginTop="10dp" android:layout_marginBottom="16dp" + android:paddingStart="16dp" + android:paddingEnd="16dp" app:layout_constraintBottom_toTopOf="@id/loginTermsSubmit" app:layout_constraintTop_toBottomOf="@id/loginTermsNotice" tools:listitem="@layout/item_policy" /> diff --git a/vector/src/main/res/layout/item_policy.xml b/vector/src/main/res/layout/item_policy.xml index 7f4a90b5d0..679a2d0a14 100644 --- a/vector/src/main/res/layout/item_policy.xml +++ b/vector/src/main/res/layout/item_policy.xml @@ -6,8 +6,6 @@ android:layout_height="wrap_content" android:foreground="?attr/selectableItemBackground" android:minHeight="72dp" - android:paddingStart="16dp" - android:paddingEnd="16dp" tools:viewBindingIgnore="true"> \ No newline at end of file