From 600674e871ced43a5b5f028e1bacf3abe7253ae6 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Tue, 3 Nov 2020 10:25:17 +0100 Subject: [PATCH] Room topic: tweak collapse behaviour some more One could argue that collapsing is only useful if we have more than 2 lines to hide. Also, @su-ex wants more lines, so let's go for 5+3. Change-Id: I5f3580171d4b1544fd8f91f1de48cea85023b60a --- .../java/im/vector/app/core/epoxy/ExpandableTextItem.kt | 8 ++++++-- .../app/features/roomprofile/RoomProfileController.kt | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) 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) } }