tachiyomi/app/src/main/java/eu/kanade/tachiyomi/di/PreferenceModule.kt
arkon 695813ef7d Add unified storage location setting
Currently only using it as a replacement for the downloads location.
2023-11-19 16:04:28 -05:00

81 lines
2.6 KiB
Kotlin

package eu.kanade.tachiyomi.di
import android.app.Application
import eu.kanade.domain.base.BasePreferences
import eu.kanade.domain.source.service.SourcePreferences
import eu.kanade.domain.track.service.TrackPreferences
import eu.kanade.domain.ui.UiPreferences
import eu.kanade.tachiyomi.core.security.SecurityPreferences
import eu.kanade.tachiyomi.network.NetworkPreferences
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
import eu.kanade.tachiyomi.util.system.isDevFlavor
import tachiyomi.core.preference.AndroidPreferenceStore
import tachiyomi.core.preference.PreferenceStore
import tachiyomi.core.provider.AndroidBackupFolderProvider
import tachiyomi.core.provider.AndroidStorageFolderProvider
import tachiyomi.domain.backup.service.BackupPreferences
import tachiyomi.domain.download.service.DownloadPreferences
import tachiyomi.domain.library.service.LibraryPreferences
import tachiyomi.domain.storage.service.StoragePreferences
import uy.kohesive.injekt.api.InjektModule
import uy.kohesive.injekt.api.InjektRegistrar
import uy.kohesive.injekt.api.addSingletonFactory
import uy.kohesive.injekt.api.get
class PreferenceModule(val app: Application) : InjektModule {
override fun InjektRegistrar.registerInjectables() {
addSingletonFactory<PreferenceStore> {
AndroidPreferenceStore(app)
}
addSingletonFactory {
NetworkPreferences(
preferenceStore = get(),
verboseLogging = isDevFlavor,
)
}
addSingletonFactory {
SourcePreferences(get())
}
addSingletonFactory {
SecurityPreferences(get())
}
addSingletonFactory {
LibraryPreferences(get())
}
addSingletonFactory {
ReaderPreferences(get())
}
addSingletonFactory {
TrackPreferences(get())
}
addSingletonFactory {
DownloadPreferences(get())
}
addSingletonFactory {
AndroidBackupFolderProvider(app)
}
addSingletonFactory {
BackupPreferences(
folderProvider = get<AndroidBackupFolderProvider>(),
preferenceStore = get(),
)
}
addSingletonFactory {
AndroidStorageFolderProvider(app)
}
addSingletonFactory {
StoragePreferences(
folderProvider = get<AndroidStorageFolderProvider>(),
preferenceStore = get(),
)
}
addSingletonFactory {
UiPreferences(get())
}
addSingletonFactory {
BasePreferences(app, get())
}
}
}