* add a UI trigger for demo annotations * Implement internal link navigation * Simplify bottom padding logic in `EpubReaderScreen` for vertical scroll mode * Add support for Calibre metadata * Implement advanced library management with Room-backed collections, tags, and smart rules. * Display book series information in book details and remove tags from home screen * Implement zoom reset functionality in PDF viewer * Add a "Pages" thumbnail view to the PDF navigation drawer * Implement jump-back navigation in PDF viewer * MainViewModel: disable FolderSyncWorker, add log export, and enhance PDF position logging * Replace Gson with Kotlin Serialization in SmartCollectionEngine * Implement ONNX-based speech bubble detection * Implement speech bubble detection in PDF viewer * Implement "Smart Comic Zoom" feature for PDF manga/comic reading * Implement reader session persistence and restoration in `MainViewModel` * Add tap-to-turn page feature to PDF viewer * Improve book cache management and recovery * Refactor top overlay padding logic in `PdfViewerScreen` * Implement stylus eraser support in PDF reader * Refactor ReaderTextFormatPanel to use ModalBottomSheet and add new formatting controls * Introduce a customizable horizontal margin setting for the EPUB reader * Refine folder sync and metadata handling for better conflict resolution and stability. * Introduce user-adjustable image scaling for the EPUB reader * Use maxWidthPx as default width fallback for blocks * Improve cross-page text selection and header styling in the paginated reader * Refactor speech bubble detection and UI to support segmentation masks and interactive scaling * Improve speech bubble detection masking and rendering quality * Update ONNX speech bubble detector to use `.ort` model and optimize inference * Improve pagination accuracy * Implement hierarchical folder navigation for the library. * Refactor library item layout for improved space efficiency * Add support for browsing and downloading Google Fonts * Persist library landing state and add shelf search functionality * Fix base tts sample. * Move SpeechBubbleDetector to main source set and update ONNX dependency * Implement a "locate" feature and improve synchronization for TTS (Text-to-Speech) playback across EPUB and PDF readers. * Refine TTS synchronization and voice management in the EPUB reader * Adjust OCR checks for OSS flavor and optimize external dictionary intent flags * Add "Locate" button to PDF drawer's pages tab and move the page number to bottom right of thumbnail * fix various crashes * Refactor SpeechBubbleDetector into product flavors * Implement speech bubble detection caching and background prefetching * Implement on-demand download for Bubble Zoom ML model * Add smooth animation for PDF speech bubble expansion * fixes #252 * hide Google Fonts option, in FontsScreen, for offline variant * Bump version to 1.0.46(46)
101 lines
5.6 KiB
Kotlin
101 lines
5.6 KiB
Kotlin
/*
|
|
* Episteme Reader - A native Android document reader.
|
|
* Copyright (C) 2026 Episteme
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*
|
|
* mail: epistemereader@gmail.com
|
|
*/
|
|
// RecentFileDao.kt
|
|
package com.aryan.reader.data
|
|
|
|
import androidx.room.Dao
|
|
import androidx.room.Query
|
|
import androidx.room.Upsert
|
|
import kotlinx.coroutines.flow.Flow
|
|
|
|
@Dao
|
|
interface RecentFileDao {
|
|
@Upsert
|
|
suspend fun insertOrUpdateFile(file: RecentFileEntity)
|
|
|
|
@Upsert
|
|
suspend fun insertOrUpdateFiles(files: List<RecentFileEntity>)
|
|
|
|
@Query("SELECT bookId, uriString, type, displayName, timestamp, coverImagePath, title, author, lastChapterIndex, lastPage, lastPositionCfi, progressPercentage, isRecent, isAvailable, lastModifiedTimestamp, isDeleted, locatorBlockIndex, locatorCharOffset, sourceFolderUri, isReflowPreferred, customName, fileSize, seriesName, seriesIndex, description FROM recent_files WHERE isDeleted = 0 ORDER BY timestamp DESC")
|
|
fun getRecentFiles(): Flow<List<RecentFileSummary>>
|
|
|
|
@Query("SELECT * FROM recent_files WHERE sourceFolderUri = :sourceFolderUri AND isDeleted = 0")
|
|
suspend fun getFilesBySourceFolder(sourceFolderUri: String): List<RecentFileEntity>
|
|
|
|
@Query("SELECT * FROM recent_files")
|
|
suspend fun getAllFiles(): List<RecentFileEntity>
|
|
|
|
@Query("UPDATE recent_files SET isReflowPreferred = :isPreferred WHERE bookId = :bookId")
|
|
suspend fun updateReflowPreference(bookId: String, isPreferred: Boolean)
|
|
|
|
@Query("SELECT bookId, uriString, type, displayName, timestamp, coverImagePath, title, author, lastChapterIndex, lastPage, lastPositionCfi, progressPercentage, isRecent, isAvailable, lastModifiedTimestamp, isDeleted, locatorBlockIndex, locatorCharOffset, sourceFolderUri, isReflowPreferred, customName, fileSize, seriesName, seriesIndex, description FROM recent_files WHERE isDeleted = 0 ORDER BY timestamp DESC LIMIT :limit")
|
|
fun getRecentFilesList(limit: Int): List<RecentFileSummary>
|
|
|
|
@Query("DELETE FROM recent_files WHERE bookId IN (:bookIds)")
|
|
suspend fun deleteFilePermanently(bookIds: List<String>)
|
|
|
|
@Query("UPDATE recent_files SET isDeleted = 1, isAvailable = 0, lastModifiedTimestamp = :timestamp WHERE bookId IN (:bookIds)")
|
|
suspend fun markAsDeleted(bookIds: List<String>, timestamp: Long)
|
|
|
|
@Query("SELECT * FROM recent_files WHERE lastModifiedTimestamp > :sinceTimestamp")
|
|
suspend fun getModifiedSince(sinceTimestamp: Long): List<RecentFileEntity>
|
|
|
|
@Query("SELECT COUNT(*) FROM recent_files")
|
|
suspend fun count(): Int
|
|
|
|
@Query("SELECT * FROM recent_files WHERE bookId = :bookId")
|
|
suspend fun getFileByBookId(bookId: String): RecentFileEntity?
|
|
|
|
@Query("SELECT * FROM recent_files WHERE uriString = :uriString")
|
|
suspend fun getFileByUri(uriString: String): RecentFileEntity?
|
|
|
|
@Query("DELETE FROM recent_files WHERE sourceFolderUri = :sourceFolderUri")
|
|
suspend fun deleteFilesBySourceFolder(sourceFolderUri: String)
|
|
|
|
@Query("SELECT * FROM recent_files WHERE bookId LIKE :prefix || '%'")
|
|
suspend fun getFilesWithIdPrefix(prefix: String): List<RecentFileEntity>
|
|
|
|
@Query("DELETE FROM recent_files")
|
|
suspend fun clearAll()
|
|
|
|
@Query("UPDATE recent_files SET lastPositionCfi = :cfi, lastChapterIndex = :chapterIndex, locatorBlockIndex = :blockIndex, locatorCharOffset = :charOffset, progressPercentage = :progress, timestamp = :timestamp, lastModifiedTimestamp = :timestamp WHERE bookId = :bookId")
|
|
suspend fun updateEpubReadingPosition(bookId: String, cfi: String?, chapterIndex: Int, blockIndex: Int, charOffset: Int, progress: Float, timestamp: Long)
|
|
|
|
@Query("UPDATE recent_files SET lastPage = :page, progressPercentage = :progress, timestamp = :timestamp, lastModifiedTimestamp = :timestamp WHERE bookId = :bookId")
|
|
suspend fun updatePdfReadingPosition(bookId: String, page: Int, progress: Float, timestamp: Long)
|
|
|
|
@Query("UPDATE recent_files SET bookmarks = :bookmarksJson, lastModifiedTimestamp = :timestamp WHERE bookId = :bookId")
|
|
suspend fun updateBookmarks(bookId: String, bookmarksJson: String, timestamp: Long)
|
|
|
|
@Query("UPDATE recent_files SET isAvailable = 1, uriString = :uriString, timestamp = :timestamp, lastModifiedTimestamp = :timestamp WHERE bookId = :bookId")
|
|
suspend fun updateBookAvailability(bookId: String, uriString: String, timestamp: Long)
|
|
|
|
@Query("UPDATE recent_files SET isRecent = 0, lastModifiedTimestamp = :timestamp WHERE bookId IN (:bookIds)")
|
|
suspend fun markAsNotRecent(bookIds: List<String>, timestamp: Long)
|
|
|
|
@Query("SELECT * FROM recent_files WHERE sourceFolderUri IS NOT NULL AND coverImagePath IS NULL AND isDeleted = 0")
|
|
suspend fun getFolderBooksWithoutCovers(): List<RecentFileEntity>
|
|
|
|
@Query("UPDATE recent_files SET sourceFolderUri = NULL WHERE sourceFolderUri IS NOT NULL")
|
|
suspend fun detachAllFolderBooks()
|
|
|
|
@Query("UPDATE recent_files SET highlights = :highlightsJson, lastModifiedTimestamp = :timestamp WHERE bookId = :bookId")
|
|
suspend fun updateHighlights(bookId: String, highlightsJson: String, timestamp: Long)
|
|
}
|