diff --git a/vector/src/main/java/im/vector/app/core/utils/Dialogs.kt b/vector/src/main/java/im/vector/app/core/utils/Dialogs.kt
index c73fa70388..99e8684229 100644
--- a/vector/src/main/java/im/vector/app/core/utils/Dialogs.kt
+++ b/vector/src/main/java/im/vector/app/core/utils/Dialogs.kt
@@ -40,13 +40,20 @@ fun Context.displayInWebView(url: String) {
.show()
}
-fun Context.showIdentityServerConsentDialog(configuredIdentityServer: String?, consentCallBack: (() -> Unit)) {
+fun Context.showIdentityServerConsentDialog(configuredIdentityServer: String?, policyLinkCallback: (() -> Unit)? = null, consentCallBack: (() -> Unit)) {
MaterialAlertDialogBuilder(this)
.setTitle(R.string.identity_server_consent_dialog_title)
.setMessage(getString(R.string.identity_server_consent_dialog_content, configuredIdentityServer ?: ""))
.setPositiveButton(R.string.yes) { _, _ ->
consentCallBack.invoke()
}
+ .apply {
+ if (policyLinkCallback != null) {
+ setNeutralButton(R.string.identity_server_consent_dialog_neutral_policy) { _, _ ->
+ policyLinkCallback.invoke()
+ }
+ }
+ }
.setNegativeButton(R.string.no, null)
.show()
}
diff --git a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsAction.kt b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsAction.kt
index 3d6038da3f..74700f668f 100644
--- a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsAction.kt
+++ b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsAction.kt
@@ -32,4 +32,5 @@ sealed class DiscoverySettingsAction : VectorViewModelAction {
data class SubmitMsisdnToken(val threePid: ThreePid.Msisdn, val code: String) : DiscoverySettingsAction()
data class CancelBinding(val threePid: ThreePid) : DiscoverySettingsAction()
object PolicyUrlsExpandedStateToggled : DiscoverySettingsAction()
+ object ExpandPolicyUrls : DiscoverySettingsAction()
}
diff --git a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsFragment.kt b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsFragment.kt
index b079157421..a1582d1a44 100644
--- a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsFragment.kt
+++ b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsFragment.kt
@@ -179,9 +179,11 @@ class DiscoverySettingsFragment @Inject constructor(
override fun onTapUpdateUserConsent(newValue: Boolean) {
if (newValue) {
withState(viewModel) { state ->
- requireContext().showIdentityServerConsentDialog(state.identityServer.invoke()?.serverUrl) {
- viewModel.handle(DiscoverySettingsAction.UpdateUserConsent(true))
- }
+ requireContext().showIdentityServerConsentDialog(
+ state.identityServer.invoke()?.serverUrl,
+ policyLinkCallback = { viewModel.handle(DiscoverySettingsAction.ExpandPolicyUrls) },
+ consentCallBack = { viewModel.handle(DiscoverySettingsAction.UpdateUserConsent(true)) }
+ )
}
} else {
viewModel.handle(DiscoverySettingsAction.UpdateUserConsent(false))
diff --git a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt
index fc3eb7b990..4c4511b089 100644
--- a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt
+++ b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt
@@ -115,6 +115,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
DiscoverySettingsAction.RetrieveBinding -> retrieveBinding()
DiscoverySettingsAction.DisconnectIdentityServer -> disconnectIdentityServer()
DiscoverySettingsAction.PolicyUrlsExpandedStateToggled -> toggleExpandedPolicyUrlsState()
+ DiscoverySettingsAction.ExpandPolicyUrls -> updatePolicyUrlsExpandedState(isExpanded = true)
is DiscoverySettingsAction.ChangeIdentityServer -> changeIdentityServer(action)
is DiscoverySettingsAction.UpdateUserConsent -> handleUpdateUserConsent(action)
is DiscoverySettingsAction.RevokeThreePid -> revokeThreePid(action)
@@ -149,11 +150,11 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
}
private fun toggleExpandedPolicyUrlsState() {
- withState {
- setState {
- copy(isIdentityPolicyUrlsExpanded = !it.isIdentityPolicyUrlsExpanded)
- }
- }
+ withState { state -> updatePolicyUrlsExpandedState(isExpanded = !state.isIdentityPolicyUrlsExpanded) }
+ }
+
+ private fun updatePolicyUrlsExpandedState(isExpanded: Boolean) {
+ setState { copy(isIdentityPolicyUrlsExpanded = isExpanded) }
}
private fun changeIdentityServer(action: DiscoverySettingsAction.ChangeIdentityServer) {
diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml
index 22cdd98e97..065e618e57 100644
--- a/vector/src/main/res/values/strings.xml
+++ b/vector/src/main/res/values/strings.xml
@@ -2368,6 +2368,7 @@
Send emails and phone numbers
In order to discover existing contacts you know, do you accept to send your contact data (phone numbers and/or emails) to the configured identity server (%1$s)?\n\nFor more privacy, the sent data will be hashed before being sent.
+ Policy
Enter an identity server URL
Could not connect to identity server