Ensure that room with long names renders correctly in the room list.
This commit is contained in:
parent
4256043338
commit
4ba465fd04
2 changed files with 6 additions and 3 deletions
|
|
@ -46,6 +46,7 @@ import io.element.android.features.home.impl.model.RoomListRoomSummaryProvider
|
||||||
import io.element.android.features.home.impl.model.RoomSummaryDisplayType
|
import io.element.android.features.home.impl.model.RoomSummaryDisplayType
|
||||||
import io.element.android.features.home.impl.roomlist.RoomListEvents
|
import io.element.android.features.home.impl.roomlist.RoomListEvents
|
||||||
import io.element.android.libraries.core.extensions.orEmpty
|
import io.element.android.libraries.core.extensions.orEmpty
|
||||||
|
import io.element.android.libraries.core.extensions.toSafeLength
|
||||||
import io.element.android.libraries.designsystem.atomic.atoms.UnreadIndicatorAtom
|
import io.element.android.libraries.designsystem.atomic.atoms.UnreadIndicatorAtom
|
||||||
import io.element.android.libraries.designsystem.atomic.molecules.InviteButtonsRowMolecule
|
import io.element.android.libraries.designsystem.atomic.molecules.InviteButtonsRowMolecule
|
||||||
import io.element.android.libraries.designsystem.components.avatar.Avatar
|
import io.element.android.libraries.designsystem.components.avatar.Avatar
|
||||||
|
|
@ -227,7 +228,7 @@ private fun NameAndTimestampRow(
|
||||||
// Name
|
// Name
|
||||||
Text(
|
Text(
|
||||||
style = ElementTheme.typography.fontBodyLgMedium,
|
style = ElementTheme.typography.fontBodyLgMedium,
|
||||||
text = name ?: stringResource(id = CommonStrings.common_no_room_name),
|
text = name?.toSafeLength(ellipsize = true) ?: stringResource(id = CommonStrings.common_no_room_name),
|
||||||
fontStyle = FontStyle.Italic.takeIf { name == null },
|
fontStyle = FontStyle.Italic.takeIf { name == null },
|
||||||
color = ElementTheme.colors.roomListRoomName,
|
color = ElementTheme.colors.roomListRoomName,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
|
|
@ -380,7 +381,7 @@ private fun InviteNameAndIndicatorRow(
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
style = ElementTheme.typography.fontBodyLgMedium,
|
style = ElementTheme.typography.fontBodyLgMedium,
|
||||||
text = name ?: stringResource(id = CommonStrings.common_no_room_name),
|
text = name?.toSafeLength(ellipsize = true) ?: stringResource(id = CommonStrings.common_no_room_name),
|
||||||
fontStyle = FontStyle.Italic.takeIf { name == null },
|
fontStyle = FontStyle.Italic.takeIf { name == null },
|
||||||
color = ElementTheme.colors.roomListRoomName,
|
color = ElementTheme.colors.roomListRoomName,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,8 @@ fun String.containsRtLOverride() = contains(RTL_OVERRIDE_CHAR)
|
||||||
|
|
||||||
fun String.filterDirectionOverrides() = filterNot { it == RTL_OVERRIDE_CHAR || it == LTR_OVERRIDE_CHAR }
|
fun String.filterDirectionOverrides() = filterNot { it == RTL_OVERRIDE_CHAR || it == LTR_OVERRIDE_CHAR }
|
||||||
|
|
||||||
|
const val DEFAULT_SAFE_LENGTH = 500
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This works around https://github.com/element-hq/element-x-android/issues/2105.
|
* This works around https://github.com/element-hq/element-x-android/issues/2105.
|
||||||
* @param maxLength Max characters to retrieve. Defaults to `500`.
|
* @param maxLength Max characters to retrieve. Defaults to `500`.
|
||||||
|
|
@ -107,7 +109,7 @@ fun String.filterDirectionOverrides() = filterNot { it == RTL_OVERRIDE_CHAR || i
|
||||||
* @return The string truncated to [maxLength] characters, with an optional ellipsis if larger.
|
* @return The string truncated to [maxLength] characters, with an optional ellipsis if larger.
|
||||||
*/
|
*/
|
||||||
fun String.toSafeLength(
|
fun String.toSafeLength(
|
||||||
maxLength: Int = 500,
|
maxLength: Int = DEFAULT_SAFE_LENGTH,
|
||||||
ellipsize: Boolean = false,
|
ellipsize: Boolean = false,
|
||||||
): String {
|
): String {
|
||||||
return if (ellipsize) {
|
return if (ellipsize) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue