Login screens: fix issue on terms
This commit is contained in:
parent
a8f24e5c39
commit
20f969d563
@ -51,6 +51,7 @@ class LoginTermsFragment @Inject constructor(private val policyController: Polic
|
|||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
loginTermsPolicyList.setController(policyController)
|
loginTermsPolicyList.setController(policyController)
|
||||||
|
policyController.homeServer = loginViewModel.getHomeServerUrlSimple()
|
||||||
policyController.listener = this
|
policyController.listener = this
|
||||||
|
|
||||||
val list = ArrayList<LocalizedFlowDataLoginTermsChecked>()
|
val list = ArrayList<LocalizedFlowDataLoginTermsChecked>()
|
||||||
@ -83,7 +84,10 @@ class LoginTermsFragment @Inject constructor(private val policyController: Polic
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun openPolicy(localizedFlowDataLoginTerms: LocalizedFlowDataLoginTerms) {
|
override fun openPolicy(localizedFlowDataLoginTerms: LocalizedFlowDataLoginTerms) {
|
||||||
openUrlInExternalBrowser(requireContext(), localizedFlowDataLoginTerms.localizedUrl!!)
|
localizedFlowDataLoginTerms.localizedUrl
|
||||||
|
?.takeIf { it.isNotBlank() }
|
||||||
|
?.let {
|
||||||
|
openUrlInExternalBrowser(requireContext(), it)
|
||||||
|
|
||||||
// This code crashed, because user is not authenticated yet
|
// This code crashed, because user is not authenticated yet
|
||||||
//val intent = VectorWebViewActivity.getIntent(requireContext(),
|
//val intent = VectorWebViewActivity.getIntent(requireContext(),
|
||||||
@ -92,6 +96,7 @@ class LoginTermsFragment @Inject constructor(private val policyController: Polic
|
|||||||
// WebViewMode.DEFAULT)
|
// WebViewMode.DEFAULT)
|
||||||
//startActivity(intent)
|
//startActivity(intent)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@OnClick(R.id.loginTermsSubmit)
|
@OnClick(R.id.loginTermsSubmit)
|
||||||
internal fun submit() {
|
internal fun submit() {
|
||||||
|
@ -25,12 +25,15 @@ class PolicyController @Inject constructor() : TypedEpoxyController<List<Localiz
|
|||||||
|
|
||||||
var listener: PolicyControllerListener? = null
|
var listener: PolicyControllerListener? = null
|
||||||
|
|
||||||
|
var homeServer: String? = null
|
||||||
|
|
||||||
override fun buildModels(data: List<LocalizedFlowDataLoginTermsChecked>) {
|
override fun buildModels(data: List<LocalizedFlowDataLoginTermsChecked>) {
|
||||||
data.forEach { entry ->
|
data.forEach { entry ->
|
||||||
policy {
|
policyItem {
|
||||||
id(entry.localizedFlowDataLoginTerms.policyName)
|
id(entry.localizedFlowDataLoginTerms.policyName)
|
||||||
checked(entry.checked)
|
checked(entry.checked)
|
||||||
title(entry.localizedFlowDataLoginTerms.localizedName!!)
|
title(entry.localizedFlowDataLoginTerms.localizedName)
|
||||||
|
subtitle(homeServer)
|
||||||
|
|
||||||
clickListener(View.OnClickListener { listener?.openPolicy(entry.localizedFlowDataLoginTerms) })
|
clickListener(View.OnClickListener { listener?.openPolicy(entry.localizedFlowDataLoginTerms) })
|
||||||
checkChangeListener { _, isChecked ->
|
checkChangeListener { _, isChecked ->
|
||||||
|
@ -27,13 +27,16 @@ import im.vector.riotx.R
|
|||||||
import im.vector.riotx.core.epoxy.VectorEpoxyHolder
|
import im.vector.riotx.core.epoxy.VectorEpoxyHolder
|
||||||
|
|
||||||
@EpoxyModelClass(layout = R.layout.item_policy)
|
@EpoxyModelClass(layout = R.layout.item_policy)
|
||||||
abstract class PolicyModel : EpoxyModelWithHolder<PolicyModel.Holder>() {
|
abstract class PolicyItem : EpoxyModelWithHolder<PolicyItem.Holder>() {
|
||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
var checked: Boolean = false
|
var checked: Boolean = false
|
||||||
|
|
||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
var title: String? = null
|
var title: String? = null
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var subtitle: String? = null
|
||||||
|
|
||||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||||
var checkChangeListener: CompoundButton.OnCheckedChangeListener? = null
|
var checkChangeListener: CompoundButton.OnCheckedChangeListener? = null
|
||||||
|
|
||||||
@ -45,6 +48,7 @@ abstract class PolicyModel : EpoxyModelWithHolder<PolicyModel.Holder>() {
|
|||||||
it.checkbox.isChecked = checked
|
it.checkbox.isChecked = checked
|
||||||
it.checkbox.setOnCheckedChangeListener(checkChangeListener)
|
it.checkbox.setOnCheckedChangeListener(checkChangeListener)
|
||||||
it.title.text = title
|
it.title.text = title
|
||||||
|
it.subtitle.text = subtitle
|
||||||
it.view.setOnClickListener(clickListener)
|
it.view.setOnClickListener(clickListener)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,5 +62,6 @@ abstract class PolicyModel : EpoxyModelWithHolder<PolicyModel.Holder>() {
|
|||||||
class Holder : VectorEpoxyHolder() {
|
class Holder : VectorEpoxyHolder() {
|
||||||
val checkbox by bind<CheckBox>(R.id.adapter_item_policy_checkbox)
|
val checkbox by bind<CheckBox>(R.id.adapter_item_policy_checkbox)
|
||||||
val title by bind<TextView>(R.id.adapter_item_policy_title)
|
val title by bind<TextView>(R.id.adapter_item_policy_title)
|
||||||
|
val subtitle by bind<TextView>(R.id.adapter_item_policy_subtitle)
|
||||||
}
|
}
|
||||||
}
|
}
|
7
vector/src/main/res/color/login_button_tint.xml
Normal file
7
vector/src/main/res/color/login_button_tint.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:color="@color/riotx_accent" android:state_checked="true" />
|
||||||
|
<item android:color="#61708B" />
|
||||||
|
|
||||||
|
</selector>
|
@ -14,14 +14,23 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/loginTermsTitle"
|
||||||
|
style="@style/TextAppearance.Vector.Login.Title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="27dp"
|
||||||
|
android:text="@string/login_terms_title"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/logoImageView" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/loginTermsNotice"
|
android:id="@+id/loginTermsNotice"
|
||||||
style="@style/TextAppearance.Vector.Login.Text.Small"
|
style="@style/TextAppearance.Vector.Login.Text.Small"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="27dp"
|
android:layout_marginTop="12dp"
|
||||||
android:text="@string/auth_accept_policies"
|
android:text="@string/auth_accept_policies"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/logoImageView" />
|
app:layout_constraintTop_toBottomOf="@+id/loginTermsTitle" />
|
||||||
|
|
||||||
<com.airbnb.epoxy.EpoxyRecyclerView
|
<com.airbnb.epoxy.EpoxyRecyclerView
|
||||||
android:id="@+id/loginTermsPolicyList"
|
android:id="@+id/loginTermsPolicyList"
|
||||||
|
@ -4,40 +4,55 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="48dp">
|
android:foreground="?attr/selectableItemBackground"
|
||||||
|
android:minHeight="72dp">
|
||||||
|
|
||||||
<CheckBox
|
<com.google.android.material.checkbox.MaterialCheckBox
|
||||||
android:id="@+id/adapter_item_policy_checkbox"
|
android:id="@+id/adapter_item_policy_checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:buttonTint="@color/login_button_tint"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/adapter_item_policy_title"
|
android:id="@+id/adapter_item_policy_title"
|
||||||
|
style="@style/TextAppearance.Vector.Login.Text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:drawablePadding="8dp"
|
android:drawablePadding="8dp"
|
||||||
android:textSize="16sp"
|
app:layout_constraintBottom_toTopOf="@+id/adapter_item_policy_subtitle"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/adapter_item_policy_arrow"
|
app:layout_constraintEnd_toStartOf="@+id/adapter_item_policy_arrow"
|
||||||
app:layout_constraintStart_toEndOf="@+id/adapter_item_policy_checkbox"
|
app:layout_constraintStart_toEndOf="@+id/adapter_item_policy_checkbox"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
tools:text="Policy title" />
|
tools:text="Policy title" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/adapter_item_policy_subtitle"
|
||||||
|
style="@style/TextAppearance.Vector.Login.Text.Small"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:drawablePadding="8dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/adapter_item_policy_arrow"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/adapter_item_policy_checkbox"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/adapter_item_policy_title"
|
||||||
|
tools:text="matrix.org" />
|
||||||
|
|
||||||
<!-- Do not use drawableEnd on the TextView because of RTL support -->
|
<!-- Do not use drawableEnd on the TextView because of RTL support -->
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/adapter_item_policy_arrow"
|
android:id="@+id/adapter_item_policy_arrow"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:importantForAccessibility="no"
|
android:importantForAccessibility="no"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="0dp"
|
||||||
android:rotationY="@integer/rtl_mirror_flip"
|
android:rotationY="@integer/rtl_mirror_flip"
|
||||||
android:src="@drawable/ic_material_chevron_right_black"
|
android:src="@drawable/ic_material_chevron_right_black"
|
||||||
|
android:tint="?riotx_android_secondary"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
@ -100,5 +100,6 @@
|
|||||||
<string name="login_a11y_choose_modular">Select modular</string>
|
<string name="login_a11y_choose_modular">Select modular</string>
|
||||||
<string name="login_a11y_choose_other">Select a custom homeserver</string>
|
<string name="login_a11y_choose_other">Select a custom homeserver</string>
|
||||||
<string name="login_a11y_captcha_container">Please perform the captcha challenge</string>
|
<string name="login_a11y_captcha_container">Please perform the captcha challenge</string>
|
||||||
|
<string name="login_terms_title">Accept terms to continue</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user