From 447bd98a78dc67ee5d7a7210f34b603aaf1b798c Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 24 May 2021 10:54:09 +0200 Subject: [PATCH 01/10] Fixes #3386 show space description in explore header --- .../api/session/room/model/SpaceChildInfo.kt | 4 +- .../api/session/room/peeking/PeekResult.kt | 3 +- .../matrix/android/sdk/api/util/MatrixItem.kt | 2 +- .../database/mapper/RoomSummaryMapper.kt | 4 +- .../session/room/peeking/PeekRoomTask.kt | 13 +- .../session/space/DefaultSpaceService.kt | 3 +- .../home/room/list/SpaceChildInfoItem.kt | 2 +- .../matrixto/MatrixToBottomSheetState.kt | 3 +- .../matrixto/MatrixToBottomSheetViewModel.kt | 14 +- .../matrixto/MatrixToRoomSpaceFragment.kt | 9 + .../app/features/matrixto/SpaceCardHelper.kt | 169 ++++++++++++++++++ .../spaces/explore/SpaceDirectoryFragment.kt | 87 ++++++++- .../spaces/explore/SpaceDirectoryViewModel.kt | 13 +- .../spaces/invite/SpaceInviteBottomSheet.kt | 47 +---- .../fragment_matrix_to_room_space_card.xml | 36 +++- .../layout/fragment_room_directory_picker.xml | 67 ++++--- vector/src/main/res/values/strings.xml | 4 + 17 files changed, 389 insertions(+), 91 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/matrixto/SpaceCardHelper.kt diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/SpaceChildInfo.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/SpaceChildInfo.kt index 66293bcb8c..8cd2a0538d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/SpaceChildInfo.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/SpaceChildInfo.kt @@ -32,5 +32,7 @@ data class SpaceChildInfo( val parentRoomId: String?, val suggested: Boolean?, val canonicalAlias: String?, - val aliases: List? + val aliases: List?, + val worldReadable: Boolean + ) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/peeking/PeekResult.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/peeking/PeekResult.kt index 888950dc12..b78cd5e032 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/peeking/PeekResult.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/peeking/PeekResult.kt @@ -28,7 +28,8 @@ sealed class PeekResult { val numJoinedMembers: Int?, val roomType: String?, val viaServers: List, - val someMembers: List? + val someMembers: List?, + val isPublic: Boolean ) : PeekResult() data class PeekingNotAllowed( diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt index deb279eb95..bc397c5b4a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt @@ -159,4 +159,4 @@ fun RoomMemberSummary.toMatrixItem() = MatrixItem.UserItem(userId, displayName, fun SenderInfo.toMatrixItem() = MatrixItem.UserItem(userId, disambiguatedDisplayName, avatarUrl) -fun SpaceChildInfo.toMatrixItem() = MatrixItem.RoomItem(childRoomId, name ?: canonicalAlias ?: "", avatarUrl) +fun SpaceChildInfo.toMatrixItem() = MatrixItem.RoomItem(childRoomId, name ?: canonicalAlias, avatarUrl) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt index 3fea15bd3d..c32c019625 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt @@ -16,6 +16,7 @@ package org.matrix.android.sdk.internal.database.mapper +import org.matrix.android.sdk.api.session.room.model.RoomJoinRules import org.matrix.android.sdk.api.session.room.model.RoomSummary import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo import org.matrix.android.sdk.api.session.room.model.SpaceParentInfo @@ -92,7 +93,8 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa parentRoomId = roomSummaryEntity.roomId, suggested = it.suggested, canonicalAlias = it.childSummaryEntity?.canonicalAlias, - aliases = it.childSummaryEntity?.aliases?.toList() + aliases = it.childSummaryEntity?.aliases?.toList(), + worldReadable = it.childSummaryEntity?.joinRules == RoomJoinRules.PUBLIC ) }, flattenParentIds = roomSummaryEntity.flattenParentIds?.split("|") ?: emptyList() diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/PeekRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/PeekRoomTask.kt index c6f4bbb4e1..219e9c903f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/PeekRoomTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/PeekRoomTask.kt @@ -23,6 +23,8 @@ import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.room.model.RoomAvatarContent import org.matrix.android.sdk.api.session.room.model.RoomCanonicalAliasContent import org.matrix.android.sdk.api.session.room.model.RoomDirectoryVisibility +import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibility +import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibilityContent import org.matrix.android.sdk.api.session.room.model.RoomMemberContent import org.matrix.android.sdk.api.session.room.model.RoomNameContent import org.matrix.android.sdk.api.session.room.model.RoomTopicContent @@ -105,7 +107,8 @@ internal class DefaultPeekRoomTask @Inject constructor( numJoinedMembers = publicRepoResult.numJoinedMembers, viaServers = serverList, roomType = null, // would be nice to get that from directory... - someMembers = null + someMembers = null, + isPublic = true ) } @@ -143,6 +146,11 @@ internal class DefaultPeekRoomTask @Inject constructor( } } + val historyVisibility = + stateEvents + .lastOrNull { it.type == EventType.STATE_ROOM_HISTORY_VISIBILITY && it.stateKey?.isNotEmpty() == true } + ?.let { it.content?.toModel()?.historyVisibility } + val roomType = stateEvents .lastOrNull { it.type == EventType.STATE_ROOM_CREATE } ?.content @@ -158,7 +166,8 @@ internal class DefaultPeekRoomTask @Inject constructor( numJoinedMembers = memberCount, roomType = roomType, viaServers = serverList, - someMembers = someMembers + someMembers = someMembers, + isPublic = historyVisibility == RoomHistoryVisibility.WORLD_READABLE ) } catch (failure: Throwable) { // Would be M_FORBIDDEN if cannot peek :/ diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt index d0ad19245f..9c6153b349 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt @@ -147,7 +147,8 @@ internal class DefaultSpaceService @Inject constructor( parentRoomId = childStateEv.roomId, suggested = childStateEvContent.suggested, canonicalAlias = childSummary.canonicalAlias, - aliases = childSummary.aliases + aliases = childSummary.aliases, + worldReadable = childSummary.worldReadable ) } }.orEmpty() diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/SpaceChildInfoItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/SpaceChildInfoItem.kt index cb9c8b1f2e..f03cc4c9dc 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/SpaceChildInfoItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/SpaceChildInfoItem.kt @@ -63,7 +63,7 @@ abstract class SpaceChildInfoItem : VectorEpoxyModel( it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) itemLongClickListener?.onLongClick(it) ?: false } - holder.titleView.text = matrixItem.getBestName() + holder.titleView.text = matrixItem.displayName ?: holder.rootView.context.getString(R.string.unnamed_room) if (space) { avatarRenderer.renderSpace(matrixItem, holder.avatarImageView) } else { diff --git a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetState.kt b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetState.kt index 2f341d48ec..7082cd16a3 100644 --- a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetState.kt +++ b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetState.kt @@ -48,7 +48,8 @@ sealed class RoomInfoResult { val alias: String?, val membership: Membership, val roomType: String?, - val viaServers: List? + val viaServers: List?, + val isPublic: Boolean ) : RoomInfoResult() data class PartialInfo( diff --git a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetViewModel.kt b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetViewModel.kt index 694f324025..1c78348b56 100644 --- a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetViewModel.kt @@ -118,11 +118,9 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor( session.getRoom(permalinkData.roomIdOrAlias) } ?.roomSummary() - // don't take if not active, as it could be outdated - ?.takeIf { it.membership.isActive() } - // XXX fix that - val forceRefresh = true - if (!forceRefresh && knownRoom != null) { + // don't take if not Join, as it could be outdated + ?.takeIf { it.membership == Membership.JOIN } + if (knownRoom != null) { setState { copy( roomPeekResult = Success( @@ -134,7 +132,8 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor( alias = knownRoom.canonicalAlias, membership = knownRoom.membership, roomType = knownRoom.roomType, - viaServers = null + viaServers = null, + isPublic = knownRoom.isPublic ) ) ) @@ -150,7 +149,8 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor( alias = peekResult.alias, membership = knownRoom?.membership ?: Membership.NONE, roomType = peekResult.roomType, - viaServers = peekResult.viaServers.takeIf { it.isNotEmpty() } ?: permalinkData.viaParameters + viaServers = peekResult.viaServers.takeIf { it.isNotEmpty() } ?: permalinkData.viaParameters, + isPublic = peekResult.isPublic ).also { peekResult.someMembers?.let { checkForKnownMembers(it) } } diff --git a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt index 04f72000fa..730a04aef7 100644 --- a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt @@ -81,6 +81,15 @@ class MatrixToRoomSpaceFragment @Inject constructor( if (peek.roomType == RoomType.SPACE) { views.matrixToBetaTag.isVisible = true avatarRenderer.renderSpace(matrixItem, views.matrixToCardAvatar) + if (peek.isPublic) { + views.matrixToAccessText.setTextOrHide(context?.getString(R.string.public_space)) + views.matrixToAccessImage.isVisible = true + views.matrixToAccessImage.setImageResource(R.drawable.ic_public_room) + } else { + views.matrixToAccessText.setTextOrHide(context?.getString(R.string.private_space)) + views.matrixToAccessImage.isVisible = true + views.matrixToAccessImage.setImageResource(R.drawable.ic_room_private) + } } else { views.matrixToBetaTag.isVisible = false avatarRenderer.render(matrixItem, views.matrixToCardAvatar) diff --git a/vector/src/main/java/im/vector/app/features/matrixto/SpaceCardHelper.kt b/vector/src/main/java/im/vector/app/features/matrixto/SpaceCardHelper.kt new file mode 100644 index 0000000000..5a64c15f30 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/matrixto/SpaceCardHelper.kt @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2021 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.matrixto + +import androidx.core.view.isGone +import androidx.core.view.isVisible +import im.vector.app.R +import im.vector.app.core.extensions.setTextOrHide +import im.vector.app.core.resources.ColorProvider +import im.vector.app.core.resources.DrawableProvider +import im.vector.app.core.resources.StringProvider +import im.vector.app.databinding.FragmentMatrixToRoomSpaceCardBinding +import im.vector.app.features.home.AvatarRenderer +import im.vector.app.features.home.room.detail.timeline.TimelineEventController +import im.vector.app.features.home.room.detail.timeline.tools.createLinkMovementMethod +import im.vector.app.features.home.room.detail.timeline.tools.linkify +import org.matrix.android.sdk.api.session.room.model.RoomSummary +import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo +import org.matrix.android.sdk.api.session.user.model.User +import org.matrix.android.sdk.api.util.toMatrixItem +import javax.inject.Inject + +class SpaceCardHelper @Inject constructor( + private val avatarRenderer: AvatarRenderer, + private val stringProvider: StringProvider, + private val drawableProvider: DrawableProvider, + private val colorProvider: ColorProvider +) { + + fun render(spaceSummary: RoomSummary?, + peopleYouKnow: List, + matrixLinkCallback: TimelineEventController.UrlClickCallback?, + inCard: FragmentMatrixToRoomSpaceCardBinding) { + if (spaceSummary == null) { + inCard.matrixToCardContentVisibility.isVisible = false + inCard.matrixToCardButtonLoading.isVisible = true + } else { + inCard.matrixToCardContentVisibility.isVisible = true + inCard.matrixToCardButtonLoading.isVisible = false + avatarRenderer.renderSpace(spaceSummary.toMatrixItem(), inCard.matrixToCardAvatar) + inCard.matrixToCardNameText.text = spaceSummary.name + inCard.matrixToBetaTag.isVisible = true + inCard.matrixToCardAliasText.setTextOrHide(spaceSummary.canonicalAlias) + inCard.matrixToCardDescText.setTextOrHide(spaceSummary.topic.linkify(matrixLinkCallback)) + if (spaceSummary.isPublic) { + inCard.matrixToAccessText.setTextOrHide(stringProvider.getString(R.string.public_space)) + inCard.matrixToAccessImage.isVisible = true + inCard.matrixToAccessImage.setImageResource(R.drawable.ic_public_room) + } else { + inCard.matrixToAccessText.setTextOrHide(stringProvider.getString(R.string.private_space)) + inCard.matrixToAccessImage.isVisible = true + inCard.matrixToAccessImage.setImageResource(R.drawable.ic_room_private) + } + val memberCount = spaceSummary.otherMemberIds.size + if (memberCount != 0) { + inCard.matrixToMemberPills.isVisible = true + inCard.spaceChildMemberCountText.text = stringProvider.getQuantityString(R.plurals.room_title_members, memberCount, memberCount) + } else { + // hide the pill + inCard.matrixToMemberPills.isVisible = false + } + + val images = listOf( + inCard.knownMember1, + inCard.knownMember2, + inCard.knownMember3, + inCard.knownMember4, + inCard.knownMember5 + ).onEach { it.isGone = true } + + if (peopleYouKnow.isEmpty()) { + inCard.peopleYouMayKnowText.isVisible = false + } else { + peopleYouKnow.forEachIndexed { index, item -> + images[index].isVisible = true + avatarRenderer.render(item.toMatrixItem(), images[index]) + } + inCard.peopleYouMayKnowText.setTextOrHide( + stringProvider.getQuantityString(R.plurals.space_people_you_know, + peopleYouKnow.count(), + peopleYouKnow.count() + ) + ) + } + } + inCard.matrixToCardDescText.movementMethod = createLinkMovementMethod(object : TimelineEventController.UrlClickCallback { + override fun onUrlClicked(url: String, title: String): Boolean { + return false + } + + override fun onUrlLongClicked(url: String): Boolean { + // host.callback?.onUrlInTopicLongClicked(url) + return true + } + }) + } + + fun render(spaceChildInfo: SpaceChildInfo?, + peopleYouKnow: List, + matrixLinkCallback: TimelineEventController.UrlClickCallback?, + inCard: FragmentMatrixToRoomSpaceCardBinding) { + if (spaceChildInfo == null) { + inCard.matrixToCardContentVisibility.isVisible = false + inCard.matrixToCardButtonLoading.isVisible = true + } else { + inCard.matrixToCardContentVisibility.isVisible = true + inCard.matrixToCardButtonLoading.isVisible = false + avatarRenderer.renderSpace(spaceChildInfo.toMatrixItem(), inCard.matrixToCardAvatar) + inCard.matrixToCardNameText.setTextOrHide(spaceChildInfo.name) + inCard.matrixToBetaTag.isVisible = true + inCard.matrixToCardAliasText.setTextOrHide(spaceChildInfo.canonicalAlias) + inCard.matrixToCardDescText.setTextOrHide(spaceChildInfo.topic?.linkify(matrixLinkCallback)) + if (spaceChildInfo.worldReadable) { + inCard.matrixToAccessText.setTextOrHide(stringProvider.getString(R.string.public_space)) + inCard.matrixToAccessImage.isVisible = true + inCard.matrixToAccessImage.setImageResource(R.drawable.ic_public_room) + } else { + inCard.matrixToAccessText.setTextOrHide(stringProvider.getString(R.string.private_space)) + inCard.matrixToAccessImage.isVisible = true + inCard.matrixToAccessImage.setImageResource(R.drawable.ic_room_private) + } + val memberCount = spaceChildInfo.activeMemberCount ?: 0 + if (memberCount != 0) { + inCard.matrixToMemberPills.isVisible = true + inCard.spaceChildMemberCountText.text = stringProvider.getQuantityString(R.plurals.room_title_members, memberCount, memberCount) + } else { + // hide the pill + inCard.matrixToMemberPills.isVisible = false + } + + val images = listOf( + inCard.knownMember1, + inCard.knownMember2, + inCard.knownMember3, + inCard.knownMember4, + inCard.knownMember5 + ).onEach { it.isGone = true } + + if (peopleYouKnow.isEmpty()) { + inCard.peopleYouMayKnowText.isVisible = false + } else { + peopleYouKnow.forEachIndexed { index, item -> + images[index].isVisible = true + avatarRenderer.render(item.toMatrixItem(), images[index]) + } + inCard.peopleYouMayKnowText.setTextOrHide( + stringProvider.getQuantityString(R.plurals.space_people_you_know, + peopleYouKnow.count(), + peopleYouKnow.count() + ) + ) + } + } + } +} diff --git a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryFragment.kt b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryFragment.kt index a866ea9b89..7f45307a0d 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryFragment.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryFragment.kt @@ -16,6 +16,7 @@ package im.vector.app.features.spaces.explore +import android.content.DialogInterface import android.os.Bundle import android.os.Parcelable import android.view.LayoutInflater @@ -23,19 +24,33 @@ import android.view.Menu import android.view.MenuItem import android.view.View import android.view.ViewGroup +import androidx.appcompat.app.AlertDialog +import androidx.core.text.toSpannable +import androidx.core.view.isVisible import com.airbnb.mvrx.activityViewModel import com.airbnb.mvrx.withState import im.vector.app.R +import im.vector.app.core.dialogs.withColoredButton import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.configureWith import im.vector.app.core.extensions.registerStartForActivityResult import im.vector.app.core.platform.OnBackPressed import im.vector.app.core.platform.VectorBaseFragment +import im.vector.app.core.resources.ColorProvider +import im.vector.app.core.utils.colorizeMatchingText +import im.vector.app.core.utils.isValidUrl +import im.vector.app.core.utils.openUrlInExternalBrowser import im.vector.app.databinding.FragmentRoomDirectoryPickerBinding +import im.vector.app.features.home.room.detail.timeline.TimelineEventController +import im.vector.app.features.matrixto.SpaceCardHelper +import im.vector.app.features.permalink.PermalinkHandler import im.vector.app.features.spaces.manage.ManageType import im.vector.app.features.spaces.manage.SpaceManageActivity +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.schedulers.Schedulers import kotlinx.parcelize.Parcelize import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo +import java.net.URL import javax.inject.Inject @Parcelize @@ -44,9 +59,13 @@ data class SpaceDirectoryArgs( ) : Parcelable class SpaceDirectoryFragment @Inject constructor( - private val epoxyController: SpaceDirectoryController + private val epoxyController: SpaceDirectoryController, + private val permalinkHandler: PermalinkHandler, + private val spaceCardHelper: SpaceCardHelper, + private val colorProvider: ColorProvider ) : VectorBaseFragment(), SpaceDirectoryController.InteractionListener, + TimelineEventController.UrlClickCallback, OnBackPressed { override fun getMenuRes() = R.menu.menu_space_directory @@ -71,6 +90,15 @@ class SpaceDirectoryFragment @Inject constructor( viewModel.selectSubscribe(this, SpaceDirectoryState::canAddRooms) { invalidateOptionsMenu() } + + views.spaceCard.matrixToCardMainButton.isVisible = false + views.spaceCard.matrixToCardSecondaryButton.isVisible = false + views.spaceCard.knownMember1.isVisible = false + views.spaceCard.knownMember2.isVisible = false + views.spaceCard.knownMember3.isVisible = false + views.spaceCard.knownMember4.isVisible = false + views.spaceCard.knownMember5.isVisible = false + views.spaceCard.peopleYouMayKnowText.isVisible = false } override fun onDestroyView() { @@ -82,10 +110,21 @@ class SpaceDirectoryFragment @Inject constructor( override fun invalidate() = withState(viewModel) { state -> epoxyController.setData(state) - val title = state.hierarchyStack.lastOrNull()?.let { currentParent -> + val currentParent = state.hierarchyStack.lastOrNull()?.let { currentParent -> state.spaceSummaryApiResult.invoke()?.firstOrNull { it.childRoomId == currentParent } - }?.name ?: getString(R.string.space_explore_activity_title) - views.toolbar.title = title + } + + if (currentParent == null) { + val title = getString(R.string.space_explore_activity_title) + views.toolbar.title = title + + spaceCardHelper.render(state.spaceSummary.invoke(), emptyList(), this, views.spaceCard) + } else { + val title = currentParent.name ?: currentParent.canonicalAlias ?: getString(R.string.space_explore_activity_title) + views.toolbar.title = title + + spaceCardHelper.render(currentParent, emptyList(), this, views.spaceCard) + } } override fun onPrepareOptionsMenu(menu: Menu) = withState(viewModel) { state -> @@ -96,7 +135,7 @@ class SpaceDirectoryFragment @Inject constructor( override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { - R.id.spaceAddRoom -> { + R.id.spaceAddRoom -> { withState(viewModel) { state -> addExistingRooms(state.spaceId) } @@ -138,6 +177,44 @@ class SpaceDirectoryFragment @Inject constructor( override fun addExistingRooms(spaceId: String) { addExistingRoomActivityResult.launch(SpaceManageActivity.newIntent(requireContext(), spaceId, ManageType.AddRooms)) } + + override fun onUrlClicked(url: String, title: String): Boolean { + permalinkHandler + .launch(requireActivity(), url, null) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe { managed -> + if (!managed) { + if (title.isValidUrl() && url.isValidUrl() && URL(title).host != URL(url).host) { + AlertDialog.Builder(requireActivity()) + .setTitle(R.string.external_link_confirmation_title) + .setMessage( + getString(R.string.external_link_confirmation_message, title, url) + .toSpannable() + .colorizeMatchingText(url, colorProvider.getColorFromAttribute(R.attr.riotx_text_primary_body_contrast)) + .colorizeMatchingText(title, colorProvider.getColorFromAttribute(R.attr.riotx_text_primary_body_contrast)) + ) + .setPositiveButton(R.string._continue) { _, _ -> + openUrlInExternalBrowser(requireContext(), url) + } + .setNegativeButton(R.string.cancel, null) + .show() + .withColoredButton(DialogInterface.BUTTON_NEGATIVE) + } else { + // Open in external browser, in a new Tab + openUrlInExternalBrowser(requireContext(), url) + } + } + } + .disposeOnDestroyView() + // In fact it is always managed + return true + } + + override fun onUrlLongClicked(url: String): Boolean { + // nothing? + return false + } // override fun navigateToRoom(roomId: String) { // viewModel.handle(SpaceDirectoryViewAction.NavigateToRoom(roomId)) // } diff --git a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryViewModel.kt index 313ddfe1dc..4d0faedd7e 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryViewModel.kt @@ -66,7 +66,8 @@ class SpaceDirectoryViewModel @AssistedInject constructor( val spaceSum = session.getRoomSummary(initialState.spaceId) setState { copy( - childList = spaceSum?.spaceChildren ?: emptyList() + childList = spaceSum?.spaceChildren ?: emptyList(), + spaceSummary = spaceSum?.let { Success(spaceSum) } ?: Loading() ) } @@ -148,7 +149,7 @@ class SpaceDirectoryViewModel @AssistedInject constructor( copy(hierarchyStack = hierarchyStack + listOf(action.spaceChildInfo.childRoomId)) } } - SpaceDirectoryViewAction.HandleBack -> { + SpaceDirectoryViewAction.HandleBack -> { withState { if (it.hierarchyStack.isEmpty()) { _viewEvents.post(SpaceDirectoryViewEvents.Dismiss) @@ -161,20 +162,20 @@ class SpaceDirectoryViewModel @AssistedInject constructor( } } } - is SpaceDirectoryViewAction.JoinOrOpen -> { + is SpaceDirectoryViewAction.JoinOrOpen -> { handleJoinOrOpen(action.spaceChildInfo) } - is SpaceDirectoryViewAction.NavigateToRoom -> { + is SpaceDirectoryViewAction.NavigateToRoom -> { _viewEvents.post(SpaceDirectoryViewEvents.NavigateToRoom(action.roomId)) } - is SpaceDirectoryViewAction.ShowDetails -> { + is SpaceDirectoryViewAction.ShowDetails -> { // This is temporary for now to at least display something for the space beta // It's not ideal as it's doing some peeking that is not needed. session.permalinkService().createRoomPermalink(action.spaceChildInfo.childRoomId)?.let { _viewEvents.post(SpaceDirectoryViewEvents.NavigateToMxToBottomSheet(it)) } } - SpaceDirectoryViewAction.Retry -> { + SpaceDirectoryViewAction.Retry -> { refreshFromApi() } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt b/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt index 8e536459a3..d393943f72 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt @@ -22,7 +22,6 @@ import android.os.Parcelable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.core.view.isGone import androidx.core.view.isVisible import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Loading @@ -33,12 +32,12 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import im.vector.app.R import im.vector.app.core.di.ScreenComponent -import im.vector.app.core.extensions.setTextOrHide import im.vector.app.core.platform.ButtonStateView import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.core.utils.toast import im.vector.app.databinding.BottomSheetInvitedToSpaceBinding import im.vector.app.features.home.AvatarRenderer +import im.vector.app.features.matrixto.SpaceCardHelper import kotlinx.parcelize.Parcelize import org.matrix.android.sdk.api.util.toMatrixItem import javax.inject.Inject @@ -60,6 +59,9 @@ class SpaceInviteBottomSheet : VectorBaseBottomSheetDialogFragment - images[index].isVisible = true - avatarRenderer.render(item.toMatrixItem(), images[index]) - } - views.spaceCard.peopleYouMayKnowText.setTextOrHide( - resources.getQuantityString(R.plurals.space_people_you_know, - peopleYouKnow.count(), - peopleYouKnow.count() - ) - ) - } } override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetInvitedToSpaceBinding { diff --git a/vector/src/main/res/layout/fragment_matrix_to_room_space_card.xml b/vector/src/main/res/layout/fragment_matrix_to_room_space_card.xml index b2d24f5218..091c8f15b2 100644 --- a/vector/src/main/res/layout/fragment_matrix_to_room_space_card.xml +++ b/vector/src/main/res/layout/fragment_matrix_to_room_space_card.xml @@ -58,7 +58,7 @@ android:id="@+id/matrixToCardAliasText" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="4dp" + android:layout_marginTop="8dp" android:maxLines="1" android:singleLine="true" android:textAlignment="textStart" @@ -70,12 +70,43 @@ tools:text="@sample/rooms.json/data/alias" tools:visibility="visible" /> + + + + + + app:layout_constraintTop_toBottomOf="@id/matrixToAccessText"> - + android:layout_height="wrap_content" + android:elevation="4dp"> - - + android:layout_height="match_parent" + android:theme="@style/Vector.Toolbar.Profile" + app:contentScrim="?riotx_background" + app:layout_scrollFlags="scroll|exitUntilCollapsed|snap" + app:scrimAnimationDuration="250" + app:scrimVisibleHeightTrigger="120dp" + app:titleEnabled="false" + app:toolbarId="@+id/toolbar"> - + + + + + + + + + + + + + + - \ No newline at end of file diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 8649b14ca3..4f59d00d27 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3262,6 +3262,7 @@ Do not notify View read receipts This room is public + This Space is public Dev Tools Explore Room State @@ -3293,6 +3294,8 @@ Delete unsent messages Are you sure you want to delete all unsent messages in this room? + Public space + Private space Add Space Your public space Your private space @@ -3388,4 +3391,5 @@ Some rooms may be hidden because they’re private and you need an invite.\nYou don’t have permission to add rooms. Some rooms may be hidden because they’re private and you need an invite. + Unnamed Room From 5d4f60ff6f74b8600107c20097f19b2bd1b15775 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 24 May 2021 11:03:14 +0200 Subject: [PATCH 02/10] Update changelog --- newsfragment/3401.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragment/3401.bugfix diff --git a/newsfragment/3401.bugfix b/newsfragment/3401.bugfix new file mode 100644 index 0000000000..42509f3ae3 --- /dev/null +++ b/newsfragment/3401.bugfix @@ -0,0 +1 @@ +Fix | On Android it seems to be impossible to view the complete description of a Space (without dev tools) (#3386) \ No newline at end of file From 432fd67ce20a7e50704b26b938f906e8ef4ed49e Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 25 May 2021 14:08:48 +0200 Subject: [PATCH 03/10] Fixes #3406 --- .../api/session/permalinks/PermalinkService.kt | 2 +- .../permalinks/DefaultPermalinkService.kt | 4 ++-- .../session/permalinks/PermalinkFactory.kt | 12 ++++++++++-- newsfragment/3401.bugfix | 3 ++- .../features/home/room/list/RoomListAction.kt | 1 + .../features/home/room/list/RoomListFragment.kt | 17 +++++++++++++---- .../features/home/room/list/RoomListListener.kt | 1 + .../home/room/list/RoomListViewEvents.kt | 1 + .../home/room/list/RoomListViewModel.kt | 7 +++++++ .../home/room/list/RoomSummaryItemFactory.kt | 6 +++--- .../room/list/SuggestedRoomListController.kt | 6 +----- .../app/features/media/ImageContentRenderer.kt | 4 ++-- 12 files changed, 44 insertions(+), 20 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt index ac1d726d03..a6d4583c76 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt @@ -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? = null): String? /** * Creates a permalink for an event. If you have an event you can use [createPermalink] diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt index 7db9d8f68a..8b45c9f570 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt @@ -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? { + return permalinkFactory.createRoomPermalink(roomId, via) } override fun createPermalink(roomId: String, eventId: String): String { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt index 970752449a..f8bc1b9b34 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt @@ -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? = 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) + ) + } } } diff --git a/newsfragment/3401.bugfix b/newsfragment/3401.bugfix index 42509f3ae3..c1774521af 100644 --- a/newsfragment/3401.bugfix +++ b/newsfragment/3401.bugfix @@ -1 +1,2 @@ -Fix | On Android it seems to be impossible to view the complete description of a Space (without dev tools) (#3386) \ No newline at end of file +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) \ No newline at end of file diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListAction.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListAction.kt index 37f7d148aa..e6b6b34503 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListAction.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListAction.kt @@ -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?) : RoomListAction() + data class ShowRoomDetails(val roomId: String, val viaServers: List?) : RoomListAction() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt index 76d7752ea7..8049d3c057 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt @@ -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)) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListListener.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListListener.kt index 0ba265f841..cf619ce435 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListListener.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListListener.kt @@ -26,4 +26,5 @@ interface RoomListListener : FilteredRoomFooterItem.FilteredRoomFooterItemListen fun onRejectRoomInvitation(room: RoomSummary) fun onAcceptRoomInvitation(room: RoomSummary) fun onJoinSuggestedRoom(room: SpaceChildInfo) + fun onSuggestedRoomClicked(room: SpaceChildInfo) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewEvents.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewEvents.kt index cb84d91373..df2ff58da6 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewEvents.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewEvents.kt @@ -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() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt index 246d5052cf..fbb8faebb0 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt @@ -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) { diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index e4826af04c..ec78a13c9f 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -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>, - 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, diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/SuggestedRoomListController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/SuggestedRoomListController.kt index 073fb43b6c..f9775967ee 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/SuggestedRoomListController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/SuggestedRoomListController.kt @@ -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)) } } } diff --git a/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt b/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt index 1c0d859fa9..8d6d1f467b 100644 --- a/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt +++ b/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt @@ -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) From a832da2124f968adcacb9e06499ad38f29c512a8 Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 26 May 2021 09:24:51 +0200 Subject: [PATCH 04/10] Fix reconcile summary API results and known room for display --- .../features/spaces/explore/SpaceDirectoryController.kt | 5 ++++- .../app/features/spaces/explore/SpaceDirectoryState.kt | 4 +++- .../app/features/spaces/explore/SpaceDirectoryViewModel.kt | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryController.kt b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryController.kt index e334868d7c..313af72c90 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryController.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryController.kt @@ -122,9 +122,12 @@ class SpaceDirectoryController @Inject constructor( val isSpace = info.roomType == RoomType.SPACE val isJoined = data?.joinedRoomsIds?.contains(info.childRoomId) == true val isLoading = data?.changeMembershipStates?.get(info.childRoomId)?.isInProgress() ?: false + // if it's known use that matrixItem because it would have a better computed name + val matrixItem = data?.knownRoomSummaries?.find { it.roomId == info.childRoomId }?.toMatrixItem() + ?: info.toMatrixItem() spaceChildInfoItem { id(info.childRoomId) - matrixItem(info.toMatrixItem()) + matrixItem(matrixItem) avatarRenderer(host.avatarRenderer) topic(info.topic) memberCount(info.activeMemberCount ?: 0) diff --git a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryState.kt b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryState.kt index 220c3e3492..21541a51ab 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryState.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryState.kt @@ -37,7 +37,9 @@ data class SpaceDirectoryState( val joinedRoomsIds: Set = emptySet(), // keys are room alias or roomId val changeMembershipStates: Map = emptyMap(), - val canAddRooms: Boolean = false + val canAddRooms: Boolean = false, + // cached room summaries of known rooms + val knownRoomSummaries : List = emptyList() ) : MvRxState { constructor(args: SpaceDirectoryArgs) : this( spaceId = args.spaceId diff --git a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryViewModel.kt index 4d0faedd7e..3d3e1dac65 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryViewModel.kt @@ -102,9 +102,14 @@ class SpaceDirectoryViewModel @AssistedInject constructor( viewModelScope.launch(Dispatchers.IO) { try { val query = session.spaceService().querySpaceChildren(initialState.spaceId) + val knownSummaries = query.second.mapNotNull { + session.getRoomSummary(it.childRoomId) + ?.takeIf { it.membership == Membership.JOIN } // only take if joined because it will be up to date (synced) + } setState { copy( - spaceSummaryApiResult = Success(query.second) + spaceSummaryApiResult = Success(query.second), + knownRoomSummaries = knownSummaries ) } } catch (failure: Throwable) { From b75d0cbfc6108e3aafe6c92b5de1896f2e75be2c Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 26 May 2021 11:16:38 +0200 Subject: [PATCH 05/10] Introduce SpaceItem --- .../matrix/android/sdk/api/util/MatrixItem.kt | 37 +++++++++- .../form/FormEditableSquareAvatarItem.kt | 2 +- .../app/features/home/AvatarRenderer.kt | 68 +++++++++++-------- .../home/room/list/SpaceChildInfoItem.kt | 7 +- .../matrixto/MatrixToBottomSheetState.kt | 2 +- .../matrixto/MatrixToRoomSpaceFragment.kt | 3 +- .../app/features/matrixto/SpaceCardHelper.kt | 4 +- .../settings/RoomSettingsController.kt | 10 ++- .../spaces/SpaceSettingsMenuBottomSheet.kt | 2 +- .../app/features/spaces/SpaceSummaryItem.kt | 2 +- .../features/spaces/SubSpaceSummaryItem.kt | 2 +- .../create/SpaceDetailEpoxyController.kt | 2 +- .../explore/SpaceDirectoryController.kt | 1 - .../spaces/manage/AddRoomListController.kt | 2 - .../spaces/manage/RoomManageSelectionItem.kt | 8 +-- .../spaces/manage/RoomSelectionItem.kt | 8 +-- .../manage/SpaceManageRoomsController.kt | 2 - .../spaces/manage/SpaceSettingsController.kt | 3 +- .../spaces/manage/SpaceSettingsFragment.kt | 2 +- .../spaces/preview/SpacePreviewFragment.kt | 4 +- .../features/spaces/preview/SubSpaceItem.kt | 4 +- 21 files changed, 98 insertions(+), 77 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt index bc397c5b4a..3d2773fb4b 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt @@ -20,6 +20,7 @@ import org.matrix.android.sdk.BuildConfig import org.matrix.android.sdk.api.session.group.model.GroupSummary import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary import org.matrix.android.sdk.api.session.room.model.RoomSummary +import org.matrix.android.sdk.api.session.room.model.RoomType import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom import org.matrix.android.sdk.api.session.room.sender.SenderInfo @@ -38,6 +39,8 @@ sealed class MatrixItem( init { if (BuildConfig.DEBUG) checkId() } + + override fun updateAvatar(newAvatar: String?) = copy(avatarUrl = newAvatar) } data class EventItem(override val id: String, @@ -47,6 +50,8 @@ sealed class MatrixItem( init { if (BuildConfig.DEBUG) checkId() } + + override fun updateAvatar(newAvatar: String?) = copy(avatarUrl = newAvatar) } data class RoomItem(override val id: String, @@ -56,6 +61,19 @@ sealed class MatrixItem( init { if (BuildConfig.DEBUG) checkId() } + + override fun updateAvatar(newAvatar: String?) = copy(avatarUrl = newAvatar) + } + + data class SpaceItem(override val id: String, + override val displayName: String? = null, + override val avatarUrl: String? = null) + : MatrixItem(id, displayName, avatarUrl) { + init { + if (BuildConfig.DEBUG) checkId() + } + + override fun updateAvatar(newAvatar: String?) = copy(avatarUrl = newAvatar) } data class RoomAliasItem(override val id: String, @@ -68,6 +86,8 @@ sealed class MatrixItem( // Best name is the id, and we keep the displayName of the room for the case we need the first letter override fun getBestName() = id + + override fun updateAvatar(newAvatar: String?) = copy(avatarUrl = newAvatar) } data class GroupItem(override val id: String, @@ -80,6 +100,8 @@ sealed class MatrixItem( // Best name is the id, and we keep the displayName of the room for the case we need the first letter override fun getBestName() = id + + override fun updateAvatar(newAvatar: String?) = copy(avatarUrl = newAvatar) } open fun getBestName(): String { @@ -92,12 +114,15 @@ sealed class MatrixItem( } } + abstract fun updateAvatar(newAvatar: String?): MatrixItem + /** * Return the prefix as defined in the matrix spec (and not extracted from the id) */ fun getIdPrefix() = when (this) { is UserItem -> '@' is EventItem -> '$' + is SpaceItem, is RoomItem -> '!' is RoomAliasItem -> '#' is GroupItem -> '+' @@ -148,7 +173,11 @@ fun User.toMatrixItem() = MatrixItem.UserItem(userId, displayName, avatarUrl) fun GroupSummary.toMatrixItem() = MatrixItem.GroupItem(groupId, displayName, avatarUrl) -fun RoomSummary.toMatrixItem() = MatrixItem.RoomItem(roomId, displayName, avatarUrl) +fun RoomSummary.toMatrixItem() = if (roomType == RoomType.SPACE) { + MatrixItem.SpaceItem(roomId, displayName, avatarUrl) +} else { + MatrixItem.RoomItem(roomId, displayName, avatarUrl) +} fun RoomSummary.toRoomAliasMatrixItem() = MatrixItem.RoomAliasItem(canonicalAlias ?: roomId, displayName, avatarUrl) @@ -159,4 +188,8 @@ fun RoomMemberSummary.toMatrixItem() = MatrixItem.UserItem(userId, displayName, fun SenderInfo.toMatrixItem() = MatrixItem.UserItem(userId, disambiguatedDisplayName, avatarUrl) -fun SpaceChildInfo.toMatrixItem() = MatrixItem.RoomItem(childRoomId, name ?: canonicalAlias, avatarUrl) +fun SpaceChildInfo.toMatrixItem() = if (roomType == RoomType.SPACE) { + MatrixItem.SpaceItem(childRoomId, name ?: canonicalAlias, avatarUrl) +} else { + MatrixItem.RoomItem(childRoomId, name ?: canonicalAlias, avatarUrl) +} diff --git a/vector/src/main/java/im/vector/app/features/form/FormEditableSquareAvatarItem.kt b/vector/src/main/java/im/vector/app/features/form/FormEditableSquareAvatarItem.kt index 0a07d27f64..b02e5c52df 100644 --- a/vector/src/main/java/im/vector/app/features/form/FormEditableSquareAvatarItem.kt +++ b/vector/src/main/java/im/vector/app/features/form/FormEditableSquareAvatarItem.kt @@ -71,7 +71,7 @@ abstract class FormEditableSquareAvatarItem : EpoxyModelWithHolder { - avatarRenderer?.renderSpace(matrixItem!!, holder.image) + avatarRenderer?.render(matrixItem!!, holder.image) } else -> { avatarRenderer?.clear(holder.image) diff --git a/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt b/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt index 65bc5e1200..c6cceee3b9 100644 --- a/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt +++ b/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt @@ -66,24 +66,24 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active DrawableImageViewTarget(imageView)) } - @UiThread - fun renderSpace(matrixItem: MatrixItem, imageView: ImageView, glideRequests: GlideRequests) { - val placeholder = getSpacePlaceholderDrawable(matrixItem) - val resolvedUrl = resolvedUrl(matrixItem.avatarUrl) - glideRequests - .load(resolvedUrl) - .transform(MultiTransformation(CenterCrop(), RoundedCorners(dimensionConverter.dpToPx(8)))) - .placeholder(placeholder) - .into(DrawableImageViewTarget(imageView)) - } - - fun renderSpace(matrixItem: MatrixItem, imageView: ImageView) { - renderSpace( - matrixItem, - imageView, - GlideApp.with(imageView) - ) - } +// fun renderSpace(matrixItem: MatrixItem, imageView: ImageView) { +// renderSpace( +// matrixItem, +// imageView, +// GlideApp.with(imageView) +// ) +// } +// +// @UiThread +// private fun renderSpace(matrixItem: MatrixItem, imageView: ImageView, glideRequests: GlideRequests) { +// val placeholder = getSpacePlaceholderDrawable(matrixItem) +// val resolvedUrl = resolvedUrl(matrixItem.avatarUrl) +// glideRequests +// .load(resolvedUrl) +// .transform(MultiTransformation(CenterCrop(), RoundedCorners(dimensionConverter.dpToPx(8)))) +// .placeholder(placeholder) +// .into(DrawableImageViewTarget(imageView)) +// } fun clear(imageView: ImageView) { // It can be called after recycler view is destroyed, just silently catch @@ -137,7 +137,16 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active target: Target) { val placeholder = getPlaceholderDrawable(matrixItem) buildGlideRequest(glideRequests, matrixItem.avatarUrl) - .apply(RequestOptions.circleCropTransform()) + .apply { + when (matrixItem) { + is MatrixItem.SpaceItem -> { + transform(MultiTransformation(CenterCrop(), RoundedCorners(dimensionConverter.dpToPx(8)))) + } + else -> { + apply(RequestOptions.circleCropTransform()) + } + } + } .placeholder(placeholder) .into(target) } @@ -197,17 +206,16 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active .beginConfig() .bold() .endConfig() - .buildRound(matrixItem.firstLetterOfDisplayName(), avatarColor) - } - - @AnyThread - fun getSpacePlaceholderDrawable(matrixItem: MatrixItem): Drawable { - val avatarColor = matrixItemColorProvider.getColor(matrixItem) - return TextDrawable.builder() - .beginConfig() - .bold() - .endConfig() - .buildRoundRect(matrixItem.firstLetterOfDisplayName(), avatarColor, dimensionConverter.dpToPx(8)) + .let { + when (matrixItem) { + is MatrixItem.SpaceItem -> { + it.buildRoundRect(matrixItem.firstLetterOfDisplayName(), avatarColor, dimensionConverter.dpToPx(8)) + } + else -> { + it.buildRound(matrixItem.firstLetterOfDisplayName(), avatarColor) + } + } + } } // PRIVATE API ********************************************************************************* diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/SpaceChildInfoItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/SpaceChildInfoItem.kt index f03cc4c9dc..65b42f437b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/SpaceChildInfoItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/SpaceChildInfoItem.kt @@ -48,7 +48,6 @@ abstract class SpaceChildInfoItem : VectorEpoxyModel( @EpoxyAttribute var memberCount: Int = 0 @EpoxyAttribute var loading: Boolean = false - @EpoxyAttribute var space: Boolean = false @EpoxyAttribute var buttonLabel: String? = null @@ -64,11 +63,7 @@ abstract class SpaceChildInfoItem : VectorEpoxyModel( itemLongClickListener?.onLongClick(it) ?: false } holder.titleView.text = matrixItem.displayName ?: holder.rootView.context.getString(R.string.unnamed_room) - if (space) { - avatarRenderer.renderSpace(matrixItem, holder.avatarImageView) - } else { - avatarRenderer.render(matrixItem, holder.avatarImageView) - } + avatarRenderer.render(matrixItem, holder.avatarImageView) holder.descriptionText.text = span { span { diff --git a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetState.kt b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetState.kt index 7082cd16a3..40213dc0ee 100644 --- a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetState.kt +++ b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToBottomSheetState.kt @@ -41,7 +41,7 @@ data class MatrixToBottomSheetState( sealed class RoomInfoResult { data class FullInfo( - val roomItem: MatrixItem.RoomItem, + val roomItem: MatrixItem, val name: String, val topic: String, val memberCount: Int?, diff --git a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt index 730a04aef7..f4affcc218 100644 --- a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt @@ -78,9 +78,9 @@ class MatrixToRoomSpaceFragment @Inject constructor( when (val peek = item.invoke()) { is RoomInfoResult.FullInfo -> { val matrixItem = peek.roomItem + avatarRenderer.render(matrixItem, views.matrixToCardAvatar) if (peek.roomType == RoomType.SPACE) { views.matrixToBetaTag.isVisible = true - avatarRenderer.renderSpace(matrixItem, views.matrixToCardAvatar) if (peek.isPublic) { views.matrixToAccessText.setTextOrHide(context?.getString(R.string.public_space)) views.matrixToAccessImage.isVisible = true @@ -92,7 +92,6 @@ class MatrixToRoomSpaceFragment @Inject constructor( } } else { views.matrixToBetaTag.isVisible = false - avatarRenderer.render(matrixItem, views.matrixToCardAvatar) } views.matrixToCardNameText.setTextOrHide(peek.name) views.matrixToCardAliasText.setTextOrHide(peek.alias) diff --git a/vector/src/main/java/im/vector/app/features/matrixto/SpaceCardHelper.kt b/vector/src/main/java/im/vector/app/features/matrixto/SpaceCardHelper.kt index 5a64c15f30..4028b3a444 100644 --- a/vector/src/main/java/im/vector/app/features/matrixto/SpaceCardHelper.kt +++ b/vector/src/main/java/im/vector/app/features/matrixto/SpaceCardHelper.kt @@ -51,7 +51,7 @@ class SpaceCardHelper @Inject constructor( } else { inCard.matrixToCardContentVisibility.isVisible = true inCard.matrixToCardButtonLoading.isVisible = false - avatarRenderer.renderSpace(spaceSummary.toMatrixItem(), inCard.matrixToCardAvatar) + avatarRenderer.render(spaceSummary.toMatrixItem(), inCard.matrixToCardAvatar) inCard.matrixToCardNameText.text = spaceSummary.name inCard.matrixToBetaTag.isVisible = true inCard.matrixToCardAliasText.setTextOrHide(spaceSummary.canonicalAlias) @@ -119,7 +119,7 @@ class SpaceCardHelper @Inject constructor( } else { inCard.matrixToCardContentVisibility.isVisible = true inCard.matrixToCardButtonLoading.isVisible = false - avatarRenderer.renderSpace(spaceChildInfo.toMatrixItem(), inCard.matrixToCardAvatar) + avatarRenderer.render(spaceChildInfo.toMatrixItem(), inCard.matrixToCardAvatar) inCard.matrixToCardNameText.setTextOrHide(spaceChildInfo.name) inCard.matrixToBetaTag.isVisible = true inCard.matrixToCardAliasText.setTextOrHide(spaceChildInfo.canonicalAlias) diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt b/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt index 24836bc504..a045f43af0 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt @@ -68,16 +68,14 @@ class RoomSettingsController @Inject constructor( id("avatar") enabled(data.actionPermissions.canChangeAvatar) when (val avatarAction = data.avatarAction) { - RoomSettingsViewState.AvatarAction.None -> { + RoomSettingsViewState.AvatarAction.None -> { // Use the current value avatarRenderer(host.avatarRenderer) // We do not want to use the fallback avatar url, which can be the other user avatar, or the current user avatar. - matrixItem(roomSummary.toMatrixItem().copy(avatarUrl = data.currentRoomAvatarUrl)) + matrixItem(roomSummary.toMatrixItem().updateAvatar(data.currentRoomAvatarUrl)) } - RoomSettingsViewState.AvatarAction.DeleteAvatar -> - imageUri(null) - is RoomSettingsViewState.AvatarAction.UpdateAvatar -> - imageUri(avatarAction.newAvatarUri) + RoomSettingsViewState.AvatarAction.DeleteAvatar -> imageUri(null) + is RoomSettingsViewState.AvatarAction.UpdateAvatar -> imageUri(avatarAction.newAvatarUri) } clickListener { host.callback?.onAvatarChange() } deleteListener { host.callback?.onAvatarDelete() } diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceSettingsMenuBottomSheet.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceSettingsMenuBottomSheet.kt index 66572f5a82..0efb0535e8 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceSettingsMenuBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceSettingsMenuBottomSheet.kt @@ -96,7 +96,7 @@ class SpaceSettingsMenuBottomSheet : VectorBaseBottomSheetDialogFragment() { holder.indentSpace.isVisible = indent > 0 holder.separator.isVisible = showSeparator - avatarRenderer.renderSpace(matrixItem, holder.avatarImageView) + avatarRenderer.render(matrixItem, holder.avatarImageView) holder.counterBadgeView.render(countState) } diff --git a/vector/src/main/java/im/vector/app/features/spaces/SubSpaceSummaryItem.kt b/vector/src/main/java/im/vector/app/features/spaces/SubSpaceSummaryItem.kt index db58353e5c..977ab57bc9 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SubSpaceSummaryItem.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SubSpaceSummaryItem.kt @@ -81,7 +81,7 @@ abstract class SubSpaceSummaryItem : VectorEpoxyModel() @EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer @EpoxyAttribute lateinit var matrixItem: MatrixItem - @EpoxyAttribute var space: Boolean = false @EpoxyAttribute var selected: Boolean = false @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: View.OnClickListener? = null override fun bind(holder: Holder) { super.bind(holder) - if (space) { - avatarRenderer.renderSpace(matrixItem, holder.avatarImageView) - } else { - avatarRenderer.render(matrixItem, holder.avatarImageView) - } + avatarRenderer.render(matrixItem, holder.avatarImageView) + holder.titleText.text = matrixItem.getBestName() if (selected) { diff --git a/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceManageRoomsController.kt b/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceManageRoomsController.kt index b16c6de921..f740938ee4 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceManageRoomsController.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceManageRoomsController.kt @@ -27,7 +27,6 @@ import im.vector.app.core.resources.StringProvider import im.vector.app.core.ui.list.genericFooterItem import im.vector.app.core.utils.DebouncedClickListener import im.vector.app.features.home.AvatarRenderer -import org.matrix.android.sdk.api.session.room.model.RoomType import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo import org.matrix.android.sdk.api.util.toMatrixItem import javax.inject.Inject @@ -83,7 +82,6 @@ class SpaceManageRoomsController @Inject constructor( matrixItem(childInfo.toMatrixItem()) avatarRenderer(host.avatarRenderer) suggested(childInfo.suggested ?: false) - space(childInfo.roomType == RoomType.SPACE) selected(data.selectedRooms.contains(childInfo.childRoomId)) itemClickListener(DebouncedClickListener({ host.listener?.toggleSelection(childInfo) diff --git a/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsController.kt b/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsController.kt index 614f6f92c8..c0cf91ecaa 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsController.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsController.kt @@ -70,8 +70,9 @@ class SpaceSettingsController @Inject constructor( RoomSettingsViewState.AvatarAction.None -> { // Use the current value avatarRenderer(host.avatarRenderer) + val mxItem = roomSummary.toMatrixItem() // We do not want to use the fallback avatar url, which can be the other user avatar, or the current user avatar. - matrixItem(roomSummary.toMatrixItem().copy(avatarUrl = data.currentRoomAvatarUrl)) + matrixItem(roomSummary.toMatrixItem().updateAvatar(data.currentRoomAvatarUrl)) } RoomSettingsViewState.AvatarAction.DeleteAvatar -> imageUri(null) diff --git a/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsFragment.kt b/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsFragment.kt index 85c73ac8ef..7b405eb4f3 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsFragment.kt @@ -139,7 +139,7 @@ class SpaceSettingsFragment @Inject constructor( drawableProvider.getDrawable(R.drawable.ic_beta_pill), null ) - avatarRenderer.renderSpace(it.toMatrixItem(), views.roomSettingsToolbarAvatarImageView) + avatarRenderer.render(it.toMatrixItem(), views.roomSettingsToolbarAvatarImageView) views.roomSettingsDecorationToolbarAvatarImageView.render(it.roomEncryptionTrustLevel) } diff --git a/vector/src/main/java/im/vector/app/features/spaces/preview/SpacePreviewFragment.kt b/vector/src/main/java/im/vector/app/features/spaces/preview/SpacePreviewFragment.kt index b6f1fb6a4e..eb02ed7c2d 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/preview/SpacePreviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/preview/SpacePreviewFragment.kt @@ -148,8 +148,8 @@ class SpacePreviewFragment @Inject constructor( // val roomPeekResult = preview.summary.roomPeekResult val spaceName = spacePreviewState.spaceInfo.invoke()?.name ?: spacePreviewState.name ?: "" val spaceAvatarUrl = spacePreviewState.spaceInfo.invoke()?.avatarUrl ?: spacePreviewState.avatarUrl - val mxItem = MatrixItem.RoomItem(spacePreviewState.idOrAlias, spaceName, spaceAvatarUrl) - avatarRenderer.renderSpace(mxItem, views.spacePreviewToolbarAvatar) + val mxItem = MatrixItem.SpaceItem(spacePreviewState.idOrAlias, spaceName, spaceAvatarUrl) + avatarRenderer.render(mxItem, views.spacePreviewToolbarAvatar) views.roomPreviewNoPreviewToolbarTitle.text = spaceName // } // is SpacePeekResult.SpacePeekError, diff --git a/vector/src/main/java/im/vector/app/features/spaces/preview/SubSpaceItem.kt b/vector/src/main/java/im/vector/app/features/spaces/preview/SubSpaceItem.kt index 367a81fe5a..1856edb61f 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/preview/SubSpaceItem.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/preview/SubSpaceItem.kt @@ -48,8 +48,8 @@ abstract class SubSpaceItem : VectorEpoxyModel() { super.bind(holder) holder.nameText.text = title - avatarRenderer.renderSpace( - MatrixItem.RoomItem(roomId, title, avatarUrl), + avatarRenderer.render( + MatrixItem.SpaceItem(roomId, title, avatarUrl), holder.avatarImageView ) holder.tabView.tabDepth = depth From d04cbadd04229caa08f6fcc0c8840ee5ce40723d Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 26 May 2021 11:19:56 +0200 Subject: [PATCH 06/10] Compute via param from list utility method --- .../sdk/internal/session/permalinks/PermalinkFactory.kt | 3 +-- .../sdk/internal/session/permalinks/ViaParameterFinder.kt | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt index f8bc1b9b34..23ed2f68a3 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt @@ -19,7 +19,6 @@ 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( @@ -49,7 +48,7 @@ internal class PermalinkFactory @Inject constructor( append(MATRIX_TO_URL_BASE) append(escape(roomId)) append( - via?.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") } + via?.takeIf { it.isNotEmpty() }?.let { viaParameterFinder.computeViaParams(it) } ?: viaParameterFinder.computeViaParams(userId, roomId) ) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/ViaParameterFinder.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/ViaParameterFinder.kt index 0da60e9ba2..f00d2a9ef7 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/ViaParameterFinder.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/ViaParameterFinder.kt @@ -43,6 +43,10 @@ internal class ViaParameterFinder @Inject constructor( .joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") } } + fun computeViaParams(viaList: List): String { + return viaList.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") } + } + fun computeViaParams(userId: String, roomId: String, max: Int): List { val userHomeserver = userId.substringAfter(":") return getUserIdsOfJoinedMembers(roomId) From f602caf323378d33cfc965aef5b6b3a52f51f65d Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 26 May 2021 11:22:56 +0200 Subject: [PATCH 07/10] Fix towncrier --- newsfragment/3401.bugfix | 3 +-- newsfragment/3406.bugfix | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 newsfragment/3406.bugfix diff --git a/newsfragment/3401.bugfix b/newsfragment/3401.bugfix index c1774521af..7f7539316d 100644 --- a/newsfragment/3401.bugfix +++ b/newsfragment/3401.bugfix @@ -1,2 +1 @@ -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) \ No newline at end of file +Fix | On Android it seems to be impossible to view the complete description of a Space (without dev tools) \ No newline at end of file diff --git a/newsfragment/3406.bugfix b/newsfragment/3406.bugfix new file mode 100644 index 0000000000..2623ccc1cd --- /dev/null +++ b/newsfragment/3406.bugfix @@ -0,0 +1 @@ +Fix | Suggest Rooms, Show a detailed view of the room on click \ No newline at end of file From 60dee6eea3fa9d448e36a8f9e3e35a151cf96f59 Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 26 May 2021 14:25:09 +0200 Subject: [PATCH 08/10] Code review --- .../matrixto/MatrixToRoomSpaceFragment.kt | 21 +---- ...paceCardHelper.kt => SpaceCardRenderer.kt} | 76 +++++++------------ .../spaces/explore/SpaceDirectoryFragment.kt | 14 +--- .../spaces/invite/SpaceInviteBottomSheet.kt | 6 +- 4 files changed, 39 insertions(+), 78 deletions(-) rename vector/src/main/java/im/vector/app/features/matrixto/{SpaceCardHelper.kt => SpaceCardRenderer.kt} (73%) diff --git a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt index f4affcc218..d17fe7d951 100644 --- a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt @@ -39,7 +39,8 @@ import org.matrix.android.sdk.api.session.room.model.RoomType import javax.inject.Inject class MatrixToRoomSpaceFragment @Inject constructor( - private val avatarRenderer: AvatarRenderer + private val avatarRenderer: AvatarRenderer, + private val spaceCardRenderer: SpaceCardRenderer ) : VectorBaseFragment() { private val sharedViewModel: MatrixToBottomSheetViewModel by parentFragmentViewModel() @@ -81,13 +82,12 @@ class MatrixToRoomSpaceFragment @Inject constructor( avatarRenderer.render(matrixItem, views.matrixToCardAvatar) if (peek.roomType == RoomType.SPACE) { views.matrixToBetaTag.isVisible = true + views.matrixToAccessImage.isVisible = true if (peek.isPublic) { views.matrixToAccessText.setTextOrHide(context?.getString(R.string.public_space)) - views.matrixToAccessImage.isVisible = true views.matrixToAccessImage.setImageResource(R.drawable.ic_public_room) } else { views.matrixToAccessText.setTextOrHide(context?.getString(R.string.private_space)) - views.matrixToAccessImage.isVisible = true views.matrixToAccessImage.setImageResource(R.drawable.ic_room_private) } } else { @@ -179,20 +179,7 @@ class MatrixToRoomSpaceFragment @Inject constructor( when (state.peopleYouKnow) { is Success -> { val someYouKnow = state.peopleYouKnow.invoke() - if (someYouKnow.isEmpty()) { - views.peopleYouMayKnowText.isVisible = false - } else { - someYouKnow.forEachIndexed { index, item -> - images[index].isVisible = true - avatarRenderer.render(item, images[index]) - } - views.peopleYouMayKnowText.setTextOrHide( - resources.getQuantityString(R.plurals.space_people_you_know, - someYouKnow.count(), - someYouKnow.count() - ) - ) - } + spaceCardRenderer.renderPeopleYouKnow(views, someYouKnow) } else -> { views.peopleYouMayKnowText.isVisible = false diff --git a/vector/src/main/java/im/vector/app/features/matrixto/SpaceCardHelper.kt b/vector/src/main/java/im/vector/app/features/matrixto/SpaceCardRenderer.kt similarity index 73% rename from vector/src/main/java/im/vector/app/features/matrixto/SpaceCardHelper.kt rename to vector/src/main/java/im/vector/app/features/matrixto/SpaceCardRenderer.kt index 4028b3a444..e51490a59c 100644 --- a/vector/src/main/java/im/vector/app/features/matrixto/SpaceCardHelper.kt +++ b/vector/src/main/java/im/vector/app/features/matrixto/SpaceCardRenderer.kt @@ -20,8 +20,6 @@ import androidx.core.view.isGone import androidx.core.view.isVisible import im.vector.app.R import im.vector.app.core.extensions.setTextOrHide -import im.vector.app.core.resources.ColorProvider -import im.vector.app.core.resources.DrawableProvider import im.vector.app.core.resources.StringProvider import im.vector.app.databinding.FragmentMatrixToRoomSpaceCardBinding import im.vector.app.features.home.AvatarRenderer @@ -31,14 +29,13 @@ import im.vector.app.features.home.room.detail.timeline.tools.linkify import org.matrix.android.sdk.api.session.room.model.RoomSummary import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo import org.matrix.android.sdk.api.session.user.model.User +import org.matrix.android.sdk.api.util.MatrixItem import org.matrix.android.sdk.api.util.toMatrixItem import javax.inject.Inject -class SpaceCardHelper @Inject constructor( +class SpaceCardRenderer @Inject constructor( private val avatarRenderer: AvatarRenderer, - private val stringProvider: StringProvider, - private val drawableProvider: DrawableProvider, - private val colorProvider: ColorProvider + private val stringProvider: StringProvider ) { fun render(spaceSummary: RoomSummary?, @@ -74,28 +71,7 @@ class SpaceCardHelper @Inject constructor( inCard.matrixToMemberPills.isVisible = false } - val images = listOf( - inCard.knownMember1, - inCard.knownMember2, - inCard.knownMember3, - inCard.knownMember4, - inCard.knownMember5 - ).onEach { it.isGone = true } - - if (peopleYouKnow.isEmpty()) { - inCard.peopleYouMayKnowText.isVisible = false - } else { - peopleYouKnow.forEachIndexed { index, item -> - images[index].isVisible = true - avatarRenderer.render(item.toMatrixItem(), images[index]) - } - inCard.peopleYouMayKnowText.setTextOrHide( - stringProvider.getQuantityString(R.plurals.space_people_you_know, - peopleYouKnow.count(), - peopleYouKnow.count() - ) - ) - } + renderPeopleYouKnow(inCard, peopleYouKnow.map { it.toMatrixItem() }) } inCard.matrixToCardDescText.movementMethod = createLinkMovementMethod(object : TimelineEventController.UrlClickCallback { override fun onUrlClicked(url: String, title: String): Boolean { @@ -142,28 +118,32 @@ class SpaceCardHelper @Inject constructor( inCard.matrixToMemberPills.isVisible = false } - val images = listOf( - inCard.knownMember1, - inCard.knownMember2, - inCard.knownMember3, - inCard.knownMember4, - inCard.knownMember5 - ).onEach { it.isGone = true } + renderPeopleYouKnow(inCard, peopleYouKnow.map { it.toMatrixItem() }) + } + } - if (peopleYouKnow.isEmpty()) { - inCard.peopleYouMayKnowText.isVisible = false - } else { - peopleYouKnow.forEachIndexed { index, item -> - images[index].isVisible = true - avatarRenderer.render(item.toMatrixItem(), images[index]) - } - inCard.peopleYouMayKnowText.setTextOrHide( - stringProvider.getQuantityString(R.plurals.space_people_you_know, - peopleYouKnow.count(), - peopleYouKnow.count() - ) - ) + fun renderPeopleYouKnow(inCard: FragmentMatrixToRoomSpaceCardBinding, peopleYouKnow: List) { + val images = listOf( + inCard.knownMember1, + inCard.knownMember2, + inCard.knownMember3, + inCard.knownMember4, + inCard.knownMember5 + ).onEach { it.isGone = true } + + if (peopleYouKnow.isEmpty()) { + inCard.peopleYouMayKnowText.isVisible = false + } else { + peopleYouKnow.forEachIndexed { index, item -> + images[index].isVisible = true + avatarRenderer.render(item, images[index]) } + inCard.peopleYouMayKnowText.setTextOrHide( + stringProvider.getQuantityString(R.plurals.space_people_you_know, + peopleYouKnow.count(), + peopleYouKnow.count() + ) + ) } } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryFragment.kt b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryFragment.kt index 7f45307a0d..910c21926c 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryFragment.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/explore/SpaceDirectoryFragment.kt @@ -42,7 +42,7 @@ import im.vector.app.core.utils.isValidUrl import im.vector.app.core.utils.openUrlInExternalBrowser import im.vector.app.databinding.FragmentRoomDirectoryPickerBinding import im.vector.app.features.home.room.detail.timeline.TimelineEventController -import im.vector.app.features.matrixto.SpaceCardHelper +import im.vector.app.features.matrixto.SpaceCardRenderer import im.vector.app.features.permalink.PermalinkHandler import im.vector.app.features.spaces.manage.ManageType import im.vector.app.features.spaces.manage.SpaceManageActivity @@ -61,7 +61,7 @@ data class SpaceDirectoryArgs( class SpaceDirectoryFragment @Inject constructor( private val epoxyController: SpaceDirectoryController, private val permalinkHandler: PermalinkHandler, - private val spaceCardHelper: SpaceCardHelper, + private val spaceCardRenderer: SpaceCardRenderer, private val colorProvider: ColorProvider ) : VectorBaseFragment(), SpaceDirectoryController.InteractionListener, @@ -93,12 +93,6 @@ class SpaceDirectoryFragment @Inject constructor( views.spaceCard.matrixToCardMainButton.isVisible = false views.spaceCard.matrixToCardSecondaryButton.isVisible = false - views.spaceCard.knownMember1.isVisible = false - views.spaceCard.knownMember2.isVisible = false - views.spaceCard.knownMember3.isVisible = false - views.spaceCard.knownMember4.isVisible = false - views.spaceCard.knownMember5.isVisible = false - views.spaceCard.peopleYouMayKnowText.isVisible = false } override fun onDestroyView() { @@ -118,12 +112,12 @@ class SpaceDirectoryFragment @Inject constructor( val title = getString(R.string.space_explore_activity_title) views.toolbar.title = title - spaceCardHelper.render(state.spaceSummary.invoke(), emptyList(), this, views.spaceCard) + spaceCardRenderer.render(state.spaceSummary.invoke(), emptyList(), this, views.spaceCard) } else { val title = currentParent.name ?: currentParent.canonicalAlias ?: getString(R.string.space_explore_activity_title) views.toolbar.title = title - spaceCardHelper.render(currentParent, emptyList(), this, views.spaceCard) + spaceCardRenderer.render(currentParent, emptyList(), this, views.spaceCard) } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt b/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt index d393943f72..434fa613ab 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/invite/SpaceInviteBottomSheet.kt @@ -37,7 +37,7 @@ import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.core.utils.toast import im.vector.app.databinding.BottomSheetInvitedToSpaceBinding import im.vector.app.features.home.AvatarRenderer -import im.vector.app.features.matrixto.SpaceCardHelper +import im.vector.app.features.matrixto.SpaceCardRenderer import kotlinx.parcelize.Parcelize import org.matrix.android.sdk.api.util.toMatrixItem import javax.inject.Inject @@ -60,7 +60,7 @@ class SpaceInviteBottomSheet : VectorBaseBottomSheetDialogFragment Date: Fri, 28 May 2021 11:12:10 +0200 Subject: [PATCH 09/10] Code review --- .../internal/session/permalinks/DefaultPermalinkService.kt | 4 ++-- .../sdk/internal/session/permalinks/PermalinkFactory.kt | 2 +- .../sdk/internal/session/permalinks/ViaParameterFinder.kt | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt index 8b45c9f570..134da4ce51 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt @@ -33,8 +33,8 @@ internal class DefaultPermalinkService @Inject constructor( return permalinkFactory.createPermalink(id) } - override fun createRoomPermalink(roomId: String, via: List?): String? { - return permalinkFactory.createRoomPermalink(roomId, via) + override fun createRoomPermalink(roomId: String, viaServers: List?): String? { + return permalinkFactory.createRoomPermalink(roomId, viaServers) } override fun createPermalink(roomId: String, eventId: String): String { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt index 23ed2f68a3..639e45582a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt @@ -48,7 +48,7 @@ internal class PermalinkFactory @Inject constructor( append(MATRIX_TO_URL_BASE) append(escape(roomId)) append( - via?.takeIf { it.isNotEmpty() }?.let { viaParameterFinder.computeViaParams(it) } + via?.takeIf { it.isNotEmpty() }?.let { viaParameterFinder.asUrlViaParameters(it) } ?: viaParameterFinder.computeViaParams(userId, roomId) ) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/ViaParameterFinder.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/ViaParameterFinder.kt index f00d2a9ef7..72fbfcced5 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/ViaParameterFinder.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/ViaParameterFinder.kt @@ -39,11 +39,10 @@ internal class ViaParameterFinder @Inject constructor( * current user one. */ fun computeViaParams(userId: String, roomId: String): String { - return computeViaParams(userId, roomId, 3) - .joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") } + return asUrlViaParameters(computeViaParams(userId, roomId, 3)) } - fun computeViaParams(viaList: List): String { + fun asUrlViaParameters(viaList: List): String { return viaList.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") } } From 836643714761b2aae92a816a14eabca9838818d6 Mon Sep 17 00:00:00 2001 From: Valere Date: Fri, 28 May 2021 12:10:20 +0200 Subject: [PATCH 10/10] Fix unused variables --- .../vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt | 2 +- .../app/features/spaces/manage/SpaceSettingsController.kt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt index d17fe7d951..ad71d0b1b5 100644 --- a/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/matrixto/MatrixToRoomSpaceFragment.kt @@ -174,7 +174,7 @@ class MatrixToRoomSpaceFragment @Inject constructor( } } - val images = listOf(views.knownMember1, views.knownMember2, views.knownMember3, views.knownMember4, views.knownMember5) + listOf(views.knownMember1, views.knownMember2, views.knownMember3, views.knownMember4, views.knownMember5) .onEach { it.isGone = true } when (state.peopleYouKnow) { is Success -> { diff --git a/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsController.kt b/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsController.kt index c0cf91ecaa..e0e7575f35 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsController.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceSettingsController.kt @@ -70,7 +70,6 @@ class SpaceSettingsController @Inject constructor( RoomSettingsViewState.AvatarAction.None -> { // Use the current value avatarRenderer(host.avatarRenderer) - val mxItem = roomSummary.toMatrixItem() // We do not want to use the fallback avatar url, which can be the other user avatar, or the current user avatar. matrixItem(roomSummary.toMatrixItem().updateAvatar(data.currentRoomAvatarUrl)) }