komikku/app/src/main/java/eu/kanade/tachiyomi/di/AppModule.kt

207 lines
7.7 KiB
Kotlin
Raw Normal View History

package eu.kanade.tachiyomi.di
import android.app.Application
import android.os.Build
import androidx.core.content.ContextCompat
import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import app.cash.sqldelight.db.SqlDriver
import app.cash.sqldelight.driver.android.AndroidSqliteDriver
import eu.kanade.domain.track.store.DelayedTrackingStore
import eu.kanade.tachiyomi.core.security.SecurityPreferences
import eu.kanade.tachiyomi.data.BackupRestoreStatus
import eu.kanade.tachiyomi.data.LibraryUpdateStatus
import eu.kanade.tachiyomi.data.SyncStatus
import eu.kanade.tachiyomi.data.cache.ChapterCache
import eu.kanade.tachiyomi.data.cache.CoverCache
import eu.kanade.tachiyomi.data.cache.PagePreviewCache
feat(discord): Discord RPC from Anikku (#1100) * Add RPC [Barebone, barely works] Co-Authored-By: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com> * refactor connections * RPC (#223) * Add error handling and refactor DiscordRPCService methods * Add Discord RPC customization options and preferences * Update Discord RPC button labels and clean up comments * Refactor DiscordRPCService to improve readability by adding braces for null checks * Refactor ConnectionsPreferences to improve code clarity and organization * Refactor ConnectionsPreferences to improve code clarity and organization (cherry picked from commit df42d196368d28c3c9dcee3692f3f9140da7f2a1) * Feat: implement Discord account management enhancements and RPC restart functionality (#245) * fix: correct indentation in CastManager for better readability * feat: implement Discord account management enhancements and RPC restart functionality (cherry picked from commit b7c50f1f0184dd717c5cc4dee0310053bfb8d613) * Notification color & icon for DiscordRPC Co-Authored-By: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com> * Change foss variant application id suffix to '.foss' and more (mihonapp/mihon#1831) - Remove `BuildConfig.PREVIEW` - Rename `BuildConfig.INCLUDE_ANALYTICS` -> `BuildConfig.ANALYTICS_INCLUDED` - Rename `BuildConfig.INCLUDE_UPDATER` -> `BuildConfig.UPDATER_ENABLED` - Rename build property `with-analytics` -> `include-analytics` - Rename build property `with-updater` -> `enable-updater` - Add build property to disable code shrink - Add build property to include dependency info in apk/app bundle (cherry picked from commit 0893609ad2c4791dc404d72a5e69a2e0373517ae) * feat(discord): update App/icon & fully works with all screens * update Discord Rich Presence application ID and icon URLs * Fix updateDiscordRPC for all screens (also reuse code) * integrate Discord Rich Presence for WebViewScreen * feat: ghibli style images for Discord RPC * optimize code * further optimize * supprest useless warning * refactor: simplify setScreen calls related to lastUsedScreen * optimize whole file * a Co-Authored-By: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com> * fix(discord): update download button URL to point to the official website * feat(discord): allow stop Discord RPC from notification also improve error handling * fix(i18n): Torrent server "stop" multi-lang * Start DiscordRPCService as foreground service on Android O+ This commit modifies the `DiscordRPCService` to start as a foreground service on Android O (API level 26) and above. This change ensures the service continues to run in the background, especially when the app is not in the foreground. - Added a conditional check using `Build.VERSION.SDK_INT` to detect if the device is running Android O or later. - If the device is running Android O or later, `startForegroundService` is called instead of `startService` to ensure it runs as foreground service. - If the device is running a version prior to Android O, `startService` is called. (cherry picked from commit 869617d8cac3aa8461158f1f9a34b9e29147e8f0) * fix(discord): episode/chapter formating * fix(discord): Fix & improve Discord login/accounts * New webview with DiscordLoginScreen * Add appbar * Using Webview directly instead of AndroidView and add clearCookies, browsing navigation * Using coroutine instead of thread * Revert service * use response block * save preference in coroutine too * no web navigator * address comments for DiscordLoginScreen * Refactor Settings screen & dialog * Using serialization to parse JSON to avoid blocking API * Don't clear all cookies and web storage aggressively * Extract constant * Fix login Co-Authored-By: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com> * fix(discord): Fix screen crash & token retrievement * Update images to my liking * spotless * small fixes * Update strings.xml * Revert "Update images to my liking" This reverts commit 4ad3b9f84fdada45ee480ae7dc242b6e1b4bc18a. * small fixes * hopeful fix + chapter progress * Update ReaderActivity.kt * Update ReaderActivity.kt * remove timestamps * Remove isNSFW check because 95% of tachi extensions are rated as +18, even when there is sfw content * Clean up * Fix ReaderActivity * Cleanup Settings * Fix login * Fix lag when getting categories * Fix jump to pages * Remove old SDK check * Fix status when back from reading * Remove pages progress * Only set necessary action in ReaderActivity * Using IO coroutine instead * Add back timestamps * Fix strings & settings * Fix crash * ActivityType * Adjust description * refactor Discord settings menu * Using its own scope * Optimize the connection waiting * remove source.isNSFW * Using screenModelScope * Fix state access * add modifier * sharing OkHttpClient instance for better resource management * Restart RPC directly via service intent instead of toggling * remove lint suppression * add back showProgress * Fix set Discord status * Fix Discord login no avatar * Handle API rate limits and errors in getDiscordUri * Token-based isLogged checking * Make Discord token sensitive data and not in backup * Minor fix * remove debug message --------- Co-authored-by: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com> Co-authored-by: Cuong-Tran <cuongtran.tm@gmail.com> Co-authored-by: Dark25 <nadiecaca2000@gmail.com> Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Co-authored-by: Jery <jery99961@gmail.com>
2025-09-04 07:40:32 +02:00
import eu.kanade.tachiyomi.data.connections.ConnectionsManager
import eu.kanade.tachiyomi.data.download.DownloadCache
import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.data.download.DownloadProvider
import eu.kanade.tachiyomi.data.saver.ImageSaver
feat: add cross device sync (#1005) * feat: add cross device sync. * chore: add google api. * chore: add SY specifics. * feat: add backupSource, backupPref, and "SY" backupSavedSearches. I forgot to add the data into the merging logic, So remote always have empty value :(. Better late than never. * feat(sync): Allow to choose what to sync. Various improvement and added the option to choose what they want to sync. Added sync library button to LibraryTab as well. Signed-off-by: KaiserBh <kaiserbh@proton.me> * oops. Signed-off-by: KaiserBh <kaiserbh@proton.me> * refactor: fix up the sync triggers, and update imports. * refactor * chore: review pointers. * refactor: update imports * refactor: add more error guard for gdrive. Also changed it to be app specific, we don't want them to use sync data from SY or other forks as some of the model and backup is different. So if people using other forks they should use the same data and not mismatch. * fix: conflict and refactor. * refactor: update imports. * chore: fix some of detekt error. * refactor: add breaks and max retries. I think we were reaching deadlock or infinite loop causing the sync to go forever. * feat: db changes to accommodate new syncing logic. Using timestamp to sync is a bit skewed due to system clock etc and therefore there was a lot of issues with it such as removing a manga that shouldn't have been removed. Marking chapters as unread even though it was marked as a read. Hopefully by using versioning system it should eliminate those issues. * chore: add migrations * chore: version and is_syncing fields. * chore: add SY only stuff. * fix: oops wrong index. Signed-off-by: KaiserBh <kaiserbh@proton.me> * chore: review pointers. Signed-off-by: KaiserBh <kaiserbh@proton.me> * chore: remove the option to reset timestamp We don't need this anymore since we are utilizing versioning system. Signed-off-by: KaiserBh <kaiserbh@proton.me> * refactor: Forgot to use the new versioning system. I forgot to cherry pick this from mihon branch. * chore: remove isSyncing from Chapter/Manga model. Signed-off-by: KaiserBh <kaiserbh@proton.me> * chore: remove unused import. Signed-off-by: KaiserBh <kaiserbh@proton.me> * chore: remove isSyncing leftover. Signed-off-by: KaiserBh <kaiserbh@proton.me> * chore: remove isSyncing. Signed-off-by: KaiserBh <kaiserbh@proton.me> * refactor: make sure the manga version is bumped. When there is changes in the chapters table such as reading or updating last read page we should bump the manga version. This way the manga is synced properly as in the History and last_read history is synced properly. This should fix the sorting issue. Signed-off-by: KaiserBh <kaiserbh@proton.me> --------- Signed-off-by: KaiserBh <kaiserbh@proton.me>
2024-03-16 16:53:20 +01:00
import eu.kanade.tachiyomi.data.sync.service.GoogleDriveService
import eu.kanade.tachiyomi.data.track.TrackerManager
import eu.kanade.tachiyomi.extension.ExtensionManager
import eu.kanade.tachiyomi.network.JavaScriptEngine
2017-01-20 21:34:15 +01:00
import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.source.AndroidSourceManager
import eu.kanade.tachiyomi.util.system.isDebugBuildType
2020-05-04 00:34:46 +02:00
import exh.eh.EHentaiUpdateHelper
import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory
import kotlinx.serialization.json.Json
import kotlinx.serialization.protobuf.ProtoBuf
import mihon.core.archive.CbzCrypto
import net.zetetic.database.sqlcipher.SupportOpenHelperFactory
import nl.adaptivity.xmlutil.XmlDeclMode
import nl.adaptivity.xmlutil.core.XmlVersion
import nl.adaptivity.xmlutil.serialization.XML
Move `:core` to `:core:common` (cherry picked from commit aa498360db90350f2642e6320dc55e7d474df1fd) # Conflicts: # app/build.gradle.kts # app/src/main/java/eu/kanade/domain/base/BasePreferences.kt # app/src/main/java/eu/kanade/domain/chapter/interactor/SetReadStatus.kt # app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt # app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt # app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt # app/src/main/java/eu/kanade/tachiyomi/App.kt # app/src/main/java/eu/kanade/tachiyomi/Migrations.kt # app/src/main/java/eu/kanade/tachiyomi/data/backup/create/BackupCreator.kt # app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt # app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateDialog.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchScreen.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesScreenModel.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceFilterDialog.kt # app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt # app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt # app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt # app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt # app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/RarPageLoader.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ZipPageLoader.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt # app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreenModel.kt # app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt # core/common/src/main/kotlin/eu/kanade/tachiyomi/util/storage/CbzCrypto.kt # data/src/main/java/tachiyomi/data/manga/MangaRepositoryImpl.kt # data/src/main/java/tachiyomi/data/source/SourcePagingSource.kt # domain/src/main/java/tachiyomi/domain/library/service/LibraryPreferences.kt # domain/src/main/java/tachiyomi/domain/manga/model/Manga.kt # settings.gradle.kts # source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt # source-local/src/androidMain/kotlin/tachiyomi/source/local/image/LocalCoverManager.kt
2024-01-29 10:11:28 +01:00
import tachiyomi.core.common.storage.AndroidStorageFolderProvider
import tachiyomi.core.common.storage.UniFileTempFileManager
import tachiyomi.data.AndroidDatabaseHandler
import tachiyomi.data.Database
import tachiyomi.data.DatabaseHandler
import tachiyomi.data.DateColumnAdapter
import tachiyomi.data.History
import tachiyomi.data.Mangas
import tachiyomi.data.StringListColumnAdapter
import tachiyomi.data.UpdateStrategyColumnAdapter
import tachiyomi.domain.manga.interactor.GetCustomMangaInfo
import tachiyomi.domain.source.service.SourceManager
import tachiyomi.domain.storage.service.StorageManager
import tachiyomi.source.local.image.LocalCoverManager
import tachiyomi.source.local.io.LocalSourceFileSystem
2020-02-27 00:12:44 +01:00
import uy.kohesive.injekt.api.InjektModule
import uy.kohesive.injekt.api.InjektRegistrar
import uy.kohesive.injekt.api.addSingleton
import uy.kohesive.injekt.api.addSingletonFactory
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
// SY -->
private const val LEGACY_DATABASE_NAME = "tachiyomi.db"
// SY <--
class AppModule(val app: Application) : InjektModule {
// SY -->
private val securityPreferences: SecurityPreferences by injectLazy()
// SY <--
override fun InjektRegistrar.registerInjectables() {
addSingleton(app)
addSingletonFactory<SqlDriver> {
// SY -->
if (securityPreferences.encryptDatabase().get()) {
System.loadLibrary("sqlcipher")
}
// SY <--
AndroidSqliteDriver(
schema = Database.Schema,
context = app,
// SY -->
name = if (securityPreferences.encryptDatabase().get()) {
CbzCrypto.DATABASE_NAME
} else {
LEGACY_DATABASE_NAME
},
factory = if (securityPreferences.encryptDatabase().get()) {
SupportOpenHelperFactory(CbzCrypto.getDecryptedPasswordSql(), null, false, 25)
} else if (isDebugBuildType && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// Support database inspector in Android Studio
FrameworkSQLiteOpenHelperFactory()
} else {
RequerySQLiteOpenHelperFactory()
},
// SY <--
callback = object : AndroidSqliteDriver.Callback(Database.Schema) {
override fun onOpen(db: SupportSQLiteDatabase) {
super.onOpen(db)
setPragma(db, "foreign_keys = ON")
setPragma(db, "journal_mode = WAL")
setPragma(db, "synchronous = NORMAL")
}
private fun setPragma(db: SupportSQLiteDatabase, pragma: String) {
val cursor = db.query("PRAGMA $pragma")
cursor.moveToFirst()
cursor.close()
}
},
)
}
addSingletonFactory {
Database(
driver = get(),
historyAdapter = History.Adapter(
last_readAdapter = DateColumnAdapter,
),
mangasAdapter = Mangas.Adapter(
genreAdapter = StringListColumnAdapter,
update_strategyAdapter = UpdateStrategyColumnAdapter,
),
)
}
addSingletonFactory<DatabaseHandler> { AndroidDatabaseHandler(get(), get()) }
addSingletonFactory {
Json {
ignoreUnknownKeys = true
explicitNulls = false
}
}
addSingletonFactory {
XML {
defaultPolicy {
ignoreUnknownChildren()
}
autoPolymorphic = true
xmlDeclMode = XmlDeclMode.Charset
indent = 2
xmlVersion = XmlVersion.XML10
}
}
addSingletonFactory<ProtoBuf> {
ProtoBuf
}
addSingletonFactory { UniFileTempFileManager(app) }
addSingletonFactory { ChapterCache(app, get(), get()) }
addSingletonFactory { CoverCache(app) }
addSingletonFactory { NetworkHelper(app, get(), isDebugBuildType) }
addSingletonFactory { JavaScriptEngine(app) }
addSingletonFactory<SourceManager> { AndroidSourceManager(app, get(), get()) }
addSingletonFactory { ExtensionManager(app) }
addSingletonFactory { DownloadProvider(app) }
addSingletonFactory { DownloadManager(app) }
addSingletonFactory { DownloadCache(app) }
addSingletonFactory { TrackerManager() }
addSingletonFactory { DelayedTrackingStore(app) }
addSingletonFactory { ImageSaver(app) }
addSingletonFactory { AndroidStorageFolderProvider(app) }
addSingletonFactory { LocalSourceFileSystem(get()) }
addSingletonFactory { LocalCoverManager(app, get()) }
addSingletonFactory { StorageManager(app, get()) }
// SY -->
2019-04-18 23:40:13 +02:00
addSingletonFactory { EHentaiUpdateHelper(app) }
addSingletonFactory { PagePreviewCache(app) }
// SY <--
2019-08-11 02:23:43 +02:00
// KMK -->
addSingletonFactory { BackupRestoreStatus() }
addSingletonFactory { SyncStatus() }
addSingletonFactory { LibraryUpdateStatus() }
// KMK <--
feat(discord): Discord RPC from Anikku (#1100) * Add RPC [Barebone, barely works] Co-Authored-By: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com> * refactor connections * RPC (#223) * Add error handling and refactor DiscordRPCService methods * Add Discord RPC customization options and preferences * Update Discord RPC button labels and clean up comments * Refactor DiscordRPCService to improve readability by adding braces for null checks * Refactor ConnectionsPreferences to improve code clarity and organization * Refactor ConnectionsPreferences to improve code clarity and organization (cherry picked from commit df42d196368d28c3c9dcee3692f3f9140da7f2a1) * Feat: implement Discord account management enhancements and RPC restart functionality (#245) * fix: correct indentation in CastManager for better readability * feat: implement Discord account management enhancements and RPC restart functionality (cherry picked from commit b7c50f1f0184dd717c5cc4dee0310053bfb8d613) * Notification color & icon for DiscordRPC Co-Authored-By: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com> * Change foss variant application id suffix to '.foss' and more (mihonapp/mihon#1831) - Remove `BuildConfig.PREVIEW` - Rename `BuildConfig.INCLUDE_ANALYTICS` -> `BuildConfig.ANALYTICS_INCLUDED` - Rename `BuildConfig.INCLUDE_UPDATER` -> `BuildConfig.UPDATER_ENABLED` - Rename build property `with-analytics` -> `include-analytics` - Rename build property `with-updater` -> `enable-updater` - Add build property to disable code shrink - Add build property to include dependency info in apk/app bundle (cherry picked from commit 0893609ad2c4791dc404d72a5e69a2e0373517ae) * feat(discord): update App/icon & fully works with all screens * update Discord Rich Presence application ID and icon URLs * Fix updateDiscordRPC for all screens (also reuse code) * integrate Discord Rich Presence for WebViewScreen * feat: ghibli style images for Discord RPC * optimize code * further optimize * supprest useless warning * refactor: simplify setScreen calls related to lastUsedScreen * optimize whole file * a Co-Authored-By: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com> * fix(discord): update download button URL to point to the official website * feat(discord): allow stop Discord RPC from notification also improve error handling * fix(i18n): Torrent server "stop" multi-lang * Start DiscordRPCService as foreground service on Android O+ This commit modifies the `DiscordRPCService` to start as a foreground service on Android O (API level 26) and above. This change ensures the service continues to run in the background, especially when the app is not in the foreground. - Added a conditional check using `Build.VERSION.SDK_INT` to detect if the device is running Android O or later. - If the device is running Android O or later, `startForegroundService` is called instead of `startService` to ensure it runs as foreground service. - If the device is running a version prior to Android O, `startService` is called. (cherry picked from commit 869617d8cac3aa8461158f1f9a34b9e29147e8f0) * fix(discord): episode/chapter formating * fix(discord): Fix & improve Discord login/accounts * New webview with DiscordLoginScreen * Add appbar * Using Webview directly instead of AndroidView and add clearCookies, browsing navigation * Using coroutine instead of thread * Revert service * use response block * save preference in coroutine too * no web navigator * address comments for DiscordLoginScreen * Refactor Settings screen & dialog * Using serialization to parse JSON to avoid blocking API * Don't clear all cookies and web storage aggressively * Extract constant * Fix login Co-Authored-By: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com> * fix(discord): Fix screen crash & token retrievement * Update images to my liking * spotless * small fixes * Update strings.xml * Revert "Update images to my liking" This reverts commit 4ad3b9f84fdada45ee480ae7dc242b6e1b4bc18a. * small fixes * hopeful fix + chapter progress * Update ReaderActivity.kt * Update ReaderActivity.kt * remove timestamps * Remove isNSFW check because 95% of tachi extensions are rated as +18, even when there is sfw content * Clean up * Fix ReaderActivity * Cleanup Settings * Fix login * Fix lag when getting categories * Fix jump to pages * Remove old SDK check * Fix status when back from reading * Remove pages progress * Only set necessary action in ReaderActivity * Using IO coroutine instead * Add back timestamps * Fix strings & settings * Fix crash * ActivityType * Adjust description * refactor Discord settings menu * Using its own scope * Optimize the connection waiting * remove source.isNSFW * Using screenModelScope * Fix state access * add modifier * sharing OkHttpClient instance for better resource management * Restart RPC directly via service intent instead of toggling * remove lint suppression * add back showProgress * Fix set Discord status * Fix Discord login no avatar * Handle API rate limits and errors in getDiscordUri * Token-based isLogged checking * Make Discord token sensitive data and not in backup * Minor fix * remove debug message --------- Co-authored-by: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com> Co-authored-by: Cuong-Tran <cuongtran.tm@gmail.com> Co-authored-by: Dark25 <nadiecaca2000@gmail.com> Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Co-authored-by: Jery <jery99961@gmail.com>
2025-09-04 07:40:32 +02:00
// AM (CONNECTIONS) -->
addSingletonFactory { ConnectionsManager() }
// <-- AM (CONNECTIONS)
// Asynchronously init expensive components for a faster cold start
ContextCompat.getMainExecutor(app).execute {
get<NetworkHelper>()
get<SourceManager>()
get<Database>()
get<DownloadManager>()
// SY -->
get<GetCustomMangaInfo>()
// SY <--
}
feat: add cross device sync (#1005) * feat: add cross device sync. * chore: add google api. * chore: add SY specifics. * feat: add backupSource, backupPref, and "SY" backupSavedSearches. I forgot to add the data into the merging logic, So remote always have empty value :(. Better late than never. * feat(sync): Allow to choose what to sync. Various improvement and added the option to choose what they want to sync. Added sync library button to LibraryTab as well. Signed-off-by: KaiserBh <kaiserbh@proton.me> * oops. Signed-off-by: KaiserBh <kaiserbh@proton.me> * refactor: fix up the sync triggers, and update imports. * refactor * chore: review pointers. * refactor: update imports * refactor: add more error guard for gdrive. Also changed it to be app specific, we don't want them to use sync data from SY or other forks as some of the model and backup is different. So if people using other forks they should use the same data and not mismatch. * fix: conflict and refactor. * refactor: update imports. * chore: fix some of detekt error. * refactor: add breaks and max retries. I think we were reaching deadlock or infinite loop causing the sync to go forever. * feat: db changes to accommodate new syncing logic. Using timestamp to sync is a bit skewed due to system clock etc and therefore there was a lot of issues with it such as removing a manga that shouldn't have been removed. Marking chapters as unread even though it was marked as a read. Hopefully by using versioning system it should eliminate those issues. * chore: add migrations * chore: version and is_syncing fields. * chore: add SY only stuff. * fix: oops wrong index. Signed-off-by: KaiserBh <kaiserbh@proton.me> * chore: review pointers. Signed-off-by: KaiserBh <kaiserbh@proton.me> * chore: remove the option to reset timestamp We don't need this anymore since we are utilizing versioning system. Signed-off-by: KaiserBh <kaiserbh@proton.me> * refactor: Forgot to use the new versioning system. I forgot to cherry pick this from mihon branch. * chore: remove isSyncing from Chapter/Manga model. Signed-off-by: KaiserBh <kaiserbh@proton.me> * chore: remove unused import. Signed-off-by: KaiserBh <kaiserbh@proton.me> * chore: remove isSyncing leftover. Signed-off-by: KaiserBh <kaiserbh@proton.me> * chore: remove isSyncing. Signed-off-by: KaiserBh <kaiserbh@proton.me> * refactor: make sure the manga version is bumped. When there is changes in the chapters table such as reading or updating last read page we should bump the manga version. This way the manga is synced properly as in the History and last_read history is synced properly. This should fix the sorting issue. Signed-off-by: KaiserBh <kaiserbh@proton.me> --------- Signed-off-by: KaiserBh <kaiserbh@proton.me>
2024-03-16 16:53:20 +01:00
addSingletonFactory { GoogleDriveService(app) }
}
}