Iterate on the consent dialog of the identity server.
This commit is contained in:
parent
8fd5e426bb
commit
3d5d9ad154
1
changelog.d/4577.feature
Normal file
1
changelog.d/4577.feature
Normal file
@ -0,0 +1 @@
|
||||
Iterate on the consent dialog of the identity server.
|
@ -17,10 +17,15 @@
|
||||
package im.vector.app.core.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import android.widget.TextView
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import im.vector.app.R
|
||||
import im.vector.app.features.discovery.IdentityServerPolicy
|
||||
import me.gujun.android.span.link
|
||||
import me.gujun.android.span.span
|
||||
|
||||
/**
|
||||
* Open a web view above the current activity.
|
||||
@ -40,16 +45,37 @@ fun Context.displayInWebView(url: String) {
|
||||
.show()
|
||||
}
|
||||
|
||||
fun Context.showIdentityServerConsentDialog(configuredIdentityServer: String?, policyLinkCallback: () -> Unit, consentCallBack: (() -> Unit)) {
|
||||
fun Context.showIdentityServerConsentDialog(configuredIdentityServer: String?,
|
||||
policies: List<IdentityServerPolicy>?,
|
||||
consentCallBack: (() -> Unit)) {
|
||||
// Build the message
|
||||
val content = span {
|
||||
+getString(R.string.identity_server_consent_dialog_content_3)
|
||||
+"\n\n"
|
||||
if (!policies.isNullOrEmpty()) {
|
||||
span {
|
||||
textStyle = "bold"
|
||||
text = getString(R.string.settings_privacy_policy)
|
||||
}
|
||||
policies.forEach {
|
||||
+"\n • "
|
||||
// Use the url as the text too
|
||||
link(it.url, it.url)
|
||||
}
|
||||
+"\n\n"
|
||||
}
|
||||
+getString(R.string.identity_server_consent_dialog_content_question)
|
||||
}
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setTitle(getString(R.string.identity_server_consent_dialog_title_2, configuredIdentityServer ?: ""))
|
||||
.setMessage(R.string.identity_server_consent_dialog_content_2)
|
||||
.setPositiveButton(R.string.yes) { _, _ ->
|
||||
.setTitle(getString(R.string.identity_server_consent_dialog_title_2, configuredIdentityServer.orEmpty()))
|
||||
.setMessage(content)
|
||||
.setPositiveButton(R.string.reactions_agree) { _, _ ->
|
||||
consentCallBack.invoke()
|
||||
}
|
||||
.setNeutralButton(R.string.identity_server_consent_dialog_neutral_policy) { _, _ ->
|
||||
policyLinkCallback.invoke()
|
||||
}
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.setNegativeButton(R.string.action_not_now, null)
|
||||
.show()
|
||||
.apply {
|
||||
// Make the link(s) clickable. Must be called after show()
|
||||
(findViewById(android.R.id.message) as? TextView)?.movementMethod = LinkMovementMethod.getInstance()
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import im.vector.app.core.extensions.hideKeyboard
|
||||
import im.vector.app.core.platform.VectorBaseFragment
|
||||
import im.vector.app.core.utils.showIdentityServerConsentDialog
|
||||
import im.vector.app.databinding.FragmentContactsBookBinding
|
||||
import im.vector.app.features.navigation.SettingsActivityPayload
|
||||
import im.vector.app.features.userdirectory.PendingSelection
|
||||
import im.vector.app.features.userdirectory.UserListAction
|
||||
import im.vector.app.features.userdirectory.UserListSharedAction
|
||||
@ -75,9 +74,7 @@ class ContactsBookFragment @Inject constructor(
|
||||
withState(contactsBookViewModel) { state ->
|
||||
requireContext().showIdentityServerConsentDialog(
|
||||
state.identityServerUrl,
|
||||
policyLinkCallback = {
|
||||
navigator.openSettings(requireContext(), SettingsActivityPayload.DiscoverySettings(expandIdentityPolicies = true))
|
||||
},
|
||||
/* TODO */ emptyList(),
|
||||
consentCallBack = { contactsBookViewModel.handle(ContactsBookAction.UserConsentGranted) }
|
||||
)
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ class DiscoverySettingsFragment @Inject constructor(
|
||||
withState(viewModel) { state ->
|
||||
requireContext().showIdentityServerConsentDialog(
|
||||
state.identityServer.invoke()?.serverUrl,
|
||||
policyLinkCallback = { viewModel.handle(DiscoverySettingsAction.SetPoliciesExpandState(expanded = true)) },
|
||||
state.identityServer.invoke()?.policies,
|
||||
consentCallBack = { viewModel.handle(DiscoverySettingsAction.UpdateUserConsent(true)) }
|
||||
)
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ import im.vector.app.core.utils.showIdentityServerConsentDialog
|
||||
import im.vector.app.core.utils.startSharePlainTextIntent
|
||||
import im.vector.app.databinding.FragmentUserListBinding
|
||||
import im.vector.app.features.homeserver.HomeServerCapabilitiesViewModel
|
||||
import im.vector.app.features.navigation.SettingsActivityPayload
|
||||
import im.vector.app.features.settings.VectorSettingsActivity
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
@ -234,9 +233,7 @@ class UserListFragment @Inject constructor(
|
||||
withState(viewModel) { state ->
|
||||
requireContext().showIdentityServerConsentDialog(
|
||||
state.configuredIdentityServer,
|
||||
policyLinkCallback = {
|
||||
navigator.openSettings(requireContext(), SettingsActivityPayload.DiscoverySettings(expandIdentityPolicies = true))
|
||||
},
|
||||
/* TODO */ emptyList(),
|
||||
consentCallBack = { viewModel.handle(UserListAction.UpdateUserConsent(true)) }
|
||||
)
|
||||
}
|
||||
|
@ -456,6 +456,7 @@
|
||||
<string name="copied_to_clipboard">Copied to clipboard</string>
|
||||
<string name="disable">Disable</string>
|
||||
<string name="action_return">Return</string>
|
||||
<string name="action_not_now">Not now</string>
|
||||
|
||||
<!-- dialog titles -->
|
||||
<string name="dialog_title_confirmation">Confirmation</string>
|
||||
@ -2193,7 +2194,9 @@
|
||||
<string name="room_list_rooms_empty_body">Your rooms will be displayed here. Tap the + bottom right to find existing ones or start some of your own.</string>
|
||||
|
||||
<string name="title_activity_emoji_reaction_picker">Reactions</string>
|
||||
<!-- TODO weblate sync: rename to "action_agree"-->
|
||||
<string name="reactions_agree">Agree</string>
|
||||
<!-- TODO weblate sync: rename to "action_like"-->
|
||||
<string name="reactions_like">Like</string>
|
||||
<string name="message_add_reaction">Add Reaction</string>
|
||||
<string name="message_view_reaction">View Reactions</string>
|
||||
@ -2377,6 +2380,8 @@
|
||||
<string name="identity_server_consent_dialog_title_2">Send emails and phone numbers to %s</string>
|
||||
<string name="identity_server_consent_dialog_content">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.</string>
|
||||
<string name="identity_server_consent_dialog_content_2">To discover existing contacts, you need to send contact info to your identity server.\n\nWe hash your data before sending for privacy. Do you consent to send this info?</string>
|
||||
<string name="identity_server_consent_dialog_content_3">To discover existing contacts, you need to send contact info (emails and phone numbers) to your identity server. We hash your data before sending for privacy.</string>
|
||||
<string name="identity_server_consent_dialog_content_question">Do you agree to send this info?</string>
|
||||
<string name="identity_server_consent_dialog_neutral_policy">Policy</string>
|
||||
|
||||
<string name="settings_discovery_enter_identity_server">Enter an identity server URL</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user