using consistent naming for the policy and opening a chrome tab when policy is tapped

This commit is contained in:
Adam Brown 2021-10-07 10:23:41 +01:00
parent 2f732affa5
commit c0fd266fc4
4 changed files with 17 additions and 13 deletions

View file

@ -121,8 +121,8 @@ class DiscoverySettingsController @Inject constructor(
title(identityServerUrl)
}
val terms = identityServer?.terms
if (terms != null) {
val policies = identityServer?.policies
if (policies != null) {
formAdvancedToggleItem {
id("policy-urls")
val titleRes = if (data.isIdentityPolicyUrlsExpanded) {
@ -133,14 +133,12 @@ class DiscoverySettingsController @Inject constructor(
listener { host.listener?.onPolicyUrlsExpandedStateToggled() }
}
if (data.isIdentityPolicyUrlsExpanded) {
terms.forEach { term ->
policies.forEach { policy ->
discoveryPolicyItem {
id(term.url)
name(term.name)
url(term.url)
clickListener {
// TODO
}
id(policy.url)
name(policy.name)
url(policy.url)
clickListener { host.listener?.onPolicyTapped(policy) }
}
}
}
@ -428,5 +426,6 @@ class DiscoverySettingsController @Inject constructor(
fun onTapUpdateUserConsent(newValue: Boolean)
fun onTapRetryToRetrieveBindings()
fun onPolicyUrlsExpandedStateToggled()
fun onPolicyTapped(policy: IdentityServerPolicy)
}
}

View file

@ -31,7 +31,9 @@ import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.extensions.observeEvent
import im.vector.app.core.extensions.registerStartForActivityResult
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.utils.displayInWebView
import im.vector.app.core.utils.ensureProtocol
import im.vector.app.core.utils.openUrlInChromeCustomTab
import im.vector.app.core.utils.showIdentityServerConsentDialog
import im.vector.app.databinding.FragmentGenericRecyclerBinding
import im.vector.app.features.discovery.change.SetIdentityServerFragment
@ -198,6 +200,10 @@ class DiscoverySettingsFragment @Inject constructor(
viewModel.handle(DiscoverySettingsAction.PolicyUrlsExpandedStateToggled)
}
override fun onPolicyTapped(policy: IdentityServerPolicy) {
openUrlInChromeCustomTab(requireContext(), null, policy.url)
}
private fun navigateToChangeIdentityServerFragment() {
(vectorBaseActivity as? VectorSettingsActivity)?.navigateTo(SetIdentityServerFragment::class.java)
}

View file

@ -19,7 +19,6 @@ package im.vector.app.features.discovery
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.MvRxState
import com.airbnb.mvrx.Uninitialized
import org.matrix.android.sdk.internal.auth.registration.LocalizedFlowDataLoginTerms
data class DiscoverySettingsState(
val identityServer: Async<IdentityServerWithTerms?> = Uninitialized,
@ -33,7 +32,7 @@ data class DiscoverySettingsState(
data class IdentityServerWithTerms(
val serverUrl: String,
val terms: List<IdentityServerTerms>
val policies: List<IdentityServerPolicy>
)
data class IdentityServerTerms(val name: String, val url: String)
data class IdentityServerPolicy(val name: String, val url: String)

View file

@ -427,7 +427,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
if (name == null || url == null) {
null
} else {
IdentityServerTerms(name = name, url = url)
IdentityServerPolicy(name = name, url = url)
}
}
IdentityServerWithTerms(identityServerUrl, policyUrls)