From 3cca4602829fd706c5b850bcf45d472ee95b2a38 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 19 Mar 2023 22:38:14 -0400 Subject: [PATCH] Misc cleanup --- .../eu/kanade/domain/base/BasePreferences.kt | 7 +++++ .../base/ExtensionInstallerPreference.kt | 2 +- .../interactor/SyncChaptersWithSource.kt | 2 +- .../domain/chapter/model/ChapterFilter.kt | 2 +- .../domain/manga/interactor/UpdateManga.kt | 2 +- .../eu/kanade/domain/manga/model/Manga.kt | 5 ++-- .../settings/screen/SettingsAdvancedScreen.kt | 3 +- .../settings/screen/SettingsReaderScreen.kt | 26 ++++++++--------- .../java/eu/kanade/tachiyomi/Migrations.kt | 5 ++-- .../data/download/DownloadManager.kt | 2 +- .../tachiyomi/data/download/Downloader.kt | 25 +++++++--------- .../data/preference/PreferenceValues.kt | 29 ------------------- .../extension/util/ExtensionInstallService.kt | 10 +++---- .../extension/util/ExtensionInstaller.kt | 3 +- .../tachiyomi/source/SourceExtensions.kt | 4 +-- .../ui/library/LibraryScreenModel.kt | 3 +- .../kanade/tachiyomi/ui/library/LibraryTab.kt | 2 +- .../tachiyomi/ui/manga/MangaScreenModel.kt | 2 +- .../tachiyomi/ui/reader/ReaderActivity.kt | 2 +- .../tachiyomi/ui/reader/ReaderViewModel.kt | 5 ++-- .../ui/reader/setting/ReaderPreferences.kt | 21 +++++++++++--- .../setting/ReaderReadingModeSettings.kt | 5 ++-- .../ui/reader/viewer/ViewerConfig.kt | 3 +- .../ui/reader/viewer/ViewerNavigation.kt | 8 ++--- .../tachiyomi/ui/stats/StatsScreenModel.kt | 2 +- .../kanade/tachiyomi/util/MangaExtensions.kt | 2 +- .../tachiyomi/util/lang/RectFExtensions.kt | 4 +-- .../core/metadata/comicinfo/ComicInfo.kt | 2 +- .../tachiyomi/source/local/LocalSource.kt | 12 ++++++-- 29 files changed, 90 insertions(+), 110 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt diff --git a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt b/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt index b669309fb..b7e0e47ce 100644 --- a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt @@ -1,6 +1,7 @@ package eu.kanade.domain.base import android.content.Context +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.isPreviewBuildType import eu.kanade.tachiyomi.util.system.isReleaseBuildType import tachiyomi.core.preference.PreferenceStore @@ -19,4 +20,10 @@ class BasePreferences( fun extensionInstaller() = ExtensionInstallerPreference(context, preferenceStore) fun acraEnabled() = preferenceStore.getBoolean("acra.enable", isPreviewBuildType || isReleaseBuildType) + + enum class ExtensionInstaller(val titleResId: Int) { + LEGACY(R.string.ext_installer_legacy), + PACKAGEINSTALLER(R.string.ext_installer_packageinstaller), + SHIZUKU(R.string.ext_installer_shizuku), + } } diff --git a/app/src/main/java/eu/kanade/domain/base/ExtensionInstallerPreference.kt b/app/src/main/java/eu/kanade/domain/base/ExtensionInstallerPreference.kt index a981bd0ff..03c63dd2b 100644 --- a/app/src/main/java/eu/kanade/domain/base/ExtensionInstallerPreference.kt +++ b/app/src/main/java/eu/kanade/domain/base/ExtensionInstallerPreference.kt @@ -1,7 +1,7 @@ package eu.kanade.domain.base import android.content.Context -import eu.kanade.tachiyomi.data.preference.PreferenceValues.ExtensionInstaller +import eu.kanade.domain.base.BasePreferences.ExtensionInstaller import eu.kanade.tachiyomi.util.system.hasMiuiPackageInstaller import eu.kanade.tachiyomi.util.system.isShizukuInstalled import kotlinx.coroutines.CoroutineScope diff --git a/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt b/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt index 3dcd8e189..41520addd 100644 --- a/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt +++ b/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt @@ -7,7 +7,6 @@ import eu.kanade.domain.manga.model.toSManga import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.download.DownloadProvider import eu.kanade.tachiyomi.source.Source -import eu.kanade.tachiyomi.source.isLocal import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.online.HttpSource import tachiyomi.data.chapter.ChapterSanitizer @@ -20,6 +19,7 @@ import tachiyomi.domain.chapter.model.toChapterUpdate import tachiyomi.domain.chapter.repository.ChapterRepository import tachiyomi.domain.chapter.service.ChapterRecognition import tachiyomi.domain.manga.model.Manga +import tachiyomi.source.local.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.lang.Long.max diff --git a/app/src/main/java/eu/kanade/domain/chapter/model/ChapterFilter.kt b/app/src/main/java/eu/kanade/domain/chapter/model/ChapterFilter.kt index b2fc31b63..623ddd751 100644 --- a/app/src/main/java/eu/kanade/domain/chapter/model/ChapterFilter.kt +++ b/app/src/main/java/eu/kanade/domain/chapter/model/ChapterFilter.kt @@ -1,13 +1,13 @@ package eu.kanade.domain.chapter.model import eu.kanade.domain.manga.model.downloadedFilter -import eu.kanade.domain.manga.model.isLocal import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.ui.manga.ChapterItem import tachiyomi.domain.chapter.model.Chapter import tachiyomi.domain.chapter.service.getChapterSort import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.manga.model.applyFilter +import tachiyomi.source.local.isLocal /** * Applies the view filters to the list of chapters obtained from the database. diff --git a/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt b/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt index c5488110a..82a2e8819 100644 --- a/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt +++ b/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt @@ -1,12 +1,12 @@ package eu.kanade.domain.manga.interactor import eu.kanade.domain.manga.model.hasCustomCover -import eu.kanade.domain.manga.model.isLocal import eu.kanade.tachiyomi.data.cache.CoverCache import eu.kanade.tachiyomi.source.model.SManga import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.manga.model.MangaUpdate import tachiyomi.domain.manga.repository.MangaRepository +import tachiyomi.source.local.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.util.Date diff --git a/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt b/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt index 5c7c1e22d..6712a06ae 100644 --- a/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt +++ b/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt @@ -5,10 +5,11 @@ import eu.kanade.tachiyomi.data.cache.CoverCache import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType +import tachiyomi.core.metadata.comicinfo.ComicInfo +import tachiyomi.core.metadata.comicinfo.ComicInfoPublishingStatus import tachiyomi.domain.chapter.model.Chapter import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.manga.model.TriStateFilter -import tachiyomi.source.local.LocalSource import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -87,8 +88,6 @@ fun SManga.toDomainManga(sourceId: Long): Manga { ) } -fun Manga.isLocal(): Boolean = source == LocalSource.ID - fun Manga.hasCustomCover(coverCache: CoverCache = Injekt.get()): Boolean { return coverCache.getCustomCoverFile(id).exists() } 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 304f8fd9a..8a334a036 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 @@ -31,7 +31,6 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.cache.ChapterCache import eu.kanade.tachiyomi.data.download.DownloadCache import eu.kanade.tachiyomi.data.library.LibraryUpdateJob -import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.NetworkPreferences @@ -376,7 +375,7 @@ object SettingsAdvancedScreen : SearchableSettings { entries = extensionInstallerPref.entries .associateWith { stringResource(it.titleResId) }, onValueChanged = { - if (it == PreferenceValues.ExtensionInstaller.SHIZUKU && + if (it == BasePreferences.ExtensionInstaller.SHIZUKU && !context.isShizukuInstalled ) { shizukuMissing = true diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt index d96a0cfdf..dad6859c1 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt @@ -12,8 +12,6 @@ import androidx.compose.ui.res.stringResource import eu.kanade.presentation.more.settings.Preference import eu.kanade.presentation.util.collectAsState import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferenceValues.ReaderHideThreshold -import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType @@ -171,10 +169,10 @@ object SettingsReaderScreen : SearchableSettings { pref = readerPreferences.pagerNavInverted(), title = stringResource(R.string.pref_read_with_tapping_inverted), entries = mapOf( - TappingInvertMode.NONE to stringResource(R.string.none), - TappingInvertMode.HORIZONTAL to stringResource(R.string.tapping_inverted_horizontal), - TappingInvertMode.VERTICAL to stringResource(R.string.tapping_inverted_vertical), - TappingInvertMode.BOTH to stringResource(R.string.tapping_inverted_both), + ReaderPreferences.TappingInvertMode.NONE to stringResource(R.string.none), + ReaderPreferences.TappingInvertMode.HORIZONTAL to stringResource(R.string.tapping_inverted_horizontal), + ReaderPreferences.TappingInvertMode.VERTICAL to stringResource(R.string.tapping_inverted_vertical), + ReaderPreferences.TappingInvertMode.BOTH to stringResource(R.string.tapping_inverted_both), ), enabled = navMode != 5, ), @@ -251,10 +249,10 @@ object SettingsReaderScreen : SearchableSettings { pref = readerPreferences.webtoonNavInverted(), title = stringResource(R.string.pref_read_with_tapping_inverted), entries = mapOf( - TappingInvertMode.NONE to stringResource(R.string.none), - TappingInvertMode.HORIZONTAL to stringResource(R.string.tapping_inverted_horizontal), - TappingInvertMode.VERTICAL to stringResource(R.string.tapping_inverted_vertical), - TappingInvertMode.BOTH to stringResource(R.string.tapping_inverted_both), + ReaderPreferences.TappingInvertMode.NONE to stringResource(R.string.none), + ReaderPreferences.TappingInvertMode.HORIZONTAL to stringResource(R.string.tapping_inverted_horizontal), + ReaderPreferences.TappingInvertMode.VERTICAL to stringResource(R.string.tapping_inverted_vertical), + ReaderPreferences.TappingInvertMode.BOTH to stringResource(R.string.tapping_inverted_both), ), enabled = navMode != 5, ), @@ -274,10 +272,10 @@ object SettingsReaderScreen : SearchableSettings { pref = readerPreferences.readerHideThreshold(), title = stringResource(R.string.pref_hide_threshold), entries = mapOf( - ReaderHideThreshold.HIGHEST to stringResource(R.string.pref_highest), - ReaderHideThreshold.HIGH to stringResource(R.string.pref_high), - ReaderHideThreshold.LOW to stringResource(R.string.pref_low), - ReaderHideThreshold.LOWEST to stringResource(R.string.pref_lowest), + ReaderPreferences.ReaderHideThreshold.HIGHEST to stringResource(R.string.pref_highest), + ReaderPreferences.ReaderHideThreshold.HIGH to stringResource(R.string.pref_high), + ReaderPreferences.ReaderHideThreshold.LOW to stringResource(R.string.pref_low), + ReaderPreferences.ReaderHideThreshold.LOWEST to stringResource(R.string.pref_lowest), ), ), Preference.PreferenceItem.SwitchPreference( diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index 4ccb1bb92..8b9dce2f8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -9,7 +9,6 @@ import eu.kanade.domain.ui.UiPreferences import eu.kanade.tachiyomi.core.security.SecurityPreferences import eu.kanade.tachiyomi.data.backup.BackupCreateJob import eu.kanade.tachiyomi.data.library.LibraryUpdateJob -import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.network.NetworkPreferences import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE @@ -244,8 +243,8 @@ object Migrations { if (oldSecureScreen) { securityPreferences.secureScreen().set(SecurityPreferences.SecureScreenMode.ALWAYS) } - if (DeviceUtil.isMiui && basePreferences.extensionInstaller().get() == PreferenceValues.ExtensionInstaller.PACKAGEINSTALLER) { - basePreferences.extensionInstaller().set(PreferenceValues.ExtensionInstaller.LEGACY) + if (DeviceUtil.isMiui && basePreferences.extensionInstaller().get() == BasePreferences.ExtensionInstaller.PACKAGEINSTALLER) { + basePreferences.extensionInstaller().set(BasePreferences.ExtensionInstaller.LEGACY) } } if (oldVersion < 76) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index fc9b80ded..3630281b7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -89,7 +89,7 @@ class DownloadManager( * @param chapterId the chapter to check. */ fun getQueuedDownloadOrNull(chapterId: Long): Download? { - return queueState.value.find { it: Download -> it.chapter.id == chapterId } + return queueState.value.find { it.chapter.id == chapterId } } fun startDownloadNow(chapterId: Long?) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index 75b199ab7..d42479e22 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -4,8 +4,6 @@ import android.content.Context import com.hippo.unifile.UniFile import com.jakewharton.rxrelay.PublishRelay import eu.kanade.domain.chapter.model.toSChapter -import eu.kanade.domain.manga.model.COMIC_INFO_FILE -import eu.kanade.domain.manga.model.ComicInfo import eu.kanade.domain.manga.model.getComicInfo import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.cache.ChapterCache @@ -39,6 +37,8 @@ import rx.Observable import rx.Subscription import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers +import tachiyomi.core.metadata.comicinfo.COMIC_INFO_FILE +import tachiyomi.core.metadata.comicinfo.ComicInfo import tachiyomi.core.util.lang.awaitSingle import tachiyomi.core.util.lang.launchIO import tachiyomi.core.util.lang.launchNow @@ -66,11 +66,6 @@ import java.util.zip.ZipOutputStream * * The queue manipulation must be done in one thread (currently the main thread) to avoid unexpected * behavior, but it's safe to read it from multiple threads. - * - * @param context the application context. - * @param provider the downloads directory provider. - * @param cache the downloads cache, used to add the downloads to the cache after their completion. - * @param sourceManager the source manager. */ class Downloader( private val context: Context, @@ -90,7 +85,7 @@ class Downloader( /** * Queue where active downloads are kept. */ - val _queueState = MutableStateFlow>(emptyList()) + private val _queueState = MutableStateFlow>(emptyList()) val queueState = _queueState.asStateFlow() /** @@ -140,7 +135,7 @@ class Downloader( initializeSubscription() - val pending = queueState.value.filter { it: Download -> it.status != Download.State.DOWNLOADED } + val pending = queueState.value.filter { it.status != Download.State.DOWNLOADED } pending.forEach { if (it.status != Download.State.QUEUE) it.status = Download.State.QUEUE } isPaused = false @@ -266,7 +261,7 @@ class Downloader( // Runs in main thread (synchronization needed). val chaptersToQueue = chaptersWithoutDir.await() // Filter out those already enqueued. - .filter { chapter -> queueState.value.none { it: Download -> it.chapter.id == chapter.id } } + .filter { chapter -> queueState.value.none { it.chapter.id == chapter.id } } // Create a download for each one. .map { Download(source, manga, it) } @@ -280,7 +275,7 @@ class Downloader( // Start downloader if needed if (autoStart && wasEmpty) { - val queuedDownloads = queueState.value.count { it: Download -> it.source !is UnmeteredSource } + val queuedDownloads = queueState.value.count { it.source !is UnmeteredSource } val maxDownloadsFromSource = queueState.value .groupBy { it.source } .filterKeys { it !is UnmeteredSource } @@ -639,10 +634,10 @@ class Downloader( * Returns true if all the queued downloads are in DOWNLOADED or ERROR state. */ private fun areAllDownloadsFinished(): Boolean { - return queueState.value.none { it: Download -> it.status.value <= Download.State.DOWNLOADING.value } + return queueState.value.none { it.status.value <= Download.State.DOWNLOADING.value } } - fun addAllToQueue(downloads: List) { + private fun addAllToQueue(downloads: List) { _queueState.update { downloads.forEach { download -> download.status = Download.State.QUEUE @@ -652,7 +647,7 @@ class Downloader( } } - fun removeFromQueue(download: Download) { + private fun removeFromQueue(download: Download) { _queueState.update { store.remove(download) if (download.status == Download.State.DOWNLOADING || download.status == Download.State.QUEUE) { @@ -672,7 +667,7 @@ class Downloader( queueState.value.filter { it.manga.id == manga.id }.forEach { removeFromQueue(it) } } - fun _clearQueue() { + private fun _clearQueue() { _queueState.update { it.forEach { download -> if (download.status == Download.State.DOWNLOADING || download.status == Download.State.QUEUE) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt deleted file mode 100644 index e4d8ef06a..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt +++ /dev/null @@ -1,29 +0,0 @@ -package eu.kanade.tachiyomi.data.preference - -import eu.kanade.tachiyomi.R - -/** - * This class stores the values for the preferences in the application. - */ -object PreferenceValues { - - enum class TappingInvertMode(val shouldInvertHorizontal: Boolean = false, val shouldInvertVertical: Boolean = false) { - NONE, - HORIZONTAL(shouldInvertHorizontal = true), - VERTICAL(shouldInvertVertical = true), - BOTH(shouldInvertHorizontal = true, shouldInvertVertical = true), - } - - enum class ReaderHideThreshold(val threshold: Int) { - HIGHEST(5), - HIGH(13), - LOW(31), - LOWEST(47), - } - - enum class ExtensionInstaller(val titleResId: Int) { - LEGACY(R.string.ext_installer_legacy), - PACKAGEINSTALLER(R.string.ext_installer_packageinstaller), - SHIZUKU(R.string.ext_installer_shizuku), - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallService.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallService.kt index 6e7368c0c..e5cf5465d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallService.kt @@ -5,9 +5,9 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.os.IBinder +import eu.kanade.domain.base.BasePreferences import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.notification.Notifications -import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.extension.installer.Installer import eu.kanade.tachiyomi.extension.installer.PackageInstallerInstaller import eu.kanade.tachiyomi.extension.installer.ShizukuInstaller @@ -36,7 +36,7 @@ class ExtensionInstallService : Service() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { val uri = intent?.data val id = intent?.getLongExtra(EXTRA_DOWNLOAD_ID, -1)?.takeIf { it != -1L } - val installerUsed = intent?.getSerializableExtraCompat(EXTRA_INSTALLER) + val installerUsed = intent?.getSerializableExtraCompat(EXTRA_INSTALLER) if (uri == null || id == null || installerUsed == null) { stopSelf() return START_NOT_STICKY @@ -44,8 +44,8 @@ class ExtensionInstallService : Service() { if (installer == null) { installer = when (installerUsed) { - PreferenceValues.ExtensionInstaller.PACKAGEINSTALLER -> PackageInstallerInstaller(this) - PreferenceValues.ExtensionInstaller.SHIZUKU -> ShizukuInstaller(this) + BasePreferences.ExtensionInstaller.PACKAGEINSTALLER -> PackageInstallerInstaller(this) + BasePreferences.ExtensionInstaller.SHIZUKU -> ShizukuInstaller(this) else -> { logcat(LogPriority.ERROR) { "Not implemented for installer $installerUsed" } stopSelf() @@ -71,7 +71,7 @@ class ExtensionInstallService : Service() { context: Context, downloadId: Long, uri: Uri, - installer: PreferenceValues.ExtensionInstaller, + installer: BasePreferences.ExtensionInstaller, ): Intent { return Intent(context, ExtensionInstallService::class.java) .setDataAndType(uri, ExtensionInstaller.APK_MIME) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt index c63d6bf2f..e6b992f8e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt @@ -12,7 +12,6 @@ import androidx.core.content.getSystemService import androidx.core.net.toUri import com.jakewharton.rxrelay.PublishRelay import eu.kanade.domain.base.BasePreferences -import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.extension.installer.Installer import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.extension.model.InstallStep @@ -134,7 +133,7 @@ internal class ExtensionInstaller(private val context: Context) { */ fun installApk(downloadId: Long, uri: Uri) { when (val installer = extensionInstaller.get()) { - PreferenceValues.ExtensionInstaller.LEGACY -> { + BasePreferences.ExtensionInstaller.LEGACY -> { val intent = Intent(context, ExtensionInstallActivity::class.java) .setDataAndType(uri, APK_MIME) .putExtra(EXTRA_DOWNLOAD_ID, downloadId) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/SourceExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/source/SourceExtensions.kt index 33a0b11c9..85e722d9e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/SourceExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/SourceExtensions.kt @@ -5,7 +5,7 @@ import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.extension.ExtensionManager import tachiyomi.domain.source.model.SourceData import tachiyomi.domain.source.model.StubSource -import tachiyomi.source.local.LocalSource +import tachiyomi.source.local.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -30,6 +30,4 @@ fun Source.getNameForMangaInfo(): String { } } -fun Source.isLocal(): Boolean = id == LocalSource.ID - fun Source.isLocalOrStub(): Boolean = isLocal() || this is StubSource diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt index 221621ae3..99c94d802 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt @@ -17,7 +17,6 @@ import eu.kanade.core.util.fastPartition import eu.kanade.domain.base.BasePreferences import eu.kanade.domain.chapter.interactor.SetReadStatus import eu.kanade.domain.manga.interactor.UpdateManga -import eu.kanade.domain.manga.model.isLocal import eu.kanade.presentation.components.SEARCH_DEBOUNCE_MILLIS import eu.kanade.presentation.library.components.LibraryToolbarTitle import eu.kanade.presentation.manga.DownloadAction @@ -61,6 +60,7 @@ import tachiyomi.domain.manga.model.TriStateFilter import tachiyomi.domain.manga.model.applyFilter import tachiyomi.domain.source.service.SourceManager import tachiyomi.domain.track.interactor.GetTracksPerManga +import tachiyomi.source.local.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.text.Collator @@ -417,7 +417,6 @@ class LibraryScreenModel( DownloadAction.NEXT_10_CHAPTERS -> downloadUnreadChapters(mangas, 10) DownloadAction.NEXT_25_CHAPTERS -> downloadUnreadChapters(mangas, 25) DownloadAction.UNREAD_CHAPTERS -> downloadUnreadChapters(mangas, null) - else -> {} } clearSelection() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt index 83235c565..52c85e72a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt @@ -28,7 +28,6 @@ import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.navigator.currentOrThrow import cafe.adriel.voyager.navigator.tab.LocalTabNavigator import cafe.adriel.voyager.navigator.tab.TabOptions -import eu.kanade.domain.manga.model.isLocal import eu.kanade.presentation.category.components.ChangeCategoryDialog import eu.kanade.presentation.library.DeleteLibraryMangaDialog import eu.kanade.presentation.library.LibrarySettingsDialog @@ -57,6 +56,7 @@ import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen import tachiyomi.presentation.core.screens.EmptyScreenAction import tachiyomi.presentation.core.screens.LoadingScreen +import tachiyomi.source.local.isLocal object LibraryTab : Tab { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt index 019086385..aab7179f3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt @@ -14,7 +14,6 @@ import eu.kanade.domain.chapter.interactor.SetReadStatus import eu.kanade.domain.chapter.interactor.SyncChaptersWithSource import eu.kanade.domain.manga.interactor.UpdateManga import eu.kanade.domain.manga.model.downloadedFilter -import eu.kanade.domain.manga.model.isLocal import eu.kanade.domain.manga.model.toSManga import eu.kanade.domain.ui.UiPreferences import eu.kanade.presentation.manga.DownloadAction @@ -71,6 +70,7 @@ import tachiyomi.domain.manga.model.TriStateFilter import tachiyomi.domain.manga.model.applyFilter import tachiyomi.domain.source.service.SourceManager import tachiyomi.domain.track.interactor.GetTracks +import tachiyomi.source.local.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.text.DecimalFormat diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 0d1d2ef09..06cbf8663 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -951,7 +951,7 @@ class ReaderActivity : BaseActivity() { * cover to the presenter. */ fun setAsCover(page: ReaderPage) { - viewModel.setAsCover(this, page) + viewModel.setAsCover(page) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt index 0f36c8945..b440e7300 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt @@ -1,7 +1,6 @@ package eu.kanade.tachiyomi.ui.reader import android.app.Application -import android.content.Context import android.net.Uri import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel @@ -9,7 +8,6 @@ import androidx.lifecycle.viewModelScope import eu.kanade.domain.base.BasePreferences import eu.kanade.domain.chapter.model.toDbChapter import eu.kanade.domain.manga.interactor.SetMangaViewerFlags -import eu.kanade.domain.manga.model.isLocal import eu.kanade.domain.manga.model.orientationType import eu.kanade.domain.manga.model.readingModeType import eu.kanade.domain.track.model.toDbTrack @@ -78,6 +76,7 @@ import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.source.service.SourceManager import tachiyomi.domain.track.interactor.GetTracks import tachiyomi.domain.track.interactor.InsertTrack +import tachiyomi.source.local.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.util.Date @@ -767,7 +766,7 @@ class ReaderViewModel( /** * Sets the image of this [page] as cover and notifies the UI of the result. */ - fun setAsCover(context: Context, page: ReaderPage) { + fun setAsCover(page: ReaderPage) { if (page.status != Page.State.READY) return val manga = manga ?: return val stream = page.stream ?: return diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt index d45ba7d96..75636f0bc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt @@ -1,6 +1,5 @@ package eu.kanade.tachiyomi.ui.reader.setting -import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.util.system.isReleaseBuildType import tachiyomi.core.preference.PreferenceStore import tachiyomi.core.preference.getEnum @@ -52,7 +51,7 @@ class ReaderPreferences( fun webtoonSidePadding() = preferenceStore.getInt("webtoon_side_padding", 0) - fun readerHideThreshold() = preferenceStore.getEnum("reader_hide_threshold", PreferenceValues.ReaderHideThreshold.LOW) + fun readerHideThreshold() = preferenceStore.getEnum("reader_hide_threshold", ReaderHideThreshold.LOW) fun folderPerManga() = preferenceStore.getBoolean("create_folder_per_manga", false) @@ -106,13 +105,27 @@ class ReaderPreferences( fun navigationModeWebtoon() = preferenceStore.getInt("reader_navigation_mode_webtoon", 0) - fun pagerNavInverted() = preferenceStore.getEnum("reader_tapping_inverted", PreferenceValues.TappingInvertMode.NONE) + fun pagerNavInverted() = preferenceStore.getEnum("reader_tapping_inverted", TappingInvertMode.NONE) - fun webtoonNavInverted() = preferenceStore.getEnum("reader_tapping_inverted_webtoon", PreferenceValues.TappingInvertMode.NONE) + fun webtoonNavInverted() = preferenceStore.getEnum("reader_tapping_inverted_webtoon", TappingInvertMode.NONE) fun showNavigationOverlayNewUser() = preferenceStore.getBoolean("reader_navigation_overlay_new_user", true) fun showNavigationOverlayOnStart() = preferenceStore.getBoolean("reader_navigation_overlay_on_start", false) // endregion + + enum class TappingInvertMode(val shouldInvertHorizontal: Boolean = false, val shouldInvertVertical: Boolean = false) { + NONE, + HORIZONTAL(shouldInvertHorizontal = true), + VERTICAL(shouldInvertVertical = true), + BOTH(shouldInvertHorizontal = true, shouldInvertVertical = true), + } + + enum class ReaderHideThreshold(val threshold: Int) { + HIGHEST(5), + HIGH(13), + LOW(31), + LOWEST(47), + } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderReadingModeSettings.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderReadingModeSettings.kt index 3cfd03aa9..b5e315b9e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderReadingModeSettings.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderReadingModeSettings.kt @@ -9,7 +9,6 @@ import androidx.lifecycle.lifecycleScope import eu.kanade.domain.manga.model.orientationType import eu.kanade.domain.manga.model.readingModeType import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.databinding.ReaderReadingModeSettingsBinding import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer @@ -71,7 +70,7 @@ class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attr binding.webtoonPrefsGroup.root.isVisible = false binding.pagerPrefsGroup.root.isVisible = true - binding.pagerPrefsGroup.tappingInverted.bindToPreference(readerPreferences.pagerNavInverted(), PreferenceValues.TappingInvertMode::class.java) + binding.pagerPrefsGroup.tappingInverted.bindToPreference(readerPreferences.pagerNavInverted(), ReaderPreferences.TappingInvertMode::class.java) binding.pagerPrefsGroup.navigatePan.bindToPreference(readerPreferences.navigateToPan()) binding.pagerPrefsGroup.pagerNav.bindToPreference(readerPreferences.navigationModePager()) @@ -107,7 +106,7 @@ class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attr binding.pagerPrefsGroup.root.isVisible = false binding.webtoonPrefsGroup.root.isVisible = true - binding.webtoonPrefsGroup.tappingInverted.bindToPreference(readerPreferences.webtoonNavInverted(), PreferenceValues.TappingInvertMode::class.java) + binding.webtoonPrefsGroup.tappingInverted.bindToPreference(readerPreferences.webtoonNavInverted(), ReaderPreferences.TappingInvertMode::class.java) binding.webtoonPrefsGroup.webtoonNav.bindToPreference(readerPreferences.navigationModeWebtoon()) readerPreferences.navigationModeWebtoon() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt index 7c9279746..b852911cd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt @@ -1,6 +1,5 @@ package eu.kanade.tachiyomi.ui.reader.viewer -import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.distinctUntilChanged @@ -17,7 +16,7 @@ abstract class ViewerConfig(readerPreferences: ReaderPreferences, private val sc var navigationModeChangedListener: (() -> Unit)? = null - var tappingInverted = TappingInvertMode.NONE + var tappingInverted = ReaderPreferences.TappingInvertMode.NONE var longTapEnabled = true var usePageTransitions = false var doubleTapAnimDuration = 500 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerNavigation.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerNavigation.kt index 224747466..d4acd01b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerNavigation.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerNavigation.kt @@ -4,7 +4,7 @@ import android.graphics.PointF import android.graphics.RectF import androidx.annotation.StringRes import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferenceValues +import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences import eu.kanade.tachiyomi.util.lang.invert abstract class ViewerNavigation { @@ -21,8 +21,8 @@ abstract class ViewerNavigation { val rectF: RectF, val type: NavigationRegion, ) { - fun invert(invertMode: PreferenceValues.TappingInvertMode): Region { - if (invertMode == PreferenceValues.TappingInvertMode.NONE) return this + fun invert(invertMode: ReaderPreferences.TappingInvertMode): Region { + if (invertMode == ReaderPreferences.TappingInvertMode.NONE) return this return this.copy( rectF = this.rectF.invert(invertMode), ) @@ -33,7 +33,7 @@ abstract class ViewerNavigation { abstract var regions: List - var invertMode: PreferenceValues.TappingInvertMode = PreferenceValues.TappingInvertMode.NONE + var invertMode: ReaderPreferences.TappingInvertMode = ReaderPreferences.TappingInvertMode.NONE fun getAction(pos: PointF): NavigationRegion { val x = pos.x diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreenModel.kt index 3870bc780..366486a0d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreenModel.kt @@ -7,7 +7,6 @@ import eu.kanade.core.util.fastDistinctBy import eu.kanade.core.util.fastFilter import eu.kanade.core.util.fastFilterNot import eu.kanade.core.util.fastMapNotNull -import eu.kanade.domain.manga.model.isLocal import eu.kanade.presentation.more.stats.StatsScreenState import eu.kanade.presentation.more.stats.data.StatsData import eu.kanade.tachiyomi.data.download.DownloadManager @@ -24,6 +23,7 @@ import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_NON_R import tachiyomi.domain.manga.interactor.GetLibraryManga import tachiyomi.domain.track.interactor.GetTracks import tachiyomi.domain.track.model.Track +import tachiyomi.source.local.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt index b8e74672e..4df23b380 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt @@ -2,13 +2,13 @@ package eu.kanade.tachiyomi.util import eu.kanade.domain.manga.interactor.UpdateManga import eu.kanade.domain.manga.model.hasCustomCover -import eu.kanade.domain.manga.model.isLocal import eu.kanade.domain.manga.model.toSManga import eu.kanade.tachiyomi.data.cache.CoverCache import eu.kanade.tachiyomi.source.model.SManga import tachiyomi.domain.download.service.DownloadPreferences import tachiyomi.domain.manga.model.Manga import tachiyomi.source.local.image.LocalCoverManager +import tachiyomi.source.local.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.io.InputStream diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/lang/RectFExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/lang/RectFExtensions.kt index d1ad0b5b9..2072bcd42 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/lang/RectFExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/lang/RectFExtensions.kt @@ -1,9 +1,9 @@ package eu.kanade.tachiyomi.util.lang import android.graphics.RectF -import eu.kanade.tachiyomi.data.preference.PreferenceValues +import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences -fun RectF.invert(invertMode: PreferenceValues.TappingInvertMode): RectF { +fun RectF.invert(invertMode: ReaderPreferences.TappingInvertMode): RectF { val horizontal = invertMode.shouldInvertHorizontal val vertical = invertMode.shouldInvertVertical return when { diff --git a/core-metadata/src/main/java/tachiyomi/core/metadata/comicinfo/ComicInfo.kt b/core-metadata/src/main/java/tachiyomi/core/metadata/comicinfo/ComicInfo.kt index 8181a8380..80c0e9d4c 100644 --- a/core-metadata/src/main/java/tachiyomi/core/metadata/comicinfo/ComicInfo.kt +++ b/core-metadata/src/main/java/tachiyomi/core/metadata/comicinfo/ComicInfo.kt @@ -1,4 +1,4 @@ -package eu.kanade.domain.manga.model +package tachiyomi.core.metadata.comicinfo import eu.kanade.tachiyomi.source.model.SManga import kotlinx.serialization.Serializable diff --git a/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt b/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt index f527083d7..320caeb8d 100644 --- a/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt +++ b/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt @@ -1,10 +1,8 @@ package tachiyomi.source.local import android.content.Context -import eu.kanade.domain.manga.model.COMIC_INFO_FILE -import eu.kanade.domain.manga.model.ComicInfo -import eu.kanade.domain.manga.model.copyFromComicInfo import eu.kanade.tachiyomi.source.CatalogueSource +import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.UnmeteredSource import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage @@ -19,11 +17,15 @@ import logcat.LogPriority import nl.adaptivity.xmlutil.AndroidXmlReader import nl.adaptivity.xmlutil.serialization.XML import rx.Observable +import tachiyomi.core.metadata.comicinfo.COMIC_INFO_FILE +import tachiyomi.core.metadata.comicinfo.ComicInfo +import tachiyomi.core.metadata.comicinfo.copyFromComicInfo import tachiyomi.core.metadata.tachiyomi.MangaDetails import tachiyomi.core.util.lang.withIOContext import tachiyomi.core.util.system.ImageUtil import tachiyomi.core.util.system.logcat import tachiyomi.domain.chapter.service.ChapterRecognition +import tachiyomi.domain.manga.model.Manga import tachiyomi.source.local.filter.OrderBy import tachiyomi.source.local.image.LocalCoverManager import tachiyomi.source.local.io.Archive @@ -349,3 +351,7 @@ actual class LocalSource( private val LATEST_THRESHOLD = TimeUnit.MILLISECONDS.convert(7, TimeUnit.DAYS) } } + +fun Manga.isLocal(): Boolean = source == LocalSource.ID + +fun Source.isLocal(): Boolean = id == LocalSource.ID