Merge branch 'feature/eric/replace-search-room-subheader' into experiment/eric/space-switching-modal
This commit is contained in:
commit
a0baf77438
1
changelog.d/5860.feature
Normal file
1
changelog.d/5860.feature
Normal file
@ -0,0 +1 @@
|
|||||||
|
Adds space or user id as a subtitle under rooms in search
|
@ -43,7 +43,6 @@ internal class RoomChildRelationInfo(
|
|||||||
data class SpaceChildInfo(
|
data class SpaceChildInfo(
|
||||||
val roomId: String,
|
val roomId: String,
|
||||||
val order: String?,
|
val order: String?,
|
||||||
// val autoJoin: Boolean,
|
|
||||||
val viaServers: List<String>
|
val viaServers: List<String>
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,18 +59,13 @@ internal class RoomChildRelationInfo(
|
|||||||
fun getDirectChildrenDescriptions(): List<SpaceChildInfo> {
|
fun getDirectChildrenDescriptions(): List<SpaceChildInfo> {
|
||||||
return CurrentStateEventEntity.whereType(realm, roomId, EventType.STATE_SPACE_CHILD)
|
return CurrentStateEventEntity.whereType(realm, roomId, EventType.STATE_SPACE_CHILD)
|
||||||
.findAll()
|
.findAll()
|
||||||
// .also {
|
|
||||||
// Timber.v("## Space: Found ${it.count()} m.space.child state events for $roomId")
|
|
||||||
// }
|
|
||||||
.mapNotNull {
|
.mapNotNull {
|
||||||
ContentMapper.map(it.root?.content).toModel<SpaceChildContent>()?.let { scc ->
|
ContentMapper.map(it.root?.content).toModel<SpaceChildContent>()?.let { scc ->
|
||||||
// Timber.v("## Space child desc state event $scc")
|
|
||||||
// Children where via is not present are ignored.
|
// Children where via is not present are ignored.
|
||||||
scc.via?.let { via ->
|
scc.via?.let { via ->
|
||||||
SpaceChildInfo(
|
SpaceChildInfo(
|
||||||
roomId = it.stateKey,
|
roomId = it.stateKey,
|
||||||
order = scc.validOrder(),
|
order = scc.validOrder(),
|
||||||
// autoJoin = scc.autoJoin ?: false,
|
|
||||||
viaServers = via
|
viaServers = via
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -83,17 +77,13 @@ internal class RoomChildRelationInfo(
|
|||||||
fun getParentDescriptions(): List<SpaceParentInfo> {
|
fun getParentDescriptions(): List<SpaceParentInfo> {
|
||||||
return CurrentStateEventEntity.whereType(realm, roomId, EventType.STATE_SPACE_PARENT)
|
return CurrentStateEventEntity.whereType(realm, roomId, EventType.STATE_SPACE_PARENT)
|
||||||
.findAll()
|
.findAll()
|
||||||
// .also {
|
|
||||||
// Timber.v("## Space: Found ${it.count()} m.space.parent state events for $roomId")
|
|
||||||
// }
|
|
||||||
.mapNotNull {
|
.mapNotNull {
|
||||||
ContentMapper.map(it.root?.content).toModel<SpaceParentContent>()?.let { scc ->
|
ContentMapper.map(it.root?.content).toModel<SpaceParentContent>()?.let { spaceParentContent ->
|
||||||
// Timber.v("## Space parent desc state event $scc")
|
|
||||||
// Parent where via is not present are ignored.
|
// Parent where via is not present are ignored.
|
||||||
scc.via?.let { via ->
|
spaceParentContent.via?.let { via ->
|
||||||
SpaceParentInfo(
|
SpaceParentInfo(
|
||||||
roomId = it.stateKey,
|
roomId = it.stateKey,
|
||||||
canonical = scc.canonical ?: false,
|
canonical = spaceParentContent.canonical ?: false,
|
||||||
viaServers = via,
|
viaServers = via,
|
||||||
stateEventSender = it.root?.sender ?: ""
|
stateEventSender = it.root?.sender ?: ""
|
||||||
)
|
)
|
||||||
|
@ -36,6 +36,7 @@ import org.matrix.android.sdk.api.session.room.UpdatableLivePageResult
|
|||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
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.RoomType
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.SpaceParentInfo
|
||||||
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||||
import org.matrix.android.sdk.api.session.room.spaceSummaryQueryParams
|
import org.matrix.android.sdk.api.session.room.spaceSummaryQueryParams
|
||||||
import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount
|
import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount
|
||||||
@ -193,6 +194,18 @@ internal class RoomSummaryDataSource @Inject constructor(
|
|||||||
}
|
}
|
||||||
val dataSourceFactory = realmDataSourceFactory.map {
|
val dataSourceFactory = realmDataSourceFactory.map {
|
||||||
roomSummaryMapper.map(it)
|
roomSummaryMapper.map(it)
|
||||||
|
}.map { roomSummary ->
|
||||||
|
val parents = roomSummary.flattenParentIds.mapNotNull { parentId ->
|
||||||
|
getRoomSummary(parentId)?.let { parentSummary ->
|
||||||
|
SpaceParentInfo(
|
||||||
|
parentId = parentSummary.flattenParentIds.firstOrNull(),
|
||||||
|
roomSummary = parentSummary,
|
||||||
|
canonical = true,
|
||||||
|
viaServers = emptyList()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
roomSummary.copy(spaceParents = parents)
|
||||||
}
|
}
|
||||||
|
|
||||||
val boundaries = MutableLiveData(ResultBoundaries())
|
val boundaries = MutableLiveData(ResultBoundaries())
|
||||||
|
@ -68,7 +68,7 @@ abstract class CollapsableTypedEpoxyController<T> :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun buildModels() {
|
override fun buildModels() {
|
||||||
check(isBuildingModels()) {
|
check(isBuildingModels) {
|
||||||
("You cannot call `buildModels` directly. Call `setData` instead to trigger a model " +
|
("You cannot call `buildModels` directly. Call `setData` instead to trigger a model " +
|
||||||
"refresh with new data.")
|
"refresh with new data.")
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ class RoomListFragment @Inject constructor(
|
|||||||
RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.isVisible = true
|
RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.isVisible = true
|
||||||
RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = true
|
RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = true
|
||||||
RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.isVisible = true
|
RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.isVisible = true
|
||||||
else -> Unit // No button in this mode
|
RoomListDisplayMode.FILTERED -> Unit // No button in this mode
|
||||||
}
|
}
|
||||||
|
|
||||||
views.createChatRoomButton.debouncedClicks {
|
views.createChatRoomButton.debouncedClicks {
|
||||||
@ -237,7 +237,7 @@ class RoomListFragment @Inject constructor(
|
|||||||
RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.hide()
|
RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.hide()
|
||||||
RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.hide()
|
RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.hide()
|
||||||
RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.hide()
|
RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.hide()
|
||||||
else -> Unit
|
RoomListDisplayMode.FILTERED -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ class RoomListFragment @Inject constructor(
|
|||||||
val contentAdapter =
|
val contentAdapter =
|
||||||
when {
|
when {
|
||||||
section.livePages != null -> {
|
section.livePages != null -> {
|
||||||
pagedControllerFactory.createRoomSummaryPagedController()
|
pagedControllerFactory.createRoomSummaryPagedController(roomListParams.displayMode)
|
||||||
.also { controller ->
|
.also { controller ->
|
||||||
section.livePages.observe(viewLifecycleOwner) { pl ->
|
section.livePages.observe(viewLifecycleOwner) { pl ->
|
||||||
controller.submitList(pl)
|
controller.submitList(pl)
|
||||||
@ -316,7 +316,7 @@ class RoomListFragment @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
section.isExpanded.observe(viewLifecycleOwner) {
|
||||||
refreshCollapseStates()
|
refreshCollapseStates()
|
||||||
}
|
}
|
||||||
controller.listener = this
|
controller.listener = this
|
||||||
@ -337,14 +337,14 @@ class RoomListFragment @Inject constructor(
|
|||||||
checkEmptyState()
|
checkEmptyState()
|
||||||
}
|
}
|
||||||
observeItemCount(section, sectionAdapter)
|
observeItemCount(section, sectionAdapter)
|
||||||
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
section.isExpanded.observe(viewLifecycleOwner) {
|
||||||
refreshCollapseStates()
|
refreshCollapseStates()
|
||||||
}
|
}
|
||||||
controller.listener = this
|
controller.listener = this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
pagedControllerFactory.createRoomSummaryListController()
|
pagedControllerFactory.createRoomSummaryListController(roomListParams.displayMode)
|
||||||
.also { controller ->
|
.also { controller ->
|
||||||
section.liveList?.observe(viewLifecycleOwner) { list ->
|
section.liveList?.observe(viewLifecycleOwner) { list ->
|
||||||
controller.setData(list)
|
controller.setData(list)
|
||||||
@ -366,7 +366,7 @@ class RoomListFragment @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
section.isExpanded.observe(viewLifecycleOwner) {
|
||||||
refreshCollapseStates()
|
refreshCollapseStates()
|
||||||
}
|
}
|
||||||
controller.listener = this
|
controller.listener = this
|
||||||
@ -402,7 +402,7 @@ class RoomListFragment @Inject constructor(
|
|||||||
RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.show()
|
RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.show()
|
||||||
RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.show()
|
RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.show()
|
||||||
RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.show()
|
RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.show()
|
||||||
else -> Unit
|
RoomListDisplayMode.FILTERED -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -498,7 +498,7 @@ class RoomListFragment @Inject constructor(
|
|||||||
isBigImage = true,
|
isBigImage = true,
|
||||||
message = getString(R.string.room_list_rooms_empty_body)
|
message = getString(R.string.room_list_rooms_empty_body)
|
||||||
)
|
)
|
||||||
else ->
|
RoomListDisplayMode.FILTERED ->
|
||||||
// Always display the content in this mode, because if the footer
|
// Always display the content in this mode, because if the footer
|
||||||
StateView.State.Content
|
StateView.State.Content
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import im.vector.app.core.ui.views.PresenceStateImageView
|
|||||||
import im.vector.app.core.ui.views.ShieldImageView
|
import im.vector.app.core.ui.views.ShieldImageView
|
||||||
import im.vector.app.features.displayname.getBestName
|
import im.vector.app.features.displayname.getBestName
|
||||||
import im.vector.app.features.home.AvatarRenderer
|
import im.vector.app.features.home.AvatarRenderer
|
||||||
|
import im.vector.app.features.home.RoomListDisplayMode
|
||||||
import im.vector.app.features.themes.ThemeUtils
|
import im.vector.app.features.themes.ThemeUtils
|
||||||
import im.vector.lib.core.utils.epoxy.charsequence.EpoxyCharSequence
|
import im.vector.lib.core.utils.epoxy.charsequence.EpoxyCharSequence
|
||||||
import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
|
import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
|
||||||
@ -45,48 +46,102 @@ import org.matrix.android.sdk.api.util.MatrixItem
|
|||||||
@EpoxyModelClass(layout = R.layout.item_room)
|
@EpoxyModelClass(layout = R.layout.item_room)
|
||||||
abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>() {
|
abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>() {
|
||||||
|
|
||||||
@EpoxyAttribute lateinit var typingMessage: String
|
@EpoxyAttribute
|
||||||
@EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer
|
lateinit var typingMessage: String
|
||||||
@EpoxyAttribute lateinit var matrixItem: MatrixItem
|
|
||||||
|
|
||||||
@EpoxyAttribute lateinit var lastFormattedEvent: EpoxyCharSequence
|
@EpoxyAttribute
|
||||||
@EpoxyAttribute lateinit var lastEventTime: String
|
lateinit var avatarRenderer: AvatarRenderer
|
||||||
@EpoxyAttribute var encryptionTrustLevel: RoomEncryptionTrustLevel? = null
|
|
||||||
@EpoxyAttribute var userPresence: UserPresence? = null
|
@EpoxyAttribute
|
||||||
@EpoxyAttribute var showPresence: Boolean = false
|
lateinit var matrixItem: MatrixItem
|
||||||
@EpoxyAttribute var izPublic: Boolean = false
|
|
||||||
@EpoxyAttribute var unreadNotificationCount: Int = 0
|
@EpoxyAttribute
|
||||||
@EpoxyAttribute var hasUnreadMessage: Boolean = false
|
var displayMode: RoomListDisplayMode = RoomListDisplayMode.PEOPLE
|
||||||
@EpoxyAttribute var hasDraft: Boolean = false
|
|
||||||
@EpoxyAttribute var showHighlighted: Boolean = false
|
@EpoxyAttribute
|
||||||
@EpoxyAttribute var hasFailedSending: Boolean = false
|
lateinit var subtitle: String
|
||||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemLongClickListener: View.OnLongClickListener? = null
|
|
||||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: ClickListener? = null
|
@EpoxyAttribute
|
||||||
@EpoxyAttribute var showSelected: Boolean = false
|
lateinit var lastFormattedEvent: EpoxyCharSequence
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
lateinit var lastEventTime: String
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var encryptionTrustLevel: RoomEncryptionTrustLevel? = null
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var userPresence: UserPresence? = null
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var showPresence: Boolean = false
|
||||||
|
|
||||||
|
@EpoxyAttribute @JvmField
|
||||||
|
var isPublic: Boolean = false
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var unreadNotificationCount: Int = 0
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var hasUnreadMessage: Boolean = false
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var hasDraft: Boolean = false
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var showHighlighted: Boolean = false
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var hasFailedSending: Boolean = false
|
||||||
|
|
||||||
|
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||||
|
var itemLongClickListener: View.OnLongClickListener? = null
|
||||||
|
|
||||||
|
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||||
|
var itemClickListener: ClickListener? = null
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var showSelected: Boolean = false
|
||||||
|
|
||||||
override fun bind(holder: Holder) {
|
override fun bind(holder: Holder) {
|
||||||
super.bind(holder)
|
super.bind(holder)
|
||||||
|
|
||||||
|
renderDisplayMode(holder)
|
||||||
holder.rootView.onClick(itemClickListener)
|
holder.rootView.onClick(itemClickListener)
|
||||||
holder.rootView.setOnLongClickListener {
|
holder.rootView.setOnLongClickListener {
|
||||||
it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
||||||
itemLongClickListener?.onLongClick(it) ?: false
|
itemLongClickListener?.onLongClick(it) ?: false
|
||||||
}
|
}
|
||||||
holder.titleView.text = matrixItem.getBestName()
|
holder.titleView.text = matrixItem.getBestName()
|
||||||
holder.lastEventTimeView.text = lastEventTime
|
|
||||||
holder.lastEventView.text = lastFormattedEvent.charSequence
|
|
||||||
holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted))
|
holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted))
|
||||||
holder.unreadIndentIndicator.isVisible = hasUnreadMessage
|
holder.unreadIndentIndicator.isVisible = hasUnreadMessage
|
||||||
holder.draftView.isVisible = hasDraft
|
holder.draftView.isVisible = hasDraft
|
||||||
avatarRenderer.render(matrixItem, holder.avatarImageView)
|
avatarRenderer.render(matrixItem, holder.avatarImageView)
|
||||||
holder.roomAvatarDecorationImageView.render(encryptionTrustLevel)
|
holder.roomAvatarDecorationImageView.render(encryptionTrustLevel)
|
||||||
holder.roomAvatarPublicDecorationImageView.isVisible = izPublic
|
holder.roomAvatarPublicDecorationImageView.isVisible = isPublic
|
||||||
holder.roomAvatarFailSendingImageView.isVisible = hasFailedSending
|
holder.roomAvatarFailSendingImageView.isVisible = hasFailedSending
|
||||||
renderSelection(holder, showSelected)
|
renderSelection(holder, showSelected)
|
||||||
holder.typingView.setTextOrHide(typingMessage)
|
|
||||||
holder.lastEventView.isInvisible = holder.typingView.isVisible
|
|
||||||
holder.roomAvatarPresenceImageView.render(showPresence, userPresence)
|
holder.roomAvatarPresenceImageView.render(showPresence, userPresence)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun renderDisplayMode(holder: Holder) = when (displayMode) {
|
||||||
|
RoomListDisplayMode.ROOMS,
|
||||||
|
RoomListDisplayMode.PEOPLE,
|
||||||
|
RoomListDisplayMode.NOTIFICATIONS -> renderForDefaultDisplayMode(holder)
|
||||||
|
RoomListDisplayMode.FILTERED -> renderForFilteredDisplayMode(holder)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderForDefaultDisplayMode(holder: Holder) {
|
||||||
|
holder.subtitleView.text = lastFormattedEvent.charSequence
|
||||||
|
holder.lastEventTimeView.text = lastEventTime
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderForFilteredDisplayMode(holder: Holder) {
|
||||||
|
holder.subtitleView.text = subtitle
|
||||||
|
holder.typingView.setTextOrHide(typingMessage)
|
||||||
|
holder.subtitleView.isInvisible = holder.typingView.isVisible
|
||||||
|
}
|
||||||
|
|
||||||
override fun unbind(holder: Holder) {
|
override fun unbind(holder: Holder) {
|
||||||
holder.rootView.setOnClickListener(null)
|
holder.rootView.setOnClickListener(null)
|
||||||
holder.rootView.setOnLongClickListener(null)
|
holder.rootView.setOnLongClickListener(null)
|
||||||
@ -110,7 +165,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>() {
|
|||||||
val titleView by bind<TextView>(R.id.roomNameView)
|
val titleView by bind<TextView>(R.id.roomNameView)
|
||||||
val unreadCounterBadgeView by bind<UnreadCounterBadgeView>(R.id.roomUnreadCounterBadgeView)
|
val unreadCounterBadgeView by bind<UnreadCounterBadgeView>(R.id.roomUnreadCounterBadgeView)
|
||||||
val unreadIndentIndicator by bind<View>(R.id.roomUnreadIndicator)
|
val unreadIndentIndicator by bind<View>(R.id.roomUnreadIndicator)
|
||||||
val lastEventView by bind<TextView>(R.id.roomLastEventView)
|
val subtitleView by bind<TextView>(R.id.subtitleView)
|
||||||
val typingView by bind<TextView>(R.id.roomTypingView)
|
val typingView by bind<TextView>(R.id.roomTypingView)
|
||||||
val draftView by bind<ImageView>(R.id.roomDraftBadge)
|
val draftView by bind<ImageView>(R.id.roomDraftBadge)
|
||||||
val lastEventTimeView by bind<TextView>(R.id.roomLastEventTimeView)
|
val lastEventTimeView by bind<TextView>(R.id.roomLastEventTimeView)
|
||||||
|
@ -26,6 +26,7 @@ import im.vector.app.core.epoxy.VectorEpoxyModel
|
|||||||
import im.vector.app.core.error.ErrorFormatter
|
import im.vector.app.core.error.ErrorFormatter
|
||||||
import im.vector.app.core.resources.StringProvider
|
import im.vector.app.core.resources.StringProvider
|
||||||
import im.vector.app.features.home.AvatarRenderer
|
import im.vector.app.features.home.AvatarRenderer
|
||||||
|
import im.vector.app.features.home.RoomListDisplayMode
|
||||||
import im.vector.app.features.home.room.detail.timeline.format.DisplayableEventFormatter
|
import im.vector.app.features.home.room.detail.timeline.format.DisplayableEventFormatter
|
||||||
import im.vector.app.features.home.room.typing.TypingHelper
|
import im.vector.app.features.home.room.typing.TypingHelper
|
||||||
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
|
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
|
||||||
@ -46,13 +47,16 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
|||||||
fun create(roomSummary: RoomSummary,
|
fun create(roomSummary: RoomSummary,
|
||||||
roomChangeMembershipStates: Map<String, ChangeMembershipState>,
|
roomChangeMembershipStates: Map<String, ChangeMembershipState>,
|
||||||
selectedRoomIds: Set<String>,
|
selectedRoomIds: Set<String>,
|
||||||
|
displayMode: RoomListDisplayMode,
|
||||||
listener: RoomListListener?): VectorEpoxyModel<*> {
|
listener: RoomListListener?): VectorEpoxyModel<*> {
|
||||||
return when (roomSummary.membership) {
|
return when (roomSummary.membership) {
|
||||||
Membership.INVITE -> {
|
Membership.INVITE -> {
|
||||||
val changeMembershipState = roomChangeMembershipStates[roomSummary.roomId] ?: ChangeMembershipState.Unknown
|
val changeMembershipState = roomChangeMembershipStates[roomSummary.roomId] ?: ChangeMembershipState.Unknown
|
||||||
createInvitationItem(roomSummary, changeMembershipState, listener)
|
createInvitationItem(roomSummary, changeMembershipState, listener)
|
||||||
}
|
}
|
||||||
else -> createRoomItem(roomSummary, selectedRoomIds, listener?.let { it::onRoomClicked }, listener?.let { it::onRoomLongClicked })
|
else -> createRoomItem(
|
||||||
|
roomSummary, selectedRoomIds, displayMode, listener?.let { it::onRoomClicked }, listener?.let { it::onRoomLongClicked }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,9 +109,11 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
|||||||
fun createRoomItem(
|
fun createRoomItem(
|
||||||
roomSummary: RoomSummary,
|
roomSummary: RoomSummary,
|
||||||
selectedRoomIds: Set<String>,
|
selectedRoomIds: Set<String>,
|
||||||
|
displayMode: RoomListDisplayMode,
|
||||||
onClick: ((RoomSummary) -> Unit)?,
|
onClick: ((RoomSummary) -> Unit)?,
|
||||||
onLongClick: ((RoomSummary) -> Boolean)?
|
onLongClick: ((RoomSummary) -> Boolean)?
|
||||||
): VectorEpoxyModel<*> {
|
): VectorEpoxyModel<*> {
|
||||||
|
val subtitle = getSearchResultSubtitle(roomSummary)
|
||||||
val unreadCount = roomSummary.notificationCount
|
val unreadCount = roomSummary.notificationCount
|
||||||
val showHighlighted = roomSummary.highlightCount > 0
|
val showHighlighted = roomSummary.highlightCount > 0
|
||||||
val showSelected = selectedRoomIds.contains(roomSummary.roomId)
|
val showSelected = selectedRoomIds.contains(roomSummary.roomId)
|
||||||
@ -118,13 +124,16 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
|||||||
latestFormattedEvent = displayableEventFormatter.format(latestEvent, roomSummary.isDirect, roomSummary.isDirect.not())
|
latestFormattedEvent = displayableEventFormatter.format(latestEvent, roomSummary.isDirect, roomSummary.isDirect.not())
|
||||||
latestEventTime = dateFormatter.format(latestEvent.root.originServerTs, DateFormatKind.ROOM_LIST)
|
latestEventTime = dateFormatter.format(latestEvent.root.originServerTs, DateFormatKind.ROOM_LIST)
|
||||||
}
|
}
|
||||||
|
|
||||||
val typingMessage = typingHelper.getTypingMessage(roomSummary.typingUsers)
|
val typingMessage = typingHelper.getTypingMessage(roomSummary.typingUsers)
|
||||||
return RoomSummaryItem_()
|
return RoomSummaryItem_()
|
||||||
.id(roomSummary.roomId)
|
.id(roomSummary.roomId)
|
||||||
.avatarRenderer(avatarRenderer)
|
.avatarRenderer(avatarRenderer)
|
||||||
// We do not display shield in the room list anymore
|
// We do not display shield in the room list anymore
|
||||||
// .encryptionTrustLevel(roomSummary.roomEncryptionTrustLevel)
|
// .encryptionTrustLevel(roomSummary.roomEncryptionTrustLevel)
|
||||||
.izPublic(roomSummary.isPublic)
|
.displayMode(displayMode)
|
||||||
|
.subtitle(subtitle)
|
||||||
|
.isPublic(roomSummary.isPublic)
|
||||||
.showPresence(roomSummary.isDirect)
|
.showPresence(roomSummary.isDirect)
|
||||||
.userPresence(roomSummary.directUserPresence)
|
.userPresence(roomSummary.directUserPresence)
|
||||||
.matrixItem(roomSummary.toMatrixItem())
|
.matrixItem(roomSummary.toMatrixItem())
|
||||||
@ -142,4 +151,12 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
|||||||
}
|
}
|
||||||
.itemClickListener { onClick?.invoke(roomSummary) }
|
.itemClickListener { onClick?.invoke(roomSummary) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getSearchResultSubtitle(roomSummary: RoomSummary): String {
|
||||||
|
val userId = roomSummary.directUserId
|
||||||
|
val spaceName = roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name
|
||||||
|
val canonicalAlias = roomSummary.canonicalAlias
|
||||||
|
|
||||||
|
return (userId ?: spaceName ?: canonicalAlias).orEmpty()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,17 +16,19 @@
|
|||||||
|
|
||||||
package im.vector.app.features.home.room.list
|
package im.vector.app.features.home.room.list
|
||||||
|
|
||||||
|
import im.vector.app.features.home.RoomListDisplayMode
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
|
|
||||||
class RoomSummaryListController(
|
class RoomSummaryListController(
|
||||||
private val roomSummaryItemFactory: RoomSummaryItemFactory
|
private val roomSummaryItemFactory: RoomSummaryItemFactory,
|
||||||
|
private val displayMode: RoomListDisplayMode
|
||||||
) : CollapsableTypedEpoxyController<List<RoomSummary>>() {
|
) : CollapsableTypedEpoxyController<List<RoomSummary>>() {
|
||||||
|
|
||||||
var listener: RoomListListener? = null
|
var listener: RoomListListener? = null
|
||||||
|
|
||||||
override fun buildModels(data: List<RoomSummary>?) {
|
override fun buildModels(data: List<RoomSummary>?) {
|
||||||
data?.forEach {
|
data?.forEach {
|
||||||
add(roomSummaryItemFactory.create(it, emptyMap(), emptySet(), listener))
|
add(roomSummaryItemFactory.create(it, emptyMap(), emptySet(), displayMode, listener))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,13 @@ package im.vector.app.features.home.room.list
|
|||||||
import com.airbnb.epoxy.EpoxyModel
|
import com.airbnb.epoxy.EpoxyModel
|
||||||
import com.airbnb.epoxy.paging.PagedListEpoxyController
|
import com.airbnb.epoxy.paging.PagedListEpoxyController
|
||||||
import im.vector.app.core.utils.createUIHandler
|
import im.vector.app.core.utils.createUIHandler
|
||||||
|
import im.vector.app.features.home.RoomListDisplayMode
|
||||||
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
|
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
|
|
||||||
class RoomSummaryPagedController(
|
class RoomSummaryPagedController(
|
||||||
private val roomSummaryItemFactory: RoomSummaryItemFactory
|
private val roomSummaryItemFactory: RoomSummaryItemFactory,
|
||||||
|
private val displayMode: RoomListDisplayMode
|
||||||
) : PagedListEpoxyController<RoomSummary>(
|
) : PagedListEpoxyController<RoomSummary>(
|
||||||
// Important it must match the PageList builder notify Looper
|
// Important it must match the PageList builder notify Looper
|
||||||
modelBuildingHandler = createUIHandler()
|
modelBuildingHandler = createUIHandler()
|
||||||
@ -57,6 +59,6 @@ class RoomSummaryPagedController(
|
|||||||
override fun buildItemModel(currentPosition: Int, item: RoomSummary?): EpoxyModel<*> {
|
override fun buildItemModel(currentPosition: Int, item: RoomSummary?): EpoxyModel<*> {
|
||||||
// for place holder if enabled
|
// for place holder if enabled
|
||||||
item ?: return RoomSummaryItemPlaceHolder_().apply { id(currentPosition) }
|
item ?: return RoomSummaryItemPlaceHolder_().apply { id(currentPosition) }
|
||||||
return roomSummaryItemFactory.create(item, roomChangeMembershipStates.orEmpty(), emptySet(), listener)
|
return roomSummaryItemFactory.create(item, roomChangeMembershipStates.orEmpty(), emptySet(), displayMode, listener)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,18 +16,19 @@
|
|||||||
|
|
||||||
package im.vector.app.features.home.room.list
|
package im.vector.app.features.home.room.list
|
||||||
|
|
||||||
|
import im.vector.app.features.home.RoomListDisplayMode
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class RoomSummaryPagedControllerFactory @Inject constructor(
|
class RoomSummaryPagedControllerFactory @Inject constructor(
|
||||||
private val roomSummaryItemFactory: RoomSummaryItemFactory
|
private val roomSummaryItemFactory: RoomSummaryItemFactory
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun createRoomSummaryPagedController(): RoomSummaryPagedController {
|
fun createRoomSummaryPagedController(displayMode: RoomListDisplayMode): RoomSummaryPagedController {
|
||||||
return RoomSummaryPagedController(roomSummaryItemFactory)
|
return RoomSummaryPagedController(roomSummaryItemFactory, displayMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createRoomSummaryListController(): RoomSummaryListController {
|
fun createRoomSummaryListController(displayMode: RoomListDisplayMode): RoomSummaryListController {
|
||||||
return RoomSummaryListController(roomSummaryItemFactory)
|
return RoomSummaryListController(roomSummaryItemFactory, displayMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createSuggestedRoomListController(): SuggestedRoomListController {
|
fun createSuggestedRoomListController(): SuggestedRoomListController {
|
||||||
|
@ -22,6 +22,7 @@ import im.vector.app.R
|
|||||||
import im.vector.app.core.epoxy.loadingItem
|
import im.vector.app.core.epoxy.loadingItem
|
||||||
import im.vector.app.core.epoxy.noResultItem
|
import im.vector.app.core.epoxy.noResultItem
|
||||||
import im.vector.app.core.resources.StringProvider
|
import im.vector.app.core.resources.StringProvider
|
||||||
|
import im.vector.app.features.home.RoomListDisplayMode
|
||||||
import im.vector.app.features.home.room.list.RoomSummaryItemFactory
|
import im.vector.app.features.home.room.list.RoomSummaryItemFactory
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -53,7 +54,13 @@ class IncomingShareController @Inject constructor(private val roomSummaryItemFac
|
|||||||
} else {
|
} else {
|
||||||
roomSummaries.forEach { roomSummary ->
|
roomSummaries.forEach { roomSummary ->
|
||||||
roomSummaryItemFactory
|
roomSummaryItemFactory
|
||||||
.createRoomItem(roomSummary, data.selectedRoomIds, callback?.let { it::onRoomClicked }, callback?.let { it::onRoomLongClicked })
|
.createRoomItem(
|
||||||
|
roomSummary,
|
||||||
|
data.selectedRoomIds,
|
||||||
|
RoomListDisplayMode.FILTERED,
|
||||||
|
callback?.let { it::onRoomClicked },
|
||||||
|
callback?.let { it::onRoomLongClicked }
|
||||||
|
)
|
||||||
.addTo(this)
|
.addTo(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@
|
|||||||
tools:text="@tools:sample/date/hhmm" />
|
tools:text="@tools:sample/date/hhmm" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/roomLastEventView"
|
android:id="@+id/subtitleView"
|
||||||
style="@style/Widget.Vector.TextView.Body"
|
style="@style/Widget.Vector.TextView.Body"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -213,7 +213,8 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="@id/roomNameView"
|
app:layout_constraintStart_toStartOf="@id/roomNameView"
|
||||||
app:layout_constraintTop_toBottomOf="@id/roomNameView"
|
app:layout_constraintTop_toBottomOf="@id/roomNameView"
|
||||||
tools:text="Alice is typing…" />
|
tools:text="Alice is typing…"
|
||||||
|
tools:visibility="gone" />
|
||||||
|
|
||||||
<!-- Margin bottom does not work, so I use space -->
|
<!-- Margin bottom does not work, so I use space -->
|
||||||
<Space
|
<Space
|
||||||
@ -221,7 +222,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="7dp"
|
android:layout_height="7dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/roomLastEventView"
|
app:layout_constraintTop_toBottomOf="@id/subtitleView"
|
||||||
tools:layout_marginStart="120dp" />
|
tools:layout_marginStart="120dp" />
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Barrier
|
<androidx.constraintlayout.widget.Barrier
|
||||||
|
Loading…
Reference in New Issue
Block a user