Skip to content

Commit 52a0693

Browse files
committed
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.
1 parent a889d8d commit 52a0693

File tree

7 files changed

+22
-16
lines changed

7 files changed

+22
-16
lines changed

matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/homeserver/HomeServerCapabilities.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ data class HomeServerCapabilities(
146146
return cap?.preferred ?: cap?.support?.lastOrNull()
147147
}
148148

149+
val delegatedOidcAuthEnabled: Boolean = authenticationIssuer != null
150+
149151
companion object {
150152
const val MAX_UPLOAD_FILE_SIZE_UNKNOWN = -1L
151153
const val ROOM_CAP_KNOCK = "knock"

vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewModel.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import kotlinx.coroutines.flow.combine
3535
import kotlinx.coroutines.flow.launchIn
3636
import kotlinx.coroutines.flow.onEach
3737
import kotlinx.coroutines.launch
38+
import org.matrix.android.sdk.api.extensions.orFalse
3839
import org.matrix.android.sdk.api.session.uia.DefaultBaseAuth
3940
import timber.log.Timber
4041

@@ -69,16 +70,17 @@ class DevicesViewModel @AssistedInject constructor(
6970
refreshDeviceList()
7071
refreshIpAddressVisibility()
7172
observePreferences()
72-
initExternalAccountManagementUrl()
73+
initDelegatedOidcAuthEnabled()
7374
}
7475

75-
private fun initExternalAccountManagementUrl() {
76+
private fun initDelegatedOidcAuthEnabled() {
7677
setState {
7778
copy(
78-
externalAccountManagementUrl = activeSessionHolder.getSafeActiveSession()
79+
delegatedOidcAuthEnabled = activeSessionHolder.getSafeActiveSession()
7980
?.homeServerCapabilitiesService()
8081
?.getHomeServerCapabilities()
81-
?.externalAccountManagementUrl
82+
?.delegatedOidcAuthEnabled
83+
.orFalse()
8284
)
8385
}
8486
}

vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ data class DevicesViewState(
2626
val devices: Async<DeviceFullInfoList> = Uninitialized,
2727
val isLoading: Boolean = false,
2828
val isShowingIpAddress: Boolean = false,
29-
val externalAccountManagementUrl: String? = null,
29+
val delegatedOidcAuthEnabled: Boolean = false,
3030
) : MavericksState
3131

3232
data class DeviceFullInfoList(

vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ class VectorSettingsDevicesFragment :
355355
views.deviceListHeaderOtherSessions.isVisible = true
356356
val colorDestructive = colorProvider.getColorFromAttribute(R.attr.colorError)
357357
val multiSignoutItem = views.deviceListHeaderOtherSessions.menu.findItem(R.id.otherSessionsHeaderMultiSignout)
358-
// Hide multi signout if we have an external account manager
359-
multiSignoutItem.isVisible = state.externalAccountManagementUrl == null
358+
// Hide multi signout if the homeserver delegates the account management
359+
multiSignoutItem.isVisible = state.delegatedOidcAuthEnabled.not()
360360
val nbDevices = otherDevices.size
361361
multiSignoutItem.title = stringProvider.getQuantityString(R.plurals.device_manager_other_sessions_multi_signout_all, nbDevices, nbDevices)
362362
multiSignoutItem.setTextColor(colorDestructive)
@@ -396,8 +396,8 @@ class VectorSettingsDevicesFragment :
396396
signoutSessionItem.setTextColor(colorDestructive)
397397
val signoutOtherSessionsItem = views.deviceListHeaderCurrentSession.menu.findItem(R.id.currentSessionHeaderSignoutOtherSessions)
398398
signoutOtherSessionsItem.setTextColor(colorDestructive)
399-
// Hide signout other sessions if we have an external account manager
400-
signoutOtherSessionsItem.isVisible = hasOtherDevices && state.externalAccountManagementUrl == null
399+
// Hide signout other sessions if the homeserver delegates the account management
400+
signoutOtherSessionsItem.isVisible = hasOtherDevices && state.delegatedOidcAuthEnabled.not()
401401
}
402402

403403
private fun renderCurrentSessionListView(currentDeviceInfo: DeviceFullInfo) {

vector/src/main/java/im/vector/app/features/settings/devices/v2/othersessions/OtherSessionsFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ class OtherSessionsFragment :
103103
val nbDevices = viewState.devices()?.size ?: 0
104104
stringProvider.getQuantityString(R.plurals.device_manager_other_sessions_multi_signout_all, nbDevices, nbDevices)
105105
}
106-
multiSignoutItem.isVisible = if (viewState.externalAccountManagementUrl != null) {
107-
// Hide multi signout if we have an external account manager
106+
multiSignoutItem.isVisible = if (viewState.delegatedOidcAuthEnabled) {
107+
// Hide multi signout if the homeserver delegates the account management
108108
false
109109
} else {
110110
if (viewState.isSelectModeEnabled) {

vector/src/main/java/im/vector/app/features/settings/devices/v2/othersessions/OtherSessionsViewModel.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import im.vector.app.features.settings.devices.v2.signout.SignoutSessionsReAuthN
3636
import im.vector.app.features.settings.devices.v2.signout.SignoutSessionsUseCase
3737
import kotlinx.coroutines.Job
3838
import kotlinx.coroutines.launch
39+
import org.matrix.android.sdk.api.extensions.orFalse
3940
import org.matrix.android.sdk.api.session.uia.DefaultBaseAuth
4041
import timber.log.Timber
4142

@@ -65,16 +66,17 @@ class OtherSessionsViewModel @AssistedInject constructor(
6566
observeDevices(initialState.currentFilter)
6667
refreshIpAddressVisibility()
6768
observePreferences()
68-
initExternalAccountManagementUrl()
69+
initDelegatedOidcAuthEnabled()
6970
}
7071

71-
private fun initExternalAccountManagementUrl() {
72+
private fun initDelegatedOidcAuthEnabled() {
7273
setState {
7374
copy(
74-
externalAccountManagementUrl = activeSessionHolder.getSafeActiveSession()
75+
delegatedOidcAuthEnabled = activeSessionHolder.getSafeActiveSession()
7576
?.homeServerCapabilitiesService()
7677
?.getHomeServerCapabilities()
77-
?.externalAccountManagementUrl
78+
?.delegatedOidcAuthEnabled
79+
.orFalse()
7880
)
7981
}
8082
}

vector/src/main/java/im/vector/app/features/settings/devices/v2/othersessions/OtherSessionsViewState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ data class OtherSessionsViewState(
2929
val isSelectModeEnabled: Boolean = false,
3030
val isLoading: Boolean = false,
3131
val isShowingIpAddress: Boolean = false,
32-
val externalAccountManagementUrl: String? = null,
32+
val delegatedOidcAuthEnabled: Boolean = false,
3333
) : MavericksState {
3434

3535
constructor(args: OtherSessionsArgs) : this(excludeCurrentDevice = args.excludeCurrentDevice)

0 commit comments

Comments
 (0)