Home and Library screen update (#101)

* Added support for filtering file types in synced folders

* Added support for custom file names and enhanced file information dialog

* added feedback option in the homescreen drawer

* Implemented a limit for number of recent files displayed on the home screen
This commit is contained in:
Aryan 2026-03-20 21:51:03 +05:30 committed by GitHub
parent 9842aea9b1
commit ddcd253c7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 637 additions and 734 deletions

View file

@ -27,7 +27,7 @@ import androidx.room.TypeConverters
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
@Database(entities = [RecentFileEntity::class, CustomFontEntity::class], version = 13, exportSchema = false)
@Database(entities =[RecentFileEntity::class, CustomFontEntity::class], version = 14, exportSchema = false)
@TypeConverters(FileTypeConverter::class)
abstract class AppDatabase : RoomDatabase() {
abstract fun recentFileDao(): RecentFileDao
@ -173,6 +173,12 @@ abstract class AppDatabase : RoomDatabase() {
}
}
val MIGRATION_13_14 = object : Migration(13, 14) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("ALTER TABLE recent_files ADD COLUMN customName TEXT DEFAULT NULL")
}
}
fun getDatabase(context: Context): AppDatabase {
return INSTANCE ?: synchronized(this) {
val instance = Room.databaseBuilder(
@ -184,7 +190,7 @@ abstract class AppDatabase : RoomDatabase() {
MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5,
MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9,
MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12,
MIGRATION_12_13
MIGRATION_12_13, MIGRATION_13_14
)
.fallbackToDestructiveMigration(false)
.build()

View file

@ -18,7 +18,8 @@ data class FolderBookMetadata(
val lastModifiedTimestamp: Long,
val bookmarksJson: String?,
val locatorBlockIndex: Int?,
val locatorCharOffset: Int?
val locatorCharOffset: Int?,
val customName: String?
) {
fun toJsonString(): String {
val json = JSONObject()
@ -36,6 +37,7 @@ data class FolderBookMetadata(
json.put("bookmarksJson", bookmarksJson)
json.put("locatorBlockIndex", locatorBlockIndex ?: -1)
json.put("locatorCharOffset", locatorCharOffset ?: -1)
json.put("customName", customName)
return json.toString()
}
@ -66,7 +68,8 @@ data class FolderBookMetadata(
lastModifiedTimestamp = json.optLong("lastModifiedTimestamp", 0L),
bookmarksJson = json.optStringNull("bookmarksJson"),
locatorBlockIndex = json.optIntNull("locatorBlockIndex"),
locatorCharOffset = json.optIntNull("locatorCharOffset")
locatorCharOffset = json.optIntNull("locatorCharOffset"),
customName = json.optStringNull("customName")
)
}
}
@ -93,6 +96,7 @@ fun FolderBookMetadata.toRecentFileItem(uriString: String?, coverPath: String?,
lastModifiedTimestamp = this.lastModifiedTimestamp,
isDeleted = false,
bookmarksJson = this.bookmarksJson,
sourceFolderUri = sourceFolderUri
sourceFolderUri = sourceFolderUri,
customName = this.customName
)
}

View file

@ -48,5 +48,6 @@ data class RecentFileEntity(
val locatorCharOffset: Int?,
val bookmarks: String?,
@ColumnInfo(defaultValue = "NULL") val sourceFolderUri: String?,
@ColumnInfo(defaultValue = "0") val isReflowPreferred: Boolean
@ColumnInfo(defaultValue = "0") val isReflowPreferred: Boolean,
@ColumnInfo(defaultValue = "NULL") val customName: String?
)

View file

@ -44,7 +44,8 @@ data class RecentFileItem(
val isDeleted: Boolean = false,
val bookmarksJson: String? = null,
val sourceFolderUri: String? = null,
val isReflowPreferred: Boolean = false
val isReflowPreferred: Boolean = false,
val customName: String? = null
) {
fun getUri(): Uri? = uriString?.toUri()
}
@ -71,7 +72,8 @@ fun RecentFileEntity.toRecentFileItem(): RecentFileItem {
isDeleted = this.isDeleted,
bookmarksJson = this.bookmarks,
sourceFolderUri = this.sourceFolderUri,
isReflowPreferred = this.isReflowPreferred
isReflowPreferred = this.isReflowPreferred,
customName = this.customName
)
}
@ -97,7 +99,8 @@ fun RecentFileItem.toRecentFileEntity(): RecentFileEntity {
isDeleted = this.isDeleted,
bookmarks = this.bookmarksJson,
sourceFolderUri = this.sourceFolderUri,
isReflowPreferred = this.isReflowPreferred
isReflowPreferred = this.isReflowPreferred,
customName = this.customName
)
}
@ -118,7 +121,8 @@ fun RecentFileItem.toBookMetadata(): BookMetadata {
isDeleted = this.isDeleted,
lastModifiedTimestamp = this.lastModifiedTimestamp,
bookmarksJson = this.bookmarksJson,
hasAnnotations = false
hasAnnotations = false,
customName = this.customName
)
}
@ -142,6 +146,7 @@ fun BookMetadata.toRecentFileItem(): RecentFileItem {
isAvailable = false,
lastModifiedTimestamp = this.lastModifiedTimestamp,
isDeleted = this.isDeleted,
bookmarksJson = this.bookmarksJson
bookmarksJson = this.bookmarksJson,
customName = this.customName
)
}

View file

@ -158,7 +158,8 @@ class RecentFilesRepository(private val context: Context) {
lastModifiedTimestamp = entity.lastModifiedTimestamp,
bookmarksJson = entity.bookmarks,
locatorBlockIndex = entity.locatorBlockIndex,
locatorCharOffset = entity.locatorCharOffset
locatorCharOffset = entity.locatorCharOffset,
customName = entity.customName
)
LocalSyncUtils.saveMetadataToFolder(