From 6822c907a1bb8b90b61b80642ad01e2996962b60 Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Sun, 23 Jul 2023 19:53:21 +0200 Subject: [PATCH 01/14] Import of a multiplatform workaround Sometimes it dosen't recognise the commonMain in source-api. This is a workaround so there are no problems with further coding. Is taken from a Tachiyomi commit --- source-api/build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source-api/build.gradle.kts b/source-api/build.gradle.kts index 285873f7ed..05e6e791d3 100644 --- a/source-api/build.gradle.kts +++ b/source-api/build.gradle.kts @@ -19,6 +19,10 @@ kotlin { dependencies { implementation(project(":core")) api(libs.preferencektx) + + // Workaround for https://youtrack.jetbrains.com/issue/KT-57605 + implementation(kotlinx.coroutines.android) + implementation(project.dependencies.platform(kotlinx.coroutines.bom)) } } } From 9a64d2a9a00b75a87551be6b78bdc68edc9e84af Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:13:22 +0200 Subject: [PATCH 02/14] Add Data Saver This adds the data saver from TachiyomiSY --- .../interactor/GetEnabledMangaSources.kt | 45 ++++++- .../ToggleExcludeFromMangaDataSaver.kt | 20 +++ .../source/service/SourcePreferences.kt | 34 +++++ .../browse/manga/MangaSourcesScreen.kt | 18 +++ .../settings/screen/SettingsAdvancedScreen.kt | 82 ++++++++++++ .../data/download/manga/MangaDownloader.kt | 22 +++- .../manga/source/MangaSourcesScreenModel.kt | 28 +++- .../ui/browse/manga/source/MangaSourcesTab.kt | 4 + .../ui/reader/loader/HttpPageLoader.kt | 12 +- .../java/exh/source/BlacklistedSources.kt | 7 + app/src/main/java/exh/source/SourcesIds.kt | 5 + app/src/main/java/exh/util/DataSaver.kt | 122 ++++++++++++++++++ .../domain/source/manga/model/Source.kt | 3 + i18n/src/main/res/values/strings-aniyomi.xml | 18 +++ .../tachiyomi/source/online/HttpSource.kt | 3 +- 15 files changed, 408 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/eu/kanade/domain/source/manga/interactor/ToggleExcludeFromMangaDataSaver.kt create mode 100644 app/src/main/java/exh/source/BlacklistedSources.kt create mode 100644 app/src/main/java/exh/source/SourcesIds.kt create mode 100644 app/src/main/java/exh/util/DataSaver.kt diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt index 2c8a2b63ff..ec44368089 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt @@ -1,6 +1,7 @@ package eu.kanade.domain.source.manga.interactor import eu.kanade.domain.source.service.SourcePreferences +import exh.source.BlacklistedSources import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged @@ -18,22 +19,52 @@ class GetEnabledMangaSources( fun subscribe(): Flow> { return combine( preferences.pinnedMangaSources().changes(), - preferences.enabledLanguages().changes(), - preferences.disabledMangaSources().changes(), - preferences.lastUsedMangaSource().changes(), + combine( + preferences.enabledLanguages().changes(), + preferences.disabledMangaSources().changes(), + preferences.lastUsedMangaSource().changes(), + ) { a, b, c -> Triple(a, b, c) }, + // SY --> + combine( + preferences.dataSaverExcludedSources().changes(), + preferences.sourcesTabSourcesInCategories().changes(), + preferences.sourcesTabCategoriesFilter().changes(), + ) { a, b, c -> Triple(a, b, c) }, + // SY <-- repository.getMangaSources(), - ) { pinnedSourceIds, enabledLanguages, disabledSources, lastUsedSource, sources -> + ) { pinnedMangaSourceIds, (enabledLanguages, disabledSources, lastUsedSource), (excludedFromDataSaver, sourcesInCategories, sourceCategoriesFilter), sources -> + val sourcesAndCategories = sourcesInCategories.map { + it.split('|').let { (source, test) -> source.toLong() to test } + } + val sourcesInSourceCategories = sourcesAndCategories.map { it.first } sources .filter { it.lang in enabledLanguages || it.id == LocalMangaSource.ID } - .filterNot { it.id.toString() in disabledSources } + .filterNot { it.id.toString() in disabledSources || it.id in BlacklistedSources.HIDDEN_SOURCES } .sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name }) .flatMap { - val flag = if ("${it.id}" in pinnedSourceIds) Pins.pinned else Pins.unpinned - val source = it.copy(pin = flag) + val flag = if ("${it.id}" in pinnedMangaSourceIds) Pins.pinned else Pins.unpinned + // SY --> + val categories = sourcesAndCategories.filter { (id) -> id == it.id } + .map(Pair<*, String>::second) + .toSet() + // SY <-- + val source = it.copy( + pin = flag, + /*isExcludedFromDataSaver = it.id.toString() in excludedFromDataSaver,*/ + /*categories = categories,*/ + ) val toFlatten = mutableListOf(source) if (source.id == lastUsedSource) { toFlatten.add(source.copy(isUsedLast = true, pin = source.pin - Pin.Actual)) } + // SY --> + categories.forEach { category -> + toFlatten.add(source.copy(/*category = category,*/ pin = source.pin - Pin.Actual)) + } + if (sourceCategoriesFilter && Pin.Actual !in toFlatten[0].pin && source.id in sourcesInSourceCategories) { + toFlatten.removeAt(0) + } + // SY <-- toFlatten } } diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/ToggleExcludeFromMangaDataSaver.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/ToggleExcludeFromMangaDataSaver.kt new file mode 100644 index 0000000000..409f8a8baa --- /dev/null +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/ToggleExcludeFromMangaDataSaver.kt @@ -0,0 +1,20 @@ +package eu.kanade.domain.source.manga.interactor + +import eu.kanade.domain.source.service.SourcePreferences +import tachiyomi.core.preference.getAndSet +import tachiyomi.domain.source.manga.model.Source + +class ToggleExcludeFromMangaDataSaver( + private val preferences: SourcePreferences, +) { + + fun await(source: Source) { + preferences.dataSaverExcludedSources().getAndSet { + if (source.id.toString() in it) { + it - source.id.toString() + } else { + it + source.id.toString() + } + } + } +} diff --git a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt index cc5ef87211..f083d4b828 100644 --- a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt @@ -43,4 +43,38 @@ class SourcePreferences( fun hideInAnimeLibraryItems() = preferenceStore.getBoolean("browse_hide_in_anime_library_items", false) fun hideInMangaLibraryItems() = preferenceStore.getBoolean("browse_hide_in_library_items", false) + + // SY --> + fun enableSourceBlacklist() = preferenceStore.getBoolean("eh_enable_source_blacklist", true) + + fun sourcesTabCategories() = preferenceStore.getStringSet("sources_tab_categories", mutableSetOf()) + + fun sourcesTabCategoriesFilter() = preferenceStore.getBoolean("sources_tab_categories_filter", false) + + fun sourcesTabSourcesInCategories() = preferenceStore.getStringSet("sources_tab_source_categories", mutableSetOf()) + + fun dataSaver() = preferenceStore.getEnum("data_saver", DataSaver.NONE) + + fun dataSaverIgnoreJpeg() = preferenceStore.getBoolean("ignore_jpeg", false) + + fun dataSaverIgnoreGif() = preferenceStore.getBoolean("ignore_gif", true) + + fun dataSaverImageQuality() = preferenceStore.getInt("data_saver_image_quality", 80) + + fun dataSaverImageFormatJpeg() = preferenceStore.getBoolean("data_saver_image_format_jpeg", false) + + fun dataSaverServer() = preferenceStore.getString("data_saver_server", "") + + fun dataSaverColorBW() = preferenceStore.getBoolean("data_saver_color_bw", false) + + fun dataSaverExcludedSources() = preferenceStore.getStringSet("data_saver_excluded", emptySet()) + + fun dataSaverDownloader() = preferenceStore.getBoolean("data_saver_downloader", true) + + enum class DataSaver { + NONE, + BANDWIDTH_HERO, + WSRV_NL, + } + // SY <-- } diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt index 8d97d67559..0aff550b9f 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt @@ -160,6 +160,9 @@ fun MangaSourceOptionsDialog( source: Source, onClickPin: () -> Unit, onClickDisable: () -> Unit, + // SY --> + onClickToggleDataSaver: (() -> Unit)?, + // SY <-- onDismiss: () -> Unit, ) { AlertDialog( @@ -185,6 +188,21 @@ fun MangaSourceOptionsDialog( .padding(vertical = 16.dp), ) } + // SY --> + if (onClickToggleDataSaver != null) { + Text( + text = if (source.isExcludedFromDataSaver) { + stringResource(id = R.string.data_saver_stop_exclude) + } else { + stringResource(id = R.string.data_saver_exclude) + }, + modifier = Modifier + .clickable(onClick = onClickToggleDataSaver) + .fillMaxWidth() + .padding(vertical = 16.dp), + ) + } + // SY <-- } }, onDismissRequest = onDismiss, diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt index 12109eef70..84a2c7dec0 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt @@ -25,6 +25,8 @@ import androidx.core.net.toUri import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow import eu.kanade.domain.base.BasePreferences +import eu.kanade.domain.source.service.SourcePreferences +import eu.kanade.domain.source.service.SourcePreferences.DataSaver import eu.kanade.presentation.more.settings.Preference import eu.kanade.presentation.more.settings.screen.debug.DebugInfoScreen import eu.kanade.presentation.util.collectAsState @@ -115,6 +117,9 @@ object SettingsAdvancedScreen : SearchableSettings { getNetworkGroup(networkPreferences = networkPreferences), getLibraryGroup(), getExtensionsGroup(basePreferences = basePreferences), + // SY --> + getDataSaverGroup(), + // SY <-- ) } @@ -400,4 +405,81 @@ object SettingsAdvancedScreen : SearchableSettings { ), ) } + // SY --> + @Composable + private fun getDataSaverGroup(): Preference.PreferenceGroup { + val sourcePreferences = remember { Injekt.get() } + val dataSaver by sourcePreferences.dataSaver().collectAsState() + return Preference.PreferenceGroup( + title = stringResource(R.string.data_saver), + preferenceItems = listOf( + Preference.PreferenceItem.ListPreference( + pref = sourcePreferences.dataSaver(), + title = stringResource(R.string.data_saver), + subtitle = stringResource(R.string.data_saver_summary), + entries = mapOf( + DataSaver.NONE to stringResource(R.string.disabled), + DataSaver.BANDWIDTH_HERO to stringResource(R.string.bandwidth_hero), + DataSaver.WSRV_NL to stringResource(R.string.wsrv), + ), + ), + Preference.PreferenceItem.EditTextPreference( + pref = sourcePreferences.dataSaverServer(), + title = stringResource(R.string.bandwidth_data_saver_server), + subtitle = stringResource(R.string.data_saver_server_summary), + enabled = dataSaver == DataSaver.BANDWIDTH_HERO, + ), + Preference.PreferenceItem.SwitchPreference( + pref = sourcePreferences.dataSaverDownloader(), + title = stringResource(R.string.data_saver_downloader), + enabled = dataSaver != DataSaver.NONE, + ), + Preference.PreferenceItem.SwitchPreference( + pref = sourcePreferences.dataSaverIgnoreJpeg(), + title = stringResource(R.string.data_saver_ignore_jpeg), + enabled = dataSaver != DataSaver.NONE, + ), + Preference.PreferenceItem.SwitchPreference( + pref = sourcePreferences.dataSaverIgnoreGif(), + title = stringResource(R.string.data_saver_ignore_gif), + enabled = dataSaver != DataSaver.NONE, + ), + Preference.PreferenceItem.ListPreference( + pref = sourcePreferences.dataSaverImageQuality(), + title = stringResource(R.string.data_saver_image_quality), + subtitle = stringResource(R.string.data_saver_image_quality_summary), + entries = listOf( + "10%", + "20%", + "40%", + "50%", + "70%", + "80%", + "90%", + "95%", + ).associateBy { it.trimEnd('%').toInt() }, + enabled = dataSaver != DataSaver.NONE, + ), + kotlin.run { + val dataSaverImageFormatJpeg by sourcePreferences.dataSaverImageFormatJpeg().collectAsState() + Preference.PreferenceItem.SwitchPreference( + pref = sourcePreferences.dataSaverImageFormatJpeg(), + title = stringResource(R.string.data_saver_image_format), + subtitle = if (dataSaverImageFormatJpeg) { + stringResource(R.string.data_saver_image_format_summary_on) + } else { + stringResource(R.string.data_saver_image_format_summary_off) + }, + enabled = dataSaver != DataSaver.NONE, + ) + }, + Preference.PreferenceItem.SwitchPreference( + pref = sourcePreferences.dataSaverColorBW(), + title = stringResource(R.string.data_saver_color_bw), + enabled = dataSaver == DataSaver.BANDWIDTH_HERO, + ), + ), + ) + } + // SY <-- } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt index 9baa850bd0..1e69a6e8d2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt @@ -5,6 +5,7 @@ import com.hippo.unifile.UniFile import com.jakewharton.rxrelay.PublishRelay import eu.kanade.domain.entries.manga.model.getComicInfo import eu.kanade.domain.items.chapter.model.toSChapter +import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.cache.ChapterCache import eu.kanade.tachiyomi.data.download.manga.model.MangaDownload @@ -16,6 +17,8 @@ import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.DiskUtil.NOMEDIA_FILE import eu.kanade.tachiyomi.util.storage.saveTo +import exh.util.DataSaver +import exh.util.DataSaver.Companion.getImage import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async @@ -75,6 +78,9 @@ class MangaDownloader( private val chapterCache: ChapterCache = Injekt.get(), private val downloadPreferences: DownloadPreferences = Injekt.get(), private val xml: XML = Injekt.get(), + // SY --> + private val sourcePreferences: SourcePreferences = Injekt.get(), + // SY <-- ) { /** @@ -331,6 +337,12 @@ class MangaDownloader( reIndexedPages } + val dataSaver = if (sourcePreferences.dataSaverDownloader().get()) { + DataSaver(download.source, sourcePreferences) + } else { + DataSaver.NoOp + } + // Delete all temporary (unfinished) files tmpDir.listFiles() ?.filter { it.name!!.endsWith(".tmp") } @@ -353,7 +365,7 @@ class MangaDownloader( pageList.asFlow() .flatMapMerge(concurrency = 2) { page -> flow { - withIOContext { getOrDownloadImage(page, download, tmpDir) } + withIOContext { getOrDownloadImage(page, download, tmpDir, dataSaver) } emit(page) }.flowOn(Dispatchers.IO) } @@ -380,7 +392,7 @@ class MangaDownloader( * @param download the download of the page. * @param tmpDir the temporary directory of the download. */ - private suspend fun getOrDownloadImage(page: Page, download: MangaDownload, tmpDir: UniFile) { + private suspend fun getOrDownloadImage(page: Page, download: MangaDownload, tmpDir: UniFile, dataSaver: DataSaver) { // If the image URL is empty, do nothing if (page.imageUrl == null) { return @@ -401,7 +413,7 @@ class MangaDownloader( val file = when { imageFile != null -> imageFile chapterCache.isImageInCache(page.imageUrl!!) -> copyImageFromCache(chapterCache.getImageFile(page.imageUrl!!), tmpDir, filename) - else -> downloadImage(page, download.source, tmpDir, filename) + else -> downloadImage(page, download.source, tmpDir, filename, dataSaver) } // When the page is ready, set page path, progress (just in case) and status @@ -426,11 +438,11 @@ class MangaDownloader( * @param tmpDir the temporary directory of the download. * @param filename the filename of the image. */ - private suspend fun downloadImage(page: Page, source: HttpSource, tmpDir: UniFile, filename: String): UniFile { + private suspend fun downloadImage(page: Page, source: HttpSource, tmpDir: UniFile, filename: String, dataSaver: DataSaver): UniFile { page.status = Page.State.DOWNLOAD_IMAGE page.progress = 0 return flow { - val response = source.getImage(page) + val response = source.getImage(page, dataSaver) val file = tmpDir.createFile("$filename.tmp") try { response.body.source().saveTo(file.openOutputStream()) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt index b9705bd295..a7af78b7c5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt @@ -5,6 +5,7 @@ import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.coroutineScope import eu.kanade.domain.base.BasePreferences import eu.kanade.domain.source.manga.interactor.GetEnabledMangaSources +import eu.kanade.domain.source.manga.interactor.ToggleExcludeFromMangaDataSaver import eu.kanade.domain.source.manga.interactor.ToggleMangaSource import eu.kanade.domain.source.manga.interactor.ToggleMangaSourcePin import eu.kanade.domain.source.service.SourcePreferences @@ -14,6 +15,8 @@ import eu.kanade.tachiyomi.util.system.PINNED_KEY import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.flow.update import logcat.LogPriority @@ -31,7 +34,10 @@ class MangaSourcesScreenModel( private val getEnabledSources: GetEnabledMangaSources = Injekt.get(), private val toggleSource: ToggleMangaSource = Injekt.get(), private val toggleSourcePin: ToggleMangaSourcePin = Injekt.get(), -) : StateScreenModel(MangaSourcesState()) { + // SY --> + private val toggleExcludeFromMangaDataSaver: ToggleExcludeFromMangaDataSaver = Injekt.get(), + // SY <-- + ) : StateScreenModel(MangaSourcesState()) { private val _events = Channel(Int.MAX_VALUE) val events = _events.receiveAsFlow() @@ -45,6 +51,17 @@ class MangaSourcesScreenModel( } .collectLatest(::collectLatestSources) } + // SY --> + sourcePreferences.dataSaver().changes() + .onEach { + mutableState.update { + it.copy( + dataSaverEnabled = sourcePreferences.dataSaver().get() != SourcePreferences.DataSaver.NONE, + ) + } + } + .launchIn(coroutineScope) + // SY <-- } private fun collectLatestSources(sources: List) { @@ -97,6 +114,12 @@ class MangaSourcesScreenModel( toggleSourcePin.await(source) } + // SY --> + fun toggleExcludeFromMangaDataSaver(source: Source) { + toggleExcludeFromMangaDataSaver.await(source) + } + // SY <-- + fun showSourceDialog(source: Source) { mutableState.update { it.copy(dialog = Dialog(source)) } } @@ -117,6 +140,9 @@ data class MangaSourcesState( val dialog: MangaSourcesScreenModel.Dialog? = null, val isLoading: Boolean = true, val items: List = emptyList(), + // SY --> + val dataSaverEnabled: Boolean = false, + // SY <-- ) { val isEmpty = items.isEmpty() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesTab.kt index 553ac32544..2a5793febd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesTab.kt @@ -66,6 +66,10 @@ fun Screen.mangaSourcesTab(): TabContent { screenModel.toggleSource(source) screenModel.closeDialog() }, + onClickToggleDataSaver = { + screenModel.toggleExcludeFromMangaDataSaver(source) + screenModel.closeDialog() + }.takeIf { state.dataSaverEnabled }, onDismiss = screenModel::closeDialog, ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt index 8f9607be24..6d3f5df961 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt @@ -1,11 +1,14 @@ package eu.kanade.tachiyomi.ui.reader.loader +import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.data.cache.ChapterCache import eu.kanade.tachiyomi.data.database.models.manga.toDomainChapter import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderPage +import exh.util.DataSaver +import exh.util.DataSaver.Companion.getImage import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -31,6 +34,9 @@ class HttpPageLoader( private val chapter: ReaderChapter, private val source: HttpSource, private val chapterCache: ChapterCache = Injekt.get(), + // SY --> + private val sourcePreferences: SourcePreferences = Injekt.get(), + // SY <-- ) : PageLoader() { private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) @@ -42,6 +48,10 @@ class HttpPageLoader( private val preloadSize = 4 + // SY --> + private val dataSaver = DataSaver(source, sourcePreferences) + // SY <-- + init { scope.launchIO { flow { @@ -203,7 +213,7 @@ class HttpPageLoader( if (!chapterCache.isImageInCache(imageUrl)) { page.status = Page.State.DOWNLOAD_IMAGE - val imageResponse = source.getImage(page) + val imageResponse = source.getImage(page, dataSaver) chapterCache.putImageToCache(imageUrl, imageResponse) } diff --git a/app/src/main/java/exh/source/BlacklistedSources.kt b/app/src/main/java/exh/source/BlacklistedSources.kt new file mode 100644 index 0000000000..804f197d37 --- /dev/null +++ b/app/src/main/java/exh/source/BlacklistedSources.kt @@ -0,0 +1,7 @@ +package exh.source + +object BlacklistedSources { + var HIDDEN_SOURCES = setOf( + MERGED_SOURCE_ID, + ) +} diff --git a/app/src/main/java/exh/source/SourcesIds.kt b/app/src/main/java/exh/source/SourcesIds.kt new file mode 100644 index 0000000000..762d640319 --- /dev/null +++ b/app/src/main/java/exh/source/SourcesIds.kt @@ -0,0 +1,5 @@ +package exh.source + +// Lewd source IDs +const val LEWD_SOURCE_SERIES = 6900L +const val MERGED_SOURCE_ID = LEWD_SOURCE_SERIES + 69 diff --git a/app/src/main/java/exh/util/DataSaver.kt b/app/src/main/java/exh/util/DataSaver.kt new file mode 100644 index 0000000000..4a4c90cc2b --- /dev/null +++ b/app/src/main/java/exh/util/DataSaver.kt @@ -0,0 +1,122 @@ +package exh.util + +import eu.kanade.domain.source.service.SourcePreferences +import eu.kanade.domain.source.service.SourcePreferences.DataSaver.BANDWIDTH_HERO +import eu.kanade.domain.source.service.SourcePreferences.DataSaver.NONE +import eu.kanade.domain.source.service.SourcePreferences.DataSaver.WSRV_NL +import eu.kanade.tachiyomi.animesource.AnimeSource +import eu.kanade.tachiyomi.source.MangaSource +import eu.kanade.tachiyomi.source.model.Page +import eu.kanade.tachiyomi.source.online.HttpSource +import okhttp3.Response +import rx.Observable +import tachiyomi.core.preference.Preference + +interface DataSaver { + + fun compress(imageUrl: String): String + + companion object { + val NoOp = object : DataSaver { + override fun compress(imageUrl: String): String { + return imageUrl + } + } + + fun HttpSource.fetchImage(page: Page, dataSaver: DataSaver): Observable { + val imageUrl = page.imageUrl ?: return fetchImage(page) + page.imageUrl = dataSaver.compress(imageUrl) + return fetchImage(page) + .doOnNext { + page.imageUrl = imageUrl + } + } + + suspend fun HttpSource.getImage(page: Page, dataSaver: DataSaver): Response { + val imageUrl = page.imageUrl ?: return getImage(page) + page.imageUrl = dataSaver.compress(imageUrl) + return try { + getImage(page) + } finally { + page.imageUrl = imageUrl + } + } + } +} + +fun DataSaver(source: MangaSource, preferences: SourcePreferences): DataSaver { + val dataSaver = preferences.dataSaver().get() + if (dataSaver != NONE && source.id.toString() in preferences.dataSaverExcludedSources().get()) { + return DataSaver.NoOp + } + return when (dataSaver) { + NONE -> DataSaver.NoOp + BANDWIDTH_HERO -> BandwidthHeroDataSaver(preferences) + WSRV_NL -> WsrvNlDataSaver(preferences) + } +} + +private class BandwidthHeroDataSaver(preferences: SourcePreferences) : DataSaver { + private val dataSavedServer = preferences.dataSaverServer().get().trimEnd('/') + + private val ignoreJpg = preferences.dataSaverIgnoreJpeg().get() + private val ignoreGif = preferences.dataSaverIgnoreGif().get() + + private val format = preferences.dataSaverImageFormatJpeg().toIntRepresentation() + private val quality = preferences.dataSaverImageQuality().get() + private val colorBW = preferences.dataSaverColorBW().toIntRepresentation() + + override fun compress(imageUrl: String): String { + return if (dataSavedServer.isNotBlank() && !imageUrl.contains(dataSavedServer)) { + when { + imageUrl.contains(".jpeg", true) || imageUrl.contains(".jpg", true) -> if (ignoreJpg) imageUrl else getUrl(imageUrl) + imageUrl.contains(".gif", true) -> if (ignoreGif) imageUrl else getUrl(imageUrl) + else -> getUrl(imageUrl) + } + } else { + imageUrl + } + } + + private fun getUrl(imageUrl: String): String { + // Network Request sent for the Bandwidth Hero Proxy server + return "$dataSavedServer/?jpg=$format&l=$quality&bw=$colorBW&url=$imageUrl" + } + + private fun Preference.toIntRepresentation() = if (get()) "1" else "0" +} + +private class WsrvNlDataSaver(preferences: SourcePreferences) : DataSaver { + private val ignoreJpg = preferences.dataSaverIgnoreJpeg().get() + private val ignoreGif = preferences.dataSaverIgnoreGif().get() + + private val format = preferences.dataSaverImageFormatJpeg().get() + private val quality = preferences.dataSaverImageQuality().get() + + override fun compress(imageUrl: String): String { + return when { + imageUrl.contains(".jpeg", true) || imageUrl.contains(".jpg", true) -> if (ignoreJpg) imageUrl else getUrl(imageUrl) + imageUrl.contains(".gif", true) -> if (ignoreGif) imageUrl else getUrl(imageUrl) + else -> getUrl(imageUrl) + } + } + + private fun getUrl(imageUrl: String): String { + // Network Request sent to wsrv + return "https://wsrv.nl/?url=$imageUrl" + if (imageUrl.contains(".webp", true) || imageUrl.contains(".gif", true)) { + if (!format) { + // Preserve output image extension for animated images(.webp and .gif) + "&q=$quality&n=-1" + } else { + // Do not preserve output Extension if User asked to convert into Jpeg + "&output=jpg&q=$quality&n=-1" + } + } else { + if (format) { + "&output=jpg&q=$quality" + } else { + "&output=webp&q=$quality" + } + } + } +} diff --git a/domain/src/main/java/tachiyomi/domain/source/manga/model/Source.kt b/domain/src/main/java/tachiyomi/domain/source/manga/model/Source.kt index fe1991b7ca..daaa08ddf5 100644 --- a/domain/src/main/java/tachiyomi/domain/source/manga/model/Source.kt +++ b/domain/src/main/java/tachiyomi/domain/source/manga/model/Source.kt @@ -8,6 +8,9 @@ data class Source( val isStub: Boolean, val pin: Pins = Pins.unpinned, val isUsedLast: Boolean = false, + // SY --> + val isExcludedFromDataSaver: Boolean = false, + // SY <-- ) { val visualName: String diff --git a/i18n/src/main/res/values/strings-aniyomi.xml b/i18n/src/main/res/values/strings-aniyomi.xml index fa0ffbf6e6..b4cfbae4a5 100644 --- a/i18n/src/main/res/values/strings-aniyomi.xml +++ b/i18n/src/main/res/values/strings-aniyomi.xml @@ -292,4 +292,22 @@ Choose video quality: Extension settings Save screenshot + + Exclude from data saver + Stop excluding from data saver + Data Saver + Compress images before downloading or loading in reader + Use data saver in the downloader + Ignore Jpeg Images + Ignore Gif Animations + Image Quality + Higher values mean that a higher percentage of the image quality is saved, but it also means the file size is larger, 80 percent is a good median between file size and image quality + Compress to Jpeg + The Jpeg file size is considerably smaller then Webp is(meaning more data is saved), but it makes the images lose more quality as well.\nCurrently compresses to Jpeg + The Jpeg file size is considerably smaller then Webp is(meaning more data is saved), but it makes the images lose more quality as well.\nCurrently compresses to Webp + Convert to Black And White + Bandwidth Hero (requires a Bandwidth Hero Proxy server) + wsrv.nl + Bandwidth Hero Proxy Server + Put Bandwidth Hero Proxy server url here \ No newline at end of file diff --git a/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt b/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt index f9e616dcdf..e7ebbe39d8 100644 --- a/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt +++ b/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt @@ -311,7 +311,8 @@ abstract class HttpSource : CatalogueSource { * * @param page the page whose source image has to be downloaded. */ - suspend fun getImage(page: Page): Response { + /* SY --> */ + open /* SY <-- */ suspend fun getImage(page: Page): Response { // images will be cached or saved manually, so don't take up network cache return client.newCachelessCallWithProgress(imageRequest(page), page) .awaitSuccess() From 9672d103ee02dc54efe1f778b1dd08c65da96666 Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Mon, 24 Jul 2023 20:04:31 +0200 Subject: [PATCH 03/14] fix registerInjectables --- app/src/main/java/eu/kanade/SYDomainModule.kt | 14 ++++++++++++++ .../more/settings/screen/SettingsAdvancedScreen.kt | 1 + app/src/main/java/eu/kanade/tachiyomi/App.kt | 4 ++++ .../browse/manga/source/MangaSourcesScreenModel.kt | 2 +- app/src/main/java/exh/util/DataSaver.kt | 1 - 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/eu/kanade/SYDomainModule.kt diff --git a/app/src/main/java/eu/kanade/SYDomainModule.kt b/app/src/main/java/eu/kanade/SYDomainModule.kt new file mode 100644 index 0000000000..12e64be8d6 --- /dev/null +++ b/app/src/main/java/eu/kanade/SYDomainModule.kt @@ -0,0 +1,14 @@ +package eu.kanade + +import eu.kanade.domain.source.manga.interactor.ToggleExcludeFromMangaDataSaver +import uy.kohesive.injekt.api.InjektModule +import uy.kohesive.injekt.api.InjektRegistrar +import uy.kohesive.injekt.api.addFactory +import uy.kohesive.injekt.api.get + +class SYDomainModule : InjektModule { + + override fun InjektRegistrar.registerInjectables() { + addFactory { ToggleExcludeFromMangaDataSaver(get()) } + } +} diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt index 84a2c7dec0..03ba4b81b3 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt @@ -405,6 +405,7 @@ object SettingsAdvancedScreen : SearchableSettings { ), ) } + // SY --> @Composable private fun getDataSaverGroup(): Preference.PreferenceGroup { diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 5b754c0573..e9912fb2be 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -22,6 +22,7 @@ import coil.decode.GifDecoder import coil.decode.ImageDecoderDecoder import coil.disk.DiskCache import coil.util.DebugLogger +import eu.kanade.SYDomainModule import eu.kanade.domain.DomainModule import eu.kanade.domain.base.BasePreferences import eu.kanade.domain.ui.UiPreferences @@ -85,6 +86,9 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory { Injekt.importModule(AppModule(this)) Injekt.importModule(PreferenceModule(this)) Injekt.importModule(DomainModule()) + // SY --> + Injekt.importModule(SYDomainModule()) + // SY <-- setupAcra() setupNotificationChannels() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt index a7af78b7c5..e8403c2f1c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt @@ -37,7 +37,7 @@ class MangaSourcesScreenModel( // SY --> private val toggleExcludeFromMangaDataSaver: ToggleExcludeFromMangaDataSaver = Injekt.get(), // SY <-- - ) : StateScreenModel(MangaSourcesState()) { +) : StateScreenModel(MangaSourcesState()) { private val _events = Channel(Int.MAX_VALUE) val events = _events.receiveAsFlow() diff --git a/app/src/main/java/exh/util/DataSaver.kt b/app/src/main/java/exh/util/DataSaver.kt index 4a4c90cc2b..70867a4ca0 100644 --- a/app/src/main/java/exh/util/DataSaver.kt +++ b/app/src/main/java/exh/util/DataSaver.kt @@ -4,7 +4,6 @@ import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.source.service.SourcePreferences.DataSaver.BANDWIDTH_HERO import eu.kanade.domain.source.service.SourcePreferences.DataSaver.NONE import eu.kanade.domain.source.service.SourcePreferences.DataSaver.WSRV_NL -import eu.kanade.tachiyomi.animesource.AnimeSource import eu.kanade.tachiyomi.source.MangaSource import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.online.HttpSource From 1148f3c6b3f91fc5c1adbaff1e7340be6b321aac Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Mon, 24 Jul 2023 20:18:58 +0200 Subject: [PATCH 04/14] fuck lint --- .../domain/source/manga/interactor/GetEnabledMangaSources.kt | 2 +- .../kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt index ec44368089..40a4c0ed7b 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt @@ -59,7 +59,7 @@ class GetEnabledMangaSources( } // SY --> categories.forEach { category -> - toFlatten.add(source.copy(/*category = category,*/ pin = source.pin - Pin.Actual)) + toFlatten.add(source.copy(pin = source.pin - Pin.Actual)) } if (sourceCategoriesFilter && Pin.Actual !in toFlatten[0].pin && source.id in sourcesInSourceCategories) { toFlatten.removeAt(0) diff --git a/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt b/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt index e7ebbe39d8..d0aa5b2da3 100644 --- a/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt +++ b/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt @@ -311,8 +311,7 @@ abstract class HttpSource : CatalogueSource { * * @param page the page whose source image has to be downloaded. */ - /* SY --> */ - open /* SY <-- */ suspend fun getImage(page: Page): Response { + open suspend fun getImage(page: Page): Response { // images will be cached or saved manually, so don't take up network cache return client.newCachelessCallWithProgress(imageRequest(page), page) .awaitSuccess() From a92e321588d48b42ccd91d242aea4796e8688eac Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Tue, 25 Jul 2023 13:47:01 +0200 Subject: [PATCH 05/14] clean up --- .../eu/kanade/{ => domain}/SYDomainModule.kt | 2 +- .../interactor/GetEnabledMangaSources.kt | 30 ++----------------- app/src/main/java/eu/kanade/tachiyomi/App.kt | 2 +- .../manga/source/MangaSourcesScreenModel.kt | 3 +- 4 files changed, 7 insertions(+), 30 deletions(-) rename app/src/main/java/eu/kanade/{ => domain}/SYDomainModule.kt (94%) diff --git a/app/src/main/java/eu/kanade/SYDomainModule.kt b/app/src/main/java/eu/kanade/domain/SYDomainModule.kt similarity index 94% rename from app/src/main/java/eu/kanade/SYDomainModule.kt rename to app/src/main/java/eu/kanade/domain/SYDomainModule.kt index 12e64be8d6..2315a60bc4 100644 --- a/app/src/main/java/eu/kanade/SYDomainModule.kt +++ b/app/src/main/java/eu/kanade/domain/SYDomainModule.kt @@ -1,4 +1,4 @@ -package eu.kanade +package eu.kanade.domain import eu.kanade.domain.source.manga.interactor.ToggleExcludeFromMangaDataSaver import uy.kohesive.injekt.api.InjektModule diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt index 40a4c0ed7b..185247c5ab 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt @@ -19,52 +19,28 @@ class GetEnabledMangaSources( fun subscribe(): Flow> { return combine( preferences.pinnedMangaSources().changes(), + preferences.enabledLanguages().changes(), combine( - preferences.enabledLanguages().changes(), preferences.disabledMangaSources().changes(), preferences.lastUsedMangaSource().changes(), - ) { a, b, c -> Triple(a, b, c) }, - // SY --> - combine( preferences.dataSaverExcludedSources().changes(), - preferences.sourcesTabSourcesInCategories().changes(), - preferences.sourcesTabCategoriesFilter().changes(), ) { a, b, c -> Triple(a, b, c) }, - // SY <-- repository.getMangaSources(), - ) { pinnedMangaSourceIds, (enabledLanguages, disabledSources, lastUsedSource), (excludedFromDataSaver, sourcesInCategories, sourceCategoriesFilter), sources -> - val sourcesAndCategories = sourcesInCategories.map { - it.split('|').let { (source, test) -> source.toLong() to test } - } - val sourcesInSourceCategories = sourcesAndCategories.map { it.first } + ) { pinnedMangaSourceIds, enabledLanguages, (disabledSources, lastUsedSource, excludedFromDataSaver), sources -> sources .filter { it.lang in enabledLanguages || it.id == LocalMangaSource.ID } .filterNot { it.id.toString() in disabledSources || it.id in BlacklistedSources.HIDDEN_SOURCES } .sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name }) .flatMap { val flag = if ("${it.id}" in pinnedMangaSourceIds) Pins.pinned else Pins.unpinned - // SY --> - val categories = sourcesAndCategories.filter { (id) -> id == it.id } - .map(Pair<*, String>::second) - .toSet() - // SY <-- val source = it.copy( pin = flag, - /*isExcludedFromDataSaver = it.id.toString() in excludedFromDataSaver,*/ - /*categories = categories,*/ + isExcludedFromDataSaver = it.id.toString() in excludedFromDataSaver, ) val toFlatten = mutableListOf(source) if (source.id == lastUsedSource) { toFlatten.add(source.copy(isUsedLast = true, pin = source.pin - Pin.Actual)) } - // SY --> - categories.forEach { category -> - toFlatten.add(source.copy(pin = source.pin - Pin.Actual)) - } - if (sourceCategoriesFilter && Pin.Actual !in toFlatten[0].pin && source.id in sourcesInSourceCategories) { - toFlatten.removeAt(0) - } - // SY <-- toFlatten } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index e9912fb2be..3ae2619248 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -22,8 +22,8 @@ import coil.decode.GifDecoder import coil.decode.ImageDecoderDecoder import coil.disk.DiskCache import coil.util.DebugLogger -import eu.kanade.SYDomainModule import eu.kanade.domain.DomainModule +import eu.kanade.domain.SYDomainModule import eu.kanade.domain.base.BasePreferences import eu.kanade.domain.ui.UiPreferences import eu.kanade.domain.ui.model.setAppCompatDelegateThemeMode diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt index e8403c2f1c..64fbfff5d4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt @@ -9,6 +9,7 @@ import eu.kanade.domain.source.manga.interactor.ToggleExcludeFromMangaDataSaver import eu.kanade.domain.source.manga.interactor.ToggleMangaSource import eu.kanade.domain.source.manga.interactor.ToggleMangaSourcePin import eu.kanade.domain.source.service.SourcePreferences +import eu.kanade.domain.source.service.SourcePreferences.DataSaver import eu.kanade.presentation.browse.manga.MangaSourceUiModel import eu.kanade.tachiyomi.util.system.LAST_USED_KEY import eu.kanade.tachiyomi.util.system.PINNED_KEY @@ -56,7 +57,7 @@ class MangaSourcesScreenModel( .onEach { mutableState.update { it.copy( - dataSaverEnabled = sourcePreferences.dataSaver().get() != SourcePreferences.DataSaver.NONE, + dataSaverEnabled = sourcePreferences.dataSaver().get() != DataSaver.NONE, ) } } From c33fbb925684149bc30b3da41481c294d54ea86f Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Tue, 25 Jul 2023 14:09:22 +0200 Subject: [PATCH 06/14] SY flags & disable some prefs for now --- .../source/manga/interactor/GetEnabledMangaSources.kt | 4 ++++ .../eu/kanade/domain/source/service/SourcePreferences.kt | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt index 185247c5ab..20aeb9b6cd 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt @@ -23,7 +23,9 @@ class GetEnabledMangaSources( combine( preferences.disabledMangaSources().changes(), preferences.lastUsedMangaSource().changes(), + // SY --> preferences.dataSaverExcludedSources().changes(), + // SY <-- ) { a, b, c -> Triple(a, b, c) }, repository.getMangaSources(), ) { pinnedMangaSourceIds, enabledLanguages, (disabledSources, lastUsedSource, excludedFromDataSaver), sources -> @@ -35,7 +37,9 @@ class GetEnabledMangaSources( val flag = if ("${it.id}" in pinnedMangaSourceIds) Pins.pinned else Pins.unpinned val source = it.copy( pin = flag, + // SY --> isExcludedFromDataSaver = it.id.toString() in excludedFromDataSaver, + // SY <-- ) val toFlatten = mutableListOf(source) if (source.id == lastUsedSource) { diff --git a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt index f083d4b828..1d35ea9a23 100644 --- a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt @@ -45,13 +45,14 @@ class SourcePreferences( fun hideInMangaLibraryItems() = preferenceStore.getBoolean("browse_hide_in_library_items", false) // SY --> - fun enableSourceBlacklist() = preferenceStore.getBoolean("eh_enable_source_blacklist", true) + + //fun enableSourceBlacklist() = preferenceStore.getBoolean("eh_enable_source_blacklist", true) - fun sourcesTabCategories() = preferenceStore.getStringSet("sources_tab_categories", mutableSetOf()) + //fun sourcesTabCategories() = preferenceStore.getStringSet("sources_tab_categories", mutableSetOf()) - fun sourcesTabCategoriesFilter() = preferenceStore.getBoolean("sources_tab_categories_filter", false) + //fun sourcesTabCategoriesFilter() = preferenceStore.getBoolean("sources_tab_categories_filter", false) - fun sourcesTabSourcesInCategories() = preferenceStore.getStringSet("sources_tab_source_categories", mutableSetOf()) + //fun sourcesTabSourcesInCategories() = preferenceStore.getStringSet("sources_tab_source_categories", mutableSetOf()) fun dataSaver() = preferenceStore.getEnum("data_saver", DataSaver.NONE) From d62b713b2df9827673ae7ea1a49d23b003543c65 Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Tue, 25 Jul 2023 14:22:57 +0200 Subject: [PATCH 07/14] fuck lint --- .../kanade/domain/source/service/SourcePreferences.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt index 1d35ea9a23..0d9daa39cc 100644 --- a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt @@ -45,14 +45,14 @@ class SourcePreferences( fun hideInMangaLibraryItems() = preferenceStore.getBoolean("browse_hide_in_library_items", false) // SY --> - - //fun enableSourceBlacklist() = preferenceStore.getBoolean("eh_enable_source_blacklist", true) - //fun sourcesTabCategories() = preferenceStore.getStringSet("sources_tab_categories", mutableSetOf()) + // fun enableSourceBlacklist() = preferenceStore.getBoolean("eh_enable_source_blacklist", true) - //fun sourcesTabCategoriesFilter() = preferenceStore.getBoolean("sources_tab_categories_filter", false) + // fun sourcesTabCategories() = preferenceStore.getStringSet("sources_tab_categories", mutableSetOf()) - //fun sourcesTabSourcesInCategories() = preferenceStore.getStringSet("sources_tab_source_categories", mutableSetOf()) + // fun sourcesTabCategoriesFilter() = preferenceStore.getBoolean("sources_tab_categories_filter", false) + + // fun sourcesTabSourcesInCategories() = preferenceStore.getStringSet("sources_tab_source_categories", mutableSetOf()) fun dataSaver() = preferenceStore.getEnum("data_saver", DataSaver.NONE) From c5a155e9499c985f89db6493152bb571140ebe73 Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Tue, 25 Jul 2023 19:16:52 +0200 Subject: [PATCH 08/14] add resmush.it to data saver --- .../source/service/SourcePreferences.kt | 1 + .../settings/screen/SettingsAdvancedScreen.kt | 3 +- app/src/main/java/exh/util/DataSaver.kt | 33 +++++++++++++++++++ i18n/src/main/res/values/strings-aniyomi.xml | 1 + 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt index 0d9daa39cc..22a24479b2 100644 --- a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt @@ -76,6 +76,7 @@ class SourcePreferences( NONE, BANDWIDTH_HERO, WSRV_NL, + RESMUSH_IT, } // SY <-- } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt index 03ba4b81b3..4953c7e0f1 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt @@ -422,6 +422,7 @@ object SettingsAdvancedScreen : SearchableSettings { DataSaver.NONE to stringResource(R.string.disabled), DataSaver.BANDWIDTH_HERO to stringResource(R.string.bandwidth_hero), DataSaver.WSRV_NL to stringResource(R.string.wsrv), + DataSaver.RESMUSH_IT to stringResource(R.string.resmush), ), ), Preference.PreferenceItem.EditTextPreference( @@ -471,7 +472,7 @@ object SettingsAdvancedScreen : SearchableSettings { } else { stringResource(R.string.data_saver_image_format_summary_off) }, - enabled = dataSaver != DataSaver.NONE, + enabled = dataSaver != DataSaver.NONE && dataSaver != DataSaver.RESMUSH_IT, ) }, Preference.PreferenceItem.SwitchPreference( diff --git a/app/src/main/java/exh/util/DataSaver.kt b/app/src/main/java/exh/util/DataSaver.kt index 70867a4ca0..cc9110aafc 100644 --- a/app/src/main/java/exh/util/DataSaver.kt +++ b/app/src/main/java/exh/util/DataSaver.kt @@ -3,13 +3,18 @@ package exh.util import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.source.service.SourcePreferences.DataSaver.BANDWIDTH_HERO import eu.kanade.domain.source.service.SourcePreferences.DataSaver.NONE +import eu.kanade.domain.source.service.SourcePreferences.DataSaver.RESMUSH_IT import eu.kanade.domain.source.service.SourcePreferences.DataSaver.WSRV_NL +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.source.MangaSource import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.online.HttpSource +import okhttp3.OkHttpClient import okhttp3.Response import rx.Observable import tachiyomi.core.preference.Preference +import uy.kohesive.injekt.injectLazy interface DataSaver { @@ -52,6 +57,7 @@ fun DataSaver(source: MangaSource, preferences: SourcePreferences): DataSaver { NONE -> DataSaver.NoOp BANDWIDTH_HERO -> BandwidthHeroDataSaver(preferences) WSRV_NL -> WsrvNlDataSaver(preferences) + RESMUSH_IT -> ReSmushItDataSaver(preferences) } } @@ -119,3 +125,30 @@ private class WsrvNlDataSaver(preferences: SourcePreferences) : DataSaver { } } } + +private class ReSmushItDataSaver(preferences: SourcePreferences) : DataSaver { + + private val network: NetworkHelper by injectLazy() + + private val client: OkHttpClient + get() = network.client + + private val ignoreJpg = preferences.dataSaverIgnoreJpeg().get() + private val ignoreGif = preferences.dataSaverIgnoreGif().get() + + private val quality = preferences.dataSaverImageQuality().get() + + override fun compress(imageUrl: String): String { + return when { + imageUrl.contains(".jpeg", true) || imageUrl.contains(".jpg", true) -> if (ignoreJpg) imageUrl else getUrl(imageUrl) + imageUrl.contains(".gif", true) -> if (ignoreGif) imageUrl else getUrl(imageUrl) + else -> getUrl(imageUrl) + } + } + + private fun getUrl(imageUrl: String): String { + // Network Request sent to resmush + return client.newCall(GET("http://api.resmush.it/ws.php?img=$imageUrl&qlty=$quality")).execute() + .body.string().substringAfter("\"dest\":\"").substringBefore("\",") + } +} diff --git a/i18n/src/main/res/values/strings-aniyomi.xml b/i18n/src/main/res/values/strings-aniyomi.xml index b4cfbae4a5..adb93ab0e4 100644 --- a/i18n/src/main/res/values/strings-aniyomi.xml +++ b/i18n/src/main/res/values/strings-aniyomi.xml @@ -308,6 +308,7 @@ Convert to Black And White Bandwidth Hero (requires a Bandwidth Hero Proxy server) wsrv.nl + resmush.it Bandwidth Hero Proxy Server Put Bandwidth Hero Proxy server url here \ No newline at end of file From 021392be91926e9428f5d6873c6e998d82bfe401 Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:14:32 +0200 Subject: [PATCH 09/14] review changes --- .../manga/interactor/GetEnabledMangaSources.kt | 12 +++++++++--- app/src/main/java/exh/source/BlacklistedSources.kt | 7 ------- 2 files changed, 9 insertions(+), 10 deletions(-) delete mode 100644 app/src/main/java/exh/source/BlacklistedSources.kt diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt index 20aeb9b6cd..570cfcf1aa 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt @@ -1,7 +1,7 @@ package eu.kanade.domain.source.manga.interactor import eu.kanade.domain.source.service.SourcePreferences -import exh.source.BlacklistedSources +import exh.source.MERGED_SOURCE_ID import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged @@ -28,13 +28,13 @@ class GetEnabledMangaSources( // SY <-- ) { a, b, c -> Triple(a, b, c) }, repository.getMangaSources(), - ) { pinnedMangaSourceIds, enabledLanguages, (disabledSources, lastUsedSource, excludedFromDataSaver), sources -> + ) { pinnedSourceIds, enabledLanguages, (disabledSources, lastUsedSource, excludedFromDataSaver), sources -> sources .filter { it.lang in enabledLanguages || it.id == LocalMangaSource.ID } .filterNot { it.id.toString() in disabledSources || it.id in BlacklistedSources.HIDDEN_SOURCES } .sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name }) .flatMap { - val flag = if ("${it.id}" in pinnedMangaSourceIds) Pins.pinned else Pins.unpinned + val flag = if ("${it.id}" in pinnedSourceIds) Pins.pinned else Pins.unpinned val source = it.copy( pin = flag, // SY --> @@ -51,3 +51,9 @@ class GetEnabledMangaSources( .distinctUntilChanged() } } + +object BlacklistedSources { + var HIDDEN_SOURCES = setOf( + MERGED_SOURCE_ID, + ) +} diff --git a/app/src/main/java/exh/source/BlacklistedSources.kt b/app/src/main/java/exh/source/BlacklistedSources.kt deleted file mode 100644 index 804f197d37..0000000000 --- a/app/src/main/java/exh/source/BlacklistedSources.kt +++ /dev/null @@ -1,7 +0,0 @@ -package exh.source - -object BlacklistedSources { - var HIDDEN_SOURCES = setOf( - MERGED_SOURCE_ID, - ) -} From 47c4914cff44c46b9fd63a8c417ba9d8bf353ab5 Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Wed, 26 Jul 2023 22:14:36 +0200 Subject: [PATCH 10/14] rename exh paths --- .../domain/source/manga/interactor/GetEnabledMangaSources.kt | 2 +- .../kanade/tachiyomi/data/download/manga/MangaDownloader.kt | 4 ++-- .../eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt | 4 ++-- app/src/main/java/{exh => fork}/source/SourcesIds.kt | 2 +- app/src/main/java/{exh => fork}/util/DataSaver.kt | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename app/src/main/java/{exh => fork}/source/SourcesIds.kt (84%) rename app/src/main/java/{exh => fork}/util/DataSaver.kt (99%) diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt index 570cfcf1aa..6dfb61661c 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt @@ -1,7 +1,7 @@ package eu.kanade.domain.source.manga.interactor import eu.kanade.domain.source.service.SourcePreferences -import exh.source.MERGED_SOURCE_ID +import fork.source.MERGED_SOURCE_ID import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt index 1e69a6e8d2..8ceedf33bf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt @@ -17,8 +17,8 @@ import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.DiskUtil.NOMEDIA_FILE import eu.kanade.tachiyomi.util.storage.saveTo -import exh.util.DataSaver -import exh.util.DataSaver.Companion.getImage +import fork.util.DataSaver +import fork.util.DataSaver.Companion.getImage import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt index 6d3f5df961..b8490f35e4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt @@ -7,8 +7,8 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderPage -import exh.util.DataSaver -import exh.util.DataSaver.Companion.getImage +import fork.util.DataSaver +import fork.util.DataSaver.Companion.getImage import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers diff --git a/app/src/main/java/exh/source/SourcesIds.kt b/app/src/main/java/fork/source/SourcesIds.kt similarity index 84% rename from app/src/main/java/exh/source/SourcesIds.kt rename to app/src/main/java/fork/source/SourcesIds.kt index 762d640319..270ba5382d 100644 --- a/app/src/main/java/exh/source/SourcesIds.kt +++ b/app/src/main/java/fork/source/SourcesIds.kt @@ -1,4 +1,4 @@ -package exh.source +package fork.source // Lewd source IDs const val LEWD_SOURCE_SERIES = 6900L diff --git a/app/src/main/java/exh/util/DataSaver.kt b/app/src/main/java/fork/util/DataSaver.kt similarity index 99% rename from app/src/main/java/exh/util/DataSaver.kt rename to app/src/main/java/fork/util/DataSaver.kt index cc9110aafc..b64b41762b 100644 --- a/app/src/main/java/exh/util/DataSaver.kt +++ b/app/src/main/java/fork/util/DataSaver.kt @@ -1,4 +1,4 @@ -package exh.util +package fork.util import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.source.service.SourcePreferences.DataSaver.BANDWIDTH_HERO From 19740e2a40cccceaf02419918b13fb0cc19e12b0 Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Wed, 26 Jul 2023 23:27:00 +0200 Subject: [PATCH 11/14] rename fork paths --- app/src/main/java/{fork => aniyomi}/source/SourcesIds.kt | 2 +- app/src/main/java/{fork => aniyomi}/util/DataSaver.kt | 2 +- .../domain/source/manga/interactor/GetEnabledMangaSources.kt | 2 +- .../kanade/tachiyomi/data/download/manga/MangaDownloader.kt | 4 ++-- .../eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) rename app/src/main/java/{fork => aniyomi}/source/SourcesIds.kt (82%) rename app/src/main/java/{fork => aniyomi}/util/DataSaver.kt (99%) diff --git a/app/src/main/java/fork/source/SourcesIds.kt b/app/src/main/java/aniyomi/source/SourcesIds.kt similarity index 82% rename from app/src/main/java/fork/source/SourcesIds.kt rename to app/src/main/java/aniyomi/source/SourcesIds.kt index 270ba5382d..15859de27e 100644 --- a/app/src/main/java/fork/source/SourcesIds.kt +++ b/app/src/main/java/aniyomi/source/SourcesIds.kt @@ -1,4 +1,4 @@ -package fork.source +package aniyomi.source // Lewd source IDs const val LEWD_SOURCE_SERIES = 6900L diff --git a/app/src/main/java/fork/util/DataSaver.kt b/app/src/main/java/aniyomi/util/DataSaver.kt similarity index 99% rename from app/src/main/java/fork/util/DataSaver.kt rename to app/src/main/java/aniyomi/util/DataSaver.kt index b64b41762b..ddefbf2621 100644 --- a/app/src/main/java/fork/util/DataSaver.kt +++ b/app/src/main/java/aniyomi/util/DataSaver.kt @@ -1,4 +1,4 @@ -package fork.util +package aniyomi.util import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.source.service.SourcePreferences.DataSaver.BANDWIDTH_HERO diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt index 6dfb61661c..4bc43ea5a3 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt @@ -1,7 +1,7 @@ package eu.kanade.domain.source.manga.interactor import eu.kanade.domain.source.service.SourcePreferences -import fork.source.MERGED_SOURCE_ID +import aniyomi.source.MERGED_SOURCE_ID import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt index 8ceedf33bf..bb74589ae0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt @@ -17,8 +17,8 @@ import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.DiskUtil.NOMEDIA_FILE import eu.kanade.tachiyomi.util.storage.saveTo -import fork.util.DataSaver -import fork.util.DataSaver.Companion.getImage +import aniyomi.util.DataSaver +import aniyomi.util.DataSaver.Companion.getImage import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt index b8490f35e4..795a4fc8b2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt @@ -7,8 +7,8 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderPage -import fork.util.DataSaver -import fork.util.DataSaver.Companion.getImage +import aniyomi.util.DataSaver +import aniyomi.util.DataSaver.Companion.getImage import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers From 2bbf77b90d536fd8307a2f44c665a0b60d880e10 Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Wed, 26 Jul 2023 23:32:56 +0200 Subject: [PATCH 12/14] fuck lint --- .../domain/source/manga/interactor/GetEnabledMangaSources.kt | 2 +- .../kanade/tachiyomi/data/download/manga/MangaDownloader.kt | 4 ++-- .../eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt index 4bc43ea5a3..69a4f46628 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt @@ -1,7 +1,7 @@ package eu.kanade.domain.source.manga.interactor -import eu.kanade.domain.source.service.SourcePreferences import aniyomi.source.MERGED_SOURCE_ID +import eu.kanade.domain.source.service.SourcePreferences import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt index bb74589ae0..d4c021987d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt @@ -1,6 +1,8 @@ package eu.kanade.tachiyomi.data.download.manga import android.content.Context +import aniyomi.util.DataSaver +import aniyomi.util.DataSaver.Companion.getImage import com.hippo.unifile.UniFile import com.jakewharton.rxrelay.PublishRelay import eu.kanade.domain.entries.manga.model.getComicInfo @@ -17,8 +19,6 @@ import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.DiskUtil.NOMEDIA_FILE import eu.kanade.tachiyomi.util.storage.saveTo -import aniyomi.util.DataSaver -import aniyomi.util.DataSaver.Companion.getImage import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt index 795a4fc8b2..9a764cdcb4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt @@ -1,5 +1,7 @@ package eu.kanade.tachiyomi.ui.reader.loader +import aniyomi.util.DataSaver +import aniyomi.util.DataSaver.Companion.getImage import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.data.cache.ChapterCache import eu.kanade.tachiyomi.data.database.models.manga.toDomainChapter @@ -7,8 +9,6 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderPage -import aniyomi.util.DataSaver -import aniyomi.util.DataSaver.Companion.getImage import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers From 66688f4d1a1a205e3b4b0586e4812fdf4b0c10b1 Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Thu, 27 Jul 2023 12:00:04 +0200 Subject: [PATCH 13/14] sourceid remove --- app/src/main/java/aniyomi/source/SourcesIds.kt | 5 ----- .../source/manga/interactor/GetEnabledMangaSources.kt | 9 +-------- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 app/src/main/java/aniyomi/source/SourcesIds.kt diff --git a/app/src/main/java/aniyomi/source/SourcesIds.kt b/app/src/main/java/aniyomi/source/SourcesIds.kt deleted file mode 100644 index 15859de27e..0000000000 --- a/app/src/main/java/aniyomi/source/SourcesIds.kt +++ /dev/null @@ -1,5 +0,0 @@ -package aniyomi.source - -// Lewd source IDs -const val LEWD_SOURCE_SERIES = 6900L -const val MERGED_SOURCE_ID = LEWD_SOURCE_SERIES + 69 diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt index 69a4f46628..af95d31c79 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt @@ -1,6 +1,5 @@ package eu.kanade.domain.source.manga.interactor -import aniyomi.source.MERGED_SOURCE_ID import eu.kanade.domain.source.service.SourcePreferences import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine @@ -31,7 +30,7 @@ class GetEnabledMangaSources( ) { pinnedSourceIds, enabledLanguages, (disabledSources, lastUsedSource, excludedFromDataSaver), sources -> sources .filter { it.lang in enabledLanguages || it.id == LocalMangaSource.ID } - .filterNot { it.id.toString() in disabledSources || it.id in BlacklistedSources.HIDDEN_SOURCES } + .filterNot { it.id.toString() in disabledSources} .sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name }) .flatMap { val flag = if ("${it.id}" in pinnedSourceIds) Pins.pinned else Pins.unpinned @@ -51,9 +50,3 @@ class GetEnabledMangaSources( .distinctUntilChanged() } } - -object BlacklistedSources { - var HIDDEN_SOURCES = setOf( - MERGED_SOURCE_ID, - ) -} From 5eca875dfe3b206e360c8982cac72eaced6d9c17 Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Thu, 27 Jul 2023 12:07:46 +0200 Subject: [PATCH 14/14] fuck lint --- .../domain/source/manga/interactor/GetEnabledMangaSources.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt index af95d31c79..ac22e7fbbf 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetEnabledMangaSources.kt @@ -30,7 +30,7 @@ class GetEnabledMangaSources( ) { pinnedSourceIds, enabledLanguages, (disabledSources, lastUsedSource, excludedFromDataSaver), sources -> sources .filter { it.lang in enabledLanguages || it.id == LocalMangaSource.ID } - .filterNot { it.id.toString() in disabledSources} + .filterNot { it.id.toString() in disabledSources } .sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name }) .flatMap { val flag = if ("${it.id}" in pinnedSourceIds) Pins.pinned else Pins.unpinned