From 60169d53d72094ba00a5e97d07b05f7169790495 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 5 Dec 2019 20:28:07 +0100 Subject: [PATCH] Breadcrumbs: add some visual attributes --- .../room/breadcrumbs/BreadcrumbsController.kt | 4 ++ .../home/room/breadcrumbs/BreadcrumbsItem.kt | 17 +++++-- .../src/main/res/layout/item_breadcrumbs.xml | 50 ++++++++++++++++++- 3 files changed, 64 insertions(+), 7 deletions(-) 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 eb97b91cbe..ea359ee2f7 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 @@ -55,6 +55,10 @@ class BreadcrumbsController @Inject constructor( roomId(it.roomId) roomName(it.displayName) avatarUrl(it.avatarUrl) + unreadNotificationCount(it.notificationCount) + showHighlighted(it.highlightCount > 0) + hasUnreadMessage(it.hasUnreadMessages) + hasDraft(it.userDrafts.isNotEmpty()) itemClickListener( DebouncedClickListener(View.OnClickListener { _ -> listener?.onRoomClicked(it) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsItem.kt b/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsItem.kt index d8d1acb6d3..074c35af00 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsItem.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsItem.kt @@ -19,12 +19,14 @@ package im.vector.riotx.features.home.room.breadcrumbs import android.view.View import android.view.ViewGroup import android.widget.ImageView +import androidx.core.view.isVisible import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass import im.vector.riotx.R import im.vector.riotx.core.epoxy.VectorEpoxyHolder import im.vector.riotx.core.epoxy.VectorEpoxyModel import im.vector.riotx.features.home.AvatarRenderer +import im.vector.riotx.features.home.room.list.UnreadCounterBadgeView @EpoxyModelClass(layout = R.layout.item_breadcrumbs) abstract class BreadcrumbsItem : VectorEpoxyModel() { @@ -33,20 +35,25 @@ abstract class BreadcrumbsItem : VectorEpoxyModel() { @EpoxyAttribute lateinit var roomId: String @EpoxyAttribute lateinit var roomName: CharSequence @EpoxyAttribute var avatarUrl: String? = null - // TODO @EpoxyAttribute var unreadNotificationCount: Int = 0 - // TODO @EpoxyAttribute var hasUnreadMessage: Boolean = false - // TODO @EpoxyAttribute var showHighlighted: Boolean = false + @EpoxyAttribute var unreadNotificationCount: Int = 0 + @EpoxyAttribute var showHighlighted: Boolean = false + @EpoxyAttribute var hasUnreadMessage: Boolean = false + @EpoxyAttribute var hasDraft: Boolean = false @EpoxyAttribute var itemClickListener: View.OnClickListener? = null override fun bind(holder: Holder) { super.bind(holder) holder.rootView.setOnClickListener(itemClickListener) + holder.unreadIndentIndicator.isVisible = hasUnreadMessage avatarRenderer.render(avatarUrl, roomId, roomName.toString(), holder.avatarImageView) + holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted)) + holder.draftIndentIndicator.isVisible = hasDraft } class Holder : VectorEpoxyHolder() { - // TODO val unreadCounterBadgeView by bind(R.id.roomUnreadCounterBadgeView) - // TODO val unreadIndentIndicator by bind(R.id.roomUnreadIndicator) + val unreadCounterBadgeView by bind(R.id.breadcrumbsUnreadCounterBadgeView) + val unreadIndentIndicator by bind(R.id.breadcrumbsUnreadIndicator) + val draftIndentIndicator by bind(R.id.breadcrumbsDraftBadge) val avatarImageView by bind(R.id.breadcrumbsImageView) val rootView by bind(R.id.breadcrumbsRoot) } diff --git a/vector/src/main/res/layout/item_breadcrumbs.xml b/vector/src/main/res/layout/item_breadcrumbs.xml index 0f8b535b7b..4d9616ab1b 100644 --- a/vector/src/main/res/layout/item_breadcrumbs.xml +++ b/vector/src/main/res/layout/item_breadcrumbs.xml @@ -1,5 +1,6 @@ - + + - + + + + +