diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesPresenter.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesPresenter.kt index 274e94617d..68383e5829 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesPresenter.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesPresenter.kt @@ -402,7 +402,7 @@ class MessagesPresenter @AssistedInject constructor( val replyToDetails = loadReplyDetails(targetEvent.eventId).map(permalinkParser) val composerMode = MessageComposerMode.Reply( replyToDetails = replyToDetails, - hideImage = timelineProtectionState.hideContent(targetEvent.eventId), + hideImage = timelineProtectionState.hideMediaContent(targetEvent.eventId), ) composerState.eventSink( MessageComposerEvents.SetMode(composerMode) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/pinned/list/PinnedMessagesListView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/pinned/list/PinnedMessagesListView.kt index b3fad87c58..6f50c057a5 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/pinned/list/PinnedMessagesListView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/pinned/list/PinnedMessagesListView.kt @@ -256,7 +256,7 @@ private fun TimelineItemEventContentViewWrapper( } else { TimelineItemEventContentView( content = event.content, - hideContent = timelineProtectionState.hideContent(event.eventId), + hideMediaContent = timelineProtectionState.hideMediaContent(event.eventId), onShowClick = { timelineProtectionState.eventSink(TimelineProtectionEvent.ShowContent(event.eventId)) }, onLinkClick = onLinkClick, eventSink = { }, diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt index 0769e451ed..07a08b3eaf 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt @@ -128,7 +128,7 @@ fun TimelineItemEventRow( eventContentView: @Composable (Modifier, (ContentAvoidingLayoutData) -> Unit) -> Unit = { contentModifier, onContentLayoutChange -> TimelineItemEventContentView( content = event.content, - hideContent = timelineProtectionState.hideContent(event.eventId), + hideMediaContent = timelineProtectionState.hideMediaContent(event.eventId), onShowClick = { timelineProtectionState.eventSink(TimelineProtectionEvent.ShowContent(event.eventId)) }, onLinkClick = onLinkClick, eventSink = eventSink, @@ -569,7 +569,7 @@ private fun MessageEventBubbleContent( .clickable(onClick = inReplyToClick) InReplyToView( inReplyTo = inReplyTo, - hideImage = timelineProtectionState.hideContent(inReplyTo.eventId()), + hideImage = timelineProtectionState.hideMediaContent(inReplyTo.eventId()), modifier = inReplyToModifier, ) } diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemGroupedEventsRow.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemGroupedEventsRow.kt index eec5adcb4e..d280efa62c 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemGroupedEventsRow.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemGroupedEventsRow.kt @@ -56,7 +56,7 @@ fun TimelineItemGroupedEventsRow( { event, contentModifier, onContentLayoutChange -> TimelineItemEventContentView( content = event.content, - hideContent = timelineProtectionState.hideContent(event.eventId), + hideMediaContent = timelineProtectionState.hideMediaContent(event.eventId), onShowClick = { timelineProtectionState.eventSink(TimelineProtectionEvent.ShowContent(event.eventId)) }, onLinkClick = onLinkClick, eventSink = eventSink, @@ -120,7 +120,7 @@ private fun TimelineItemGroupedEventsRowContent( { event, contentModifier, onContentLayoutChange -> TimelineItemEventContentView( content = event.content, - hideContent = timelineProtectionState.hideContent(event.eventId), + hideMediaContent = timelineProtectionState.hideMediaContent(event.eventId), onShowClick = { timelineProtectionState.eventSink(TimelineProtectionEvent.ShowContent(event.eventId)) }, onLinkClick = onLinkClick, eventSink = eventSink, diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemRow.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemRow.kt index 35199837cc..c7c1cb5350 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemRow.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemRow.kt @@ -59,7 +59,7 @@ internal fun TimelineItemRow( { event, contentModifier, onContentLayoutChange -> TimelineItemEventContentView( content = event.content, - hideContent = timelineProtectionState.hideContent(event.eventId), + hideMediaContent = timelineProtectionState.hideMediaContent(event.eventId), onShowClick = { timelineProtectionState.eventSink(TimelineProtectionEvent.ShowContent(event.eventId)) }, onLinkClick = onLinkClick, eventSink = eventSink, @@ -118,7 +118,7 @@ internal fun TimelineItemRow( timelineProtectionState = timelineProtectionState, isLastOutgoingMessage = isLastOutgoingMessage, isHighlighted = timelineItem.isEvent(focusedEventId), - onClick = if (timelineProtectionState.hideContent(timelineItem.eventId) && timelineItem.mustBeProtected()) { + onClick = if (timelineProtectionState.hideMediaContent(timelineItem.eventId) && timelineItem.mustBeProtected()) { {} } else { { onClick(timelineItem) } diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemStateEventRow.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemStateEventRow.kt index 2e3812a09d..f023a63c35 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemStateEventRow.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemStateEventRow.kt @@ -71,7 +71,7 @@ fun TimelineItemStateEventRow( TimelineItemEventContentView( content = event.content, onLinkClick = {}, - hideContent = false, + hideMediaContent = false, onShowClick = {}, eventSink = eventSink, modifier = Modifier.defaultTimelineContentPadding() diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEventContentView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEventContentView.kt index c855714d14..b24a5ca0be 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEventContentView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEventContentView.kt @@ -35,7 +35,7 @@ import io.element.android.libraries.architecture.Presenter @Composable fun TimelineItemEventContentView( content: TimelineItemEventContent, - hideContent: Boolean, + hideMediaContent: Boolean, onShowClick: () -> Unit, onLinkClick: (url: String) -> Unit, eventSink: (TimelineEvents.EventFromTimelineItem) -> Unit, @@ -71,20 +71,20 @@ fun TimelineItemEventContentView( ) is TimelineItemImageContent -> TimelineItemImageView( content = content, - hideContent = hideContent, + hideMediaContent = hideMediaContent, onShowClick = onShowClick, onContentLayoutChange = onContentLayoutChange, modifier = modifier, ) is TimelineItemStickerContent -> TimelineItemStickerView( content = content, - hideContent = hideContent, + hideMediaContent = hideMediaContent, onShowClick = onShowClick, modifier = modifier, ) is TimelineItemVideoContent -> TimelineItemVideoView( content = content, - hideContent = hideContent, + hideMediaContent = hideMediaContent, onShowClick = onShowClick, onContentLayoutChange = onContentLayoutChange, modifier = modifier diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemImageView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemImageView.kt index e7cacede9e..85b2b7f678 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemImageView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemImageView.kt @@ -59,7 +59,7 @@ import io.element.android.wysiwyg.compose.EditorStyledText @Composable fun TimelineItemImageView( content: TimelineItemImageContent, - hideContent: Boolean, + hideMediaContent: Boolean, onShowClick: () -> Unit, onContentLayoutChange: (ContentAvoidingLayoutData) -> Unit, modifier: Modifier = Modifier, @@ -80,7 +80,7 @@ fun TimelineItemImageView( aspectRatio = content.aspectRatio, ) { ProtectedView( - hideContent = hideContent, + hideContent = hideMediaContent, onShowClick = onShowClick, ) { var isLoaded by remember { mutableStateOf(false) } @@ -133,7 +133,7 @@ fun TimelineItemImageView( internal fun TimelineItemImageViewPreview(@PreviewParameter(TimelineItemImageContentProvider::class) content: TimelineItemImageContent) = ElementPreview { TimelineItemImageView( content = content, - hideContent = false, + hideMediaContent = false, onShowClick = {}, onContentLayoutChange = {}, ) @@ -141,10 +141,10 @@ internal fun TimelineItemImageViewPreview(@PreviewParameter(TimelineItemImageCon @PreviewsDayNight @Composable -internal fun TimelineItemImageViewHideContentPreview() = ElementPreview { +internal fun TimelineItemImageViewHideMediaContentPreview() = ElementPreview { TimelineItemImageView( content = aTimelineItemImageContent(), - hideContent = true, + hideMediaContent = true, onShowClick = {}, onContentLayoutChange = {}, ) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemStickerView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemStickerView.kt index d41b985d86..cef5acd1dd 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemStickerView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemStickerView.kt @@ -39,7 +39,7 @@ private const val STICKER_SIZE_IN_DP = 128 @Composable fun TimelineItemStickerView( content: TimelineItemStickerContent, - hideContent: Boolean, + hideMediaContent: Boolean, onShowClick: () -> Unit, modifier: Modifier = Modifier, ) { @@ -54,7 +54,7 @@ fun TimelineItemStickerView( maxHeight = STICKER_SIZE_IN_DP, ) { ProtectedView( - hideContent = hideContent, + hideContent = hideMediaContent, onShowClick = onShowClick, ) { var isLoaded by remember { mutableStateOf(false) } @@ -84,7 +84,7 @@ fun TimelineItemStickerView( internal fun TimelineItemStickerViewPreview(@PreviewParameter(TimelineItemStickerContentProvider::class) content: TimelineItemStickerContent) = ElementPreview { TimelineItemStickerView( content = content, - hideContent = false, + hideMediaContent = false, onShowClick = {}, ) } diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemVideoView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemVideoView.kt index 9c28172c2e..7815e02610 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemVideoView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemVideoView.kt @@ -65,7 +65,7 @@ import io.element.android.wysiwyg.compose.EditorStyledText @Composable fun TimelineItemVideoView( content: TimelineItemVideoContent, - hideContent: Boolean, + hideMediaContent: Boolean, onShowClick: () -> Unit, onContentLayoutChange: (ContentAvoidingLayoutData) -> Unit, modifier: Modifier = Modifier, @@ -87,7 +87,7 @@ fun TimelineItemVideoView( contentAlignment = Alignment.Center, ) { ProtectedView( - hideContent = hideContent, + hideContent = hideMediaContent, onShowClick = onShowClick, ) { var isLoaded by remember { mutableStateOf(false) } @@ -151,7 +151,7 @@ fun TimelineItemVideoView( internal fun TimelineItemVideoViewPreview(@PreviewParameter(TimelineItemVideoContentProvider::class) content: TimelineItemVideoContent) = ElementPreview { TimelineItemVideoView( content = content, - hideContent = false, + hideMediaContent = false, onShowClick = {}, onContentLayoutChange = {}, ) @@ -159,10 +159,10 @@ internal fun TimelineItemVideoViewPreview(@PreviewParameter(TimelineItemVideoCon @PreviewsDayNight @Composable -internal fun TimelineItemVideoViewHideContentPreview() = ElementPreview { +internal fun TimelineItemVideoViewHideMediaContentPreview() = ElementPreview { TimelineItemVideoView( content = aTimelineItemVideoContent(), - hideContent = true, + hideMediaContent = true, onShowClick = {}, onContentLayoutChange = {}, ) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionPresenter.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionPresenter.kt index 46ac375aa4..5d83347e67 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionPresenter.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionPresenter.kt @@ -25,11 +25,11 @@ class TimelineProtectionPresenter @Inject constructor( ) : Presenter { @Composable override fun present(): TimelineProtectionState { - val hideContent by appPreferencesStore.doesHideImagesAndVideosFlow().collectAsState(initial = false) + val hideMediaContent by appPreferencesStore.doesHideImagesAndVideosFlow().collectAsState(initial = false) var allowedEvents by remember { mutableStateOf>(setOf()) } - val protectionState by remember(hideContent) { + val protectionState by remember(hideMediaContent) { derivedStateOf { - if (hideContent) { + if (hideMediaContent) { ProtectionState.RenderOnly(eventIds = allowedEvents.toImmutableSet()) } else { ProtectionState.RenderAll diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionState.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionState.kt index 66ebb279f5..af1f26127c 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionState.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionState.kt @@ -15,7 +15,7 @@ data class TimelineProtectionState( val protectionState: ProtectionState, val eventSink: (TimelineProtectionEvent) -> Unit, ) { - fun hideContent(eventId: EventId?) = when (protectionState) { + fun hideMediaContent(eventId: EventId?) = when (protectionState) { is ProtectionState.RenderAll -> false is ProtectionState.RenderOnly -> eventId !in protectionState.eventIds } diff --git a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionStateTest.kt b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionStateTest.kt index cc42b4fd9b..81187eb6d4 100644 --- a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionStateTest.kt +++ b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionStateTest.kt @@ -15,30 +15,30 @@ import org.junit.Test class TimelineProtectionStateTest { @Test - fun `when protectionState is RenderAll, hideContent always return null`() { + fun `when protectionState is RenderAll, hideMediaContent always return null`() { val sut = aTimelineProtectionState( protectionState = ProtectionState.RenderAll ) - assertThat(sut.hideContent(null)).isFalse() - assertThat(sut.hideContent(AN_EVENT_ID)).isFalse() + assertThat(sut.hideMediaContent(null)).isFalse() + assertThat(sut.hideMediaContent(AN_EVENT_ID)).isFalse() } @Test - fun `when protectionState is RenderOnly with empty set, hideContent always return true`() { + fun `when protectionState is RenderOnly with empty set, hideMediaContent always return true`() { val sut = aTimelineProtectionState( protectionState = ProtectionState.RenderOnly(persistentSetOf()) ) - assertThat(sut.hideContent(null)).isTrue() - assertThat(sut.hideContent(AN_EVENT_ID)).isTrue() + assertThat(sut.hideMediaContent(null)).isTrue() + assertThat(sut.hideMediaContent(AN_EVENT_ID)).isTrue() } @Test - fun `when protectionState is RenderOnly with an Event, hideContent can return true or false`() { + fun `when protectionState is RenderOnly with an Event, hideMediaContent can return true or false`() { val sut = aTimelineProtectionState( protectionState = ProtectionState.RenderOnly(persistentSetOf(AN_EVENT_ID)) ) - assertThat(sut.hideContent(null)).isTrue() - assertThat(sut.hideContent(AN_EVENT_ID)).isFalse() - assertThat(sut.hideContent(AN_EVENT_ID_2)).isTrue() + assertThat(sut.hideMediaContent(null)).isTrue() + assertThat(sut.hideMediaContent(AN_EVENT_ID)).isFalse() + assertThat(sut.hideMediaContent(AN_EVENT_ID_2)).isTrue() } } diff --git a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt index 1776b070d4..ac3474e7f9 100644 --- a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt +++ b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt @@ -118,8 +118,8 @@ class KonsistPreviewTest { "TimelineItemEventRowWithReplyPreview", "TimelineItemGroupedEventsRowContentCollapsePreview", "TimelineItemGroupedEventsRowContentExpandedPreview", - "TimelineItemImageViewHideContentPreview", - "TimelineItemVideoViewHideContentPreview", + "TimelineItemImageViewHideMediaContentPreview", + "TimelineItemVideoViewHideMediaContentPreview", "TimelineItemVoiceViewUnifiedPreview", "TimelineVideoWithCaptionRowPreview", "TimelineViewMessageShieldPreview",