diff --git a/app/schemas/com.muedsa.tvbox.room.AppDatabase/2.json b/app/schemas/com.muedsa.tvbox.room.AppDatabase/2.json new file mode 100644 index 0000000..b846957 --- /dev/null +++ b/app/schemas/com.muedsa.tvbox.room.AppDatabase/2.json @@ -0,0 +1,156 @@ +{ + "formatVersion": 1, + "database": { + "version": 2, + "identityHash": "9962e622da90216c9c87bb7fdc2d98c2", + "entities": [ + { + "tableName": "favorite_media", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`plugin_package` TEXT NOT NULL, `media_id` TEXT NOT NULL, `media_title` TEXT NOT NULL, `media_detail_url` TEXT NOT NULL, `media_sub_title` TEXT DEFAULT NULL, `cover_image_url` TEXT NOT NULL, `card_width` INTEGER NOT NULL, `card_height` INTEGER NOT NULL, `update_at` INTEGER NOT NULL DEFAULT (CURRENT_TIMESTAMP), PRIMARY KEY(`plugin_package`, `media_id`))", + "fields": [ + { + "fieldPath": "pluginPackage", + "columnName": "plugin_package", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "mediaId", + "columnName": "media_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "mediaTitle", + "columnName": "media_title", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "mediaDetailUrl", + "columnName": "media_detail_url", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "mediaSubTitle", + "columnName": "media_sub_title", + "affinity": "TEXT", + "defaultValue": "NULL" + }, + { + "fieldPath": "coverImageUrl", + "columnName": "cover_image_url", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "cardWidth", + "columnName": "card_width", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "cardHeight", + "columnName": "card_height", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateAt", + "columnName": "update_at", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "(CURRENT_TIMESTAMP)" + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "plugin_package", + "media_id" + ] + }, + "indices": [ + { + "name": "index_favorite_media_update_at", + "unique": false, + "columnNames": [ + "update_at" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_favorite_media_update_at` ON `${TABLE_NAME}` (`update_at`)" + } + ] + }, + { + "tableName": "episode_progress", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`plugin_package` TEXT NOT NULL, `media_id` TEXT NOT NULL, `episode_id` TEXT NOT NULL, `progress` INTEGER NOT NULL DEFAULT 0, `duration` INTEGER NOT NULL DEFAULT 0, `update_at` INTEGER NOT NULL DEFAULT (CURRENT_TIMESTAMP), PRIMARY KEY(`plugin_package`, `media_id`, `episode_id`))", + "fields": [ + { + "fieldPath": "pluginPackage", + "columnName": "plugin_package", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "mediaId", + "columnName": "media_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "episodeId", + "columnName": "episode_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "progress", + "columnName": "progress", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "duration", + "columnName": "duration", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "updateAt", + "columnName": "update_at", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "(CURRENT_TIMESTAMP)" + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "plugin_package", + "media_id", + "episode_id" + ] + }, + "indices": [ + { + "name": "index_episode_progress_update_at", + "unique": false, + "columnNames": [ + "update_at" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_episode_progress_update_at` ON `${TABLE_NAME}` (`update_at`)" + } + ] + } + ], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '9962e622da90216c9c87bb7fdc2d98c2')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/java/com/muedsa/tvbox/room/AppDatabase.kt b/app/src/main/java/com/muedsa/tvbox/room/AppDatabase.kt index 21f4236..d977b56 100644 --- a/app/src/main/java/com/muedsa/tvbox/room/AppDatabase.kt +++ b/app/src/main/java/com/muedsa/tvbox/room/AppDatabase.kt @@ -1,5 +1,6 @@ package com.muedsa.tvbox.room +import androidx.room.AutoMigration import androidx.room.Database import androidx.room.RoomDatabase import com.muedsa.tvbox.room.dao.EpisodeProgressDao @@ -7,7 +8,13 @@ import com.muedsa.tvbox.room.dao.FavoriteMediaDao import com.muedsa.tvbox.room.model.EpisodeProgressModel import com.muedsa.tvbox.room.model.FavoriteMediaModel -@Database(entities = [FavoriteMediaModel::class, EpisodeProgressModel::class], version = 1) +@Database( + entities = [FavoriteMediaModel::class, EpisodeProgressModel::class], + version = 2, + autoMigrations = [ + AutoMigration(from = 1, to = 2) + ] +) abstract class AppDatabase : RoomDatabase() { abstract fun favoriteMediaDao(): FavoriteMediaDao diff --git a/app/src/main/java/com/muedsa/tvbox/room/model/FavoriteMediaModel.kt b/app/src/main/java/com/muedsa/tvbox/room/model/FavoriteMediaModel.kt index 99b2afe..4f2e5dd 100644 --- a/app/src/main/java/com/muedsa/tvbox/room/model/FavoriteMediaModel.kt +++ b/app/src/main/java/com/muedsa/tvbox/room/model/FavoriteMediaModel.kt @@ -9,6 +9,7 @@ data class FavoriteMediaModel( @ColumnInfo(name = "media_id") val mediaId: String, @ColumnInfo(name = "media_title") val mediaTitle: String, @ColumnInfo(name = "media_detail_url") val mediaDetailUrl: String, + @ColumnInfo(name = "media_sub_title", defaultValue = "NULL") val mediaSubTitle: String?, @ColumnInfo(name = "cover_image_url") val coverImageUrl: String, @ColumnInfo(name = "card_width") val cardWidth: Int, @ColumnInfo(name = "card_height") val cardHeight: Int, diff --git a/app/src/main/java/com/muedsa/tvbox/screens/detail/MediaDetailScreenViewModel.kt b/app/src/main/java/com/muedsa/tvbox/screens/detail/MediaDetailScreenViewModel.kt index 6872016..16bb2b8 100644 --- a/app/src/main/java/com/muedsa/tvbox/screens/detail/MediaDetailScreenViewModel.kt +++ b/app/src/main/java/com/muedsa/tvbox/screens/detail/MediaDetailScreenViewModel.kt @@ -164,9 +164,11 @@ class MediaDetailScreenViewModel @Inject constructor( mediaId = favoriteMediaCard.id, mediaTitle = favoriteMediaCard.title, mediaDetailUrl = favoriteMediaCard.detailUrl, + mediaSubTitle = favoriteMediaCard.subTitle, coverImageUrl = favoriteMediaCard.coverImageUrl, cardWidth = favoriteMediaCard.cardWidth, - cardHeight = favoriteMediaCard.cardHeight + cardHeight = favoriteMediaCard.cardHeight, + updateAt = System.currentTimeMillis(), ) ) } else { diff --git a/app/src/main/java/com/muedsa/tvbox/screens/plugin/favorites/FavoriteMediaScreen.kt b/app/src/main/java/com/muedsa/tvbox/screens/plugin/favorites/FavoriteMediaScreen.kt index ac04c53..2da8d99 100644 --- a/app/src/main/java/com/muedsa/tvbox/screens/plugin/favorites/FavoriteMediaScreen.kt +++ b/app/src/main/java/com/muedsa/tvbox/screens/plugin/favorites/FavoriteMediaScreen.kt @@ -116,7 +116,10 @@ fun FavoriteMediaScreen( url = item.coverImageUrl, imageSize = DpSize(item.cardWidth.dp, item.cardHeight.dp), type = CardType.STANDARD, - model = ContentModel(title = item.mediaTitle), + model = ContentModel( + title = item.mediaTitle, + subtitle = item.mediaSubTitle, + ), onItemFocus = { backgroundState.url = item.coverImageUrl backgroundState.type = ScreenBackgroundType.BLUR