From b6279b03c074b8c71dedd5ffffb2217e8f05a577 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 20 May 2025 16:33:22 +0200 Subject: [PATCH] Make sure that files grid in chat bubble is using at most 3 columns --- .../org/linphone/ui/main/chat/model/MessageModel.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/main/chat/model/MessageModel.kt b/app/src/main/java/org/linphone/ui/main/chat/model/MessageModel.kt index d1575dc08..298d62c80 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/model/MessageModel.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/model/MessageModel.kt @@ -436,6 +436,11 @@ class MessageModel displayableContentFound = true } else { + val wrapBefore = if (exactly4Contents) { + contentIndex == 2 // To have a 2x2 grid + } else { + contentIndex % 3 == 0 // To have at most 3 columns + } if (content.isFile) { Log.d("$TAG Found file content with type [${content.type}/${content.subtype}]") contentIndex += 1 @@ -456,8 +461,6 @@ class MessageModel Log.d( "$TAG Found file ready to be displayed [$path] with MIME [${content.type}/${content.subtype}] for message [${chatMessage.messageId}]" ) - - val wrapBefore = exactly4Contents && contentIndex == 3 val fileSize = content.fileSize.toLong() val timestamp = content.creationTimestamp val fileModel = FileModel( @@ -496,7 +499,8 @@ class MessageModel timestamp, isFileEncrypted, path, - chatMessage.isEphemeral + chatMessage.isEphemeral, + flexboxLayoutWrapBefore = wrapBefore ) { model -> onContentClicked?.invoke(model) } @@ -509,7 +513,8 @@ class MessageModel isFileEncrypted, name, chatMessage.isEphemeral, - isWaitingToBeDownloaded = true + isWaitingToBeDownloaded = true, + flexboxLayoutWrapBefore = wrapBefore ) { model -> downloadContent(model, content) }