Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,23 @@ internal fun ConversationMessageBubble(

when (layout.bubbleLayoutMode) {
ConversationMessageBubbleLayoutMode.AttachmentOnlyWithoutSurface -> {
ConversationMessageAttachmentOnlyBubble(
ConversationMessageAttachmentOnlyContainer(
modifier = bubbleModifier,
layout = layout,
bubbleShape = layout.bubbleShape,
message = message,
isSelected = isSelected,
isSelectionMode = isSelectionMode,
onAttachmentClick = onAttachmentClick,
onExternalUriClick = onExternalUriClick,
onMessageLongClick = onMessageLongClick,
)
) {
ConversationMessageAttachmentBubbleContent(
modifier = Modifier.fillMaxWidth(),
layout = layout,
message = message,
isSelected = isSelected,
isSelectionMode = isSelectionMode,
onAttachmentClick = onAttachmentClick,
onExternalUriClick = onExternalUriClick,
onMessageLongClick = onMessageLongClick,
)
}
}

ConversationMessageBubbleLayoutMode.AttachmentsInSurface -> {
Expand Down Expand Up @@ -105,36 +112,6 @@ internal fun ConversationMessageBubble(
}
}

@Composable
private fun ConversationMessageAttachmentOnlyBubble(
modifier: Modifier,
layout: ConversationMessageLayout,
message: ConversationMessageUiModel,
isSelected: Boolean,
isSelectionMode: Boolean,
onAttachmentClick: (contentType: String, contentUri: String) -> Unit,
onExternalUriClick: (String) -> Unit,
onMessageLongClick: () -> Unit,
) {
ConversationMessageAttachmentOnlyContainer(
modifier = modifier,
bubbleShape = layout.bubbleShape,
message = message,
isSelected = isSelected,
) {
ConversationMessageAttachmentBubbleContent(
modifier = Modifier.fillMaxWidth(),
layout = layout,
message = message,
isSelected = isSelected,
isSelectionMode = isSelectionMode,
onAttachmentClick = onAttachmentClick,
onExternalUriClick = onExternalUriClick,
onMessageLongClick = onMessageLongClick,
)
}
}

@Composable
private fun ConversationMessageAttachmentSurfaceBubble(
modifier: Modifier,
Expand Down Expand Up @@ -292,6 +269,8 @@ private fun ConversationMessageTextBubbleContent(

when {
message.mmsDownload != null -> {
ConversationMessageSubject(subjectText = layout.content.subjectText)

ConversationMmsDownloadBody(
download = message.mmsDownload,
canDownloadMessage = message.canDownloadMessage,
Expand Down Expand Up @@ -351,18 +330,15 @@ private fun ConversationMessageAttachmentBubbleContent(
showSender = layout.showSender,
)

content.subjectText?.let { subjectText ->
Text(
modifier = Modifier.padding(
start = MESSAGE_BUBBLE_MEDIA_TEXT_PADDING,
top = conversationMessageSubjectTopPadding(showSender = layout.showSender),
end = MESSAGE_BUBBLE_MEDIA_TEXT_PADDING,
bottom = MESSAGE_BUBBLE_MEDIA_SECTION_SPACING,
),
text = subjectText,
style = MaterialTheme.typography.titleSmall,
)
}
ConversationMessageSubject(
modifier = Modifier.padding(
start = MESSAGE_BUBBLE_MEDIA_TEXT_PADDING,
top = conversationMessageSubjectTopPadding(showSender = layout.showSender),
end = MESSAGE_BUBBLE_MEDIA_TEXT_PADDING,
bottom = MESSAGE_BUBBLE_MEDIA_SECTION_SPACING,
),
subjectText = content.subjectText,
)

ConversationMessageAttachments(
attachmentSections = content.attachmentSections,
Expand Down Expand Up @@ -418,12 +394,7 @@ private fun ConversationMessageBody(
onExternalUriClick: (String) -> Unit,
onMessageLongClick: () -> Unit,
) {
content.subjectText?.let { subjectText ->
Text(
text = subjectText,
style = MaterialTheme.typography.titleSmall,
)
}
ConversationMessageSubject(subjectText = content.subjectText)

ConversationMessageAttachments(
attachmentSections = content.attachmentSections,
Expand All @@ -447,6 +418,22 @@ private fun ConversationMessageBody(
}
}

@Composable
private fun ConversationMessageSubject(
subjectText: String?,
modifier: Modifier = Modifier,
) {
if (subjectText.isNullOrBlank()) {
return
}
Comment on lines +421 to +428

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subjectText could also be blank too; https://github.com/GrapheneOS/Messaging/blob/main/src/com/android/messaging/sms/MmsSubjectSanitizer.kt doesn't clean blanks (it probably should)


Text(
modifier = modifier,
text = subjectText,
style = MaterialTheme.typography.titleSmall,
)
}

@Composable
private fun ConversationMessageSender(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -592,6 +579,8 @@ private fun ConversationMessageBubbleMmsDownloadPreview() {
mmsDownload = previewMmsDownloadUiModel(state = item.downloadState),
protocol = ConversationMessageUiModel.Protocol.MMS_PUSH_NOTIFICATION,
canDownloadMessage = item.canDownloadMessage,
).copy(
mmsSubject = "Weekend photos",
),
bubbleLayoutMode = ConversationMessageBubbleLayoutMode.TextInSurface,
isSelected = item.isSelected,
Expand Down