mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Fixes #3406
This commit is contained in:
parent
5d4f60ff6f
commit
432fd67ce2
12 changed files with 44 additions and 20 deletions
|
@ -54,7 +54,7 @@ interface PermalinkService {
|
|||
*
|
||||
* @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]
|
||||
|
|
|
@ -33,8 +33,8 @@ internal class DefaultPermalinkService @Inject constructor(
|
|||
return permalinkFactory.createPermalink(id)
|
||||
}
|
||||
|
||||
override fun createRoomPermalink(roomId: String): String? {
|
||||
return permalinkFactory.createRoomPermalink(roomId)
|
||||
override fun createRoomPermalink(roomId: String, via: List<String>?): String? {
|
||||
return permalinkFactory.createRoomPermalink(roomId, via)
|
||||
}
|
||||
|
||||
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.permalinks.PermalinkService.Companion.MATRIX_TO_URL_BASE
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import java.net.URLEncoder
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class PermalinkFactory @Inject constructor(
|
||||
|
@ -40,11 +41,18 @@ internal class PermalinkFactory @Inject constructor(
|
|||
} 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()) {
|
||||
null
|
||||
} 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 LeaveRoom(val roomId: 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)
|
||||
roomListViewModel.observeViewEvents {
|
||||
when (it) {
|
||||
is RoomListViewEvents.Loading -> showLoading(it.message)
|
||||
is RoomListViewEvents.Failure -> showFailure(it.throwable)
|
||||
is RoomListViewEvents.SelectRoom -> handleSelectRoom(it)
|
||||
is RoomListViewEvents.Done -> Unit
|
||||
is RoomListViewEvents.Loading -> showLoading(it.message)
|
||||
is RoomListViewEvents.Failure -> showFailure(it.throwable)
|
||||
is RoomListViewEvents.SelectRoom -> handleSelectRoom(it)
|
||||
is RoomListViewEvents.Done -> Unit
|
||||
is RoomListViewEvents.NavigateToMxToBottomSheet -> handleShowMxToLink(it.link)
|
||||
}.exhaustive
|
||||
}
|
||||
|
||||
|
@ -155,6 +156,10 @@ class RoomListFragment @Inject constructor(
|
|||
showErrorInSnackbar(throwable)
|
||||
}
|
||||
|
||||
private fun handleShowMxToLink(link: String) {
|
||||
navigator.openMatrixToBottomSheet(requireContext(), link)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
adapterInfosList.onEach { it.contentEpoxyController.removeModelBuildListener(modelBuildListener) }
|
||||
adapterInfosList.clear()
|
||||
|
@ -474,6 +479,10 @@ class RoomListFragment @Inject constructor(
|
|||
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) {
|
||||
notificationDrawerManager.clearMemberShipNotificationForRoom(room.roomId)
|
||||
roomListViewModel.handle(RoomListAction.RejectInvitation(room))
|
||||
|
|
|
@ -26,4 +26,5 @@ interface RoomListListener : FilteredRoomFooterItem.FilteredRoomFooterItemListen
|
|||
fun onRejectRoomInvitation(room: RoomSummary)
|
||||
fun onAcceptRoomInvitation(room: RoomSummary)
|
||||
fun onJoinSuggestedRoom(room: SpaceChildInfo)
|
||||
fun onSuggestedRoomClicked(room: SpaceChildInfo)
|
||||
}
|
||||
|
|
|
@ -29,4 +29,5 @@ sealed class RoomListViewEvents : VectorViewEvents {
|
|||
|
||||
data class SelectRoom(val roomSummary: RoomSummary) : 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.ToggleSection -> handleToggleSection(action.section)
|
||||
is RoomListAction.JoinSuggestedRoom -> handleJoinSuggestedRoom(action)
|
||||
is RoomListAction.ShowRoomDetails -> handleShowRoomDetails(action)
|
||||
}.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) {
|
||||
session.getRoom(action.roomId)?.let { room ->
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package im.vector.app.features.home.room.list
|
||||
|
||||
import android.view.View
|
||||
import com.airbnb.mvrx.Async
|
||||
import com.airbnb.mvrx.Loading
|
||||
import im.vector.app.R
|
||||
|
@ -56,7 +55,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
|||
|
||||
fun createSuggestion(spaceChildInfo: SpaceChildInfo,
|
||||
suggestedRoomJoiningStates: Map<String, Async<Unit>>,
|
||||
onJoinClick: View.OnClickListener): VectorEpoxyModel<*> {
|
||||
listener: RoomListListener?): VectorEpoxyModel<*> {
|
||||
return SpaceChildInfoItem_()
|
||||
.id("sug_${spaceChildInfo.childRoomId}")
|
||||
.matrixItem(spaceChildInfo.toMatrixItem())
|
||||
|
@ -65,7 +64,8 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
|||
.buttonLabel(stringProvider.getString(R.string.join))
|
||||
.loading(suggestedRoomJoiningStates[spaceChildInfo.childRoomId] is Loading)
|
||||
.memberCount(spaceChildInfo.activeMemberCount ?: 0)
|
||||
.buttonClickListener(onJoinClick)
|
||||
.buttonClickListener(DebouncedClickListener({ listener?.onJoinSuggestedRoom(spaceChildInfo) }))
|
||||
.itemClickListener(DebouncedClickListener({ listener?.onSuggestedRoomClicked(spaceChildInfo) }))
|
||||
}
|
||||
|
||||
private fun createInvitationItem(roomSummary: RoomSummary,
|
||||
|
|
|
@ -24,11 +24,7 @@ class SuggestedRoomListController(
|
|||
|
||||
override fun buildModels(data: SuggestedRoomInfo?) {
|
||||
data?.rooms?.forEach { info ->
|
||||
roomSummaryItemFactory.createSuggestion(info, data.joinEcho) {
|
||||
listener?.onJoinSuggestedRoom(info)
|
||||
}.let {
|
||||
add(it)
|
||||
}
|
||||
add(roomSummaryItemFactory.createSuggestion(info, data.joinEcho, listener))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
|||
val contentUrlResolver = activeSessionHolder.getActiveSession().contentUrlResolver()
|
||||
val resolvedUrl = when (mode) {
|
||||
Mode.FULL_SIZE,
|
||||
Mode.STICKER -> resolveUrl(data)
|
||||
Mode.STICKER -> resolveUrl(data)
|
||||
Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, size.width, size.height, ContentUrlResolver.ThumbnailMethod.SCALE)
|
||||
}
|
||||
// Fallback to base url
|
||||
|
@ -313,7 +313,7 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
|||
finalHeight = min(maxImageWidth * height / width, maxImageHeight)
|
||||
finalWidth = finalHeight * width / height
|
||||
}
|
||||
Mode.STICKER -> {
|
||||
Mode.STICKER -> {
|
||||
// limit on width
|
||||
val maxWidthDp = min(dimensionConverter.dpToPx(120), maxImageWidth / 2)
|
||||
finalWidth = min(dimensionConverter.dpToPx(width), maxWidthDp)
|
||||
|
|
Loading…
Reference in a new issue