mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 03:49:04 +03:00
updating discovery consent dialog to include policy link which expands the policy urls view
This commit is contained in:
parent
5a4f320bf9
commit
3111d0b46d
5 changed files with 21 additions and 9 deletions
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -2368,6 +2368,7 @@
|
|||
|
||||
<string name="identity_server_consent_dialog_title">Send emails and phone numbers</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_neutral_policy">Policy</string>
|
||||
|
||||
<string name="settings_discovery_enter_identity_server">Enter an identity server URL</string>
|
||||
<string name="settings_discovery_bad_identity_server">Could not connect to identity server</string>
|
||||
|
|
Loading…
Reference in a new issue