Add setting entry point to manage account (OIDC)
This commit is contained in:
parent
06a9b129d0
commit
79aa128377
11 changed files with 57 additions and 1 deletions
|
|
@ -66,6 +66,12 @@ class PreferencesRootNode @AssistedInject constructor(
|
|||
plugins<Callback>().forEach { it.onOpenAbout() }
|
||||
}
|
||||
|
||||
private fun onManageAccountClicked(activity: Activity, accountManagementUrl: String?) {
|
||||
accountManagementUrl?.let {
|
||||
activity.openUrlInChromeCustomTab(null, false, it)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
override fun View(modifier: Modifier) {
|
||||
val state = presenter.present()
|
||||
|
|
@ -79,7 +85,8 @@ class PreferencesRootNode @AssistedInject constructor(
|
|||
onOpenAbout = this::onOpenAbout,
|
||||
onVerifyClicked = this::onVerifyClicked,
|
||||
onOpenDeveloperSettings = this::onOpenDeveloperSettings,
|
||||
onSuccessLogout = { onSuccessLogout(activity, it) }
|
||||
onSuccessLogout = { onSuccessLogout(activity, it) },
|
||||
onManageAccountClicked = { onManageAccountClicked(activity, state.accountManagementUrl) },
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,14 @@ class PreferencesRootPresenter @Inject constructor(
|
|||
derivedStateOf { sessionVerifiedStatus == SessionVerifiedStatus.NotVerified }
|
||||
}
|
||||
|
||||
val accountManagementUrl: MutableState<String?> = remember {
|
||||
mutableStateOf(null)
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
initAccountManagementUrl(accountManagementUrl)
|
||||
}
|
||||
|
||||
val logoutState = logoutPresenter.present()
|
||||
val showDeveloperSettings = buildType != BuildType.RELEASE
|
||||
return PreferencesRootState(
|
||||
|
|
@ -75,6 +83,7 @@ class PreferencesRootPresenter @Inject constructor(
|
|||
myUser = matrixUser.value,
|
||||
version = versionFormatter.get(),
|
||||
showCompleteVerification = sessionIsNotVerified,
|
||||
accountManagementUrl = accountManagementUrl.value,
|
||||
showAnalyticsSettings = hasAnalyticsProviders,
|
||||
showDeveloperSettings = showDeveloperSettings,
|
||||
snackbarMessage = snackbarMessage,
|
||||
|
|
@ -84,4 +93,8 @@ class PreferencesRootPresenter @Inject constructor(
|
|||
private fun CoroutineScope.initialLoad(matrixUser: MutableState<MatrixUser?>) = launch {
|
||||
matrixUser.value = matrixClient.getCurrentUser()
|
||||
}
|
||||
|
||||
private fun CoroutineScope.initAccountManagementUrl(accountManagementUrl: MutableState<String?>) = launch {
|
||||
accountManagementUrl.value = matrixClient.getAccountManagementUrl().getOrNull()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ data class PreferencesRootState(
|
|||
val myUser: MatrixUser?,
|
||||
val version: String,
|
||||
val showCompleteVerification: Boolean,
|
||||
val accountManagementUrl: String?,
|
||||
val showAnalyticsSettings: Boolean,
|
||||
val showDeveloperSettings: Boolean,
|
||||
val snackbarMessage: SnackbarMessage?,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ fun aPreferencesRootState() = PreferencesRootState(
|
|||
myUser = null,
|
||||
version = "Version 1.1 (1)",
|
||||
showCompleteVerification = true,
|
||||
accountManagementUrl = "aUrl",
|
||||
showAnalyticsSettings = true,
|
||||
showDeveloperSettings = true,
|
||||
snackbarMessage = SnackbarMessage(CommonStrings.common_verification_complete),
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import androidx.compose.material.icons.outlined.BugReport
|
|||
import androidx.compose.material.icons.outlined.DeveloperMode
|
||||
import androidx.compose.material.icons.outlined.Help
|
||||
import androidx.compose.material.icons.outlined.InsertChart
|
||||
import androidx.compose.material.icons.outlined.ManageAccounts
|
||||
import androidx.compose.material.icons.outlined.VerifiedUser
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
@ -51,6 +52,7 @@ fun PreferencesRootView(
|
|||
state: PreferencesRootState,
|
||||
onBackPressed: () -> Unit,
|
||||
onVerifyClicked: () -> Unit,
|
||||
onManageAccountClicked: () -> Unit,
|
||||
onOpenAnalytics: () -> Unit,
|
||||
onOpenRageShake: () -> Unit,
|
||||
onOpenAbout: () -> Unit,
|
||||
|
|
@ -76,6 +78,13 @@ fun PreferencesRootView(
|
|||
)
|
||||
HorizontalDivider()
|
||||
}
|
||||
if (state.accountManagementUrl != null) {
|
||||
PreferenceText(
|
||||
title = stringResource(id = CommonStrings.screen_settings_oidc_account),
|
||||
icon = Icons.Outlined.ManageAccounts,
|
||||
onClick = onManageAccountClicked,
|
||||
)
|
||||
}
|
||||
if (state.showAnalyticsSettings) {
|
||||
PreferenceText(
|
||||
title = stringResource(id = CommonStrings.common_analytics),
|
||||
|
|
@ -143,5 +152,6 @@ private fun ContentToPreview(matrixUser: MatrixUser) {
|
|||
onOpenAbout = {},
|
||||
onVerifyClicked = {},
|
||||
onSuccessLogout = {},
|
||||
onManageAccountClicked = {},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ class PreferencesRootPresenterTest {
|
|||
)
|
||||
assertThat(loadedState.showDeveloperSettings).isEqualTo(true)
|
||||
assertThat(loadedState.showAnalyticsSettings).isEqualTo(false)
|
||||
assertThat(loadedState.accountManagementUrl).isNull()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue