Skip to content

add low-bandwidth mode#2111

Merged
dessalines merged 14 commits intoLemmyNet:mainfrom
KiaraGrouwstra:feat/low-bandwidth-mode
Apr 22, 2026
Merged

add low-bandwidth mode#2111
dessalines merged 14 commits intoLemmyNet:mainfrom
KiaraGrouwstra:feat/low-bandwidth-mode

Conversation

@KiaraGrouwstra
Copy link
Copy Markdown
Contributor

@KiaraGrouwstra KiaraGrouwstra commented Apr 10, 2026

closes #1594.

disclaimer i used a coding agent in the creation of this patch.

Adds a "Low bandwidth mode on metered connections" toggle in Look
and Feel. When enabled and the device is on a metered connection,
images and videos are not loaded in post listings.
Image and video posts in card view now show a tappable outlined
card with an icon where the expanded media would normally appear.
Tapping opens the media viewer; long-pressing shows the link popup.
The post detail screen uses SmallCard mode with expandedImage=false,
which skipped the placeholder. Now sets expandedImage=true when both
fullBody and lowBandwidthMode are active so the placeholder renders.
Low bandwidth mode now also activates when Android's system-wide
Data Saver is enabled and the app isn't whitelisted, even if the
user setting is off. Still gated on a metered connection.
Adds a LocalLowBandwidthMode CompositionLocal and a second
markwon instance without ClickableCoilImagesPlugin. Inline
markdown images (comments, post bodies, private messages, etc.)
render as their alt text instead of being fetched.
The alternate markwon parser still went through the default image
visitor for markdown ![alt](url) syntax, so images kept loading.
Preprocess the markdown source in low bandwidth mode to rewrite
both markdown image syntax and HTML img tags as plain links.
Comment thread app/src/main/java/com/jerboa/ui/components/post/PostListing.kt Outdated
Comment thread app/src/main/java/com/jerboa/Utils.kt
Comment thread app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt Outdated
@MV-GH
Copy link
Copy Markdown
Collaborator

MV-GH commented Apr 10, 2026

run the formatter

If I understand correctly, the "low bandwith mode" just disables the images and videos?

If so can you add a disable image setting and low band with mode. the low band mode then disables the images and video setting when enabled.

Then use those settings to disable the features. For video it should already be there.

Also remove the CompositionLocalProvider Dessalines prefers prop drilling instead, all though to reach that markwon stuff might not be easy

Also i think it would be better if setting was like this

  • "auto" -> when connected to metered network enable it (like now)
  • "enabled"
  • "disabled"

Signed-off-by: cinereal <cinereal@riseup.net>
Comment thread app/src/main/java/com/jerboa/ui/components/common/MarkdownHelper.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/community/CommunityScreen.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/home/BottomNavScreen.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/post/PostListing.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/post/PostListingCard.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/post/PostListingCard.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/post/PostListingList.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/post/PostScreen.kt Outdated
Comment thread app/src/main/java/com/jerboa/MainActivity.kt
Comment thread app/src/main/java/com/jerboa/MainActivity.kt Outdated
Previously the SmallCard call site used
`expandedImage = fullBody && lowBandwidthMode` as an indirect way to
force the low-bandwidth media placeholder in the post detail view,
which conflated two unrelated concepts. PostTitleBlock now takes
fullBody explicitly and the placeholder branch checks
`expandedImage || fullBody`, letting the SmallCard caller revert to
`expandedImage = false`.
Extract the shared link/thumbnail rendering into a private ThumbnailBox
helper so the low bandwidth path can reuse the same placeholder the
normal path already falls back to when a thumbnail is absent. This
drops the added mid-function `return` in favor of an if/else.
Replace the isVideo boolean parameter of PostTitleAndMediaPlaceholder
with a PostLinkType directly, and swap the hard-coded 48.dp icon size
for the existing LINK_ICON_SIZE constant.
Replace the regex-based stripInlineImages preprocessing with a small
markwon plugin (LinkOnlyImagesPlugin) that installs a SpanFactory
returning a URLSpan for commonmark Image nodes. Collapse the two
markwon parser fields into one and pick the image plugin at init
time based on lowBandwidthMode.

Drop the LocalLowBandwidthMode CompositionLocal: MainActivity already
computes the effective mode, and now passes it directly to
MarkdownHelper.init and to BottomNavScreen so components just receive
the boolean instead of recomputing it themselves or reading it from
a CompositionLocal.
Introduces a LowBandwidthMode enum (Auto, Always, Never) to replace
the previous boolean. Auto activates on metered connections or when
Data Saver is enabled; the other states are unconditional. The LookAndFeel
screen now exposes this as a dropdown, matching reviewer feedback on
the PR.
Copy link
Copy Markdown
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

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

LGTM, great job!

After @MV-GH has a look, we can merge then do another release.

val loader = context.imageLoader
// main markdown parser has coil + html on
val imagesPlugin = if (lowBandwidthMode) {
// Render `![alt](url)` as a plain clickable link — no network load.
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.

👍

shape = MaterialTheme.shapes.large,
@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun ThumbnailBox(
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.

LGTM

@dessalines dessalines requested a review from MV-GH April 14, 2026 14:27
@MV-GH
Copy link
Copy Markdown
Collaborator

MV-GH commented Apr 14, 2026

I'll review it this weekend

@MV-GH
Copy link
Copy Markdown
Collaborator

MV-GH commented Apr 18, 2026

Add an icon (preferable the data saver icon) to the setting and add it below the last other enum setting

around here
image

@MV-GH
Copy link
Copy Markdown
Collaborator

MV-GH commented Apr 18, 2026

Also the feature doesn't hide avatars/logos

isn't that like the biggest consumption? scrolling through the comments you will download far more images than going through the feed?

Signed-off-by: cinereal <cinereal@riseup.net>
Signed-off-by: cinereal <cinereal@riseup.net>
Copy link
Copy Markdown
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

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

Nice, LGTM. Thx!

@MV-GH
Copy link
Copy Markdown
Collaborator

MV-GH commented Apr 22, 2026

These still show but imo they don't need be hidden, just FYI (community and person profile)

afbeelding afbeelding

@dessalines dessalines merged commit 3e03bdc into LemmyNet:main Apr 22, 2026
1 check passed
@KiaraGrouwstra KiaraGrouwstra deleted the feat/low-bandwidth-mode branch April 23, 2026 05:36
@KiaraGrouwstra KiaraGrouwstra mentioned this pull request Apr 23, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add low-bandwidth mode

3 participants