diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-07-22 18:26:14 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-07-22 18:26:14 +0000 |
| commit | 91edd1f5f29a3336fa9e3bd1762c70ea74e3e48d (patch) | |
| tree | 6ebe8615b61d174348a8467aa1fd7dbbfdb03a0a /app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt | |
| parent | 9da3fbcdef71e90d52045531c7c18faff02f2ff6 (diff) | |
Split save/Stash actions, follow links in-app via reader pipeline, tune scroll, fix title entities
- ReaderScreen: bookmark icon is now a purely local save (just flips isSaved,
no network) -- Stash archiving is a separate explicit action (new cloud
icon), since it's a heavier networked action the user should trigger on
purpose rather than have bundled into "save." Verified via direct DB
queries and (once I stopped misreading small screenshots) the icon
updates immediately in-session for both actions.
- New ReaderWebView.kt: shared WebView factory for the dark reader palette
and link handling, used by both ReaderScreen and the new LinkReaderScreen.
Links tapped inside an article's WebView now open in a lightweight
in-app reader (extracted via the same Readability pipeline, no DB
persistence) instead of falling through to the system browser --
recursive, so a chain of links stays in-app. Verified live: tapping a
link mid-article navigated to a real extracted page with a working back
stack.
- WebView scroll tuning: overscroll glow and scrollbars off, on both the
article reader and the new link reader -- aimed at the reported "still a
little choppy" scrolling on top of the previous reload-on-recompose fix.
- FeedParser: some feeds (kottke.org among them) double-encode titles --
the XML parser resolves outer XML escaping, but leftover HTML entities
like "“" were showing up literally in the title text. Titles are
now run through a second HTML-entity decode pass. Verified: a kottke
title that previously showed a literal “ now renders the actual
curly quote.
All changes verified live on the emulator against the real 107-feed dataset.
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.kt | 43 |
1 files changed, 43 insertions, 0 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 new file mode 100644 index 0000000..42a15f0 --- /dev/null +++ b/app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt @@ -0,0 +1,43 @@ +package org.terst.feedreader.ui + +import android.content.Context +import android.view.View +import android.webkit.WebResourceRequest +import android.webkit.WebView +import android.webkit.WebViewClient + +/** + * Shared factory for the read-only, dark-themed article WebView used by both the + * per-article ReaderScreen and LinkReaderScreen (for links tapped inside an article). + * JS is always off -- extracted/feed HTML never needs it, and this keeps articles + * from running arbitrary scripts. Link taps are intercepted rather than left to + * WebView's default behavior (handing off to the system browser) so following a + * link stays inside the app's own reader/extraction pipeline. + */ +fun newReaderWebView(context: Context, onOpenLink: (String) -> Unit): WebView = + WebView(context).apply { + settings.javaScriptEnabled = false + overScrollMode = View.OVER_SCROLL_NEVER + isVerticalScrollBarEnabled = false + isHorizontalScrollBarEnabled = false + webViewClient = object : WebViewClient() { + override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean { + onOpenLink(request.url.toString()) + return true + } + } + } + +// Hardcoded dark palette, not @media (prefers-color-scheme) -- the app itself always +// forces dark colorScheme() regardless of system setting (see MainActivity), so reader +// content should match rather than following a system light/dark the app itself ignores. +fun wrapReaderHtml(bodyContent: String): String = """ + <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; + background-color: #121212; color: #e1e1e1; } + a { color: #8ab4f8; } + img { max-width: 100%; height: auto; } + </style></head> + <body>$bodyContent</body></html> +""".trimIndent() |
