From c9ed95ed21a3e538d9b47f425a3530fde164a105 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 16 Dec 2019 10:46:24 +0100 Subject: [PATCH] MatrixItem: create extension and check ids --- .../matrix/android/api/util/MatrixItem.kt | 51 +++++++++++++++---- .../core/preference/UserAvatarPreference.kt | 3 +- .../user/AutocompleteUserController.kt | 4 +- .../SASVerificationIncomingFragment.kt | 3 +- .../riotx/features/home/HomeDetailFragment.kt | 4 +- .../riotx/features/home/HomeDrawerFragment.kt | 4 +- .../createdirect/CreateDirectRoomViewModel.kt | 4 +- .../createdirect/DirectoryUsersController.kt | 4 +- .../home/createdirect/KnownUsersController.kt | 4 +- .../features/home/group/GroupListViewModel.kt | 2 +- .../home/group/GroupSummaryController.kt | 4 +- .../room/breadcrumbs/BreadcrumbsController.kt | 4 +- .../home/room/detail/RoomDetailFragment.kt | 5 +- .../home/room/list/RoomSummaryItemFactory.kt | 6 +-- .../RoomListQuickActionsEpoxyController.kt | 4 +- .../riotx/features/invite/VectorInviteView.kt | 4 +- .../roomdirectory/PublicRoomsController.kt | 4 +- .../ignored/IgnoredUsersController.kt | 4 +- 18 files changed, 76 insertions(+), 42 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/MatrixItem.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/MatrixItem.kt index aacb5472d9..a976e60c77 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/MatrixItem.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/MatrixItem.kt @@ -16,6 +16,7 @@ package im.vector.matrix.android.api.util +import im.vector.matrix.android.BuildConfig import im.vector.matrix.android.api.session.group.model.GroupSummary import im.vector.matrix.android.api.session.room.model.RoomSummary import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom @@ -30,32 +31,58 @@ sealed class MatrixItem( data class UserItem(override val id: String, override val displayName: String? = null, override val avatarUrl: String? = null) - : MatrixItem(id, displayName?.removeSuffix(ircPattern), avatarUrl) + : MatrixItem(id, displayName?.removeSuffix(ircPattern), avatarUrl) { + init { + if (BuildConfig.DEBUG) checkId() + } + } data class EventItem(override val id: String, override val displayName: String? = null, override val avatarUrl: String? = null) - : MatrixItem(id, displayName, avatarUrl) + : MatrixItem(id, displayName, avatarUrl) { + init { + if (BuildConfig.DEBUG) checkId() + } + } data class RoomItem(override val id: String, override val displayName: String? = null, override val avatarUrl: String? = null) - : MatrixItem(id, displayName, avatarUrl) + : MatrixItem(id, displayName, avatarUrl) { + init { + if (BuildConfig.DEBUG) checkId() + } + } data class RoomAliasItem(override val id: String, override val displayName: String? = null, override val avatarUrl: String? = null) - : MatrixItem(id, displayName, avatarUrl) + : MatrixItem(id, displayName, avatarUrl) { + init { + if (BuildConfig.DEBUG) checkId() + } + } data class GroupItem(override val id: String, override val displayName: String? = null, override val avatarUrl: String? = null) - : MatrixItem(id, displayName, avatarUrl) + : MatrixItem(id, displayName, avatarUrl) { + init { + if (BuildConfig.DEBUG) checkId() + } + } fun getBestName(): String { return displayName?.takeIf { it.isNotBlank() } ?: id } + protected fun checkId() { + if (!id.startsWith(getIdPrefix())) { + error("Wrong usage of MatrixItem: check the id $id should start with ${getIdPrefix()}") + } + } + /** * Return the prefix as defined in the matrix spec (and not extracted from the id) */ @@ -104,10 +131,14 @@ sealed class MatrixItem( companion object { private const val ircPattern = " (IRC)" - - fun from(user: User) = UserItem(user.userId, user.displayName, user.avatarUrl) - fun from(groupSummary: GroupSummary) = GroupItem(groupSummary.groupId, groupSummary.displayName, groupSummary.avatarUrl) - fun from(roomSummary: RoomSummary) = RoomItem(roomSummary.roomId, roomSummary.displayName, roomSummary.avatarUrl) - fun from(publicRoom: PublicRoom) = RoomItem(publicRoom.roomId, publicRoom.name, publicRoom.avatarUrl) } } + +/* ========================================================================================== + * Extensions to create MatrixItem + * ========================================================================================== */ + +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 PublicRoom.toMatrixItem() = MatrixItem.RoomItem(roomId, name, avatarUrl) diff --git a/vector/src/main/java/im/vector/riotx/core/preference/UserAvatarPreference.kt b/vector/src/main/java/im/vector/riotx/core/preference/UserAvatarPreference.kt index ef0541ce13..c7fcf85a16 100755 --- a/vector/src/main/java/im/vector/riotx/core/preference/UserAvatarPreference.kt +++ b/vector/src/main/java/im/vector/riotx/core/preference/UserAvatarPreference.kt @@ -24,6 +24,7 @@ import androidx.preference.Preference import androidx.preference.PreferenceViewHolder import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.R import im.vector.riotx.core.extensions.vectorComponent import im.vector.riotx.features.home.AvatarRenderer @@ -60,7 +61,7 @@ open class UserAvatarPreference : Preference { val session = mSession ?: return val view = mAvatarView ?: return session.getUser(session.myUserId)?.let { - avatarRenderer.render(MatrixItem.from(it), view) + avatarRenderer.render(it.toMatrixItem(), view) } ?: run { avatarRenderer.render(MatrixItem.UserItem(session.myUserId), view) } diff --git a/vector/src/main/java/im/vector/riotx/features/autocomplete/user/AutocompleteUserController.kt b/vector/src/main/java/im/vector/riotx/features/autocomplete/user/AutocompleteUserController.kt index fa264e9200..8f0090001f 100644 --- a/vector/src/main/java/im/vector/riotx/features/autocomplete/user/AutocompleteUserController.kt +++ b/vector/src/main/java/im/vector/riotx/features/autocomplete/user/AutocompleteUserController.kt @@ -18,7 +18,7 @@ package im.vector.riotx.features.autocomplete.user import com.airbnb.epoxy.TypedEpoxyController import im.vector.matrix.android.api.session.user.model.User -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.features.autocomplete.AutocompleteClickListener import im.vector.riotx.features.home.AvatarRenderer import javax.inject.Inject @@ -36,7 +36,7 @@ class AutocompleteUserController @Inject constructor() : TypedEpoxyController
  • autocompleteUserItem { id(user.userId) - matrixItem(MatrixItem.from(user)) + matrixItem(user.toMatrixItem()) avatarRenderer(avatarRenderer) clickListener { _ -> listener?.onItemClick(user) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/SASVerificationIncomingFragment.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/SASVerificationIncomingFragment.kt index 47d7e783b4..61f5c5f9fe 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/SASVerificationIncomingFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/SASVerificationIncomingFragment.kt @@ -23,6 +23,7 @@ import butterknife.BindView import butterknife.OnClick import im.vector.matrix.android.api.session.crypto.sas.IncomingSasVerificationTransaction import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.R import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.features.home.AvatarRenderer @@ -58,7 +59,7 @@ class SASVerificationIncomingFragment @Inject constructor( otherDeviceTextView.text = viewModel.otherDeviceId viewModel.otherUser?.let { - avatarRenderer.render(MatrixItem.from(it), avatarImageView) + avatarRenderer.render(it.toMatrixItem(), avatarImageView) } ?: run { // Fallback to what we know avatarRenderer.render(MatrixItem.UserItem(viewModel.otherUserId ?: "", viewModel.otherUserId), avatarImageView) diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt index d844d0a2f0..fc0eeaf92c 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt @@ -27,7 +27,7 @@ import com.google.android.material.bottomnavigation.BottomNavigationItemView import com.google.android.material.bottomnavigation.BottomNavigationMenuView import im.vector.matrix.android.api.session.crypto.keysbackup.KeysBackupState import im.vector.matrix.android.api.session.group.model.GroupSummary -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.R import im.vector.riotx.core.extensions.commitTransactionNow import im.vector.riotx.core.platform.ToolbarConfigurable @@ -75,7 +75,7 @@ class HomeDetailFragment @Inject constructor( private fun onGroupChange(groupSummary: GroupSummary?) { groupSummary?.let { - avatarRenderer.render(MatrixItem.from(it), groupToolbarAvatarImageView) + avatarRenderer.render(it.toMatrixItem(), groupToolbarAvatarImageView) } } diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeDrawerFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeDrawerFragment.kt index 32344db2df..6ff836e8c8 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeDrawerFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeDrawerFragment.kt @@ -19,7 +19,7 @@ package im.vector.riotx.features.home import android.os.Bundle import android.view.View import im.vector.matrix.android.api.session.Session -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.R import im.vector.riotx.core.extensions.observeK import im.vector.riotx.core.extensions.replaceChildFragment @@ -43,7 +43,7 @@ class HomeDrawerFragment @Inject constructor( session.liveUser(session.myUserId).observeK(this) { optionalUser -> val user = optionalUser?.getOrNull() if (user != null) { - avatarRenderer.render(MatrixItem.from(user), homeDrawerHeaderAvatarView) + avatarRenderer.render(user.toMatrixItem(), homeDrawerHeaderAvatarView) homeDrawerUsernameView.text = user.displayName homeDrawerUserIdView.text = user.userId } diff --git a/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomViewModel.kt index 221b078daa..b71b0cd9d0 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomViewModel.kt @@ -30,7 +30,7 @@ import com.squareup.inject.assisted.AssistedInject import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams import im.vector.matrix.android.api.session.user.model.User -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.matrix.rx.rx import im.vector.riotx.core.extensions.postLiveEvent import im.vector.riotx.core.platform.VectorViewModel @@ -142,7 +142,7 @@ class CreateDirectRoomViewModel @AssistedInject constructor(@Assisted session.rx() .searchUsersDirectory(search, 50, emptySet()) .map { users -> - users.sortedBy { MatrixItem.from(it).firstLetterOfDisplayName() } + users.sortedBy { it.toMatrixItem().firstLetterOfDisplayName() } } } stream.toAsync { diff --git a/vector/src/main/java/im/vector/riotx/features/home/createdirect/DirectoryUsersController.kt b/vector/src/main/java/im/vector/riotx/features/home/createdirect/DirectoryUsersController.kt index c11260a296..8d2b3928be 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/createdirect/DirectoryUsersController.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/createdirect/DirectoryUsersController.kt @@ -25,7 +25,7 @@ import com.airbnb.mvrx.Success import com.airbnb.mvrx.Uninitialized import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.user.model.User -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.R import im.vector.riotx.core.epoxy.errorWithRetryItem import im.vector.riotx.core.epoxy.loadingItem @@ -98,7 +98,7 @@ class DirectoryUsersController @Inject constructor(private val session: Session, createDirectRoomUserItem { id(user.userId) selected(isSelected) - matrixItem(MatrixItem.from(user)) + matrixItem(user.toMatrixItem()) avatarRenderer(avatarRenderer) clickListener { _ -> callback?.onItemClick(user) diff --git a/vector/src/main/java/im/vector/riotx/features/home/createdirect/KnownUsersController.kt b/vector/src/main/java/im/vector/riotx/features/home/createdirect/KnownUsersController.kt index 437e617bd6..8270683975 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/createdirect/KnownUsersController.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/createdirect/KnownUsersController.kt @@ -23,7 +23,7 @@ import com.airbnb.mvrx.Incomplete import com.airbnb.mvrx.Uninitialized import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.user.model.User -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.R import im.vector.riotx.core.epoxy.EmptyItem_ import im.vector.riotx.core.epoxy.loadingItem @@ -68,7 +68,7 @@ class KnownUsersController @Inject constructor(private val session: Session, CreateDirectRoomUserItem_() .id(item.userId) .selected(isSelected) - .matrixItem(MatrixItem.from(item)) + .matrixItem(item.toMatrixItem()) .avatarRenderer(avatarRenderer) .clickListener { _ -> callback?.onItemClick(item) diff --git a/vector/src/main/java/im/vector/riotx/features/home/group/GroupListViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/group/GroupListViewModel.kt index d9a38d5d9b..bbeda127fc 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/group/GroupListViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/group/GroupListViewModel.kt @@ -36,7 +36,7 @@ import im.vector.riotx.core.utils.LiveEvent import io.reactivex.Observable import io.reactivex.functions.BiFunction -const val ALL_COMMUNITIES_GROUP_ID = "ALL_COMMUNITIES_GROUP_ID" +const val ALL_COMMUNITIES_GROUP_ID = "+ALL_COMMUNITIES_GROUP_ID" class GroupListViewModel @AssistedInject constructor(@Assisted initialState: GroupListViewState, private val selectedGroupStore: SelectedGroupDataSource, diff --git a/vector/src/main/java/im/vector/riotx/features/home/group/GroupSummaryController.kt b/vector/src/main/java/im/vector/riotx/features/home/group/GroupSummaryController.kt index 4e98ddb412..95054d1689 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/group/GroupSummaryController.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/group/GroupSummaryController.kt @@ -18,7 +18,7 @@ package im.vector.riotx.features.home.group import com.airbnb.epoxy.EpoxyController import im.vector.matrix.android.api.session.group.model.GroupSummary -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.features.home.AvatarRenderer import javax.inject.Inject @@ -50,7 +50,7 @@ class GroupSummaryController @Inject constructor(private val avatarRenderer: Ava groupSummaryItem { avatarRenderer(avatarRenderer) id(groupSummary.groupId) - matrixItem(MatrixItem.from(groupSummary)) + matrixItem(groupSummary.toMatrixItem()) selected(isSelected) listener { callback?.onGroupSelected(groupSummary) } } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsController.kt b/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsController.kt index a3e46d3197..bfc91bf5a1 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsController.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsController.kt @@ -18,7 +18,7 @@ package im.vector.riotx.features.home.room.breadcrumbs import android.view.View import com.airbnb.epoxy.EpoxyController -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.core.utils.DebouncedClickListener import im.vector.riotx.features.home.AvatarRenderer import javax.inject.Inject @@ -53,7 +53,7 @@ class BreadcrumbsController @Inject constructor( breadcrumbsItem { id(it.roomId) avatarRenderer(avatarRenderer) - matrixItem(MatrixItem.from(it)) + matrixItem(it.toMatrixItem()) unreadNotificationCount(it.notificationCount) showHighlighted(it.highlightCount > 0) hasUnreadMessage(it.hasUnreadMessages) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index fd72e85199..cd9287f7d1 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -67,6 +67,7 @@ import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.matrix.android.api.session.room.timeline.getLastMessageContent import im.vector.matrix.android.api.session.user.model.User import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.R import im.vector.riotx.core.dialogs.withColoredButton import im.vector.riotx.core.epoxy.LayoutManagerStateRestorer @@ -600,7 +601,7 @@ class RoomDetailFragment @Inject constructor( } // Replace the word by its completion - val matrixItem = MatrixItem.from(item) + val matrixItem = item.toMatrixItem() val displayName = matrixItem.getBestName() // with a trailing space @@ -711,7 +712,7 @@ class RoomDetailFragment @Inject constructor( activity?.finish() } else { roomToolbarTitleView.text = it.displayName - avatarRenderer.render(MatrixItem.from(it), roomToolbarAvatarImageView) + avatarRenderer.render(it.toMatrixItem(), roomToolbarAvatarImageView) roomToolbarSubtitleView.setTextOrHide(it.topic) } jumpToBottomView.count = it.notificationCount diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomSummaryItemFactory.kt index 96c8673ca7..84a5f942e8 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomSummaryItemFactory.kt @@ -21,7 +21,7 @@ import im.vector.matrix.android.api.session.events.model.EventType import im.vector.matrix.android.api.session.room.model.Membership import im.vector.matrix.android.api.session.room.model.RoomSummary import im.vector.matrix.android.api.session.room.timeline.getLastMessageContent -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.R import im.vector.riotx.core.date.VectorDateFormatter import im.vector.riotx.core.epoxy.VectorEpoxyModel @@ -70,7 +70,7 @@ class RoomSummaryItemFactory @Inject constructor(private val noticeEventFormatte return RoomInvitationItem_() .id(roomSummary.roomId) .avatarRenderer(avatarRenderer) - .matrixItem(MatrixItem.from(roomSummary)) + .matrixItem(roomSummary.toMatrixItem()) .secondLine(secondLine) .invitationAcceptInProgress(joiningRoomsIds.contains(roomSummary.roomId)) .invitationAcceptInError(joiningErrorRoomsIds.contains(roomSummary.roomId)) @@ -124,7 +124,7 @@ class RoomSummaryItemFactory @Inject constructor(private val noticeEventFormatte return RoomSummaryItem_() .id(roomSummary.roomId) .avatarRenderer(avatarRenderer) - .matrixItem(MatrixItem.from(roomSummary)) + .matrixItem(roomSummary.toMatrixItem()) .lastEventTime(latestEventTime) .lastFormattedEvent(latestFormattedEvent) .showHighlighted(showHighlighted) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt b/vector/src/main/java/im/vector/riotx/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt index 559dfd7301..8d25f5713a 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt @@ -18,7 +18,7 @@ package im.vector.riotx.features.home.room.list.actions import android.view.View import com.airbnb.epoxy.TypedEpoxyController import im.vector.matrix.android.api.session.room.notification.RoomNotificationState -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.core.epoxy.bottomsheet.bottomSheetActionItem import im.vector.riotx.core.epoxy.bottomsheet.bottomSheetRoomPreviewItem import im.vector.riotx.core.epoxy.bottomsheet.bottomSheetSeparatorItem @@ -40,7 +40,7 @@ class RoomListQuickActionsEpoxyController @Inject constructor(private val avatar bottomSheetRoomPreviewItem { id("preview") avatarRenderer(avatarRenderer) - matrixItem(MatrixItem.from(roomSummary)) + matrixItem(roomSummary.toMatrixItem()) settingsClickListener(View.OnClickListener { listener?.didSelectMenuAction(RoomListQuickActionsSharedAction.Settings(roomSummary.roomId)) }) } diff --git a/vector/src/main/java/im/vector/riotx/features/invite/VectorInviteView.kt b/vector/src/main/java/im/vector/riotx/features/invite/VectorInviteView.kt index 56217d9980..b9bd9b0e1e 100644 --- a/vector/src/main/java/im/vector/riotx/features/invite/VectorInviteView.kt +++ b/vector/src/main/java/im/vector/riotx/features/invite/VectorInviteView.kt @@ -22,7 +22,7 @@ import android.view.View import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.updateLayoutParams import im.vector.matrix.android.api.session.user.model.User -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.R import im.vector.riotx.core.di.HasScreenInjector import im.vector.riotx.features.home.AvatarRenderer @@ -57,7 +57,7 @@ class VectorInviteView @JvmOverloads constructor(context: Context, attrs: Attrib fun render(sender: User, mode: Mode = Mode.LARGE) { if (mode == Mode.LARGE) { updateLayoutParams { height = LayoutParams.MATCH_CONSTRAINT } - avatarRenderer.render(MatrixItem.from(sender), inviteAvatarView) + avatarRenderer.render(sender.toMatrixItem(), inviteAvatarView) inviteIdentifierView.text = sender.userId inviteNameView.text = sender.displayName inviteLabelView.text = context.getString(R.string.send_you_invite) diff --git a/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsController.kt b/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsController.kt index 97952059ce..83a1768843 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsController.kt @@ -22,7 +22,7 @@ import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Incomplete import com.airbnb.mvrx.Success import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.R import im.vector.riotx.core.epoxy.errorWithRetryItem import im.vector.riotx.core.epoxy.loadingItem @@ -84,7 +84,7 @@ class PublicRoomsController @Inject constructor(private val stringProvider: Stri publicRoomItem { avatarRenderer(avatarRenderer) id(publicRoom.roomId) - matrixItem(MatrixItem.from(publicRoom)) + matrixItem(publicRoom.toMatrixItem()) roomAlias(publicRoom.canonicalAlias) roomTopic(publicRoom.topic) nbOfMembers(publicRoom.numJoinedMembers) diff --git a/vector/src/main/java/im/vector/riotx/features/settings/ignored/IgnoredUsersController.kt b/vector/src/main/java/im/vector/riotx/features/settings/ignored/IgnoredUsersController.kt index 18f256a207..5f4158b542 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/ignored/IgnoredUsersController.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/ignored/IgnoredUsersController.kt @@ -18,7 +18,7 @@ package im.vector.riotx.features.settings.ignored import com.airbnb.epoxy.EpoxyController import im.vector.matrix.android.api.session.user.model.User -import im.vector.matrix.android.api.util.MatrixItem +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.R import im.vector.riotx.core.epoxy.noResultItem import im.vector.riotx.core.resources.StringProvider @@ -56,7 +56,7 @@ class IgnoredUsersController @Inject constructor(private val stringProvider: Str userItem { id(user.userId) avatarRenderer(avatarRenderer) - matrixItem(MatrixItem.from(user)) + matrixItem(user.toMatrixItem()) itemClickAction { callback?.onUserIdClicked(user.userId) } } }