Minor cleanup
This commit is contained in:
parent
cb67f1de52
commit
4a6571d310
11 changed files with 95 additions and 139 deletions
|
@ -2,8 +2,8 @@ package eu.kanade.presentation.track
|
|||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import eu.kanade.tachiyomi.dev.preview.DummyTracker
|
||||
import eu.kanade.tachiyomi.ui.manga.track.TrackItem
|
||||
import eu.kanade.test.DummyTracker
|
||||
import tachiyomi.domain.track.model.Track
|
||||
import java.text.DateFormat
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.graphics.Color
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.track.Tracker
|
||||
import eu.kanade.tachiyomi.dev.preview.DummyTracker
|
||||
import eu.kanade.test.DummyTracker
|
||||
|
||||
internal class TrackLogoIconPreviewProvider : PreviewParameterProvider<Tracker> {
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ import eu.kanade.tachiyomi.data.coil.MangaCoverKeyer
|
|||
import eu.kanade.tachiyomi.data.coil.MangaKeyer
|
||||
import eu.kanade.tachiyomi.data.coil.TachiyomiImageDecoder
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.di.AppModule
|
||||
import eu.kanade.tachiyomi.di.PreferenceModule
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.network.NetworkPreferences
|
||||
import eu.kanade.tachiyomi.ui.base.delegate.SecureActivityDelegate
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package eu.kanade.tachiyomi
|
||||
package eu.kanade.tachiyomi.di
|
||||
|
||||
import android.app.Application
|
||||
import android.os.Build
|
||||
|
@ -7,12 +7,8 @@ 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.base.BasePreferences
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.domain.track.service.TrackPreferences
|
||||
import eu.kanade.domain.track.store.DelayedTrackingStore
|
||||
import eu.kanade.domain.ui.UiPreferences
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.data.download.DownloadCache
|
||||
|
@ -23,19 +19,12 @@ import eu.kanade.tachiyomi.data.track.TrackerManager
|
|||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.network.JavaScriptEngine
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.network.NetworkPreferences
|
||||
import eu.kanade.tachiyomi.source.AndroidSourceManager
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
import eu.kanade.tachiyomi.util.system.isDevFlavor
|
||||
import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory
|
||||
import kotlinx.serialization.json.Json
|
||||
import nl.adaptivity.xmlutil.XmlDeclMode
|
||||
import nl.adaptivity.xmlutil.core.XmlVersion
|
||||
import nl.adaptivity.xmlutil.serialization.XML
|
||||
import tachiyomi.core.preference.AndroidPreferenceStore
|
||||
import tachiyomi.core.preference.PreferenceStore
|
||||
import tachiyomi.core.provider.AndroidBackupFolderProvider
|
||||
import tachiyomi.core.provider.AndroidDownloadFolderProvider
|
||||
import tachiyomi.data.AndroidDatabaseHandler
|
||||
import tachiyomi.data.Database
|
||||
import tachiyomi.data.DatabaseHandler
|
||||
|
@ -44,9 +33,6 @@ import tachiyomi.data.History
|
|||
import tachiyomi.data.Mangas
|
||||
import tachiyomi.data.StringListColumnAdapter
|
||||
import tachiyomi.data.UpdateStrategyColumnAdapter
|
||||
import tachiyomi.domain.backup.service.BackupPreferences
|
||||
import tachiyomi.domain.download.service.DownloadPreferences
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.domain.source.service.SourceManager
|
||||
import tachiyomi.source.local.image.LocalCoverManager
|
||||
import tachiyomi.source.local.io.LocalSourceFileSystem
|
||||
|
@ -152,56 +138,3 @@ class AppModule(val app: Application) : InjektModule {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PreferenceModule(val application: Application) : InjektModule {
|
||||
override fun InjektRegistrar.registerInjectables() {
|
||||
addSingletonFactory<PreferenceStore> {
|
||||
AndroidPreferenceStore(application)
|
||||
}
|
||||
addSingletonFactory {
|
||||
NetworkPreferences(
|
||||
preferenceStore = get(),
|
||||
verboseLogging = isDevFlavor,
|
||||
)
|
||||
}
|
||||
addSingletonFactory {
|
||||
SourcePreferences(get())
|
||||
}
|
||||
addSingletonFactory {
|
||||
SecurityPreferences(get())
|
||||
}
|
||||
addSingletonFactory {
|
||||
LibraryPreferences(get())
|
||||
}
|
||||
addSingletonFactory {
|
||||
ReaderPreferences(get())
|
||||
}
|
||||
addSingletonFactory {
|
||||
TrackPreferences(get())
|
||||
}
|
||||
addSingletonFactory {
|
||||
AndroidDownloadFolderProvider(application)
|
||||
}
|
||||
addSingletonFactory {
|
||||
DownloadPreferences(
|
||||
folderProvider = get<AndroidDownloadFolderProvider>(),
|
||||
preferenceStore = get(),
|
||||
)
|
||||
}
|
||||
addSingletonFactory {
|
||||
AndroidBackupFolderProvider(application)
|
||||
}
|
||||
addSingletonFactory {
|
||||
BackupPreferences(
|
||||
folderProvider = get<AndroidBackupFolderProvider>(),
|
||||
preferenceStore = get(),
|
||||
)
|
||||
}
|
||||
addSingletonFactory {
|
||||
UiPreferences(get())
|
||||
}
|
||||
addSingletonFactory {
|
||||
BasePreferences(application, get())
|
||||
}
|
||||
}
|
||||
}
|
76
app/src/main/java/eu/kanade/tachiyomi/di/PreferenceModule.kt
Normal file
76
app/src/main/java/eu/kanade/tachiyomi/di/PreferenceModule.kt
Normal file
|
@ -0,0 +1,76 @@
|
|||
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.AndroidDownloadFolderProvider
|
||||
import tachiyomi.domain.backup.service.BackupPreferences
|
||||
import tachiyomi.domain.download.service.DownloadPreferences
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
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 {
|
||||
AndroidDownloadFolderProvider(app)
|
||||
}
|
||||
addSingletonFactory {
|
||||
DownloadPreferences(
|
||||
folderProvider = get<AndroidDownloadFolderProvider>(),
|
||||
preferenceStore = get(),
|
||||
)
|
||||
}
|
||||
addSingletonFactory {
|
||||
AndroidBackupFolderProvider(app)
|
||||
}
|
||||
addSingletonFactory {
|
||||
BackupPreferences(
|
||||
folderProvider = get<AndroidBackupFolderProvider>(),
|
||||
preferenceStore = get(),
|
||||
)
|
||||
}
|
||||
addSingletonFactory {
|
||||
UiPreferences(get())
|
||||
}
|
||||
addSingletonFactory {
|
||||
BasePreferences(app, get())
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,7 +56,7 @@ class AndroidSourceManager(
|
|||
extensions.forEach { extension ->
|
||||
extension.sources.forEach {
|
||||
mutableMap[it.id] = it
|
||||
registerStubSource(it.toStubSource())
|
||||
registerStubSource(StubSource.from(it))
|
||||
}
|
||||
}
|
||||
sourcesMapFlow.value = mutableMap
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
package eu.kanade.tachiyomi.source
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import tachiyomi.domain.source.model.StubSource
|
||||
import tachiyomi.source.local.isLocal
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
fun Source.icon(): Drawable? = Injekt.get<ExtensionManager>().getAppIconForSource(this.id)
|
||||
|
||||
fun Source.toStubSource(): StubSource = StubSource(id = id, lang = lang, name = name)
|
||||
|
||||
fun Source.getNameForMangaInfo(): String {
|
||||
val preferences = Injekt.get<SourcePreferences>()
|
||||
val enabledLanguages = preferences.enabledLanguages().get()
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package eu.kanade.tachiyomi.source.model
|
||||
|
||||
import tachiyomi.data.Chapters
|
||||
|
||||
fun SChapter.copyFrom(other: Chapters) {
|
||||
name = other.name
|
||||
url = other.url
|
||||
date_upload = other.date_upload
|
||||
chapter_number = other.chapter_number.toFloat()
|
||||
scanlator = other.scanlator
|
||||
}
|
|
@ -3,58 +3,14 @@ package eu.kanade.tachiyomi.source.model
|
|||
import tachiyomi.data.Mangas
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
|
||||
fun SManga.copyFrom(other: Mangas) {
|
||||
if (other.author != null) {
|
||||
author = other.author
|
||||
}
|
||||
|
||||
if (other.artist != null) {
|
||||
artist = other.artist
|
||||
}
|
||||
|
||||
if (other.description != null) {
|
||||
description = other.description
|
||||
}
|
||||
|
||||
if (other.genre != null) {
|
||||
genre = other.genre!!.joinToString(separator = ", ")
|
||||
}
|
||||
|
||||
if (other.thumbnail_url != null) {
|
||||
thumbnail_url = other.thumbnail_url
|
||||
}
|
||||
|
||||
status = other.status.toInt()
|
||||
|
||||
if (!initialized) {
|
||||
initialized = other.initialized
|
||||
}
|
||||
}
|
||||
|
||||
fun Manga.copyFrom(other: Mangas): Manga {
|
||||
var manga = this
|
||||
if (other.author != null) {
|
||||
manga = manga.copy(author = other.author)
|
||||
}
|
||||
|
||||
if (other.artist != null) {
|
||||
manga = manga.copy(artist = other.artist)
|
||||
}
|
||||
|
||||
if (other.description != null) {
|
||||
manga = manga.copy(description = other.description)
|
||||
}
|
||||
|
||||
if (other.genre != null) {
|
||||
manga = manga.copy(genre = other.genre)
|
||||
}
|
||||
|
||||
if (other.thumbnail_url != null) {
|
||||
manga = manga.copy(thumbnailUrl = other.thumbnail_url)
|
||||
}
|
||||
|
||||
other.author?.let { manga = manga.copy(author = it) }
|
||||
other.artist?.let { manga = manga.copy(artist = it) }
|
||||
other.description?.let { manga = manga.copy(description = it) }
|
||||
other.genre?.let { manga = manga.copy(genre = it) }
|
||||
other.thumbnail_url?.let { manga = manga.copy(thumbnailUrl = it) }
|
||||
manga = manga.copy(status = other.status)
|
||||
|
||||
if (!initialized) {
|
||||
manga = manga.copy(initialized = other.initialized)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package eu.kanade.tachiyomi.dev.preview
|
||||
package eu.kanade.test
|
||||
|
||||
import android.graphics.Color
|
||||
import eu.kanade.tachiyomi.R
|
|
@ -23,6 +23,12 @@ class StubSource(
|
|||
|
||||
override fun toString(): String =
|
||||
if (isInvalid.not()) "$name (${lang.uppercase()})" else id.toString()
|
||||
|
||||
companion object {
|
||||
fun from(source: Source): StubSource {
|
||||
return StubSource(id = source.id, lang = source.lang, name = source.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SourceNotInstalledException : Exception()
|
||||
|
|
Reference in a new issue