Add alias management in space settings

This commit is contained in:
Valere 2021-06-10 16:17:24 +02:00
parent fb337dacd6
commit b1ab6eb58f
10 changed files with 35 additions and 7 deletions

View File

@ -16,8 +16,6 @@
package org.matrix.android.sdk.api.session.room
import arrow.core.Either
import org.matrix.android.sdk.api.session.room.failure.CreateRoomFailure
import org.matrix.android.sdk.api.session.room.model.RoomDirectoryVisibility
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoomsParams
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoomsResponse

View File

@ -16,11 +16,8 @@
package org.matrix.android.sdk.internal.session.room
import arrow.core.Either
import arrow.core.Right
import org.matrix.android.sdk.api.session.room.RoomDirectoryService
import org.matrix.android.sdk.api.session.room.alias.RoomAliasError
import org.matrix.android.sdk.api.session.room.failure.CreateRoomFailure
import org.matrix.android.sdk.api.session.room.model.RoomDirectoryVisibility
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoomsParams
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoomsResponse
@ -50,7 +47,6 @@ internal class DefaultRoomDirectoryService @Inject constructor(
setRoomDirectoryVisibilityTask.execute(SetRoomDirectoryVisibilityTask.Params(roomId, roomDirectoryVisibility))
}
override suspend fun checkAliasAvailability(aliasLocalPart: String?): Result<Unit> {
return try {
roomAliasAvailabilityChecker.check(aliasLocalPart)

View File

@ -39,6 +39,7 @@ import im.vector.app.features.roomdirectory.createroom.RoomAliasErrorFormatter
import im.vector.app.features.roomdirectory.createroom.roomAliasEditItem
import org.matrix.android.sdk.api.session.room.alias.RoomAliasError
import org.matrix.android.sdk.api.session.room.model.RoomDirectoryVisibility
import org.matrix.android.sdk.api.session.room.model.RoomType
import javax.inject.Inject
class RoomAliasController @Inject constructor(
@ -71,7 +72,9 @@ class RoomAliasController @Inject constructor(
// Published alias
buildPublishInfo(data)
// Room directory visibility
if (data.roomSummary.invoke()?.roomType != RoomType.SPACE) {
buildRoomDirectoryVisibility(data)
}
// Local alias
buildLocalInfo(data)
}

View File

@ -39,6 +39,7 @@ import im.vector.app.features.roomdirectory.RoomDirectorySharedActionViewModel
import im.vector.app.features.roomdirectory.createroom.CreateRoomArgs
import im.vector.app.features.roomdirectory.createroom.CreateRoomFragment
import im.vector.app.features.roomprofile.RoomProfileArgs
import im.vector.app.features.roomprofile.alias.RoomAliasFragment
import kotlinx.parcelize.Parcelize
import javax.inject.Inject
@ -155,6 +156,15 @@ class SpaceManageActivity : VectorBaseActivity<ActivitySimpleLoadingBinding>(),
)
}
}
SpaceManagedSharedViewEvents.NavigateToAliasSettings -> {
args?.spaceId?.let { spaceId ->
addFragmentToBackstack(
R.id.simpleFragmentContainer,
RoomAliasFragment::class.java,
RoomProfileArgs(spaceId)
)
}
}
}
}
}

View File

@ -56,6 +56,7 @@ class SpaceManageSharedViewModel @AssistedInject constructor(
SpaceManagedSharedAction.ShowLoading -> _viewEvents.post(SpaceManagedSharedViewEvents.ShowLoading)
SpaceManagedSharedAction.CreateRoom -> _viewEvents.post(SpaceManagedSharedViewEvents.NavigateToCreateRoom)
SpaceManagedSharedAction.ManageRooms -> _viewEvents.post(SpaceManagedSharedViewEvents.NavigateToManageRooms)
SpaceManagedSharedAction.OpenSpaceAliasesSettings -> _viewEvents.post(SpaceManagedSharedViewEvents.NavigateToAliasSettings)
}
}
}

View File

@ -24,4 +24,5 @@ sealed class SpaceManagedSharedAction : VectorViewModelAction {
object HideLoading : SpaceManagedSharedAction()
object CreateRoom : SpaceManagedSharedAction()
object ManageRooms : SpaceManagedSharedAction()
object OpenSpaceAliasesSettings : SpaceManagedSharedAction()
}

View File

@ -24,4 +24,5 @@ sealed class SpaceManagedSharedViewEvents : VectorViewEvents {
object HideLoading : SpaceManagedSharedViewEvents()
object NavigateToCreateRoom : SpaceManagedSharedViewEvents()
object NavigateToManageRooms : SpaceManagedSharedViewEvents()
object NavigateToAliasSettings : SpaceManagedSharedViewEvents()
}

View File

@ -52,6 +52,7 @@ class SpaceSettingsController @Inject constructor(
fun onDevRoomSettings()
fun onManageRooms()
fun setIsPublic(public: Boolean)
fun onRoomAliasesClicked()
}
var callback: Callback? = null
@ -139,6 +140,17 @@ class SpaceSettingsController @Inject constructor(
if (data.actionPermissions.canAddChildren) callback?.onManageRooms()
}
)
if (roomSummary.isPublic) {
buildProfileAction(
id = "alias",
title = stringProvider.getString(R.string.space_settings_alias_title),
subtitle = stringProvider.getString(R.string.space_settings_alias_subtitle),
dividerColor = dividerColor,
divider = true,
editable = true,
action = { callback?.onRoomAliasesClicked() }
)
}
if (vectorPreferences.developerMode()) {
buildProfileAction(

View File

@ -233,6 +233,10 @@ class SpaceSettingsFragment @Inject constructor(
}
}
override fun onRoomAliasesClicked() {
sharedViewModel.handle(SpaceManagedSharedAction.OpenSpaceAliasesSettings)
}
override fun onImageReady(uri: Uri?) {
uri ?: return
viewModel.handle(

View File

@ -1414,6 +1414,8 @@
<!-- room settings : alias -->
<string name="room_settings_alias_title">Room addresses</string>
<string name="room_settings_alias_subtitle">See and managed addresses of this room, and its visibility in the room directory.</string>
<string name="space_settings_alias_title">Space addresses</string>
<string name="space_settings_alias_subtitle">See and managed addresses of this space.</string>
<string name="room_alias_title">Room Addresses</string>
<string name="room_alias_published_alias_title">Published Addresses</string>