summaryrefslogtreecommitdiff
path: root/app/src/main/java/org/terst/feedreader/data/ArticleSaving.kt
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-07-24 03:28:31 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-07-24 03:28:31 +0000
commit72f76cc41ae406e00a4dd9d448e2b552f9a6baaa (patch)
tree5f23e410b2ac4f8dddf89422ab57e738b3b04b2f /app/src/main/java/org/terst/feedreader/data/ArticleSaving.kt
parentab392e2ab983a4c87e241b457c98244251b2206a (diff)
Collapsible folders, long-press link menu, YouTube thumbnails, strip more Ars sequel chrome
- Feed list: folders now collapse (start collapsed, with a per-folder unread count so collapsing doesn't hide "is there anything new") - Long-pressing a link inside an article shows an action menu (open in browser, share, save to Stash, save for later) instead of WebView's default text-selection popup -- confirmed live end to end, including the Stash/save-for-later paths creating a real standalone article - New shared ensureStandaloneArticle() helper (data/ArticleSaving.kt), factored out of ShareReceiverActivity, now also used by the long-press menu - YouTube iframe embeds become tap-to-open thumbnails (JS is off in the reader WebView, so the real player never worked anyway); tapping one goes straight to the YouTube app/browser instead of our own article-extraction pipeline - Fixed back navigation through a chain of links-within-links: each hop was stacking a new backstack entry, so back stepped through the chain one link at a time instead of returning straight to the source article. Confirmed live: A -> link -> B -> link -> C, one back-press now goes straight to A - Extended the <header> chrome-stripping from last round: also strip <footer>, an author bio card, and a "Most Read" trending-stories widget -- confirmed live one of the latter showed up as a giant unrelated photo plus an empty numbered list (its lazy-loaded items never populate in this hidden, off-screen extraction WebView) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EZ7ikw2ukGJFTHE3bJS7zL
Diffstat (limited to 'app/src/main/java/org/terst/feedreader/data/ArticleSaving.kt')
-rw-r--r--app/src/main/java/org/terst/feedreader/data/ArticleSaving.kt30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/src/main/java/org/terst/feedreader/data/ArticleSaving.kt b/app/src/main/java/org/terst/feedreader/data/ArticleSaving.kt
new file mode 100644
index 0000000..f2bcb72
--- /dev/null
+++ b/app/src/main/java/org/terst/feedreader/data/ArticleSaving.kt
@@ -0,0 +1,30 @@
+package org.terst.feedreader.data
+
+import android.content.Context
+import org.terst.feedreader.readability.ReaderExtractor
+import java.security.MessageDigest
+
+fun urlToArticleId(url: String): String =
+ MessageDigest.getInstance("SHA-256").digest(url.toByteArray()).joinToString("") { "%02x".format(it) }
+
+/**
+ * Creates (or returns the existing) standalone ArticleEntity for a bare URL not tied to any
+ * feed, extracting it fresh via Readability if it's not already on-device. Shared by every
+ * "save something without opening it in the reader first" entry point: the share-sheet
+ * target, and long-pressing a link inside an article to save/stash it directly.
+ */
+suspend fun ensureStandaloneArticle(context: Context, db: AppDatabase, url: String): ArticleEntity {
+ val id = urlToArticleId(url)
+ db.articleDao().getById(id)?.let { return it }
+ val extracted = ReaderExtractor.extract(context, url)
+ val entity = ArticleEntity(
+ id = id,
+ feedId = null,
+ title = extracted?.title ?: url,
+ link = url,
+ extractedContent = extracted?.content,
+ createdAt = System.currentTimeMillis()
+ )
+ db.articleDao().upsert(entity)
+ return entity
+}