Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add developer setting to hide images in the timeline #3592

Merged
merged 17 commits into from
Oct 4, 2024

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Oct 3, 2024

Content

Add a switch to the developer settings screen to prevent preview of images, videos and sticker to be rendered automatically in the timeline.
When enabled:

  • the blurhash (if available) will be rendered by default, or a color surface will be rendered.
  • A button exist to render the image
  • The image is not clickable, it must be rendered first
  • The thumbnail (for replyied image) is not rendered, expect if the original image has been rendered.
  • The image does not render in the notification

Motivation and context

Closes #3386

Screenshots / GIFs

Waiting for the final design before recording the screenshot.

Tests

  • Navigate to the developer setting to enable the new option
  • Go to a room and observe that the images are not rendered automatically

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

@bmarty bmarty added the PR-Feature For a new feature label Oct 3, 2024
@bmarty bmarty changed the title Hide images in the timeline Add developer setting to hide images in the timeline Oct 3, 2024
Copy link
Contributor

github-actions bot commented Oct 3, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/qVBAbQ

@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Oct 3, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Oct 3, 2024
@bmarty bmarty marked this pull request as ready for review October 3, 2024 16:55
@bmarty bmarty requested a review from a team as a code owner October 3, 2024 16:55
@bmarty bmarty requested review from jmartinesp and removed request for a team October 3, 2024 16:55
Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

LGTM once Konsist tests pass, I added a couple of suggestions too.

By the way, this feature seems more like something that would fit in the advanced settings since some users may want this as the default instead. I saw it was decided to add it in developer settings instead, but maybe we'll iterate on that in the future?

timelineController.invokeOnCurrentTimeline {
val replyToDetails = loadReplyDetails(draftType.eventId).map(permalinkParser)
run { messageComposerContext.composerMode = MessageComposerMode.Reply(replyToDetails) }
run {
Copy link
Member

Choose a reason for hiding this comment

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

Is this run needed?

Copy link
Member Author

@bmarty bmarty Oct 4, 2024

Choose a reason for hiding this comment

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

Was needed, but not anymore with 6ee0dd3.

@@ -35,6 +35,8 @@ import io.element.android.libraries.architecture.Presenter
@Composable
fun TimelineItemEventContentView(
content: TimelineItemEventContent,
hideContent: Boolean,
Copy link
Member

Choose a reason for hiding this comment

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

hideMediaContent?

Copy link
Member Author

@bmarty bmarty Oct 4, 2024

Choose a reason for hiding this comment

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

Better, yes: 0bb2fee.

) : Presenter<TimelineProtectionState> {
@Composable
override fun present(): TimelineProtectionState {
val hideContent by appPreferencesStore.doesHideImagesAndVideosFlow().collectAsState(initial = false)
Copy link
Member

Choose a reason for hiding this comment

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

hideMediaContent?

Copy link
Member Author

@bmarty bmarty Oct 4, 2024

Choose a reason for hiding this comment

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

Better, yes: 0bb2fee.

@Composable
override fun present(): TimelineProtectionState {
val hideContent by appPreferencesStore.doesHideImagesAndVideosFlow().collectAsState(initial = false)
var allowedEvents by remember { mutableStateOf<Set<EventId>>(setOf()) }
Copy link
Member

Choose a reason for hiding this comment

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

Should this be an immutable Set? I'm not sure if it might affect recompositions in any way, probably not.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is simpler to leave it like that.

@@ -72,6 +74,7 @@ import kotlinx.coroutines.launch
@Composable
fun TimelineView(
state: TimelineState,
timelineProtectionState: TimelineProtectionState,
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this could be used as a CompositionLocalProvider? This way we don't have it to explicitly pass it around through so many classes and functions, but it's ok as it is too.

Copy link
Member

Choose a reason for hiding this comment

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

Add it to TimelineRoomInfo as it's already passed everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not easy at the state is computed in MessagesPresenter as I need the state for the MessageComposer. I may revisit this later.

@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Oct 4, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Oct 4, 2024
@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Oct 4, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Oct 4, 2024
Copy link

sonarcloud bot commented Oct 4, 2024

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 4, 2024
@bmarty bmarty enabled auto-merge October 4, 2024 15:26
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 4, 2024
Copy link

codecov bot commented Oct 4, 2024

Codecov Report

Attention: Patch coverage is 84.07643% with 50 lines in your changes missing coverage. Please review.

Project coverage is 82.67%. Comparing base (98d9abe) to head (1f7b05a).
Report is 18 commits behind head on develop.

Files with missing lines Patch % Lines
.../messages/impl/timeline/protection/TimelineItem.kt 0.00% 22 Missing and 1 partial ⚠️
...imeline/components/TimelineItemGroupedEventsRow.kt 33.33% 4 Missing ⚠️
...eferences/impl/store/DefaultAppPreferencesStore.kt 0.00% 4 Missing ⚠️
...pl/notifications/DefaultNotifiableEventResolver.kt 66.66% 1 Missing and 3 partials ⚠️
...ries/matrix/ui/messages/reply/InReplyToMetadata.kt 40.00% 0 Missing and 3 partials ⚠️
...ssages/impl/timeline/components/TimelineItemRow.kt 71.42% 1 Missing and 1 partial ⚠️
...e/components/event/TimelineItemEventContentView.kt 66.66% 2 Missing ⚠️
...meline/components/event/TimelineItemStickerView.kt 92.59% 0 Missing and 2 partials ⚠️
...l/timeline/components/TimelineItemStateEventRow.kt 50.00% 1 Missing ⚠️
...timeline/components/event/TimelineItemImageView.kt 94.44% 0 Missing and 1 partial ⚠️
... and 4 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3592      +/-   ##
===========================================
- Coverage    82.68%   82.67%   -0.02%     
===========================================
  Files         1731     1737       +6     
  Lines        41014    41214     +200     
  Branches      4973     5003      +30     
===========================================
+ Hits         33912    34073     +161     
- Misses        5342     5372      +30     
- Partials      1760     1769       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bmarty bmarty merged commit 779c6db into develop Oct 4, 2024
30 checks passed
@bmarty bmarty deleted the feature/bma/hideImages branch October 4, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Feature For a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add user controls for whether to display media (including thumbnails)
4 participants