[merge] Revert back to old section header

Change-Id: Id7a4a9b31a02acbabff028d8d684e3d02dc1c1ec
This commit is contained in:
SpiritCroc 2022-03-30 17:07:24 +02:00
parent cb3658859e
commit 886cd253ec
3 changed files with 78 additions and 11 deletions

View file

@ -29,7 +29,7 @@ import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.epoxy.onClick import im.vector.app.core.epoxy.onClick
import im.vector.app.features.themes.ThemeUtils import im.vector.app.features.themes.ThemeUtils
@EpoxyModelClass(layout = R.layout.item_room_category) @EpoxyModelClass(layout = R.layout.item_room_category_sc)
abstract class RoomCategoryItem : VectorEpoxyModel<RoomCategoryItem.Holder>() { abstract class RoomCategoryItem : VectorEpoxyModel<RoomCategoryItem.Holder>() {
@EpoxyAttribute lateinit var title: String @EpoxyAttribute lateinit var title: String
@ -50,15 +50,16 @@ abstract class RoomCategoryItem : VectorEpoxyModel<RoomCategoryItem.Holder>() {
} }
holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted, unreadMessages, markedUnread)) holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted, unreadMessages, markedUnread))
holder.titleView.text = title holder.titleView.text = title
holder.counterView.text = itemCount.takeIf { it > 0 }?.toString().orEmpty() //holder.counterView.text = itemCount.takeIf { it > 0 }?.toString().orEmpty()
holder.counterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null) //holder.counterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null)
holder.titleView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null)
holder.rootView.onClick(listener) holder.rootView.onClick(listener)
} }
class Holder : VectorEpoxyHolder() { class Holder : VectorEpoxyHolder() {
val unreadCounterBadgeView by bind<UnreadCounterBadgeView>(R.id.roomCategoryUnreadCounterBadgeView) val unreadCounterBadgeView by bind<UnreadCounterBadgeView>(R.id.roomCategoryUnreadCounterBadgeView)
val titleView by bind<TextView>(R.id.roomCategoryTitleView) val titleView by bind<TextView>(R.id.roomCategoryTitleView)
val counterView by bind<TextView>(R.id.roomCategoryCounterView) //val counterView by bind<TextView>(R.id.roomCategoryCounterView)
val rootView by bind<ViewGroup>(R.id.roomCategoryRootView) val rootView by bind<ViewGroup>(R.id.roomCategoryRootView)
} }
} }

View file

@ -25,7 +25,7 @@ import androidx.recyclerview.widget.RecyclerView
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.epoxy.ClickListener import im.vector.app.core.epoxy.ClickListener
import im.vector.app.core.epoxy.onClick import im.vector.app.core.epoxy.onClick
import im.vector.app.databinding.ItemRoomCategoryBinding import im.vector.app.databinding.ItemRoomCategoryScBinding
import im.vector.app.features.themes.ThemeUtils import im.vector.app.features.themes.ThemeUtils
class SectionHeaderAdapter constructor( class SectionHeaderAdapter constructor(
@ -66,7 +66,7 @@ class SectionHeaderAdapter constructor(
override fun getItemId(position: Int) = roomsSectionData.hashCode().toLong() override fun getItemId(position: Int) = roomsSectionData.hashCode().toLong()
override fun getItemViewType(position: Int) = R.layout.item_room_category override fun getItemViewType(position: Int) = R.layout.item_room_category_sc
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
return VH.create(parent, onClickAction) return VH.create(parent, onClickAction)
@ -79,7 +79,7 @@ class SectionHeaderAdapter constructor(
override fun getItemCount(): Int = if (roomsSectionData.isHidden) 0 else 1 override fun getItemCount(): Int = if (roomsSectionData.isHidden) 0 else 1
class VH constructor( class VH constructor(
private val binding: ItemRoomCategoryBinding, private val binding: ItemRoomCategoryScBinding,
onClickAction: ClickListener onClickAction: ClickListener
) : RecyclerView.ViewHolder(binding.root) { ) : RecyclerView.ViewHolder(binding.root) {
@ -99,16 +99,17 @@ class SectionHeaderAdapter constructor(
null null
} }
binding.root.isClickable = roomsSectionData.isCollapsable binding.root.isClickable = roomsSectionData.isCollapsable
binding.roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, collapsableArrowDrawable, null) binding.roomCategoryTitleView.setCompoundDrawablesWithIntrinsicBounds(null, null, collapsableArrowDrawable, null)
binding.roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty() //binding.roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, collapsableArrowDrawable, null)
//binding.roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty()
binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted, roomsSectionData.unread, roomsSectionData.markedUnread)) binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted, roomsSectionData.unread, roomsSectionData.markedUnread))
} }
companion object { companion object {
fun create(parent: ViewGroup, onClickAction: ClickListener): VH { fun create(parent: ViewGroup, onClickAction: ClickListener): VH {
val view = LayoutInflater.from(parent.context) val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_room_category, parent, false) .inflate(R.layout.item_room_category_sc, parent, false)
val binding = ItemRoomCategoryBinding.bind(view) val binding = ItemRoomCategoryScBinding.bind(view)
return VH(binding, onClickAction) return VH(binding, onClickAction)
} }
} }

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/roomCategoryRootView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:colorBackground"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="8dp"
android:paddingTop="12dp"
android:paddingEnd="@dimen/layout_horizontal_margin"
android:paddingBottom="4dp">
<TextView
android:id="@+id/roomCategoryTitleView"
style="@style/Widget.Vector.TextView.Body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:textColor="?vctr_content_secondary"
android:textStyle="bold"
app:drawableTint="?vctr_content_secondary"
tools:drawableEnd="@drawable/ic_expand_more"
tools:text="@string/room_participants_header_direct_chats" />
<!--
<TextView
android:id="@+id/roomCategoryCounterView"
style="@style/Widget.Vector.TextView.Subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:drawablePadding="2dp"
android:gravity="center_vertical"
android:maxLines="1"
android:textColor="?vctr_content_secondary"
app:drawableTint="?vctr_content_secondary"
tools:drawableEnd="@drawable/ic_expand_more"
tools:text="14" />
-->
<im.vector.app.features.home.room.list.UnreadCounterBadgeView
android:id="@+id/roomCategoryUnreadCounterBadgeView"
style="@style/Widget.Vector.TextView.Micro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:minWidth="16dp"
android:minHeight="16dp"
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:textColor="?colorOnError"
tools:background="@drawable/bg_unread_highlight"
tools:text="24" />
</LinearLayout>