mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-22 14:38:15 +08:00
Change the test to hide multi signout of devices.
We do not need an external account management URL, which is optional, but we need to know if account management is delegate to Oidc.
This commit is contained in:
parent
a889d8d678
commit
52a06931f4
@ -146,6 +146,8 @@ data class HomeServerCapabilities(
|
||||
return cap?.preferred ?: cap?.support?.lastOrNull()
|
||||
}
|
||||
|
||||
val delegatedOidcAuthEnabled: Boolean = authenticationIssuer != null
|
||||
|
||||
companion object {
|
||||
const val MAX_UPLOAD_FILE_SIZE_UNKNOWN = -1L
|
||||
const val ROOM_CAP_KNOCK = "knock"
|
||||
|
@ -35,6 +35,7 @@ import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.session.uia.DefaultBaseAuth
|
||||
import timber.log.Timber
|
||||
|
||||
@ -69,16 +70,17 @@ class DevicesViewModel @AssistedInject constructor(
|
||||
refreshDeviceList()
|
||||
refreshIpAddressVisibility()
|
||||
observePreferences()
|
||||
initExternalAccountManagementUrl()
|
||||
initDelegatedOidcAuthEnabled()
|
||||
}
|
||||
|
||||
private fun initExternalAccountManagementUrl() {
|
||||
private fun initDelegatedOidcAuthEnabled() {
|
||||
setState {
|
||||
copy(
|
||||
externalAccountManagementUrl = activeSessionHolder.getSafeActiveSession()
|
||||
delegatedOidcAuthEnabled = activeSessionHolder.getSafeActiveSession()
|
||||
?.homeServerCapabilitiesService()
|
||||
?.getHomeServerCapabilities()
|
||||
?.externalAccountManagementUrl
|
||||
?.delegatedOidcAuthEnabled
|
||||
.orFalse()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ data class DevicesViewState(
|
||||
val devices: Async<DeviceFullInfoList> = Uninitialized,
|
||||
val isLoading: Boolean = false,
|
||||
val isShowingIpAddress: Boolean = false,
|
||||
val externalAccountManagementUrl: String? = null,
|
||||
val delegatedOidcAuthEnabled: Boolean = false,
|
||||
) : MavericksState
|
||||
|
||||
data class DeviceFullInfoList(
|
||||
|
@ -355,8 +355,8 @@ class VectorSettingsDevicesFragment :
|
||||
views.deviceListHeaderOtherSessions.isVisible = true
|
||||
val colorDestructive = colorProvider.getColorFromAttribute(R.attr.colorError)
|
||||
val multiSignoutItem = views.deviceListHeaderOtherSessions.menu.findItem(R.id.otherSessionsHeaderMultiSignout)
|
||||
// Hide multi signout if we have an external account manager
|
||||
multiSignoutItem.isVisible = state.externalAccountManagementUrl == null
|
||||
// Hide multi signout if the homeserver delegates the account management
|
||||
multiSignoutItem.isVisible = state.delegatedOidcAuthEnabled.not()
|
||||
val nbDevices = otherDevices.size
|
||||
multiSignoutItem.title = stringProvider.getQuantityString(R.plurals.device_manager_other_sessions_multi_signout_all, nbDevices, nbDevices)
|
||||
multiSignoutItem.setTextColor(colorDestructive)
|
||||
@ -396,8 +396,8 @@ class VectorSettingsDevicesFragment :
|
||||
signoutSessionItem.setTextColor(colorDestructive)
|
||||
val signoutOtherSessionsItem = views.deviceListHeaderCurrentSession.menu.findItem(R.id.currentSessionHeaderSignoutOtherSessions)
|
||||
signoutOtherSessionsItem.setTextColor(colorDestructive)
|
||||
// Hide signout other sessions if we have an external account manager
|
||||
signoutOtherSessionsItem.isVisible = hasOtherDevices && state.externalAccountManagementUrl == null
|
||||
// Hide signout other sessions if the homeserver delegates the account management
|
||||
signoutOtherSessionsItem.isVisible = hasOtherDevices && state.delegatedOidcAuthEnabled.not()
|
||||
}
|
||||
|
||||
private fun renderCurrentSessionListView(currentDeviceInfo: DeviceFullInfo) {
|
||||
|
@ -103,8 +103,8 @@ class OtherSessionsFragment :
|
||||
val nbDevices = viewState.devices()?.size ?: 0
|
||||
stringProvider.getQuantityString(R.plurals.device_manager_other_sessions_multi_signout_all, nbDevices, nbDevices)
|
||||
}
|
||||
multiSignoutItem.isVisible = if (viewState.externalAccountManagementUrl != null) {
|
||||
// Hide multi signout if we have an external account manager
|
||||
multiSignoutItem.isVisible = if (viewState.delegatedOidcAuthEnabled) {
|
||||
// Hide multi signout if the homeserver delegates the account management
|
||||
false
|
||||
} else {
|
||||
if (viewState.isSelectModeEnabled) {
|
||||
|
@ -36,6 +36,7 @@ import im.vector.app.features.settings.devices.v2.signout.SignoutSessionsReAuthN
|
||||
import im.vector.app.features.settings.devices.v2.signout.SignoutSessionsUseCase
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.session.uia.DefaultBaseAuth
|
||||
import timber.log.Timber
|
||||
|
||||
@ -65,16 +66,17 @@ class OtherSessionsViewModel @AssistedInject constructor(
|
||||
observeDevices(initialState.currentFilter)
|
||||
refreshIpAddressVisibility()
|
||||
observePreferences()
|
||||
initExternalAccountManagementUrl()
|
||||
initDelegatedOidcAuthEnabled()
|
||||
}
|
||||
|
||||
private fun initExternalAccountManagementUrl() {
|
||||
private fun initDelegatedOidcAuthEnabled() {
|
||||
setState {
|
||||
copy(
|
||||
externalAccountManagementUrl = activeSessionHolder.getSafeActiveSession()
|
||||
delegatedOidcAuthEnabled = activeSessionHolder.getSafeActiveSession()
|
||||
?.homeServerCapabilitiesService()
|
||||
?.getHomeServerCapabilities()
|
||||
?.externalAccountManagementUrl
|
||||
?.delegatedOidcAuthEnabled
|
||||
.orFalse()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ data class OtherSessionsViewState(
|
||||
val isSelectModeEnabled: Boolean = false,
|
||||
val isLoading: Boolean = false,
|
||||
val isShowingIpAddress: Boolean = false,
|
||||
val externalAccountManagementUrl: String? = null,
|
||||
val delegatedOidcAuthEnabled: Boolean = false,
|
||||
) : MavericksState {
|
||||
|
||||
constructor(args: OtherSessionsArgs) : this(excludeCurrentDevice = args.excludeCurrentDevice)
|
||||
|
Loading…
Reference in New Issue
Block a user