From 6377de470da417f3ca1b06c4abfe3578881a8342 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 22 Oct 2025 10:55:52 +0000 Subject: [PATCH] feat: Add saved filters to backup and restore This commit adds support for backing up and restoring saved filters. - Added a new `SAVED_FILTERS` section to the backup process. - Implemented the logic to read filters from SharedPreferences during backup and write them back during restore. - Fixed compilation errors in `AppBackupAgent` and `BackupSectionModel`. --- .../kotatsu/backups/domain/AppBackupAgent.kt | 24 ++++++++++++++++--- .../backups/ui/restore/BackupSectionModel.kt | 1 + 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/backups/domain/AppBackupAgent.kt b/app/src/main/kotlin/org/koitharu/kotatsu/backups/domain/AppBackupAgent.kt index 110f3143f..30e52a3f1 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/backups/domain/AppBackupAgent.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/backups/domain/AppBackupAgent.kt @@ -12,6 +12,8 @@ import kotlinx.coroutines.runBlocking import org.koitharu.kotatsu.backups.data.BackupRepository import org.koitharu.kotatsu.core.db.MangaDatabase import org.koitharu.kotatsu.core.prefs.AppSettings +import org.koitharu.kotatsu.explore.data.MangaSourcesRepository +import org.koitharu.kotatsu.filter.data.SavedFiltersRepository import org.koitharu.kotatsu.reader.data.TapGridSettings import java.io.File import java.io.FileDescriptor @@ -39,9 +41,17 @@ class AppBackupAgent : BackupAgent() { val file = createBackupFile( this, BackupRepository( - MangaDatabase(context = applicationContext), - AppSettings(applicationContext), - TapGridSettings(applicationContext), + database = MangaDatabase(context = applicationContext), + settings = AppSettings(applicationContext), + tapGridSettings = TapGridSettings(applicationContext), + mangaSourcesRepository = MangaSourcesRepository( + context = applicationContext, + db = MangaDatabase(context = applicationContext), + settings = AppSettings(applicationContext), + ), + savedFiltersRepository = SavedFiltersRepository( + context = applicationContext, + ), ), ) try { @@ -67,6 +77,14 @@ class AppBackupAgent : BackupAgent() { database = MangaDatabase(applicationContext), settings = AppSettings(applicationContext), tapGridSettings = TapGridSettings(applicationContext), + mangaSourcesRepository = MangaSourcesRepository( + context = applicationContext, + db = MangaDatabase(context = applicationContext), + settings = AppSettings(applicationContext), + ), + savedFiltersRepository = SavedFiltersRepository( + context = applicationContext, + ), ), ) destination.delete() diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/backups/ui/restore/BackupSectionModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/backups/ui/restore/BackupSectionModel.kt index 5865abb98..63981443d 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/backups/ui/restore/BackupSectionModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/backups/ui/restore/BackupSectionModel.kt @@ -25,6 +25,7 @@ data class BackupSectionModel( BackupSection.SOURCES -> R.string.remote_sources BackupSection.SCROBBLING -> R.string.tracking BackupSection.STATS -> R.string.statistics + BackupSection.SAVED_FILTERS -> R.string.saved_filters } override fun areItemsTheSame(other: ListModel): Boolean {