Fixes #3406
This commit is contained in:
parent
5d4f60ff6f
commit
432fd67ce2
|
@ -54,7 +54,7 @@ interface PermalinkService {
|
||||||
*
|
*
|
||||||
* @return the permalink, or null in case of error
|
* @return the permalink, or null in case of error
|
||||||
*/
|
*/
|
||||||
fun createRoomPermalink(roomId: String): String?
|
fun createRoomPermalink(roomId: String, viaServers: List<String>? = null): String?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a permalink for an event. If you have an event you can use [createPermalink]
|
* Creates a permalink for an event. If you have an event you can use [createPermalink]
|
||||||
|
|
|
@ -33,8 +33,8 @@ internal class DefaultPermalinkService @Inject constructor(
|
||||||
return permalinkFactory.createPermalink(id)
|
return permalinkFactory.createPermalink(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createRoomPermalink(roomId: String): String? {
|
override fun createRoomPermalink(roomId: String, via: List<String>?): String? {
|
||||||
return permalinkFactory.createRoomPermalink(roomId)
|
return permalinkFactory.createRoomPermalink(roomId, via)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createPermalink(roomId: String, eventId: String): String {
|
override fun createPermalink(roomId: String, eventId: String): String {
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.session.permalinks
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkService.Companion.MATRIX_TO_URL_BASE
|
import org.matrix.android.sdk.api.session.permalinks.PermalinkService.Companion.MATRIX_TO_URL_BASE
|
||||||
import org.matrix.android.sdk.internal.di.UserId
|
import org.matrix.android.sdk.internal.di.UserId
|
||||||
|
import java.net.URLEncoder
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class PermalinkFactory @Inject constructor(
|
internal class PermalinkFactory @Inject constructor(
|
||||||
|
@ -40,11 +41,18 @@ internal class PermalinkFactory @Inject constructor(
|
||||||
} else MATRIX_TO_URL_BASE + escape(id)
|
} else MATRIX_TO_URL_BASE + escape(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createRoomPermalink(roomId: String): String? {
|
fun createRoomPermalink(roomId: String, via: List<String>? = null): String? {
|
||||||
return if (roomId.isEmpty()) {
|
return if (roomId.isEmpty()) {
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
MATRIX_TO_URL_BASE + escape(roomId) + viaParameterFinder.computeViaParams(userId, roomId)
|
buildString {
|
||||||
|
append(MATRIX_TO_URL_BASE)
|
||||||
|
append(escape(roomId))
|
||||||
|
append(
|
||||||
|
via?.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") }
|
||||||
|
?: viaParameterFinder.computeViaParams(userId, roomId)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
Fix | On Android it seems to be impossible to view the complete description of a Space (without dev tools) (#3386)
|
Fix | On Android it seems to be impossible to view the complete description of a Space (without dev tools) (#3386)
|
||||||
|
Fix | Suggest Rooms, Show a detailed view of the room on click (#3406)
|
|
@ -30,4 +30,5 @@ sealed class RoomListAction : VectorViewModelAction {
|
||||||
data class ToggleTag(val roomId: String, val tag: String) : RoomListAction()
|
data class ToggleTag(val roomId: String, val tag: String) : RoomListAction()
|
||||||
data class LeaveRoom(val roomId: String) : RoomListAction()
|
data class LeaveRoom(val roomId: String) : RoomListAction()
|
||||||
data class JoinSuggestedRoom(val roomId: String, val viaServers: List<String>?) : RoomListAction()
|
data class JoinSuggestedRoom(val roomId: String, val viaServers: List<String>?) : RoomListAction()
|
||||||
|
data class ShowRoomDetails(val roomId: String, val viaServers: List<String>?) : RoomListAction()
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,10 +108,11 @@ class RoomListFragment @Inject constructor(
|
||||||
sharedActionViewModel = activityViewModelProvider.get(RoomListQuickActionsSharedActionViewModel::class.java)
|
sharedActionViewModel = activityViewModelProvider.get(RoomListQuickActionsSharedActionViewModel::class.java)
|
||||||
roomListViewModel.observeViewEvents {
|
roomListViewModel.observeViewEvents {
|
||||||
when (it) {
|
when (it) {
|
||||||
is RoomListViewEvents.Loading -> showLoading(it.message)
|
is RoomListViewEvents.Loading -> showLoading(it.message)
|
||||||
is RoomListViewEvents.Failure -> showFailure(it.throwable)
|
is RoomListViewEvents.Failure -> showFailure(it.throwable)
|
||||||
is RoomListViewEvents.SelectRoom -> handleSelectRoom(it)
|
is RoomListViewEvents.SelectRoom -> handleSelectRoom(it)
|
||||||
is RoomListViewEvents.Done -> Unit
|
is RoomListViewEvents.Done -> Unit
|
||||||
|
is RoomListViewEvents.NavigateToMxToBottomSheet -> handleShowMxToLink(it.link)
|
||||||
}.exhaustive
|
}.exhaustive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +156,10 @@ class RoomListFragment @Inject constructor(
|
||||||
showErrorInSnackbar(throwable)
|
showErrorInSnackbar(throwable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleShowMxToLink(link: String) {
|
||||||
|
navigator.openMatrixToBottomSheet(requireContext(), link)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
adapterInfosList.onEach { it.contentEpoxyController.removeModelBuildListener(modelBuildListener) }
|
adapterInfosList.onEach { it.contentEpoxyController.removeModelBuildListener(modelBuildListener) }
|
||||||
adapterInfosList.clear()
|
adapterInfosList.clear()
|
||||||
|
@ -474,6 +479,10 @@ class RoomListFragment @Inject constructor(
|
||||||
roomListViewModel.handle(RoomListAction.JoinSuggestedRoom(room.childRoomId, room.viaServers))
|
roomListViewModel.handle(RoomListAction.JoinSuggestedRoom(room.childRoomId, room.viaServers))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onSuggestedRoomClicked(room: SpaceChildInfo) {
|
||||||
|
roomListViewModel.handle(RoomListAction.ShowRoomDetails(room.childRoomId, room.viaServers))
|
||||||
|
}
|
||||||
|
|
||||||
override fun onRejectRoomInvitation(room: RoomSummary) {
|
override fun onRejectRoomInvitation(room: RoomSummary) {
|
||||||
notificationDrawerManager.clearMemberShipNotificationForRoom(room.roomId)
|
notificationDrawerManager.clearMemberShipNotificationForRoom(room.roomId)
|
||||||
roomListViewModel.handle(RoomListAction.RejectInvitation(room))
|
roomListViewModel.handle(RoomListAction.RejectInvitation(room))
|
||||||
|
|
|
@ -26,4 +26,5 @@ interface RoomListListener : FilteredRoomFooterItem.FilteredRoomFooterItemListen
|
||||||
fun onRejectRoomInvitation(room: RoomSummary)
|
fun onRejectRoomInvitation(room: RoomSummary)
|
||||||
fun onAcceptRoomInvitation(room: RoomSummary)
|
fun onAcceptRoomInvitation(room: RoomSummary)
|
||||||
fun onJoinSuggestedRoom(room: SpaceChildInfo)
|
fun onJoinSuggestedRoom(room: SpaceChildInfo)
|
||||||
|
fun onSuggestedRoomClicked(room: SpaceChildInfo)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,5 @@ sealed class RoomListViewEvents : VectorViewEvents {
|
||||||
|
|
||||||
data class SelectRoom(val roomSummary: RoomSummary) : RoomListViewEvents()
|
data class SelectRoom(val roomSummary: RoomSummary) : RoomListViewEvents()
|
||||||
object Done : RoomListViewEvents()
|
object Done : RoomListViewEvents()
|
||||||
|
data class NavigateToMxToBottomSheet(val link: String) : RoomListViewEvents()
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,7 @@ class RoomListViewModel @Inject constructor(
|
||||||
is RoomListAction.ToggleTag -> handleToggleTag(action)
|
is RoomListAction.ToggleTag -> handleToggleTag(action)
|
||||||
is RoomListAction.ToggleSection -> handleToggleSection(action.section)
|
is RoomListAction.ToggleSection -> handleToggleSection(action.section)
|
||||||
is RoomListAction.JoinSuggestedRoom -> handleJoinSuggestedRoom(action)
|
is RoomListAction.JoinSuggestedRoom -> handleJoinSuggestedRoom(action)
|
||||||
|
is RoomListAction.ShowRoomDetails -> handleShowRoomDetails(action)
|
||||||
}.exhaustive
|
}.exhaustive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,6 +290,12 @@ class RoomListViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleShowRoomDetails(action: RoomListAction.ShowRoomDetails) {
|
||||||
|
session.permalinkService().createRoomPermalink(action.roomId, action.viaServers)?.let {
|
||||||
|
_viewEvents.post(RoomListViewEvents.NavigateToMxToBottomSheet(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleToggleTag(action: RoomListAction.ToggleTag) {
|
private fun handleToggleTag(action: RoomListAction.ToggleTag) {
|
||||||
session.getRoom(action.roomId)?.let { room ->
|
session.getRoom(action.roomId)?.let { room ->
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package im.vector.app.features.home.room.list
|
package im.vector.app.features.home.room.list
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import com.airbnb.mvrx.Async
|
import com.airbnb.mvrx.Async
|
||||||
import com.airbnb.mvrx.Loading
|
import com.airbnb.mvrx.Loading
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
|
@ -56,7 +55,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
||||||
|
|
||||||
fun createSuggestion(spaceChildInfo: SpaceChildInfo,
|
fun createSuggestion(spaceChildInfo: SpaceChildInfo,
|
||||||
suggestedRoomJoiningStates: Map<String, Async<Unit>>,
|
suggestedRoomJoiningStates: Map<String, Async<Unit>>,
|
||||||
onJoinClick: View.OnClickListener): VectorEpoxyModel<*> {
|
listener: RoomListListener?): VectorEpoxyModel<*> {
|
||||||
return SpaceChildInfoItem_()
|
return SpaceChildInfoItem_()
|
||||||
.id("sug_${spaceChildInfo.childRoomId}")
|
.id("sug_${spaceChildInfo.childRoomId}")
|
||||||
.matrixItem(spaceChildInfo.toMatrixItem())
|
.matrixItem(spaceChildInfo.toMatrixItem())
|
||||||
|
@ -65,7 +64,8 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
||||||
.buttonLabel(stringProvider.getString(R.string.join))
|
.buttonLabel(stringProvider.getString(R.string.join))
|
||||||
.loading(suggestedRoomJoiningStates[spaceChildInfo.childRoomId] is Loading)
|
.loading(suggestedRoomJoiningStates[spaceChildInfo.childRoomId] is Loading)
|
||||||
.memberCount(spaceChildInfo.activeMemberCount ?: 0)
|
.memberCount(spaceChildInfo.activeMemberCount ?: 0)
|
||||||
.buttonClickListener(onJoinClick)
|
.buttonClickListener(DebouncedClickListener({ listener?.onJoinSuggestedRoom(spaceChildInfo) }))
|
||||||
|
.itemClickListener(DebouncedClickListener({ listener?.onSuggestedRoomClicked(spaceChildInfo) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createInvitationItem(roomSummary: RoomSummary,
|
private fun createInvitationItem(roomSummary: RoomSummary,
|
||||||
|
|
|
@ -24,11 +24,7 @@ class SuggestedRoomListController(
|
||||||
|
|
||||||
override fun buildModels(data: SuggestedRoomInfo?) {
|
override fun buildModels(data: SuggestedRoomInfo?) {
|
||||||
data?.rooms?.forEach { info ->
|
data?.rooms?.forEach { info ->
|
||||||
roomSummaryItemFactory.createSuggestion(info, data.joinEcho) {
|
add(roomSummaryItemFactory.createSuggestion(info, data.joinEcho, listener))
|
||||||
listener?.onJoinSuggestedRoom(info)
|
|
||||||
}.let {
|
|
||||||
add(it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
||||||
val contentUrlResolver = activeSessionHolder.getActiveSession().contentUrlResolver()
|
val contentUrlResolver = activeSessionHolder.getActiveSession().contentUrlResolver()
|
||||||
val resolvedUrl = when (mode) {
|
val resolvedUrl = when (mode) {
|
||||||
Mode.FULL_SIZE,
|
Mode.FULL_SIZE,
|
||||||
Mode.STICKER -> resolveUrl(data)
|
Mode.STICKER -> resolveUrl(data)
|
||||||
Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, size.width, size.height, ContentUrlResolver.ThumbnailMethod.SCALE)
|
Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, size.width, size.height, ContentUrlResolver.ThumbnailMethod.SCALE)
|
||||||
}
|
}
|
||||||
// Fallback to base url
|
// Fallback to base url
|
||||||
|
@ -313,7 +313,7 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
||||||
finalHeight = min(maxImageWidth * height / width, maxImageHeight)
|
finalHeight = min(maxImageWidth * height / width, maxImageHeight)
|
||||||
finalWidth = finalHeight * width / height
|
finalWidth = finalHeight * width / height
|
||||||
}
|
}
|
||||||
Mode.STICKER -> {
|
Mode.STICKER -> {
|
||||||
// limit on width
|
// limit on width
|
||||||
val maxWidthDp = min(dimensionConverter.dpToPx(120), maxImageWidth / 2)
|
val maxWidthDp = min(dimensionConverter.dpToPx(120), maxImageWidth / 2)
|
||||||
finalWidth = min(dimensionConverter.dpToPx(width), maxWidthDp)
|
finalWidth = min(dimensionConverter.dpToPx(width), maxWidthDp)
|
||||||
|
|
Loading…
Reference in New Issue