summaryrefslogtreecommitdiff
path: root/app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-08-31 15:43:02 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-08-31 15:43:02 +0000
commit0cd94d0821661fef3fc34b51011be95034e51a5b (patch)
treeea91f813be8bbe0e5aac506744fcfbb22ce3ad41 /app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt
parente42bfbd6a65eefd0f24677aebb74993ae56490cf (diff)
Add reader font size setting, rewrite paywall-avoidance settings copy
Font size was hardcoded at 18px in ReaderWebView's injected CSS. Added a DataStore-backed setting (Settings.readerFontSizePx, 14-28px range) with a slider in Settings, threaded through ReaderScreen/ReaderContent into wrapReaderHtml. The reload-tracking key in ReaderContent's AndroidView now includes font size alongside content, so changing it and returning to an already-open article picks up the new size without reloading on every unrelated recomposition (matches the existing comment there about avoiding scroll-position jank). Rewrote the Settings screen's paywall note -- it read as defensive throat-clearing about what the app won't do. Restated as what it's actually for: avoiding tracking, manipulation, and junk fees, with reader mode pulling up anything findable by search anyway. Regenerated the detekt baseline: ReaderContent's pre-existing LongMethod/LongParameterList/CyclomaticComplexMethod findings are keyed by exact function signature text, and adding the fontSizePx parameter changed that text, invalidating the old baseline entries. The underlying debt (a 300+ line, 9-now-10-parameter composable) predates this change and isn't what this commit is about. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018AwnALZL6bD4VBtATDVv3B
Diffstat (limited to 'app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt')
-rw-r--r--app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt b/app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt
index 31fcb02..b13fc58 100644
--- a/app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt
+++ b/app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt
@@ -22,6 +22,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
+import org.terst.feedreader.data.DEFAULT_READER_FONT_SIZE_PX
// In-memory only (process lifetime, not persisted to disk) -- scoped to "don't lose my
// place if Next/Previous takes me away and back," not to surviving an app restart. A
@@ -344,7 +345,13 @@ private fun escapeHtml(text: String): String = text
// on whatever heading Readability happened to keep in bodyContent (increasingly nothing --
// see ReaderExtractor's <header> stripping) or on the top app bar's title, which truncates
// to one line and was the only place a long title showed up before this.
-fun wrapReaderHtml(bodyContent: String, title: String? = null, publishedAt: Long? = null, imageUrl: String? = null): String {
+fun wrapReaderHtml(
+ bodyContent: String,
+ title: String? = null,
+ publishedAt: Long? = null,
+ imageUrl: String? = null,
+ fontSizePx: Int = DEFAULT_READER_FONT_SIZE_PX
+): String {
val processedBody = replaceGenericIframes(replaceYouTubeIframes(bodyContent))
// Some feeds' body HTML never embeds an image at all -- the only image they give us
// is a separate RSS media:content/enclosure field (ArticleEntity.imageUrl), which
@@ -369,7 +376,7 @@ fun wrapReaderHtml(bodyContent: String, title: String? = null, publishedAt: Long
return """
<html><head><meta name="viewport" content="width=device-width, initial-scale=1">
<style>
- body { font-family: sans-serif; font-size: 18px; line-height: 1.5; padding: 16px;
+ body { font-family: sans-serif; font-size: ${fontSizePx}px; line-height: 1.5; padding: 16px;
background-color: #121212; color: #e1e1e1; }
h1.article-title { font-size: 1.5em; line-height: 1.3; margin: 0 0 0.6em 0; }
p.article-date { font-size: 0.85em; color: #9aa0a6; margin: -0.4em 0 1em 0; }