Minor cleanup
(cherry picked from commit 4a6571d310ecf2bf77e86a303f1788aaaab3df25) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/di/AppModule.kt # app/src/main/java/eu/kanade/tachiyomi/source/SourceExtensions.kt # app/src/main/java/eu/kanade/tachiyomi/source/model/SMangaExtensions.kt
This commit is contained in:
parent
19746904e1
commit
5d565f436f
@ -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> {
|
||||
|
||||
|
@ -46,6 +46,9 @@ import eu.kanade.tachiyomi.data.coil.PagePreviewFetcher
|
||||
import eu.kanade.tachiyomi.data.coil.PagePreviewKeyer
|
||||
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.di.SYPreferenceModule
|
||||
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,11 +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.BuildConfig
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
@ -24,11 +21,8 @@ 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.storage.CbzCrypto
|
||||
import eu.kanade.tachiyomi.util.system.isDevFlavor
|
||||
import exh.eh.EHentaiUpdateHelper
|
||||
import exh.pref.DelegateSourcePreferences
|
||||
import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory
|
||||
@ -37,10 +31,6 @@ import net.zetetic.database.sqlcipher.SupportOpenHelperFactory
|
||||
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
|
||||
@ -50,9 +40,6 @@ import tachiyomi.data.Mangas
|
||||
import tachiyomi.data.StringListColumnAdapter
|
||||
import tachiyomi.data.UpdateStrategyColumnAdapter
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import tachiyomi.domain.backup.service.BackupPreferences
|
||||
import tachiyomi.domain.download.service.DownloadPreferences
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.domain.manga.interactor.GetCustomMangaInfo
|
||||
import tachiyomi.domain.source.service.SourceManager
|
||||
import tachiyomi.source.local.image.LocalCoverManager
|
||||
@ -192,72 +179,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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SY -->
|
||||
class SYPreferenceModule(val application: Application) : InjektModule {
|
||||
|
||||
override fun InjektRegistrar.registerInjectables() {
|
||||
addSingletonFactory {
|
||||
DelegateSourcePreferences(
|
||||
preferenceStore = get(),
|
||||
)
|
||||
}
|
||||
|
||||
addSingletonFactory {
|
||||
UnsortedPreferences(get())
|
||||
}
|
||||
}
|
||||
}
|
||||
// SY <--
|
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())
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package eu.kanade.tachiyomi.di
|
||||
|
||||
import android.app.Application
|
||||
import exh.pref.DelegateSourcePreferences
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
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 SYPreferenceModule(val application: Application) : InjektModule {
|
||||
|
||||
override fun InjektRegistrar.registerInjectables() {
|
||||
addSingletonFactory {
|
||||
DelegateSourcePreferences(
|
||||
preferenceStore = get(),
|
||||
)
|
||||
}
|
||||
|
||||
addSingletonFactory {
|
||||
UnsortedPreferences(get())
|
||||
}
|
||||
}
|
||||
}
|
@ -99,7 +99,7 @@ class AndroidSourceManager(
|
||||
extensions.forEach { extension ->
|
||||
extension.sources.mapNotNull { it.toInternalSource() }.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(
|
||||
// SY -->
|
||||
mergeSources: List<Source>?,
|
||||
|
@ -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,64 +3,14 @@ package eu.kanade.tachiyomi.source.model
|
||||
import tachiyomi.data.Mangas
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
|
||||
fun SManga.copyFrom(other: Mangas) {
|
||||
// EXH -->
|
||||
if (other.title.isNotBlank() && originalTitle != other.title) {
|
||||
title = other.title
|
||||
}
|
||||
// EXH <--
|
||||
|
||||
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(ogAuthor = other.author)
|
||||
}
|
||||
|
||||
if (other.artist != null) {
|
||||
manga = manga.copy(ogArtist = other.artist)
|
||||
}
|
||||
|
||||
if (other.description != null) {
|
||||
manga = manga.copy(ogDescription = other.description)
|
||||
}
|
||||
|
||||
if (other.genre != null) {
|
||||
manga = manga.copy(ogGenre = other.genre)
|
||||
}
|
||||
|
||||
if (other.thumbnail_url != null) {
|
||||
manga = manga.copy(thumbnailUrl = other.thumbnail_url)
|
||||
}
|
||||
|
||||
other.author?.let { manga = manga.copy(ogAuthor = it) }
|
||||
other.artist?.let { manga = manga.copy(ogArtist = it) }
|
||||
other.description?.let { manga = manga.copy(ogDescription = it) }
|
||||
other.genre?.let { manga = manga.copy(ogGenre = it) }
|
||||
other.thumbnail_url?.let { manga = manga.copy(thumbnailUrl = it) }
|
||||
manga = manga.copy(ogStatus = other.status)
|
||||
|
||||
if (!initialized) {
|
||||
manga = manga.copy(initialized = other.initialized)
|
||||
}
|
||||
|
@ -4,9 +4,11 @@ import android.graphics.Paint.STRIKE_THRU_TEXT_FLAG
|
||||
import android.view.View
|
||||
import eu.davidea.viewholders.FlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.databinding.MigrationSourceItemBinding
|
||||
import eu.kanade.tachiyomi.source.icon
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import exh.util.capitalize
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter) :
|
||||
FlexibleViewHolder(view, adapter) {
|
||||
@ -22,7 +24,7 @@ class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter) :
|
||||
binding.title.text = sourceName
|
||||
// Update circle letter image.
|
||||
itemView.post {
|
||||
val icon = source.icon()
|
||||
val icon = Injekt.get<ExtensionManager>().getAppIconForSource(source.id)
|
||||
if (icon != null) {
|
||||
binding.image.setImageDrawable(icon)
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user