Handle delegated source id lists better using a LisenterMutableMap
Better source id comparisons
This commit is contained in:
parent
cf1ce9e069
commit
295af5306b
@ -34,10 +34,10 @@ import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.model.toSManga
|
||||
import eu.kanade.tachiyomi.source.online.MetadataSource
|
||||
import eu.kanade.tachiyomi.source.online.all.MergedSource
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.metadata.metadata.base.getFlatMetadataForManga
|
||||
import exh.metadata.metadata.base.insertFlatMetadataAsync
|
||||
import exh.savedsearches.JsonSavedSearch
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.source.getMainSource
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.decodeFromString
|
||||
@ -529,7 +529,7 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
|
||||
|
||||
internal suspend fun restoreFlatMetadata(manga: Manga, backupFlatMetadata: BackupFlatMetadata) {
|
||||
manga.id?.let { mangaId ->
|
||||
databaseHelper.getFlatMetadataForManga(mangaId).executeAsBlocking().let {
|
||||
databaseHelper.getFlatMetadataForManga(mangaId).executeOnIO().let {
|
||||
if (it == null) {
|
||||
val flatMetadata = backupFlatMetadata.getFlatMetadata(mangaId)
|
||||
databaseHelper.insertFlatMetadataAsync(flatMetadata).await()
|
||||
|
@ -19,7 +19,7 @@ import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.online.all.MergedSource
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import exh.EXHMigrations
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import okio.buffer
|
||||
import okio.gzip
|
||||
|
@ -54,10 +54,10 @@ import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.model.toSManga
|
||||
import eu.kanade.tachiyomi.source.online.all.MergedSource
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.eh.EHentaiThrottleManager
|
||||
import exh.merged.sql.models.MergedMangaReference
|
||||
import exh.savedsearches.JsonSavedSearch
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
@ -1,6 +1,6 @@
|
||||
package eu.kanade.tachiyomi.data.database.queries
|
||||
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import eu.kanade.tachiyomi.data.database.tables.CategoryTable as Category
|
||||
import eu.kanade.tachiyomi.data.database.tables.ChapterTable as Chapter
|
||||
import eu.kanade.tachiyomi.data.database.tables.HistoryTable as History
|
||||
|
@ -38,13 +38,13 @@ import eu.kanade.tachiyomi.util.shouldDownloadNewChapters
|
||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||
import eu.kanade.tachiyomi.util.system.acquireWakeLock
|
||||
import eu.kanade.tachiyomi.util.system.isServiceRunning
|
||||
import exh.LIBRARY_UPDATE_EXCLUDED_SOURCES
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.mangaDexSourceIds
|
||||
import exh.md.utils.FollowStatus
|
||||
import exh.md.utils.MdUtil
|
||||
import exh.metadata.metadata.base.insertFlatMetadata
|
||||
import exh.source.LIBRARY_UPDATE_EXCLUDED_SOURCES
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.source.getMainSource
|
||||
import exh.source.mangaDexSourceIds
|
||||
import exh.util.executeOnIO
|
||||
import exh.util.nullIfBlank
|
||||
import rx.Observable
|
||||
|
@ -19,10 +19,10 @@ import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.util.lang.launchNow
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.source.BlacklistedSources
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import kotlinx.coroutines.async
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
|
@ -19,18 +19,19 @@ import eu.kanade.tachiyomi.source.online.english.HBrowse
|
||||
import eu.kanade.tachiyomi.source.online.english.HentaiCafe
|
||||
import eu.kanade.tachiyomi.source.online.english.Pururin
|
||||
import eu.kanade.tachiyomi.source.online.english.Tsumino
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EIGHTMUSES_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.HBROWSE_SOURCE_ID
|
||||
import exh.HENTAI_CAFE_SOURCE_ID
|
||||
import exh.PERV_EDEN_EN_SOURCE_ID
|
||||
import exh.PERV_EDEN_IT_SOURCE_ID
|
||||
import exh.PURURIN_SOURCE_ID
|
||||
import exh.TSUMINO_SOURCE_ID
|
||||
import exh.source.BlacklistedSources
|
||||
import exh.source.DelegatedHttpSource
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EIGHTMUSES_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
import exh.source.EnhancedHttpSource
|
||||
import exh.source.HBROWSE_SOURCE_ID
|
||||
import exh.source.HENTAI_CAFE_SOURCE_ID
|
||||
import exh.source.PERV_EDEN_EN_SOURCE_ID
|
||||
import exh.source.PERV_EDEN_IT_SOURCE_ID
|
||||
import exh.source.PURURIN_SOURCE_ID
|
||||
import exh.source.TSUMINO_SOURCE_ID
|
||||
import exh.source.handleSourceLibrary
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
@ -119,8 +120,14 @@ open class SourceManager(private val context: Context) {
|
||||
source,
|
||||
delegate.newSourceClass.constructors.find { it.parameters.size == 2 }!!.call(source, context)
|
||||
)
|
||||
val map = listOf(DelegatedSource(enhancedSource.originalSource.name, enhancedSource.originalSource.id, enhancedSource.originalSource::class.qualifiedName ?: delegate.originalSourceQualifiedClassName, (enhancedSource.enhancedSource as DelegatedHttpSource)::class, delegate.factory)).associateBy { it.sourceId }
|
||||
currentDelegatedSources.plusAssign(map)
|
||||
|
||||
currentDelegatedSources[enhancedSource.originalSource.id] = DelegatedSource(
|
||||
enhancedSource.originalSource.name,
|
||||
enhancedSource.originalSource.id,
|
||||
enhancedSource.originalSource::class.qualifiedName ?: delegate.originalSourceQualifiedClassName,
|
||||
(enhancedSource.enhancedSource as DelegatedHttpSource)::class,
|
||||
delegate.factory
|
||||
)
|
||||
enhancedSource
|
||||
} else source
|
||||
|
||||
@ -137,6 +144,9 @@ open class SourceManager(private val context: Context) {
|
||||
|
||||
internal fun unregisterSource(source: Source) {
|
||||
sourcesMap.remove(source.id)
|
||||
// SY -->
|
||||
currentDelegatedSources.remove(source.id)
|
||||
// SY <--
|
||||
}
|
||||
|
||||
private fun createInternalSources(): List<Source> = listOf(
|
||||
@ -250,7 +260,7 @@ open class SourceManager(private val context: Context) {
|
||||
)
|
||||
).associateBy { it.originalSourceQualifiedClassName }
|
||||
|
||||
var currentDelegatedSources = mutableMapOf<Long, DelegatedSource>()
|
||||
val currentDelegatedSources = ListenMutableMap(mutableMapOf<Long, DelegatedSource>(), ::handleSourceLibrary)
|
||||
|
||||
data class DelegatedSource(
|
||||
val sourceName: String,
|
||||
@ -260,5 +270,47 @@ open class SourceManager(private val context: Context) {
|
||||
val factory: Boolean = false
|
||||
)
|
||||
}
|
||||
|
||||
class ListenMutableMap<K, V>(private val internalMap: MutableMap<K, V>, val listener: () -> Unit) : MutableMap<K, V> {
|
||||
override val size: Int
|
||||
get() = internalMap.size
|
||||
override fun containsKey(key: K): Boolean = internalMap.containsKey(key)
|
||||
override fun containsValue(value: V): Boolean = internalMap.containsValue(value)
|
||||
override fun get(key: K): V? = get(key)
|
||||
override fun isEmpty(): Boolean = internalMap.isEmpty()
|
||||
override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
|
||||
get() = internalMap.entries
|
||||
override val keys: MutableSet<K>
|
||||
get() = internalMap.keys
|
||||
override val values: MutableCollection<V>
|
||||
get() = internalMap.values
|
||||
override fun clear() {
|
||||
val clearResult = internalMap.clear()
|
||||
listener()
|
||||
return clearResult
|
||||
}
|
||||
|
||||
override fun put(key: K, value: V): V? {
|
||||
val putResult = internalMap.put(key, value)
|
||||
if (putResult == null) {
|
||||
listener()
|
||||
}
|
||||
return putResult
|
||||
}
|
||||
|
||||
override fun putAll(from: Map<out K, V>) {
|
||||
internalMap.putAll(from)
|
||||
listener()
|
||||
}
|
||||
|
||||
override fun remove(key: K): V? {
|
||||
val removeResult = internalMap.remove(key)
|
||||
if (removeResult != null) {
|
||||
listener()
|
||||
}
|
||||
return removeResult
|
||||
}
|
||||
}
|
||||
|
||||
// SY <--
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||
import eu.kanade.tachiyomi.util.lang.awaitSingle
|
||||
import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import eu.kanade.tachiyomi.util.shouldDownloadNewChapters
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.merged.sql.models.MergedMangaReference
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.util.executeOnIO
|
||||
import okhttp3.Response
|
||||
import rx.Observable
|
||||
|
@ -21,7 +21,7 @@ import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.util.executeOnIO
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
@ -6,7 +6,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
@ -56,10 +56,10 @@ import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import eu.kanade.tachiyomi.widget.EmptyView
|
||||
import exh.isEhBasedSource
|
||||
import exh.md.similar.ui.EnableMangaDexSimilarDialogController
|
||||
import exh.savedsearches.EXHSavedSearch
|
||||
import exh.source.getMainSource
|
||||
import exh.source.isEhBasedSource
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.filter
|
||||
|
@ -17,10 +17,8 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.databinding.SourceComfortableGridItemBinding
|
||||
import eu.kanade.tachiyomi.databinding.SourceCompactGridItemBinding
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.metadata.metadata.base.RaisedSearchMetadata
|
||||
import uy.kohesive.injekt.api.get
|
||||
import exh.source.isEhBasedManga
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMode> /* SY --> */, private val metadata: RaisedSearchMetadata? = null /* SY <-- */) :
|
||||
@ -30,7 +28,7 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
|
||||
// SY <--
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return /* SY --> */ if ((manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID) && preferences.enhancedEHentaiView().get()) R.layout.source_enhanced_ehentai_list_item
|
||||
return /* SY --> */ if (manga.isEhBasedManga() && preferences.enhancedEHentaiView().get()) R.layout.source_enhanced_ehentai_list_item
|
||||
else /* SY <-- */ when (displayMode.get()) {
|
||||
DisplayMode.COMPACT_GRID -> R.layout.source_compact_grid_item
|
||||
DisplayMode.COMFORTABLE_GRID, /* SY --> */ DisplayMode.NO_TITLE_GRID /* SY <-- */ -> R.layout.source_comfortable_grid_item
|
||||
@ -42,7 +40,7 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
|
||||
view: View,
|
||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
||||
): SourceHolder<*> {
|
||||
return /* SY --> */ if ((manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID) && preferences.enhancedEHentaiView().get()) {
|
||||
return /* SY --> */ if (manga.isEhBasedManga() && preferences.enhancedEHentaiView().get()) {
|
||||
SourceEnhancedEHentaiListHolder(view, adapter)
|
||||
} else /* SY <-- */ when (displayMode.get()) {
|
||||
DisplayMode.COMPACT_GRID -> {
|
||||
|
@ -12,13 +12,13 @@ import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
import eu.kanade.tachiyomi.ui.category.CategoryAdapter
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import exh.isMetadataSource
|
||||
import exh.metadata.sql.models.SearchTag
|
||||
import exh.metadata.sql.models.SearchTitle
|
||||
import exh.search.Namespace
|
||||
import exh.search.QueryComponent
|
||||
import exh.search.SearchEngine
|
||||
import exh.search.Text
|
||||
import exh.source.isMetadataSource
|
||||
import exh.util.cancellable
|
||||
import exh.util.executeOnIO
|
||||
import kotlinx.coroutines.CancellationException
|
||||
|
@ -42,14 +42,13 @@ import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.PERV_EDEN_EN_SOURCE_ID
|
||||
import exh.PERV_EDEN_IT_SOURCE_ID
|
||||
import exh.favorites.FavoritesIntroDialog
|
||||
import exh.favorites.FavoritesSyncStatus
|
||||
import exh.mangaDexSourceIds
|
||||
import exh.nHentaiSourceIds
|
||||
import exh.source.PERV_EDEN_EN_SOURCE_ID
|
||||
import exh.source.PERV_EDEN_IT_SOURCE_ID
|
||||
import exh.source.isEhBasedManga
|
||||
import exh.source.mangaDexSourceIds
|
||||
import exh.source.nHentaiSourceIds
|
||||
import exh.ui.LoaderManager
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.drop
|
||||
@ -524,8 +523,7 @@ class LibraryController(
|
||||
|
||||
// SY -->
|
||||
binding.actionToolbar.findItem(R.id.action_clean)?.isVisible = selectedMangas.any {
|
||||
it.source == EH_SOURCE_ID ||
|
||||
it.source == EXH_SOURCE_ID ||
|
||||
it.isEhBasedManga() ||
|
||||
it.source in nHentaiSourceIds ||
|
||||
it.source == PERV_EDEN_EN_SOURCE_ID ||
|
||||
it.source == PERV_EDEN_IT_SOURCE_ID
|
||||
@ -653,8 +651,7 @@ class LibraryController(
|
||||
// SY -->
|
||||
private fun cleanTitles() {
|
||||
val mangas = selectedMangas.filter {
|
||||
it.source == EH_SOURCE_ID ||
|
||||
it.source == EXH_SOURCE_ID ||
|
||||
it.isEhBasedManga() ||
|
||||
it.source in nHentaiSourceIds ||
|
||||
it.source == PERV_EDEN_EN_SOURCE_ID ||
|
||||
it.source == PERV_EDEN_IT_SOURCE_ID
|
||||
|
@ -25,12 +25,11 @@ import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.removeCovers
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.favorites.FavoritesSyncHelper
|
||||
import exh.md.utils.FollowStatus
|
||||
import exh.md.utils.MdUtil
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.source.isEhBasedManga
|
||||
import exh.util.executeOnIO
|
||||
import exh.util.isLewd
|
||||
import exh.util.nullIfBlank
|
||||
@ -525,7 +524,7 @@ class LibraryPresenter(
|
||||
fun downloadUnreadChapters(mangas: List<Manga>) {
|
||||
mangas.forEach { manga ->
|
||||
launchIO {
|
||||
/* SY --> */ val chapters = if (manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID) {
|
||||
/* SY --> */ val chapters = if (manga.isEhBasedManga()) {
|
||||
val chapter = db.getChapters(manga).executeOnIO().minByOrNull { it.source_order }
|
||||
if (chapter != null && !chapter.read) listOf(chapter) else emptyList()
|
||||
} else if (manga.source == MERGED_SOURCE_ID) {
|
||||
@ -672,7 +671,7 @@ class LibraryPresenter(
|
||||
/** Returns first unread chapter of a manga */
|
||||
fun getFirstUnread(manga: Manga): Chapter? {
|
||||
val chapters = (if (manga.source == MERGED_SOURCE_ID) (sourceManager.get(MERGED_SOURCE_ID) as? MergedSource).let { runBlocking { it?.getChaptersFromDB(manga)?.awaitSingle().orEmpty() } } else db.getChapters(manga).executeAsBlocking())
|
||||
return if (manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID) {
|
||||
return if (manga.isEhBasedManga()) {
|
||||
val chapter = chapters.sortedBy { it.source_order }.getOrNull(0)
|
||||
if (chapter?.read == false) chapter else null
|
||||
} else {
|
||||
|
@ -42,11 +42,11 @@ import eu.kanade.tachiyomi.ui.recent.history.HistoryController
|
||||
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXHMigrations
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.eh.EHentaiUpdateWorker
|
||||
import exh.source.BlacklistedSources
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
import exh.uconfig.WarnConfigureDialogController
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
|
@ -99,12 +99,12 @@ import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.getCoordinates
|
||||
import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.isEhBasedSource
|
||||
import exh.md.similar.ui.MangaDexSimilarController
|
||||
import exh.metadata.metadata.base.FlatMetadata
|
||||
import exh.recs.RecommendsController
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.source.getMainSource
|
||||
import exh.source.isEhBasedSource
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.NonCancellable
|
||||
|
@ -41,10 +41,8 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import eu.kanade.tachiyomi.util.updateCoverLastModified
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.debug.DebugToggles
|
||||
import exh.eh.EHentaiUpdateHelper
|
||||
import exh.isEhBasedSource
|
||||
import exh.md.utils.FollowStatus
|
||||
import exh.md.utils.MdUtil
|
||||
import exh.md.utils.scanlatorList
|
||||
@ -53,7 +51,9 @@ import exh.metadata.metadata.base.FlatMetadata
|
||||
import exh.metadata.metadata.base.RaisedSearchMetadata
|
||||
import exh.metadata.metadata.base.getFlatMetadataForManga
|
||||
import exh.metadata.metadata.base.insertFlatMetadataAsync
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.source.getMainSource
|
||||
import exh.source.isEhBasedSource
|
||||
import exh.util.shouldDeleteChapters
|
||||
import exh.util.trimOrNull
|
||||
import kotlinx.coroutines.Job
|
||||
|
@ -10,9 +10,8 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.databinding.ChaptersItemBinding
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.ui.manga.chapter.base.BaseChapterHolder
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.metadata.MetadataUtil
|
||||
import exh.source.isEhBasedManga
|
||||
import java.util.Date
|
||||
|
||||
class ChapterHolder(
|
||||
@ -60,11 +59,11 @@ class ChapterHolder(
|
||||
|
||||
if (chapter.date_upload > 0) {
|
||||
// SY -->
|
||||
if (manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID) {
|
||||
if (manga.isEhBasedManga()) {
|
||||
descriptions.add(MetadataUtil.EX_DATE_FORMAT.format(Date(chapter.date_upload)))
|
||||
} else /* SY <-- */ descriptions.add(adapter.dateFormat.format(Date(chapter.date_upload)))
|
||||
}
|
||||
if ((!chapter.read || (adapter.preserveReadingPosition && (manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID))) && chapter.last_page_read > 0) {
|
||||
if ((!chapter.read || (adapter.preserveReadingPosition && manga.isEhBasedManga())) && chapter.last_page_read > 0) {
|
||||
val lastPageRead = SpannableString(itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1)).apply {
|
||||
setSpan(ForegroundColorSpan(adapter.readColor), 0, length, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import eu.kanade.tachiyomi.source.online.all.MangaDex
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.source.getMainSource
|
||||
import exh.util.SourceTagsUtil
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
|
@ -20,10 +20,10 @@ import eu.kanade.tachiyomi.source.online.NamespaceSource
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import exh.isEhBasedSource
|
||||
import exh.metadata.metadata.base.RaisedSearchMetadata
|
||||
import exh.metadata.metadata.base.RaisedSearchMetadata.Companion.TAG_TYPE_VIRTUAL
|
||||
import exh.source.getMainSource
|
||||
import exh.source.isEhBasedSource
|
||||
import exh.util.getRaisedTags
|
||||
import exh.util.makeSearchChip
|
||||
import exh.util.setChipsExtended
|
||||
|
@ -14,8 +14,8 @@ import eu.kanade.tachiyomi.databinding.EditMergedSettingsDialogBinding
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.merged.sql.models.MergedMangaReference
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class EditMergedSettingsDialog : DialogController, EditMergedMangaAdapter.EditMergedMangaItemListener {
|
||||
|
@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.mangaDexSourceIds
|
||||
import exh.source.mangaDexSourceIds
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
|
@ -68,7 +68,7 @@ import eu.kanade.tachiyomi.util.view.showBar
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.widget.SimpleAnimationListener
|
||||
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
|
||||
import exh.isEhBasedSource
|
||||
import exh.source.isEhBasedSource
|
||||
import exh.util.defaultReaderType
|
||||
import exh.util.mangaType
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -34,15 +34,14 @@ import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import eu.kanade.tachiyomi.util.updateCoverLastModified
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.md.utils.FollowStatus
|
||||
import exh.md.utils.MdUtil
|
||||
import exh.md.utils.scanlatorList
|
||||
import exh.metadata.metadata.base.RaisedSearchMetadata
|
||||
import exh.metadata.metadata.base.getFlatMetadataForManga
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.source.getMainSource
|
||||
import exh.source.isEhBasedManga
|
||||
import exh.util.defaultReaderType
|
||||
import exh.util.mangaType
|
||||
import exh.util.shouldDeleteChapters
|
||||
@ -451,7 +450,7 @@ class ReaderPresenter(
|
||||
if (selectedChapter.pages?.lastIndex == page.index && shouldTrack) {
|
||||
selectedChapter.chapter.read = true
|
||||
// SY -->
|
||||
if (manga?.source == EH_SOURCE_ID || manga?.source == EXH_SOURCE_ID) {
|
||||
if (manga?.isEhBasedManga() == true) {
|
||||
chapterList
|
||||
.filter { it.chapter.source_order > selectedChapter.chapter.source_order }
|
||||
.onEach {
|
||||
|
@ -10,8 +10,7 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerPageHolder
|
||||
import eu.kanade.tachiyomi.util.lang.plusAssign
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.source.isEhBasedSource
|
||||
import rx.Completable
|
||||
import rx.Observable
|
||||
import rx.schedulers.Schedulers
|
||||
@ -188,7 +187,7 @@ class HttpPageLoader(
|
||||
}
|
||||
// EXH -->
|
||||
// Grab a new image URL on EXH sources
|
||||
if (source.id == EH_SOURCE_ID || source.id == EXH_SOURCE_ID) {
|
||||
if (source.isEhBasedSource()) {
|
||||
page.imageUrl = null
|
||||
}
|
||||
|
||||
|
@ -39,11 +39,11 @@ import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||
import eu.kanade.tachiyomi.util.system.powerManager
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.debug.SettingsDebugController
|
||||
import exh.log.EHLogLevel
|
||||
import exh.source.BlacklistedSources
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
|
@ -16,6 +16,7 @@ import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
||||
import com.tfcporciuncula.flow.Preference
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
||||
import eu.kanade.tachiyomi.databinding.EhDialogCategoriesBinding
|
||||
@ -34,8 +35,6 @@ import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.eh.EHentaiUpdateWorker
|
||||
import exh.eh.EHentaiUpdateWorkerConstants
|
||||
import exh.eh.EHentaiUpdaterStats
|
||||
@ -43,6 +42,7 @@ import exh.favorites.FavoritesIntroDialog
|
||||
import exh.favorites.LocalFavoritesStorage
|
||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||
import exh.metadata.metadata.base.getFlatMetadataForManga
|
||||
import exh.source.isEhBasedManga
|
||||
import exh.uconfig.WarnConfigureDialogController
|
||||
import exh.ui.login.LoginController
|
||||
import exh.util.floor
|
||||
@ -640,12 +640,12 @@ class SettingsEhController : SettingsController() {
|
||||
context.getString(R.string.gallery_updater_stats_text, getRelativeTimeString(getRelativeTimeFromNow(stats.startTime.milliseconds), context), stats.updateCount, stats.possibleUpdates)
|
||||
} else context.getString(R.string.gallery_updater_not_ran_yet)
|
||||
|
||||
val allMeta = db.getFavoriteMangaWithMetadata().executeAsBlocking().filter {
|
||||
it.source == EH_SOURCE_ID || it.source == EXH_SOURCE_ID
|
||||
}.mapNotNull {
|
||||
db.getFlatMetadataForManga(it.id!!).executeOnIO()
|
||||
?.raise<EHentaiSearchMetadata>()
|
||||
}.toList()
|
||||
val allMeta = db.getFavoriteMangaWithMetadata().executeAsBlocking()
|
||||
.filter(Manga::isEhBasedManga)
|
||||
.mapNotNull {
|
||||
db.getFlatMetadataForManga(it.id!!).executeOnIO()
|
||||
?.raise<EHentaiSearchMetadata>()
|
||||
}.toList()
|
||||
|
||||
fun metaInRelativeDuration(duration: Duration): Int {
|
||||
val durationMs = duration.toLongMilliseconds()
|
||||
|
@ -7,8 +7,7 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.source.isEhBasedManga
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.util.Date
|
||||
@ -134,7 +133,7 @@ fun syncChaptersWithSource(
|
||||
}
|
||||
|
||||
// --> EXH (carry over reading progress)
|
||||
if (manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID) {
|
||||
if (manga.isEhBasedManga()) {
|
||||
val finalAdded = toAdd.subtract(readded)
|
||||
if (finalAdded.isNotEmpty()) {
|
||||
val max = dbChapters.maxByOrNull { it.last_page_read }
|
||||
|
@ -1,88 +0,0 @@
|
||||
package exh
|
||||
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.online.all.Hitomi
|
||||
import eu.kanade.tachiyomi.source.online.all.MangaDex
|
||||
import eu.kanade.tachiyomi.source.online.all.NHentai
|
||||
import eu.kanade.tachiyomi.source.online.all.PervEden
|
||||
import eu.kanade.tachiyomi.source.online.english.EightMuses
|
||||
import eu.kanade.tachiyomi.source.online.english.HBrowse
|
||||
import eu.kanade.tachiyomi.source.online.english.HentaiCafe
|
||||
import eu.kanade.tachiyomi.source.online.english.Pururin
|
||||
import eu.kanade.tachiyomi.source.online.english.Tsumino
|
||||
|
||||
/**
|
||||
* Source helpers
|
||||
*/
|
||||
|
||||
// Lewd source IDs
|
||||
const val LEWD_SOURCE_SERIES = 6900L
|
||||
const val EH_SOURCE_ID = LEWD_SOURCE_SERIES + 1
|
||||
const val EXH_SOURCE_ID = LEWD_SOURCE_SERIES + 2
|
||||
const val PERV_EDEN_EN_SOURCE_ID = 4673633799850248749
|
||||
const val PERV_EDEN_IT_SOURCE_ID = 1433898225963724122
|
||||
const val HENTAI_CAFE_SOURCE_ID = 260868874183818481
|
||||
const val PURURIN_SOURCE_ID = 2221515250486218861
|
||||
const val TSUMINO_SOURCE_ID = 6707338697138388238
|
||||
const val EIGHTMUSES_SOURCE_ID = 1802675169972965535
|
||||
const val HBROWSE_SOURCE_ID = 1401584337232758222
|
||||
const val MERGED_SOURCE_ID = LEWD_SOURCE_SERIES + 69
|
||||
|
||||
private val DELEGATED_METADATA_SOURCES = listOf(
|
||||
HentaiCafe::class,
|
||||
Pururin::class,
|
||||
Tsumino::class,
|
||||
HBrowse::class,
|
||||
EightMuses::class,
|
||||
Hitomi::class,
|
||||
PervEden::class,
|
||||
NHentai::class
|
||||
)
|
||||
|
||||
private val hitomiClass = listOf(Hitomi::class)
|
||||
private val nHentaiClass = listOf(NHentai::class)
|
||||
private val mangaDexClass = listOf(MangaDex::class)
|
||||
|
||||
// Used to speed up isLewdSource
|
||||
val metadataDelegatedSourceIds by lazy {
|
||||
SourceManager.currentDelegatedSources.filter {
|
||||
it.value.newSourceClass in DELEGATED_METADATA_SOURCES
|
||||
}.map { it.value.sourceId }.sorted()
|
||||
}
|
||||
|
||||
val hitomiSourceIds by lazy {
|
||||
SourceManager.currentDelegatedSources.filter {
|
||||
it.value.newSourceClass in hitomiClass
|
||||
}.map { it.value.sourceId }.sorted()
|
||||
}
|
||||
|
||||
val nHentaiSourceIds by lazy {
|
||||
SourceManager.currentDelegatedSources.filter {
|
||||
it.value.newSourceClass in nHentaiClass
|
||||
}.map { it.value.sourceId }.sorted()
|
||||
}
|
||||
|
||||
val mangaDexSourceIds by lazy {
|
||||
SourceManager.currentDelegatedSources.filter {
|
||||
it.value.newSourceClass in mangaDexClass
|
||||
}.map { it.value.sourceId }.sorted()
|
||||
}
|
||||
|
||||
// This method MUST be fast!
|
||||
fun isMetadataSource(source: Long) = source in 6900..6999 ||
|
||||
metadataDelegatedSourceIds.binarySearch(source) >= 0
|
||||
|
||||
val LIBRARY_UPDATE_EXCLUDED_SOURCES by lazy {
|
||||
listOf(
|
||||
EH_SOURCE_ID,
|
||||
EXH_SOURCE_ID,
|
||||
HENTAI_CAFE_SOURCE_ID,
|
||||
TSUMINO_SOURCE_ID,
|
||||
PURURIN_SOURCE_ID,
|
||||
*hitomiSourceIds.toTypedArray(),
|
||||
*nHentaiSourceIds.toTypedArray()
|
||||
)
|
||||
}
|
||||
|
||||
fun Source.isEhBasedSource() = id == EH_SOURCE_ID || id == EXH_SOURCE_ID
|
@ -26,6 +26,13 @@ import eu.kanade.tachiyomi.source.online.all.Hitomi
|
||||
import eu.kanade.tachiyomi.source.online.all.NHentai
|
||||
import exh.merged.sql.models.MergedMangaReference
|
||||
import exh.source.BlacklistedSources
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.HBROWSE_SOURCE_ID
|
||||
import exh.source.HENTAI_CAFE_SOURCE_ID
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.source.PERV_EDEN_EN_SOURCE_ID
|
||||
import exh.source.PERV_EDEN_IT_SOURCE_ID
|
||||
import exh.source.TSUMINO_SOURCE_ID
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
@ -41,7 +48,7 @@ object EXHMigrations {
|
||||
private val db: DatabaseHelper by injectLazy()
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
|
||||
private val logger = XLog.tag("EXHMigrations")
|
||||
private val logger by lazy { XLog.tag("EXHMigrations") }
|
||||
|
||||
/**
|
||||
* Performs a migration when the application is updated.
|
||||
|
@ -10,15 +10,16 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.toSManga
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXHMigrations
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.eh.EHentaiThrottleManager
|
||||
import exh.eh.EHentaiUpdateWorker
|
||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||
import exh.metadata.metadata.base.getFlatMetadataForManga
|
||||
import exh.metadata.metadata.base.insertFlatMetadataAsync
|
||||
import exh.savedsearches.JsonSavedSearch
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
import exh.source.isEhBasedManga
|
||||
import exh.util.cancellable
|
||||
import exh.util.executeOnIO
|
||||
import exh.util.jobScheduler
|
||||
@ -54,9 +55,8 @@ object DebugFunctions {
|
||||
val metadataManga = db.getFavoriteMangaWithMetadata().executeOnIO()
|
||||
|
||||
val allManga = metadataManga.asFlow().cancellable().mapNotNull { manga ->
|
||||
if (manga.source != EH_SOURCE_ID && manga.source != EXH_SOURCE_ID) {
|
||||
null
|
||||
} else manga
|
||||
if (manga.isEhBasedManga()) manga
|
||||
else null
|
||||
}.toList()
|
||||
|
||||
allManga.forEach { manga ->
|
||||
@ -77,9 +77,8 @@ object DebugFunctions {
|
||||
val metadataManga = db.getFavoriteMangaWithMetadata().executeOnIO()
|
||||
|
||||
val allManga = metadataManga.asFlow().cancellable().mapNotNull { manga ->
|
||||
if (manga.source != EH_SOURCE_ID && manga.source != EXH_SOURCE_ID) {
|
||||
null
|
||||
} else manga
|
||||
if (manga.isEhBasedManga()) manga
|
||||
else null
|
||||
}.toList()
|
||||
val eh = sourceManager.get(EH_SOURCE_ID)
|
||||
val ex = sourceManager.get(EXH_SOURCE_ID)
|
||||
@ -107,9 +106,8 @@ object DebugFunctions {
|
||||
val metadataManga = db.getFavoriteMangaWithMetadata().executeOnIO()
|
||||
|
||||
val allManga = metadataManga.asFlow().cancellable().mapNotNull { manga ->
|
||||
if (manga.source != EH_SOURCE_ID && manga.source != EXH_SOURCE_ID) {
|
||||
null
|
||||
} else manga
|
||||
if (manga.isEhBasedManga()) manga
|
||||
else null
|
||||
}.toList()
|
||||
|
||||
allManga.forEach { manga ->
|
||||
@ -126,9 +124,8 @@ object DebugFunctions {
|
||||
val metadataManga = db.getFavoriteMangaWithMetadata().executeOnIO()
|
||||
|
||||
val allManga = metadataManga.asFlow().cancellable().mapNotNull { manga ->
|
||||
if (manga.source != EH_SOURCE_ID && manga.source != EXH_SOURCE_ID) {
|
||||
null
|
||||
} else manga
|
||||
if (manga.isEhBasedManga()) manga
|
||||
else null
|
||||
}.toList()
|
||||
|
||||
allManga.forEach { manga ->
|
||||
|
@ -20,13 +20,12 @@ import eu.kanade.tachiyomi.source.model.toSChapter
|
||||
import eu.kanade.tachiyomi.source.model.toSManga
|
||||
import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.debug.DebugToggles
|
||||
import exh.eh.EHentaiUpdateWorkerConstants.UPDATES_PER_ITERATION
|
||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||
import exh.metadata.metadata.base.getFlatMetadataForManga
|
||||
import exh.metadata.metadata.base.insertFlatMetadataAsync
|
||||
import exh.source.isEhBasedManga
|
||||
import exh.util.cancellable
|
||||
import exh.util.executeOnIO
|
||||
import exh.util.jobScheduler
|
||||
@ -140,7 +139,7 @@ class EHentaiUpdateWorker : JobService() {
|
||||
logger.d("Filtering manga and raising metadata...")
|
||||
val curTime = System.currentTimeMillis()
|
||||
val allMeta = metadataManga.asFlow().cancellable().mapNotNull { manga ->
|
||||
if (manga.source != EH_SOURCE_ID && manga.source != EXH_SOURCE_ID) {
|
||||
if (!manga.isEhBasedManga()) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,13 @@ import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.powerManager
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.GalleryAddEvent
|
||||
import exh.GalleryAdder
|
||||
import exh.eh.EHentaiThrottleManager
|
||||
import exh.eh.EHentaiUpdateWorker
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
import exh.source.isEhBasedManga
|
||||
import exh.util.executeOnIO
|
||||
import exh.util.ignore
|
||||
import exh.util.trans
|
||||
@ -87,7 +88,7 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
val libraryManga = db.getLibraryMangas().executeOnIO()
|
||||
val seenManga = HashSet<Long>(libraryManga.size)
|
||||
libraryManga.forEach {
|
||||
if (it.source != EXH_SOURCE_ID && it.source != EH_SOURCE_ID) return@forEach
|
||||
if (!it.isEhBasedManga()) return@forEach
|
||||
|
||||
if (it.id in seenManga) {
|
||||
val inCategories = db.getCategoriesForManga(it).executeOnIO()
|
||||
|
@ -3,9 +3,8 @@ package exh.favorites
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||
import exh.source.isEhBasedManga
|
||||
import exh.util.executeOnIO
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
@ -128,7 +127,7 @@ class LocalFavoritesStorage {
|
||||
}
|
||||
|
||||
private fun validateDbManga(manga: Manga) =
|
||||
manga.favorite && (manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID)
|
||||
manga.favorite && manga.isEhBasedManga()
|
||||
|
||||
companion object {
|
||||
const val MAX_CATEGORIES = 9
|
||||
|
@ -1,7 +1,5 @@
|
||||
package exh.source
|
||||
|
||||
import exh.MERGED_SOURCE_ID
|
||||
|
||||
object BlacklistedSources {
|
||||
val EHENTAI_EXT_SOURCES = listOf(
|
||||
8100626124886895451,
|
||||
|
107
app/src/main/java/exh/source/SourceHelper.kt
Normal file
107
app/src/main/java/exh/source/SourceHelper.kt
Normal file
@ -0,0 +1,107 @@
|
||||
package exh.source
|
||||
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.online.all.Hitomi
|
||||
import eu.kanade.tachiyomi.source.online.all.MangaDex
|
||||
import eu.kanade.tachiyomi.source.online.all.NHentai
|
||||
import eu.kanade.tachiyomi.source.online.all.PervEden
|
||||
import eu.kanade.tachiyomi.source.online.english.EightMuses
|
||||
import eu.kanade.tachiyomi.source.online.english.HBrowse
|
||||
import eu.kanade.tachiyomi.source.online.english.HentaiCafe
|
||||
import eu.kanade.tachiyomi.source.online.english.Pururin
|
||||
import eu.kanade.tachiyomi.source.online.english.Tsumino
|
||||
|
||||
/**
|
||||
* Source helpers
|
||||
*/
|
||||
|
||||
// Lewd source IDs
|
||||
const val LEWD_SOURCE_SERIES = 6900L
|
||||
const val EH_SOURCE_ID = LEWD_SOURCE_SERIES + 1
|
||||
const val EXH_SOURCE_ID = LEWD_SOURCE_SERIES + 2
|
||||
const val PERV_EDEN_EN_SOURCE_ID = 4673633799850248749
|
||||
const val PERV_EDEN_IT_SOURCE_ID = 1433898225963724122
|
||||
const val HENTAI_CAFE_SOURCE_ID = 260868874183818481
|
||||
const val PURURIN_SOURCE_ID = 2221515250486218861
|
||||
const val TSUMINO_SOURCE_ID = 6707338697138388238
|
||||
const val EIGHTMUSES_SOURCE_ID = 1802675169972965535
|
||||
const val HBROWSE_SOURCE_ID = 1401584337232758222
|
||||
const val MERGED_SOURCE_ID = LEWD_SOURCE_SERIES + 69
|
||||
|
||||
private val DELEGATED_METADATA_SOURCES by lazy {
|
||||
listOf(
|
||||
HentaiCafe::class,
|
||||
Pururin::class,
|
||||
Tsumino::class,
|
||||
HBrowse::class,
|
||||
EightMuses::class,
|
||||
Hitomi::class,
|
||||
PervEden::class,
|
||||
NHentai::class
|
||||
)
|
||||
}
|
||||
|
||||
// Used to speed up isLewdSource
|
||||
var metadataDelegatedSourceIds: List<Long> = emptyList()
|
||||
|
||||
var hitomiSourceIds: List<Long> = emptyList()
|
||||
|
||||
var nHentaiSourceIds: List<Long> = emptyList()
|
||||
|
||||
var mangaDexSourceIds: List<Long> = emptyList()
|
||||
|
||||
var LIBRARY_UPDATE_EXCLUDED_SOURCES = listOf(
|
||||
EH_SOURCE_ID,
|
||||
EXH_SOURCE_ID,
|
||||
HENTAI_CAFE_SOURCE_ID,
|
||||
TSUMINO_SOURCE_ID,
|
||||
PURURIN_SOURCE_ID
|
||||
)
|
||||
|
||||
fun handleSourceLibrary() {
|
||||
metadataDelegatedSourceIds = SourceManager.currentDelegatedSources
|
||||
.filter {
|
||||
it.value.newSourceClass in DELEGATED_METADATA_SOURCES
|
||||
}
|
||||
.map { it.value.sourceId }
|
||||
.sorted()
|
||||
|
||||
hitomiSourceIds = SourceManager.currentDelegatedSources
|
||||
.filter {
|
||||
it.value.newSourceClass == Hitomi::class
|
||||
}
|
||||
.map { it.value.sourceId }
|
||||
.sorted()
|
||||
|
||||
nHentaiSourceIds = SourceManager.currentDelegatedSources
|
||||
.filter {
|
||||
it.value.newSourceClass == NHentai::class
|
||||
}
|
||||
.map { it.value.sourceId }
|
||||
.sorted()
|
||||
|
||||
mangaDexSourceIds = SourceManager.currentDelegatedSources
|
||||
.filter {
|
||||
it.value.newSourceClass == MangaDex::class
|
||||
}
|
||||
.map { it.value.sourceId }
|
||||
.sorted()
|
||||
|
||||
LIBRARY_UPDATE_EXCLUDED_SOURCES = listOf(
|
||||
EH_SOURCE_ID,
|
||||
EXH_SOURCE_ID,
|
||||
HENTAI_CAFE_SOURCE_ID,
|
||||
TSUMINO_SOURCE_ID,
|
||||
PURURIN_SOURCE_ID
|
||||
) + hitomiSourceIds + nHentaiSourceIds
|
||||
}
|
||||
|
||||
// This method MUST be fast!
|
||||
fun isMetadataSource(source: Long) = source in 6900..6999 ||
|
||||
metadataDelegatedSourceIds.binarySearch(source) >= 0
|
||||
|
||||
fun Source.isEhBasedSource() = id == EH_SOURCE_ID || id == EXH_SOURCE_ID
|
||||
|
||||
fun Manga.isEhBasedManga() = source == EH_SOURCE_ID || source == EXH_SOURCE_ID
|
@ -8,9 +8,9 @@ import eu.kanade.tachiyomi.network.await
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.log.maybeInjectEHLogger
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
|
@ -2,9 +2,8 @@ package exh.util
|
||||
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.nHentaiSourceIds
|
||||
import exh.source.isEhBasedManga
|
||||
import exh.source.nHentaiSourceIds
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
@ -12,7 +11,7 @@ fun Manga.isLewd(): Boolean {
|
||||
val sourceName = Injekt.get<SourceManager>().get(source)?.name
|
||||
val currentTags = getGenres().orEmpty()
|
||||
|
||||
if (source == EH_SOURCE_ID || source == EXH_SOURCE_ID || source in nHentaiSourceIds) {
|
||||
if (isEhBasedManga() || source in nHentaiSourceIds) {
|
||||
return currentTags.none { tag -> isNonHentaiTag(tag) }
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,13 @@ package exh.util
|
||||
|
||||
import android.graphics.Color
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.PURURIN_SOURCE_ID
|
||||
import exh.TSUMINO_SOURCE_ID
|
||||
import exh.hitomiSourceIds
|
||||
import exh.metadata.metadata.base.RaisedTag
|
||||
import exh.nHentaiSourceIds
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
import exh.source.PURURIN_SOURCE_ID
|
||||
import exh.source.TSUMINO_SOURCE_ID
|
||||
import exh.source.hitomiSourceIds
|
||||
import exh.source.nHentaiSourceIds
|
||||
import java.util.Locale
|
||||
|
||||
object SourceTagsUtil {
|
||||
|
@ -3,9 +3,9 @@ package exh.util
|
||||
import android.content.Context
|
||||
import com.google.android.material.chip.Chip
|
||||
import com.google.android.material.chip.ChipGroup
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
|
||||
/**
|
||||
* Replaces chips in a ChipGroup.
|
||||
|
Loading…
x
Reference in New Issue
Block a user