diff --git a/vector/src/main/java/im/vector/app/core/epoxy/ExpandableTextItem.kt b/vector/src/main/java/im/vector/app/core/epoxy/ExpandableTextItem.kt index 39486423c4..a7ca834bdc 100644 --- a/vector/src/main/java/im/vector/app/core/epoxy/ExpandableTextItem.kt +++ b/vector/src/main/java/im/vector/app/core/epoxy/ExpandableTextItem.kt @@ -36,6 +36,10 @@ abstract class ExpandableTextItem : VectorEpoxyModel( @EpoxyAttribute var maxLines: Int = 3 + // Number of hidden lines that justify collapsing + @EpoxyAttribute + var minCollapsedLines: Int = 2 + private var isExpanded = false private var expandedLines = 0 @@ -47,7 +51,7 @@ abstract class ExpandableTextItem : VectorEpoxyModel( holder.content.doOnPreDraw { // Allow for displaying maxLines + 1 lines: in this case, the expand button // would reserve just as much space as the expaned text - if (holder.content.lineCount > maxLines + 1) { + if (holder.content.lineCount > maxLines + minCollapsedLines) { expandedLines = holder.content.lineCount holder.content.maxLines = maxLines @@ -61,7 +65,7 @@ abstract class ExpandableTextItem : VectorEpoxyModel( holder.arrow.isVisible = true } else { holder.arrow.isVisible = false - holder.content.maxLines = maxLines + 1 + holder.content.maxLines = maxLines + minCollapsedLines } } } diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileController.kt b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileController.kt index 987f063530..0b536c3a2a 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileController.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileController.kt @@ -68,7 +68,8 @@ class RoomProfileController @Inject constructor( expandableTextItem { id("topic") content(it) - maxLines(3) + maxLines(5) + minCollapsedLines(3) } }