summaryrefslogtreecommitdiff
path: root/app/src/main/java/org/terst/feedreader/data/AppDatabase.kt
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-07-22 16:26:45 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-07-22 16:26:45 +0000
commit52d7877fccd60a1dae33d877ba6aa765dc098a52 (patch)
treedd23bf9c42fd59dfb475759d8de969216e7b49e0 /app/src/main/java/org/terst/feedreader/data/AppDatabase.kt
parent2c04d2dbef2e36025a4b795291117ad208fba411 (diff)
First round of testing feedback: images, unread landing, dark, delete
- Fix OPML import status message reporting the raw pre-dedup count (144) instead of the actual unique feed count after Room's upsert collapses duplicates (108) -- cosmetic bug, the DB was already correct. - Article thumbnails: extract media:thumbnail/enclosure or the first <img> in feed content, show via Coil in the article list. - App now lands on Unread instead of the feed list; a top-bar icon gets from there to the feed list (forward nav, not back-stack pop, since Unread is now the root). - Dark color scheme by default. - Delete-feed action (with confirmation) on each feed row -- was entirely missing. Deletes its non-saved articles too, so they don't linger as orphaned rows in the cross-feed Unread view; saved articles are kept regardless. - Room migration 1->2 for the new imageUrl column (real migration, not destructive fallback, since there's now real on-device subscription data from testing). 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/AppDatabase.kt')
-rw-r--r--app/src/main/java/org/terst/feedreader/data/AppDatabase.kt17
1 files changed, 15 insertions, 2 deletions
diff --git a/app/src/main/java/org/terst/feedreader/data/AppDatabase.kt b/app/src/main/java/org/terst/feedreader/data/AppDatabase.kt
index 8579341..e2f6c1a 100644
--- a/app/src/main/java/org/terst/feedreader/data/AppDatabase.kt
+++ b/app/src/main/java/org/terst/feedreader/data/AppDatabase.kt
@@ -4,10 +4,12 @@ import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
+import androidx.sqlite.db.SupportSQLiteDatabase
+import androidx.room.migration.Migration
@Database(
entities = [FeedEntity::class, ArticleEntity::class, FilterRuleEntity::class],
- version = 1,
+ version = 2,
exportSchema = false
)
abstract class AppDatabase : RoomDatabase() {
@@ -18,12 +20,23 @@ abstract class AppDatabase : RoomDatabase() {
companion object {
@Volatile private var instance: AppDatabase? = null
+ // v2: added ArticleEntity.imageUrl (thumbnail support). Real migrations,
+ // not fallbackToDestructiveMigration, since this app already has real
+ // subscriptions/read-state on-device during active development --
+ // wiping the DB on every schema tweak would mean re-importing OPML
+ // and losing read history each time.
+ private val MIGRATION_1_2 = object : Migration(1, 2) {
+ override fun migrate(db: SupportSQLiteDatabase) {
+ db.execSQL("ALTER TABLE articles ADD COLUMN imageUrl TEXT")
+ }
+ }
+
fun get(context: Context): AppDatabase = instance ?: synchronized(this) {
instance ?: Room.databaseBuilder(
context.applicationContext,
AppDatabase::class.java,
"feedreader.db"
- ).build().also { instance = it }
+ ).addMigrations(MIGRATION_1_2).build().also { instance = it }
}
}
}