navigating to the settings discovery page on policy link clicked from non discovery screens

This commit is contained in:
Adam Brown 2021-10-07 12:45:59 +01:00
parent c0fd266fc4
commit 05166944d8
4 changed files with 14 additions and 14 deletions

View File

@ -40,20 +40,16 @@ fun Context.displayInWebView(url: String) {
.show()
}
fun Context.showIdentityServerConsentDialog(configuredIdentityServer: String?, policyLinkCallback: (() -> Unit)? = null, consentCallBack: (() -> Unit)) {
fun Context.showIdentityServerConsentDialog(configuredIdentityServer: String?, policyLinkCallback: () -> Unit, 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) { _, _ ->
.setNeutralButton(R.string.identity_server_consent_dialog_neutral_policy) { _, _ ->
policyLinkCallback.invoke()
}
}
}
.setNegativeButton(R.string.no, null)
.show()
}

View File

@ -31,6 +31,7 @@ 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.settings.VectorSettingsActivity
import im.vector.app.features.userdirectory.PendingSelection
import im.vector.app.features.userdirectory.UserListAction
import im.vector.app.features.userdirectory.UserListSharedAction
@ -74,9 +75,11 @@ class ContactsBookFragment @Inject constructor(
private fun setupConsentView() {
views.phoneBookSearchForMatrixContacts.setOnClickListener {
withState(contactsBookViewModel) { state ->
requireContext().showIdentityServerConsentDialog(state.identityServerUrl) {
contactsBookViewModel.handle(ContactsBookAction.UserConsentGranted)
}
requireContext().showIdentityServerConsentDialog(
state.identityServerUrl,
policyLinkCallback = { navigator.openSettings(requireContext(), VectorSettingsActivity.EXTRA_DIRECT_ACCESS_DISCOVERY_SETTINGS) },
consentCallBack = { contactsBookViewModel.handle(ContactsBookAction.UserConsentGranted) }
)
}
}
}

View File

@ -31,7 +31,6 @@ 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

View File

@ -227,9 +227,11 @@ class UserListFragment @Inject constructor(
override fun giveIdentityServerConsent() {
withState(viewModel) { state ->
requireContext().showIdentityServerConsentDialog(state.configuredIdentityServer) {
viewModel.handle(UserListAction.UpdateUserConsent(true))
}
requireContext().showIdentityServerConsentDialog(
state.configuredIdentityServer,
policyLinkCallback = { navigator.openSettings(requireContext(), VectorSettingsActivity.EXTRA_DIRECT_ACCESS_DISCOVERY_SETTINGS) },
consentCallBack = { viewModel.handle(UserListAction.UpdateUserConsent(true)) }
)
}
}