From d6252ab7703d52ecf9f43de3ee36fd63e665a31f Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Mon, 19 Aug 2024 18:11:39 +0600 Subject: [PATCH] Address spotless lint errors (#1138) * Add spotless (with ktlint) * Run spotlessApply * screaming case screaming case screaming case * Update PagerViewerAdapter.kt * Update ReaderTransitionView.kt --- app/build.gradle.kts | 9 ++- .../interactor/SyncChaptersWithSource.kt | 5 +- .../java/eu/kanade/domain/ui/UiPreferences.kt | 6 +- .../browse/ExtensionDetailsScreen.kt | 6 +- .../presentation/browse/ExtensionsScreen.kt | 8 ++- .../presentation/browse/SourcesScreen.kt | 4 +- .../presentation/components/TabbedDialog.kt | 2 +- .../library/components/CommonMangaItem.kt | 10 ++-- .../manga/components/ChapterHeader.kt | 4 +- .../manga/components/MangaChapterListItem.kt | 10 ++-- .../manga/components/MangaInfoHeader.kt | 3 +- .../presentation/more/NewUpdateScreen.kt | 2 +- .../settings/screen/SettingsAdvancedScreen.kt | 2 +- .../screen/about/OpenSourceLicensesScreen.kt | 2 +- .../screen/debug/BackupSchemaScreen.kt | 6 +- .../settings/screen/debug/DebugInfoScreen.kt | 4 +- .../settings/screen/debug/WorkerInfoScreen.kt | 8 +-- .../settings/widget/TriStateListDialog.kt | 4 +- .../more/stats/components/StatsItem.kt | 4 +- .../presentation/reader/ChapterTransition.kt | 6 +- .../presentation/track/TrackInfoDialogHome.kt | 14 ++--- .../presentation/updates/UpdatesUiItem.kt | 6 +- .../eu/kanade/presentation/util/Navigator.kt | 1 - .../data/backup/restore/BackupRestorer.kt | 2 +- .../data/backup/restore/RestoreOptions.kt | 4 +- .../restorers/ExtensionRepoRestorer.kt | 4 +- .../tachiyomi/data/coil/MangaCoverFetcher.kt | 2 +- .../tachiyomi/data/database/models/Chapter.kt | 2 + .../data/database/models/ChapterImpl.kt | 2 + .../tachiyomi/data/database/models/Track.kt | 2 + .../data/database/models/TrackImpl.kt | 2 + .../tachiyomi/data/download/Downloader.kt | 15 +++-- .../data/library/LibraryUpdateJob.kt | 4 +- .../data/track/anilist/AnilistApi.kt | 38 ++++++------ .../data/track/bangumi/BangumiApi.kt | 46 +++++++------- .../tachiyomi/data/track/kitsu/KitsuApi.kt | 60 +++++++++---------- .../data/track/kitsu/KitsuDateHelper.kt | 4 +- .../tachiyomi/data/track/model/TrackSearch.kt | 2 + .../data/track/shikimori/ShikimoriApi.kt | 52 ++++++++-------- .../tachiyomi/extension/ExtensionManager.kt | 48 +++++++-------- .../tachiyomi/extension/model/InstallStep.kt | 8 ++- .../base/delegate/SecureActivityDelegate.kt | 2 +- .../browse/extension/ExtensionsScreenModel.kt | 20 ++++--- .../eu/kanade/tachiyomi/ui/home/HomeScreen.kt | 13 ++-- .../ui/library/LibraryScreenModel.kt | 2 +- .../ui/library/LibrarySettingsScreenModel.kt | 2 +- .../eu/kanade/tachiyomi/ui/more/MoreTab.kt | 6 +- .../tachiyomi/ui/reader/ReaderViewModel.kt | 10 +++- .../ui/reader/setting/ReaderPreferences.kt | 2 +- .../ui/reader/viewer/ReaderPageImageView.kt | 4 +- .../ui/reader/viewer/ReaderTransitionView.kt | 19 +++--- .../reader/viewer/pager/PagerViewerAdapter.kt | 4 +- .../ui/reader/viewer/webtoon/WebtoonConfig.kt | 2 +- .../viewer/webtoon/WebtoonRecyclerView.kt | 6 +- .../ui/reader/viewer/webtoon/WebtoonViewer.kt | 4 +- .../util/system/ChildFirstPathClassLoader.kt | 2 +- .../core/migration/MigrationJobFactory.kt | 10 +++- .../mihon/core/migration/MigrationStrategy.kt | 4 +- .../java/mihon/core/migration/Migrator.kt | 2 +- .../upcoming/components/calendar/Calendar.kt | 12 ++-- .../components/calendar/CalendarDay.kt | 9 +-- .../components/calendar/CalendarHeader.kt | 10 ++-- .../components/calendar/CalendarIndicator.kt | 8 +-- app/src/main/res/drawable/ic_glasses_24dp.xml | 2 +- .../drawable/material_popup_background.xml | 2 +- app/src/main/res/values/themes.xml | 2 +- app/src/main/res/xml/s_pen_actions.xml | 2 +- .../java/mihon/core/migration/MigratorTest.kt | 4 +- core-metadata/src/main/AndroidManifest.xml | 2 +- core/common/src/main/AndroidManifest.xml | 2 +- .../eu/kanade/tachiyomi/network/Requests.kt | 2 + .../core/common/util/system/ImageUtil.kt | 20 ++++--- data/src/main/AndroidManifest.xml | 2 +- .../java/tachiyomi/data/QueryPagingSource.kt | 4 +- domain/src/main/AndroidManifest.xml | 2 +- .../interactor/ShouldUpdateDbChapter.kt | 3 +- .../interactor/GetApplicationRelease.kt | 6 +- i18n/src/androidMain/AndroidManifest.xml | 2 +- .../commonMain/moko-resources/am/plurals.xml | 2 +- .../commonMain/moko-resources/am/strings.xml | 2 +- .../commonMain/moko-resources/ar/plurals.xml | 2 +- .../commonMain/moko-resources/ar/strings.xml | 2 +- .../commonMain/moko-resources/be/plurals.xml | 2 +- .../commonMain/moko-resources/be/strings.xml | 2 +- .../commonMain/moko-resources/bg/plurals.xml | 2 +- .../commonMain/moko-resources/bg/strings.xml | 2 +- .../commonMain/moko-resources/bn/plurals.xml | 2 +- .../commonMain/moko-resources/bn/strings.xml | 2 +- .../commonMain/moko-resources/ca/plurals.xml | 2 +- .../commonMain/moko-resources/ca/strings.xml | 2 +- .../commonMain/moko-resources/ceb/plurals.xml | 2 +- .../commonMain/moko-resources/ceb/strings.xml | 2 +- .../commonMain/moko-resources/cs/plurals.xml | 2 +- .../commonMain/moko-resources/cs/strings.xml | 2 +- .../commonMain/moko-resources/cv/plurals.xml | 2 +- .../commonMain/moko-resources/cv/strings.xml | 2 +- .../commonMain/moko-resources/da/plurals.xml | 2 +- .../commonMain/moko-resources/da/strings.xml | 2 +- .../commonMain/moko-resources/de/plurals.xml | 2 +- .../commonMain/moko-resources/de/strings.xml | 2 +- .../commonMain/moko-resources/el/plurals.xml | 2 +- .../commonMain/moko-resources/el/strings.xml | 2 +- .../commonMain/moko-resources/eo/plurals.xml | 2 +- .../commonMain/moko-resources/eo/strings.xml | 2 +- .../commonMain/moko-resources/es/plurals.xml | 2 +- .../commonMain/moko-resources/es/strings.xml | 2 +- .../commonMain/moko-resources/eu/plurals.xml | 2 +- .../commonMain/moko-resources/eu/strings.xml | 2 +- .../commonMain/moko-resources/fa/plurals.xml | 2 +- .../commonMain/moko-resources/fa/strings.xml | 2 +- .../commonMain/moko-resources/fi/plurals.xml | 2 +- .../commonMain/moko-resources/fi/strings.xml | 2 +- .../commonMain/moko-resources/fil/plurals.xml | 2 +- .../commonMain/moko-resources/fil/strings.xml | 2 +- .../commonMain/moko-resources/fr/plurals.xml | 2 +- .../commonMain/moko-resources/fr/strings.xml | 2 +- .../commonMain/moko-resources/gl/plurals.xml | 2 +- .../commonMain/moko-resources/gl/strings.xml | 2 +- .../commonMain/moko-resources/he/plurals.xml | 2 +- .../commonMain/moko-resources/he/strings.xml | 2 +- .../commonMain/moko-resources/hi/plurals.xml | 2 +- .../commonMain/moko-resources/hi/strings.xml | 2 +- .../commonMain/moko-resources/hr/plurals.xml | 2 +- .../commonMain/moko-resources/hr/strings.xml | 2 +- .../commonMain/moko-resources/hu/plurals.xml | 2 +- .../commonMain/moko-resources/hu/strings.xml | 2 +- .../commonMain/moko-resources/in/plurals.xml | 2 +- .../commonMain/moko-resources/in/strings.xml | 2 +- .../commonMain/moko-resources/it/plurals.xml | 2 +- .../commonMain/moko-resources/it/strings.xml | 2 +- .../commonMain/moko-resources/ja/plurals.xml | 2 +- .../commonMain/moko-resources/ja/strings.xml | 2 +- .../commonMain/moko-resources/jv/plurals.xml | 2 +- .../commonMain/moko-resources/jv/strings.xml | 2 +- .../moko-resources/ka-rGE/plurals.xml | 2 +- .../moko-resources/ka-rGE/strings.xml | 2 +- .../commonMain/moko-resources/kk/plurals.xml | 2 +- .../commonMain/moko-resources/kk/strings.xml | 2 +- .../commonMain/moko-resources/km/plurals.xml | 2 +- .../commonMain/moko-resources/km/strings.xml | 2 +- .../commonMain/moko-resources/kn/plurals.xml | 2 +- .../commonMain/moko-resources/kn/strings.xml | 2 +- .../commonMain/moko-resources/ko/plurals.xml | 2 +- .../commonMain/moko-resources/ko/strings.xml | 2 +- .../commonMain/moko-resources/lt/plurals.xml | 2 +- .../commonMain/moko-resources/lt/strings.xml | 2 +- .../commonMain/moko-resources/lv/plurals.xml | 2 +- .../commonMain/moko-resources/lv/strings.xml | 2 +- .../commonMain/moko-resources/ml/plurals.xml | 2 +- .../commonMain/moko-resources/ml/strings.xml | 2 +- .../commonMain/moko-resources/mr/plurals.xml | 2 +- .../commonMain/moko-resources/mr/strings.xml | 2 +- .../commonMain/moko-resources/ms/plurals.xml | 2 +- .../commonMain/moko-resources/ms/strings.xml | 2 +- .../moko-resources/nb-rNO/plurals.xml | 2 +- .../moko-resources/nb-rNO/strings.xml | 2 +- .../commonMain/moko-resources/ne/plurals.xml | 2 +- .../commonMain/moko-resources/ne/strings.xml | 2 +- .../commonMain/moko-resources/nl/plurals.xml | 2 +- .../commonMain/moko-resources/nl/strings.xml | 2 +- .../commonMain/moko-resources/nn/plurals.xml | 2 +- .../commonMain/moko-resources/nn/strings.xml | 2 +- .../commonMain/moko-resources/pl/plurals.xml | 2 +- .../commonMain/moko-resources/pl/strings.xml | 2 +- .../moko-resources/pt-rBR/plurals.xml | 2 +- .../moko-resources/pt-rBR/strings.xml | 2 +- .../commonMain/moko-resources/pt/plurals.xml | 2 +- .../commonMain/moko-resources/pt/strings.xml | 2 +- .../commonMain/moko-resources/ro/plurals.xml | 2 +- .../commonMain/moko-resources/ro/strings.xml | 2 +- .../commonMain/moko-resources/ru/plurals.xml | 2 +- .../commonMain/moko-resources/ru/strings.xml | 2 +- .../commonMain/moko-resources/sa/plurals.xml | 2 +- .../commonMain/moko-resources/sa/strings.xml | 2 +- .../commonMain/moko-resources/sah/plurals.xml | 2 +- .../commonMain/moko-resources/sah/strings.xml | 2 +- .../commonMain/moko-resources/sc/plurals.xml | 2 +- .../commonMain/moko-resources/sc/strings.xml | 2 +- .../commonMain/moko-resources/sdh/plurals.xml | 2 +- .../commonMain/moko-resources/sdh/strings.xml | 2 +- .../commonMain/moko-resources/sk/plurals.xml | 2 +- .../commonMain/moko-resources/sk/strings.xml | 2 +- .../commonMain/moko-resources/sq/plurals.xml | 2 +- .../commonMain/moko-resources/sq/strings.xml | 2 +- .../commonMain/moko-resources/sr/plurals.xml | 2 +- .../commonMain/moko-resources/sr/strings.xml | 2 +- .../commonMain/moko-resources/sv/plurals.xml | 2 +- .../commonMain/moko-resources/sv/strings.xml | 2 +- .../commonMain/moko-resources/te/plurals.xml | 2 +- .../commonMain/moko-resources/te/strings.xml | 2 +- .../commonMain/moko-resources/th/plurals.xml | 2 +- .../commonMain/moko-resources/th/strings.xml | 2 +- .../commonMain/moko-resources/tr/plurals.xml | 2 +- .../commonMain/moko-resources/tr/strings.xml | 2 +- .../commonMain/moko-resources/uk/plurals.xml | 2 +- .../commonMain/moko-resources/uk/strings.xml | 2 +- .../commonMain/moko-resources/uz/plurals.xml | 2 +- .../commonMain/moko-resources/uz/strings.xml | 2 +- .../commonMain/moko-resources/vi/plurals.xml | 2 +- .../commonMain/moko-resources/vi/strings.xml | 2 +- .../moko-resources/zh-rCN/plurals.xml | 2 +- .../moko-resources/zh-rCN/strings.xml | 2 +- .../moko-resources/zh-rTW/plurals.xml | 2 +- .../moko-resources/zh-rTW/strings.xml | 2 +- .../src/main/AndroidManifest.xml | 2 +- .../core/components/AdaptiveSheet.kt | 4 +- .../core/components/SettingsItems.kt | 7 +-- .../core/components/VerticalFastScroller.kt | 3 +- .../core/components/WheelPicker.kt | 10 ++-- .../core/components/material/Button.kt | 4 +- .../core/components/material/Constants.kt | 4 +- .../core/components/material/Scaffold.kt | 7 +-- .../presentation/core/icons/Discord.kt | 17 ++++-- .../presentation/core/icons/Facebook.kt | 17 ++++-- .../presentation/core/icons/Github.kt | 17 ++++-- .../presentation/core/icons/Reddit.kt | 17 ++++-- .../tachiyomi/presentation/core/icons/X.kt | 14 ++++- .../presentation/core/util/Modifier.kt | 4 +- .../res/values-night/colors_midnightdusk.xml | 2 +- .../res/values-night/colors_tidalwave.xml | 2 +- .../src/main/res/values/colors_tidalwave.xml | 2 +- .../src/main/AndroidManifest.xml | 2 +- .../src/main/res/values/colors_appwidget.xml | 2 +- .../src/androidMain/AndroidManifest.xml | 2 +- .../kanade/tachiyomi/source/model/SChapter.kt | 2 + .../tachiyomi/source/model/SChapterImpl.kt | 2 + .../kanade/tachiyomi/source/model/SManga.kt | 2 + .../tachiyomi/source/model/SMangaImpl.kt | 2 + .../src/androidMain/AndroidManifest.xml | 2 +- .../tachiyomi/source/local/LocalSource.kt | 13 ++-- 230 files changed, 580 insertions(+), 467 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1dbee966e..015af54d7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,7 +17,7 @@ if (gradle.startParameter.taskRequests.toString().contains("Standard")) { shortcutHelper.setFilePath("./shortcuts.xml") -val SUPPORTED_ABIS = setOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64") +val supportedAbis = setOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64") android { namespace = "eu.kanade.tachiyomi" @@ -35,7 +35,7 @@ android { buildConfigField("boolean", "PREVIEW", "false") ndk { - abiFilters += SUPPORTED_ABIS + abiFilters += supportedAbis } testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -45,7 +45,7 @@ android { abi { isEnable = true reset() - include(*SUPPORTED_ABIS.toTypedArray()) + include(*supportedAbis.toTypedArray()) isUniversalApk = true } } @@ -158,7 +158,7 @@ dependencies { implementation(compose.ui.tooling.preview) implementation(compose.ui.util) implementation(compose.accompanist.systemuicontroller) - + implementation(androidx.interpolator) implementation(androidx.paging.runtime) @@ -236,7 +236,6 @@ dependencies { implementation(libs.compose.webview) implementation(libs.compose.grid) - // Logging implementation(libs.logcat) 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 300794b4c..80b6438ad 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 @@ -110,7 +110,10 @@ class SyncChaptersWithSource( if (shouldUpdateDbChapter.await(dbChapter, chapter)) { val shouldRenameChapter = downloadProvider.isChapterDirNameChanged(dbChapter, chapter) && downloadManager.isChapterDownloaded( - dbChapter.name, dbChapter.scanlator, manga.title, manga.source, + dbChapter.name, + dbChapter.scanlator, + manga.title, + manga.source, ) if (shouldRenameChapter) { diff --git a/app/src/main/java/eu/kanade/domain/ui/UiPreferences.kt b/app/src/main/java/eu/kanade/domain/ui/UiPreferences.kt index 2efefb517..a0a16251d 100644 --- a/app/src/main/java/eu/kanade/domain/ui/UiPreferences.kt +++ b/app/src/main/java/eu/kanade/domain/ui/UiPreferences.kt @@ -19,7 +19,11 @@ class UiPreferences( fun appTheme() = preferenceStore.getEnum( "pref_app_theme", - if (DeviceUtil.isDynamicColorAvailable) { AppTheme.MONET } else { AppTheme.DEFAULT }, + if (DeviceUtil.isDynamicColorAvailable) { + AppTheme.MONET + } else { + AppTheme.DEFAULT + }, ) fun themeDarkAmoled() = preferenceStore.getBoolean("pref_theme_dark_amoled_key", false) diff --git a/app/src/main/java/eu/kanade/presentation/browse/ExtensionDetailsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/ExtensionDetailsScreen.kt index 277dc5e65..501c0b6fd 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/ExtensionDetailsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/ExtensionDetailsScreen.kt @@ -232,7 +232,7 @@ private fun DetailsHeader( Extension name: ${extension.name} (lang: ${extension.lang}; package: ${extension.pkgName}) Extension version: ${extension.versionName} (lib: ${extension.libVersion}; version code: ${extension.versionCode}) NSFW: ${extension.isNsfw} - """.trimIndent() + """.trimIndent(), ) if (extension is Extension.Installed) { @@ -242,8 +242,8 @@ private fun DetailsHeader( Update available: ${extension.hasUpdate} Obsolete: ${extension.isObsolete} Shared: ${extension.isShared} - Repository: ${extension.repoUrl} - """.trimIndent() + Repository: ${extension.repoUrl} + """.trimIndent(), ) } } diff --git a/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt index f5a6fedd4..475f0172d 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt @@ -219,7 +219,9 @@ private fun ExtensionContent( when (it) { is Extension.Available -> onInstallExtension(it) is Extension.Installed -> onOpenExtension(it) - is Extension.Untrusted -> { trustState = it } + is Extension.Untrusted -> { + trustState = it + } } }, onLongClickItem = onLongClickItem, @@ -241,7 +243,9 @@ private fun ExtensionContent( onOpenExtension(it) } } - is Extension.Untrusted -> { trustState = it } + is Extension.Untrusted -> { + trustState = it + } } }, ) diff --git a/app/src/main/java/eu/kanade/presentation/browse/SourcesScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/SourcesScreen.kt index 56644b3d8..37c77419b 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/SourcesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/SourcesScreen.kt @@ -28,7 +28,7 @@ import tachiyomi.domain.source.model.Pin import tachiyomi.domain.source.model.Source import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.ScrollbarLazyColumn -import tachiyomi.presentation.core.components.material.SecondaryItemAlpha +import tachiyomi.presentation.core.components.material.SECONDARY_ALPHA import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.components.material.topSmallPaddingValues import tachiyomi.presentation.core.i18n.stringResource @@ -148,7 +148,7 @@ private fun SourcePinButton( MaterialTheme.colorScheme.primary } else { MaterialTheme.colorScheme.onBackground.copy( - alpha = SecondaryItemAlpha, + alpha = SECONDARY_ALPHA, ) } val description = if (isPinned) MR.strings.action_unpin else MR.strings.action_pin diff --git a/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt b/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt index b651060f7..69b58c616 100644 --- a/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt @@ -79,7 +79,7 @@ fun TabbedDialog( modifier = Modifier.animateContentSize(), state = pagerState, verticalAlignment = Alignment.Top, - pageContent = { page -> content(page) } + pageContent = { page -> content(page) }, ) } } diff --git a/app/src/main/java/eu/kanade/presentation/library/components/CommonMangaItem.kt b/app/src/main/java/eu/kanade/presentation/library/components/CommonMangaItem.kt index b4a4c2cc0..a78462a75 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/CommonMangaItem.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/CommonMangaItem.kt @@ -62,7 +62,7 @@ private val ContinueReadingButtonIconSizeLarge = 20.dp private val ContinueReadingButtonGridPadding = 6.dp private val ContinueReadingButtonListSpacing = 8.dp -private const val GridSelectedCoverAlpha = 0.76f +private const val GRID_SELECTED_COVER_ALPHA = 0.76f /** * Layout of grid list item with title overlaying the cover. @@ -90,7 +90,7 @@ fun MangaCompactGridItem( MangaCover.Book( modifier = Modifier .fillMaxWidth() - .alpha(if (isSelected) GridSelectedCoverAlpha else coverAlpha), + .alpha(if (isSelected) GRID_SELECTED_COVER_ALPHA else coverAlpha), data = coverData, ) }, @@ -197,7 +197,7 @@ fun MangaComfortableGridItem( MangaCover.Book( modifier = Modifier .fillMaxWidth() - .alpha(if (isSelected) GridSelectedCoverAlpha else coverAlpha), + .alpha(if (isSelected) GRID_SELECTED_COVER_ALPHA else coverAlpha), data = coverData, ) }, @@ -371,7 +371,7 @@ fun MangaListItem( size = ContinueReadingButtonSizeSmall, iconSize = ContinueReadingButtonIconSizeSmall, onClick = onClickContinueReading, - modifier = Modifier.padding(start = ContinueReadingButtonListSpacing) + modifier = Modifier.padding(start = ContinueReadingButtonListSpacing), ) } } @@ -392,7 +392,7 @@ private fun ContinueReadingButton( containerColor = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.9f), contentColor = contentColorFor(MaterialTheme.colorScheme.primaryContainer), ), - modifier = Modifier.size(size) + modifier = Modifier.size(size), ) { Icon( imageVector = Icons.Filled.PlayArrow, diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/ChapterHeader.kt b/app/src/main/java/eu/kanade/presentation/manga/components/ChapterHeader.kt index 99ad1b37a..6067d24bd 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/ChapterHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/ChapterHeader.kt @@ -12,7 +12,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import tachiyomi.i18n.MR -import tachiyomi.presentation.core.components.material.SecondaryItemAlpha +import tachiyomi.presentation.core.components.material.SECONDARY_ALPHA import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.i18n.pluralStringResource import tachiyomi.presentation.core.i18n.stringResource @@ -60,6 +60,6 @@ private fun MissingChaptersWarning(count: Int) { maxLines = 1, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.error.copy(alpha = SecondaryItemAlpha), + color = MaterialTheme.colorScheme.error.copy(alpha = SECONDARY_ALPHA), ) } diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt index 6f323993c..730c98afe 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt @@ -40,8 +40,8 @@ import eu.kanade.tachiyomi.data.download.model.Download import me.saket.swipe.SwipeableActionsBox import tachiyomi.domain.library.service.LibraryPreferences import tachiyomi.i18n.MR -import tachiyomi.presentation.core.components.material.ReadItemAlpha -import tachiyomi.presentation.core.components.material.SecondaryItemAlpha +import tachiyomi.presentation.core.components.material.DISABLED_ALPHA +import tachiyomi.presentation.core.components.material.SECONDARY_ALPHA import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.util.selectedBackground @@ -132,7 +132,7 @@ fun MangaChapterListItem( maxLines = 1, overflow = TextOverflow.Ellipsis, onTextLayout = { textHeight = it.size.height }, - color = LocalContentColor.current.copy(alpha = if (read) ReadItemAlpha else 1f), + color = LocalContentColor.current.copy(alpha = if (read) DISABLED_ALPHA else 1f), ) } @@ -140,7 +140,7 @@ fun MangaChapterListItem( val subtitleStyle = MaterialTheme.typography.bodySmall .merge( color = LocalContentColor.current - .copy(alpha = if (read) ReadItemAlpha else SecondaryItemAlpha) + .copy(alpha = if (read) DISABLED_ALPHA else SECONDARY_ALPHA), ) ProvideTextStyle(value = subtitleStyle) { if (date != null) { @@ -156,7 +156,7 @@ fun MangaChapterListItem( text = readProgress, maxLines = 1, overflow = TextOverflow.Ellipsis, - color = LocalContentColor.current.copy(alpha = ReadItemAlpha), + color = LocalContentColor.current.copy(alpha = DISABLED_ALPHA), ) if (scanlator != null) DotSeparatorText() } diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MangaInfoHeader.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MangaInfoHeader.kt index f65525646..3b8275f84 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/MangaInfoHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MangaInfoHeader.kt @@ -81,6 +81,7 @@ import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.util.system.copyToClipboard import tachiyomi.domain.manga.model.Manga import tachiyomi.i18n.MR +import tachiyomi.presentation.core.components.material.DISABLED_ALPHA import tachiyomi.presentation.core.components.material.TextButton import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.i18n.pluralStringResource @@ -177,7 +178,7 @@ fun MangaActionRow( onEditCategory: (() -> Unit)?, modifier: Modifier = Modifier, ) { - val defaultActionButtonColor = MaterialTheme.colorScheme.onSurface.copy(alpha = .38f) + val defaultActionButtonColor = MaterialTheme.colorScheme.onSurface.copy(alpha = DISABLED_ALPHA) // TODO: show something better when using custom interval val nextUpdateDays = remember(nextUpdate) { diff --git a/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt b/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt index 3d561b0c3..87dd1ee4d 100644 --- a/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt @@ -75,7 +75,7 @@ private fun NewUpdateScreenPreview() { changelogInfo = """ ## Yay Foobar - + ### More info - Hello - World 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 646c8c042..b3a999559 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 @@ -340,7 +340,7 @@ object SettingsAdvancedScreen : SearchableSettings { chooseColorProfile.launch(arrayOf("*/*")) }, ), - ) + ), ) } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/OpenSourceLicensesScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/OpenSourceLicensesScreen.kt index 3c2309b32..6e92d0cfc 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/OpenSourceLicensesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/OpenSourceLicensesScreen.kt @@ -37,7 +37,7 @@ class OpenSourceLicensesScreen : Screen() { name = it.name, website = it.website, license = it.licenses.firstOrNull()?.htmlReadyLicenseContent.orEmpty(), - ) + ), ) }, ) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/BackupSchemaScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/BackupSchemaScreen.kt index d5652b16a..8fe1d18c1 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/BackupSchemaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/BackupSchemaScreen.kt @@ -28,7 +28,7 @@ import tachiyomi.presentation.core.i18n.stringResource class BackupSchemaScreen : Screen() { companion object { - const val title = "Backup file schema" + const val TITLE = "Backup file schema" } @Composable @@ -41,7 +41,7 @@ class BackupSchemaScreen : Screen() { Scaffold( topBar = { AppBar( - title = title, + title = TITLE, navigateUp = navigator::pop, actions = { AppBarActions( @@ -50,7 +50,7 @@ class BackupSchemaScreen : Screen() { title = stringResource(MR.strings.action_copy_to_clipboard), icon = Icons.Default.ContentCopy, onClick = { - context.copyToClipboard(title, schema) + context.copyToClipboard(TITLE, schema) }, ), ), diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/DebugInfoScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/DebugInfoScreen.kt index 0db4bd3c7..d44ee1319 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/DebugInfoScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/DebugInfoScreen.kt @@ -31,11 +31,11 @@ class DebugInfoScreen : Screen() { itemsProvider = { listOf( Preference.PreferenceItem.TextPreference( - title = WorkerInfoScreen.title, + title = WorkerInfoScreen.TITLE, onClick = { navigator.push(WorkerInfoScreen()) }, ), Preference.PreferenceItem.TextPreference( - title = BackupSchemaScreen.title, + title = BackupSchemaScreen.TITLE, onClick = { navigator.push(BackupSchemaScreen()) }, ), getAppInfoGroup(), diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/WorkerInfoScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/WorkerInfoScreen.kt index 4a57103d8..88f1e6da2 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/WorkerInfoScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/WorkerInfoScreen.kt @@ -49,7 +49,7 @@ import java.time.ZoneId class WorkerInfoScreen : Screen() { companion object { - const val title = "Worker info" + const val TITLE = "Worker info" } @Composable @@ -65,7 +65,7 @@ class WorkerInfoScreen : Screen() { Scaffold( topBar = { AppBar( - title = title, + title = TITLE, navigateUp = navigator::pop, actions = { AppBarActions( @@ -74,7 +74,7 @@ class WorkerInfoScreen : Screen() { title = stringResource(MR.strings.action_copy_to_clipboard), icon = Icons.Default.ContentCopy, onClick = { - context.copyToClipboard(title, enqueued + finished + running) + context.copyToClipboard(TITLE, enqueued + finished + running) }, ), ), @@ -159,7 +159,7 @@ class WorkerInfoScreen : Screen() { Injekt.get().dateFormat().get(), ), ) - appendLine("Next scheduled run: $timestamp",) + appendLine("Next scheduled run: $timestamp") appendLine("Attempt #${workInfo.runAttemptCount + 1}") } appendLine() diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/TriStateListDialog.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/TriStateListDialog.kt index be5029ac3..4f396068a 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/TriStateListDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/TriStateListDialog.kt @@ -32,7 +32,9 @@ import tachiyomi.i18n.MR import tachiyomi.presentation.core.i18n.stringResource private enum class State { - CHECKED, INVERSED, UNCHECKED + CHECKED, + INVERSED, + UNCHECKED, } @Composable diff --git a/app/src/main/java/eu/kanade/presentation/more/stats/components/StatsItem.kt b/app/src/main/java/eu/kanade/presentation/more/stats/components/StatsItem.kt index 8002b3d04..d38643ee1 100644 --- a/app/src/main/java/eu/kanade/presentation/more/stats/components/StatsItem.kt +++ b/app/src/main/java/eu/kanade/presentation/more/stats/components/StatsItem.kt @@ -15,7 +15,7 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign -import tachiyomi.presentation.core.components.material.SecondaryItemAlpha +import tachiyomi.presentation.core.components.material.SECONDARY_ALPHA import tachiyomi.presentation.core.components.material.padding @Composable @@ -73,7 +73,7 @@ private fun RowScope.BaseStatsItem( style = subtitleStyle .copy( color = MaterialTheme.colorScheme.onSurface - .copy(alpha = SecondaryItemAlpha), + .copy(alpha = SECONDARY_ALPHA), ), textAlign = TextAlign.Center, ) diff --git a/app/src/main/java/eu/kanade/presentation/reader/ChapterTransition.kt b/app/src/main/java/eu/kanade/presentation/reader/ChapterTransition.kt index 5fb749828..f76628b1a 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/ChapterTransition.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/ChapterTransition.kt @@ -226,7 +226,7 @@ private fun ChapterText( Text( text = buildAnnotatedString { if (downloaded) { - appendInlineContent(DownloadedIconContentId) + appendInlineContent(DOWNLOADED_ICON_ID) append(' ') } append(name) @@ -236,7 +236,7 @@ private fun ChapterText( overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.titleLarge, inlineContent = persistentMapOf( - DownloadedIconContentId to InlineTextContent( + DOWNLOADED_ICON_ID to InlineTextContent( Placeholder( width = 22.sp, height = 22.sp, @@ -273,7 +273,7 @@ private val CardColor: CardColors ) private val VerticalSpacerSize = 24.dp -private const val DownloadedIconContentId = "downloaded" +private const val DOWNLOADED_ICON_ID = "downloaded" private fun previewChapter(name: String, scanlator: String, chapterNumber: Double) = Chapter.create().copy( id = 0L, diff --git a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt index 4e146c60e..3d766c4cf 100644 --- a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt +++ b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt @@ -38,7 +38,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.style.TextAlign @@ -58,8 +57,6 @@ import tachiyomi.i18n.MR import tachiyomi.presentation.core.i18n.stringResource import java.time.format.DateTimeFormatter -private const val UnsetStatusTextAlpha = 0.5F - @Composable fun TrackInfoDialogHome( trackItems: List, @@ -211,10 +208,9 @@ private fun TrackInfoItem( if (onScoreClick != null) { VerticalDivider() TrackDetailsItem( - modifier = Modifier - .weight(1f) - .alpha(if (score == null) UnsetStatusTextAlpha else 1f), - text = score ?: stringResource(MR.strings.score), + modifier = Modifier.weight(1f), + text = score, + placeholder = stringResource(MR.strings.score), onClick = onScoreClick, ) } @@ -243,6 +239,8 @@ private fun TrackInfoItem( } } +private const val UNSET_TEXT_ALPHA = 0.5F + @Composable private fun TrackDetailsItem( text: String?, @@ -263,7 +261,7 @@ private fun TrackDetailsItem( overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.bodyMedium, textAlign = TextAlign.Center, - color = MaterialTheme.colorScheme.onSurface.copy(alpha = if (text == null) UnsetStatusTextAlpha else 1f), + color = MaterialTheme.colorScheme.onSurface.copy(alpha = if (text == null) UNSET_TEXT_ALPHA else 1f), ) } } diff --git a/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt b/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt index e0e60d4fb..40743185d 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt @@ -44,7 +44,7 @@ import eu.kanade.tachiyomi.ui.updates.UpdatesItem import tachiyomi.domain.updates.model.UpdatesWithRelations import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.ListGroupHeader -import tachiyomi.presentation.core.components.material.ReadItemAlpha +import tachiyomi.presentation.core.components.material.DISABLED_ALPHA import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.util.selectedBackground @@ -146,7 +146,7 @@ private fun UpdatesUiItem( modifier: Modifier = Modifier, ) { val haptic = LocalHapticFeedback.current - val textAlpha = if (update.read) ReadItemAlpha else 1f + val textAlpha = if (update.read) DISABLED_ALPHA else 1f Row( modifier = modifier @@ -220,7 +220,7 @@ private fun UpdatesUiItem( Text( text = readProgress, maxLines = 1, - color = LocalContentColor.current.copy(alpha = ReadItemAlpha), + color = LocalContentColor.current.copy(alpha = DISABLED_ALPHA), overflow = TextOverflow.Ellipsis, ) } diff --git a/app/src/main/java/eu/kanade/presentation/util/Navigator.kt b/app/src/main/java/eu/kanade/presentation/util/Navigator.kt index 6cc93d6b2..b033d4883 100644 --- a/app/src/main/java/eu/kanade/presentation/util/Navigator.kt +++ b/app/src/main/java/eu/kanade/presentation/util/Navigator.kt @@ -1,6 +1,5 @@ package eu.kanade.presentation.util -import android.annotation.SuppressLint import androidx.compose.animation.AnimatedContent import androidx.compose.animation.AnimatedContentTransitionScope import androidx.compose.animation.ContentTransform diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt index c4275f96f..fec340fa3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt @@ -167,7 +167,7 @@ class BackupRestorer( } private fun CoroutineScope.restoreExtensionRepos( - backupExtensionRepo: List + backupExtensionRepo: List, ) = launch { backupExtensionRepo .forEach { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/RestoreOptions.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/RestoreOptions.kt index 933bf0568..c2c88c16b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/RestoreOptions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/RestoreOptions.kt @@ -9,7 +9,7 @@ data class RestoreOptions( val categories: Boolean = true, val appSettings: Boolean = true, val extensionRepoSettings: Boolean = true, - val sourceSettings: Boolean = true + val sourceSettings: Boolean = true, ) { fun asBooleanArray() = booleanArrayOf( @@ -17,7 +17,7 @@ data class RestoreOptions( categories, appSettings, extensionRepoSettings, - sourceSettings + sourceSettings, ) fun canRestore() = libraryEntries || categories || appSettings || extensionRepoSettings || sourceSettings diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/ExtensionRepoRestorer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/ExtensionRepoRestorer.kt index 1dd0da491..006e48df1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/ExtensionRepoRestorer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/ExtensionRepoRestorer.kt @@ -8,7 +8,7 @@ import uy.kohesive.injekt.api.get class ExtensionRepoRestorer( private val handler: DatabaseHandler = Injekt.get(), - private val getExtensionRepos: GetExtensionRepo = Injekt.get() + private val getExtensionRepos: GetExtensionRepo = Injekt.get(), ) { suspend operator fun invoke( @@ -32,7 +32,7 @@ class ExtensionRepoRestorer( backupRepo.name, backupRepo.shortName, backupRepo.website, - backupRepo.signingKeyFingerprint + backupRepo.signingKeyFingerprint, ) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/coil/MangaCoverFetcher.kt b/app/src/main/java/eu/kanade/tachiyomi/data/coil/MangaCoverFetcher.kt index 832fe95f9..8ccd6d4ba 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/coil/MangaCoverFetcher.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/coil/MangaCoverFetcher.kt @@ -85,7 +85,7 @@ class MangaCoverFetcher( source = ImageSource( file = file.toOkioPath(), fileSystem = FileSystem.SYSTEM, - diskCacheKey = diskCacheKey + diskCacheKey = diskCacheKey, ), mimeType = "image/*", dataSource = DataSource.DISK, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt index f91368084..799998f20 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt @@ -1,3 +1,5 @@ +@file:Suppress("PropertyName", "ktlint:standard:property-naming") + package eu.kanade.tachiyomi.data.database.models import eu.kanade.tachiyomi.source.model.SChapter diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt index a92dd56df..7db913c99 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt @@ -1,3 +1,5 @@ +@file:Suppress("PropertyName", "ktlint:standard:property-naming") + package eu.kanade.tachiyomi.data.database.models class ChapterImpl : Chapter { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt index aac7ec4c3..15c12c4a0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt @@ -1,3 +1,5 @@ +@file:Suppress("PropertyName", "ktlint:standard:property-naming") + package eu.kanade.tachiyomi.data.database.models import java.io.Serializable diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt index 85868219f..da5aa2856 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt @@ -1,3 +1,5 @@ +@file:Suppress("PropertyName", "ktlint:standard:property-naming") + package eu.kanade.tachiyomi.data.database.models class TrackImpl : Track { 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 57c3a9824..bf4940e2a 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 @@ -180,7 +180,7 @@ class Downloader( fun clearQueue() { cancelDownloaderJob() - _clearQueue() + internalClearQueue() notifier.dismissProgress() } @@ -194,9 +194,12 @@ class Downloader( val activeDownloadsFlow = queueState.transformLatest { queue -> while (true) { val activeDownloads = queue.asSequence() - .filter { it.status.value <= Download.State.DOWNLOADING.value } // Ignore completed downloads, leave them in the queue + // Ignore completed downloads, leave them in the queue + .filter { it.status.value <= Download.State.DOWNLOADING.value } .groupBy { it.source } - .toList().take(5) // Concurrently download from 5 different sources + .toList() + // Concurrently download from 5 different sources + .take(5) .map { (_, downloads) -> downloads.first() } emit(activeDownloads) @@ -616,7 +619,7 @@ class Downloader( chapter, urls, categories, - source.name + source.name, ) // Remove the old file @@ -676,7 +679,7 @@ class Downloader( removeFromQueueIf { it.manga.id == manga.id } } - private fun _clearQueue() { + private fun internalClearQueue() { _queueState.update { it.forEach { download -> if (download.status == Download.State.DOWNLOADING || download.status == Download.State.QUEUE) { @@ -698,7 +701,7 @@ class Downloader( } pause() - _clearQueue() + internalClearQueue() addAllToQueue(downloads) if (wasRunning) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt index 258b1f754..3749c71fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt @@ -437,7 +437,9 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet val constraints = Constraints( requiredNetworkType = if (DEVICE_NETWORK_NOT_METERED in restrictions) { NetworkType.UNMETERED - } else { NetworkType.CONNECTED }, + } else { + NetworkType.CONNECTED + }, requiresCharging = DEVICE_CHARGING in restrictions, requiresBatteryNotLow = true, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt index c808d0f31..e31454e74 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt @@ -47,10 +47,10 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { return withIOContext { val query = """ |mutation AddManga(${'$'}mangaId: Int, ${'$'}progress: Int, ${'$'}status: MediaListStatus) { - |SaveMediaListEntry (mediaId: ${'$'}mangaId, progress: ${'$'}progress, status: ${'$'}status) { - | id - | status - |} + |SaveMediaListEntry (mediaId: ${'$'}mangaId, progress: ${'$'}progress, status: ${'$'}status) { + | id + | status + |} |} | """.trimMargin() @@ -65,7 +65,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { with(json) { authClient.newCall( POST( - apiUrl, + API_URL, body = payload.toString().toRequestBody(jsonMime), ), ) @@ -109,7 +109,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { put("completedAt", createDate(track.finished_reading_date)) } } - authClient.newCall(POST(apiUrl, body = payload.toString().toRequestBody(jsonMime))) + authClient.newCall(POST(API_URL, body = payload.toString().toRequestBody(jsonMime))) .awaitSuccess() track } @@ -119,9 +119,9 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { withIOContext { val query = """ |mutation DeleteManga(${'$'}listId: Int) { - |DeleteMediaListEntry(id: ${'$'}listId) { + |DeleteMediaListEntry(id: ${'$'}listId) { |deleted - |} + |} |} | """.trimMargin() @@ -131,7 +131,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { put("listId", track.libraryId) } } - authClient.newCall(POST(apiUrl, body = payload.toString().toRequestBody(jsonMime))) + authClient.newCall(POST(API_URL, body = payload.toString().toRequestBody(jsonMime))) .awaitSuccess() } } @@ -172,7 +172,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { with(json) { authClient.newCall( POST( - apiUrl, + API_URL, body = payload.toString().toRequestBody(jsonMime), ), ) @@ -242,7 +242,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { with(json) { authClient.newCall( POST( - apiUrl, + API_URL, body = payload.toString().toRequestBody(jsonMime), ), ) @@ -286,7 +286,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { with(json) { authClient.newCall( POST( - apiUrl, + API_URL, body = payload.toString().toRequestBody(jsonMime), ), ) @@ -364,17 +364,17 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { } companion object { - private const val clientId = "16329" - private const val apiUrl = "https://graphql.anilist.co/" - private const val baseUrl = "https://anilist.co/api/v2/" - private const val baseMangaUrl = "https://anilist.co/manga/" + private const val CLIENT_ID = "16329" + private const val API_URL = "https://graphql.anilist.co/" + private const val BASE_URL = "https://anilist.co/api/v2/" + private const val BASE_MANGA_URL = "https://anilist.co/manga/" fun mangaUrl(mediaId: Long): String { - return baseMangaUrl + mediaId + return BASE_MANGA_URL + mediaId } - fun authUrl(): Uri = "${baseUrl}oauth/authorize".toUri().buildUpon() - .appendQueryParameter("client_id", clientId) + fun authUrl(): Uri = "${BASE_URL}oauth/authorize".toUri().buildUpon() + .appendQueryParameter("client_id", CLIENT_ID) .appendQueryParameter("response_type", "token") .build() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt index 65d2dc805..c48fa2490 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt @@ -42,7 +42,7 @@ class BangumiApi( .add("rating", track.score.toInt().toString()) .add("status", track.toBangumiStatus()) .build() - authClient.newCall(POST("$apiUrl/collection/${track.remote_id}/update", body = body)) + authClient.newCall(POST("$API_URL/collection/${track.remote_id}/update", body = body)) .awaitSuccess() track } @@ -55,7 +55,7 @@ class BangumiApi( .add("rating", track.score.toInt().toString()) .add("status", track.toBangumiStatus()) .build() - authClient.newCall(POST("$apiUrl/collection/${track.remote_id}/update", body = sbody)) + authClient.newCall(POST("$API_URL/collection/${track.remote_id}/update", body = sbody)) .awaitSuccess() // chapter update @@ -64,7 +64,7 @@ class BangumiApi( .build() authClient.newCall( POST( - "$apiUrl/subject/${track.remote_id}/update/watched_eps", + "$API_URL/subject/${track.remote_id}/update/watched_eps", body = body, ), ).awaitSuccess() @@ -75,7 +75,7 @@ class BangumiApi( suspend fun search(search: String): List { return withIOContext { - val url = "$apiUrl/search/subject/${URLEncoder.encode(search, StandardCharsets.UTF_8.name())}" + val url = "$API_URL/search/subject/${URLEncoder.encode(search, StandardCharsets.UTF_8.name())}" .toUri() .buildUpon() .appendQueryParameter("max_results", "20") @@ -124,7 +124,7 @@ class BangumiApi( suspend fun findLibManga(track: Track): Track? { return withIOContext { with(json) { - authClient.newCall(GET("$apiUrl/subject/${track.remote_id}")) + authClient.newCall(GET("$API_URL/subject/${track.remote_id}")) .awaitSuccess() .parseAs() .let { jsonToSearch(it) } @@ -134,7 +134,7 @@ class BangumiApi( suspend fun statusLibManga(track: Track): Track? { return withIOContext { - val urlUserRead = "$apiUrl/collection/${track.remote_id}" + val urlUserRead = "$API_URL/collection/${track.remote_id}" val requestUserRead = Request.Builder() .url(urlUserRead) .cacheControl(CacheControl.FORCE_NETWORK) @@ -171,41 +171,41 @@ class BangumiApi( } private fun accessTokenRequest(code: String) = POST( - oauthUrl, + OAUTH_URL, body = FormBody.Builder() .add("grant_type", "authorization_code") - .add("client_id", clientId) - .add("client_secret", clientSecret) + .add("client_id", CLIENT_ID) + .add("client_secret", CLIENT_SECRET) .add("code", code) - .add("redirect_uri", redirectUrl) + .add("redirect_uri", REDIRECT_URL) .build(), ) companion object { - private const val clientId = "bgm291665acbd06a4c28" - private const val clientSecret = "43e5ce36b207de16e5d3cfd3e79118db" + private const val CLIENT_ID = "bgm291665acbd06a4c28" + private const val CLIENT_SECRET = "43e5ce36b207de16e5d3cfd3e79118db" - private const val apiUrl = "https://api.bgm.tv" - private const val oauthUrl = "https://bgm.tv/oauth/access_token" - private const val loginUrl = "https://bgm.tv/oauth/authorize" + private const val API_URL = "https://api.bgm.tv" + private const val OAUTH_URL = "https://bgm.tv/oauth/access_token" + private const val LOGIN_URL = "https://bgm.tv/oauth/authorize" - private const val redirectUrl = "mihon://bangumi-auth" + private const val REDIRECT_URL = "mihon://bangumi-auth" fun authUrl(): Uri = - loginUrl.toUri().buildUpon() - .appendQueryParameter("client_id", clientId) + LOGIN_URL.toUri().buildUpon() + .appendQueryParameter("client_id", CLIENT_ID) .appendQueryParameter("response_type", "code") - .appendQueryParameter("redirect_uri", redirectUrl) + .appendQueryParameter("redirect_uri", REDIRECT_URL) .build() fun refreshTokenRequest(token: String) = POST( - oauthUrl, + OAUTH_URL, body = FormBody.Builder() .add("grant_type", "refresh_token") - .add("client_id", clientId) - .add("client_secret", clientSecret) + .add("client_id", CLIENT_ID) + .add("client_secret", CLIENT_SECRET) .add("refresh_token", token) - .add("redirect_uri", redirectUrl) + .add("redirect_uri", REDIRECT_URL) .build(), ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt index cabdf87be..c124ddd13 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt @@ -66,7 +66,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) with(json) { authClient.newCall( POST( - "${baseUrl}library-entries", + "${BASE_URL}library-entries", headers = headersOf( "Content-Type", "application/vnd.api+json", @@ -104,7 +104,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) with(json) { authClient.newCall( Request.Builder() - .url("${baseUrl}library-entries/${track.remote_id}") + .url("${BASE_URL}library-entries/${track.remote_id}") .headers( headersOf( "Content-Type", @@ -130,7 +130,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) authClient .newCall( DELETE( - "${baseUrl}library-entries/${track.remoteId}", + "${BASE_URL}library-entries/${track.remoteId}", headers = headersOf( "Content-Type", "application/vnd.api+json", @@ -143,7 +143,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) suspend fun search(query: String): List { return withIOContext { with(json) { - authClient.newCall(GET(algoliaKeyUrl)) + authClient.newCall(GET(ALGOLIA_KEY_URL)) .awaitSuccess() .parseAs() .let { @@ -157,16 +157,16 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) private suspend fun algoliaSearch(key: String, query: String): List { return withIOContext { val jsonObject = buildJsonObject { - put("params", "query=${URLEncoder.encode(query, StandardCharsets.UTF_8.name())}$algoliaFilter") + put("params", "query=${URLEncoder.encode(query, StandardCharsets.UTF_8.name())}$ALGOLIA_FILTER") } with(json) { client.newCall( POST( - algoliaUrl, + ALGOLIA_URL, headers = headersOf( "X-Algolia-Application-Id", - algoliaAppId, + ALGOLIA_APP_ID, "X-Algolia-API-Key", key, ), @@ -187,7 +187,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) suspend fun findLibManga(track: Track, userId: String): Track? { return withIOContext { - val url = "${baseUrl}library-entries".toUri().buildUpon() + val url = "${BASE_URL}library-entries".toUri().buildUpon() .encodedQuery("filter[manga_id]=${track.remote_id}&filter[user_id]=$userId") .appendQueryParameter("include", "manga") .build() @@ -210,7 +210,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) suspend fun getLibManga(track: Track): Track { return withIOContext { - val url = "${baseUrl}library-entries".toUri().buildUpon() + val url = "${BASE_URL}library-entries".toUri().buildUpon() .encodedQuery("filter[id]=${track.remote_id}") .appendQueryParameter("include", "manga") .build() @@ -237,11 +237,11 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) .add("username", username) .add("password", password) .add("grant_type", "password") - .add("client_id", clientId) - .add("client_secret", clientSecret) + .add("client_id", CLIENT_ID) + .add("client_secret", CLIENT_SECRET) .build() with(json) { - client.newCall(POST(loginUrl, body = formBody)) + client.newCall(POST(LOGIN_URL, body = formBody)) .awaitSuccess() .parseAs() } @@ -250,7 +250,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) suspend fun getCurrentUser(): String { return withIOContext { - val url = "${baseUrl}users".toUri().buildUpon() + val url = "${BASE_URL}users".toUri().buildUpon() .encodedQuery("filter[self]=true") .build() with(json) { @@ -265,35 +265,31 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) } companion object { - private const val clientId = - "dd031b32d2f56c990b1425efe6c42ad847e7fe3ab46bf1299f05ecd856bdb7dd" - private const val clientSecret = - "54d7307928f63414defd96399fc31ba847961ceaecef3a5fd93144e960c0e151" + private const val CLIENT_ID = "dd031b32d2f56c990b1425efe6c42ad847e7fe3ab46bf1299f05ecd856bdb7dd" + private const val CLIENT_SECRET = "54d7307928f63414defd96399fc31ba847961ceaecef3a5fd93144e960c0e151" - private const val baseUrl = "https://kitsu.app/api/edge/" - private const val loginUrl = "https://kitsu.app/api/oauth/token" - private const val baseMangaUrl = "https://kitsu.app/manga/" - private const val algoliaKeyUrl = "https://kitsu.app/api/edge/algolia-keys/media/" + private const val BASE_URL = "https://kitsu.app/api/edge/" + private const val LOGIN_URL = "https://kitsu.app/api/oauth/token" + private const val BASE_MANGA_URL = "https://kitsu.app/manga/" + private const val ALGOLIA_KEY_URL = "https://kitsu.app/api/edge/algolia-keys/media/" - private const val algoliaUrl = - "https://AWQO5J657S-dsn.algolia.net/1/indexes/production_media/query/" - private const val algoliaAppId = "AWQO5J657S" - private const val algoliaFilter = - "&facetFilters=%5B%22kind%3Amanga%22%5D&attributesToRetrieve=" + - "%5B%22synopsis%22%2C%22averageRating%22%2C%22canonicalTitle%22%2C%22chapterCount%22%2C%22" + - "posterImage%22%2C%22startDate%22%2C%22subtype%22%2C%22endDate%22%2C%20%22id%22%5D" + private const val ALGOLIA_APP_ID = "AWQO5J657S" + private const val ALGOLIA_URL = "https://$ALGOLIA_APP_ID-dsn.algolia.net/1/indexes/production_media/query/" + private const val ALGOLIA_FILTER = "&facetFilters=%5B%22kind%3Amanga%22%5D&attributesToRetrieve=" + + "%5B%22synopsis%22%2C%22averageRating%22%2C%22canonicalTitle%22%2C%22chapterCount%22%2C%22" + + "posterImage%22%2C%22startDate%22%2C%22subtype%22%2C%22endDate%22%2C%20%22id%22%5D" fun mangaUrl(remoteId: Long): String { - return baseMangaUrl + remoteId + return BASE_MANGA_URL + remoteId } fun refreshTokenRequest(token: String) = POST( - loginUrl, + LOGIN_URL, body = FormBody.Builder() .add("grant_type", "refresh_token") .add("refresh_token", token) - .add("client_id", clientId) - .add("client_secret", clientSecret) + .add("client_id", CLIENT_ID) + .add("client_secret", CLIENT_SECRET) .build(), ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuDateHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuDateHelper.kt index 6828e1e1a..e4521438b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuDateHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuDateHelper.kt @@ -6,8 +6,8 @@ import java.util.Locale object KitsuDateHelper { - private const val pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" - private val formatter = SimpleDateFormat(pattern, Locale.ENGLISH) + private const val PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" + private val formatter = SimpleDateFormat(PATTERN, Locale.ENGLISH) fun convert(dateValue: Long): String? { if (dateValue == 0L) return null diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/model/TrackSearch.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/model/TrackSearch.kt index c1af76ebf..94160d6ab 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/model/TrackSearch.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/model/TrackSearch.kt @@ -1,3 +1,5 @@ +@file:Suppress("PropertyName", "ktlint:standard:property-naming") + package eu.kanade.tachiyomi.data.track.model import eu.kanade.tachiyomi.data.database.models.Track diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt index 6eb93a636..08a695930 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt @@ -54,7 +54,7 @@ class ShikimoriApi( } authClient.newCall( POST( - "$apiUrl/v2/user_rates", + "$API_URL/v2/user_rates", body = payload.toString().toRequestBody(jsonMime), ), ).awaitSuccess() @@ -73,14 +73,14 @@ class ShikimoriApi( suspend fun deleteLibManga(track: DomainTrack) { withIOContext { authClient - .newCall(DELETE("$apiUrl/v2/user_rates/${track.libraryId}")) + .newCall(DELETE("$API_URL/v2/user_rates/${track.libraryId}")) .awaitSuccess() } } suspend fun search(search: String): List { return withIOContext { - val url = "$apiUrl/mangas".toUri().buildUpon() + val url = "$API_URL/mangas".toUri().buildUpon() .appendQueryParameter("order", "popularity") .appendQueryParameter("search", search) .appendQueryParameter("limit", "20") @@ -103,10 +103,10 @@ class ShikimoriApi( remote_id = obj["id"]!!.jsonPrimitive.long title = obj["name"]!!.jsonPrimitive.content total_chapters = obj["chapters"]!!.jsonPrimitive.long - cover_url = baseUrl + obj["image"]!!.jsonObject["preview"]!!.jsonPrimitive.content + cover_url = BASE_URL + obj["image"]!!.jsonObject["preview"]!!.jsonPrimitive.content summary = "" score = obj["score"]!!.jsonPrimitive.double - tracking_url = baseUrl + obj["url"]!!.jsonPrimitive.content + tracking_url = BASE_URL + obj["url"]!!.jsonPrimitive.content publishing_status = obj["status"]!!.jsonPrimitive.content publishing_type = obj["kind"]!!.jsonPrimitive.content start_date = obj["aired_on"]!!.jsonPrimitive.contentOrNull ?: "" @@ -122,13 +122,13 @@ class ShikimoriApi( last_chapter_read = obj["chapters"]!!.jsonPrimitive.double score = obj["score"]!!.jsonPrimitive.int.toDouble() status = toTrackStatus(obj["status"]!!.jsonPrimitive.content) - tracking_url = baseUrl + mangas["url"]!!.jsonPrimitive.content + tracking_url = BASE_URL + mangas["url"]!!.jsonPrimitive.content } } suspend fun findLibManga(track: Track, userId: String): Track? { return withIOContext { - val urlMangas = "$apiUrl/mangas".toUri().buildUpon() + val urlMangas = "$API_URL/mangas".toUri().buildUpon() .appendPath(track.remote_id.toString()) .build() val mangas = with(json) { @@ -137,7 +137,7 @@ class ShikimoriApi( .parseAs() } - val url = "$apiUrl/v2/user_rates".toUri().buildUpon() + val url = "$API_URL/v2/user_rates".toUri().buildUpon() .appendQueryParameter("user_id", userId) .appendQueryParameter("target_id", track.remote_id.toString()) .appendQueryParameter("target_type", "Manga") @@ -161,7 +161,7 @@ class ShikimoriApi( suspend fun getCurrentUser(): Int { return with(json) { - authClient.newCall(GET("$apiUrl/users/whoami")) + authClient.newCall(GET("$API_URL/users/whoami")) .awaitSuccess() .parseAs() .let { @@ -181,39 +181,39 @@ class ShikimoriApi( } private fun accessTokenRequest(code: String) = POST( - oauthUrl, + OAUTH_URL, body = FormBody.Builder() .add("grant_type", "authorization_code") - .add("client_id", clientId) - .add("client_secret", clientSecret) + .add("client_id", CLIENT_ID) + .add("client_secret", CLIENT_SECRET) .add("code", code) - .add("redirect_uri", redirectUrl) + .add("redirect_uri", REDIRECT_URL) .build(), ) companion object { - private const val clientId = "PB9dq8DzI405s7wdtwTdirYqHiyVMh--djnP7lBUqSA" - private const val clientSecret = "NajpZcOBKB9sJtgNcejf8OB9jBN1OYYoo-k4h2WWZus" + private const val CLIENT_ID = "PB9dq8DzI405s7wdtwTdirYqHiyVMh--djnP7lBUqSA" + private const val CLIENT_SECRET = "NajpZcOBKB9sJtgNcejf8OB9jBN1OYYoo-k4h2WWZus" - private const val baseUrl = "https://shikimori.one" - private const val apiUrl = "$baseUrl/api" - private const val oauthUrl = "$baseUrl/oauth/token" - private const val loginUrl = "$baseUrl/oauth/authorize" + private const val BASE_URL = "https://shikimori.one" + private const val API_URL = "$BASE_URL/api" + private const val OAUTH_URL = "$BASE_URL/oauth/token" + private const val LOGIN_URL = "$BASE_URL/oauth/authorize" - private const val redirectUrl = "mihon://shikimori-auth" + private const val REDIRECT_URL = "mihon://shikimori-auth" - fun authUrl(): Uri = loginUrl.toUri().buildUpon() - .appendQueryParameter("client_id", clientId) - .appendQueryParameter("redirect_uri", redirectUrl) + fun authUrl(): Uri = LOGIN_URL.toUri().buildUpon() + .appendQueryParameter("client_id", CLIENT_ID) + .appendQueryParameter("redirect_uri", REDIRECT_URL) .appendQueryParameter("response_type", "code") .build() fun refreshTokenRequest(token: String) = POST( - oauthUrl, + OAUTH_URL, body = FormBody.Builder() .add("grant_type", "refresh_token") - .add("client_id", clientId) - .add("client_secret", clientSecret) + .add("client_id", CLIENT_ID) + .add("client_secret", CLIENT_SECRET) .add("refresh_token", token) .build(), ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt index 968263b5d..1b0f0f9b4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt @@ -62,14 +62,14 @@ class ExtensionManager( private val iconMap = mutableMapOf() - private val _installedExtensionsMapFlow = MutableStateFlow(emptyMap()) - val installedExtensionsFlow = _installedExtensionsMapFlow.mapExtensions(scope) + private val installedExtensionMapFlow = MutableStateFlow(emptyMap()) + val installedExtensionsFlow = installedExtensionMapFlow.mapExtensions(scope) - private val _availableExtensionsMapFlow = MutableStateFlow(emptyMap()) - val availableExtensionsFlow = _availableExtensionsMapFlow.mapExtensions(scope) + private val availableExtensionMapFlow = MutableStateFlow(emptyMap()) + val availableExtensionsFlow = availableExtensionMapFlow.mapExtensions(scope) - private val _untrustedExtensionsMapFlow = MutableStateFlow(emptyMap()) - val untrustedExtensionsFlow = _untrustedExtensionsMapFlow.mapExtensions(scope) + private val untrustedExtensionMapFlow = MutableStateFlow(emptyMap()) + val untrustedExtensionsFlow = untrustedExtensionMapFlow.mapExtensions(scope) init { initExtensions() @@ -79,7 +79,7 @@ class ExtensionManager( private var subLanguagesEnabledOnFirstRun = preferences.enabledLanguages().isSet() fun getAppIconForSource(sourceId: Long): Drawable? { - val pkgName = _installedExtensionsMapFlow.value.values + val pkgName = installedExtensionMapFlow.value.values .find { ext -> ext.sources.any { it.id == sourceId } } @@ -109,11 +109,11 @@ class ExtensionManager( private fun initExtensions() { val extensions = ExtensionLoader.loadExtensions(context) - _installedExtensionsMapFlow.value = extensions + installedExtensionMapFlow.value = extensions .filterIsInstance() .associate { it.extension.pkgName to it.extension } - _untrustedExtensionsMapFlow.value = extensions + untrustedExtensionMapFlow.value = extensions .filterIsInstance() .associate { it.extension.pkgName to it.extension } @@ -121,7 +121,7 @@ class ExtensionManager( } /** - * Finds the available extensions in the [api] and updates [_availableExtensionsMapFlow]. + * Finds the available extensions in the [api] and updates [availableExtensionMapFlow]. */ suspend fun findAvailableExtensions() { val extensions: List = try { @@ -134,7 +134,7 @@ class ExtensionManager( enableAdditionalSubLanguages(extensions) - _availableExtensionsMapFlow.value = extensions.associateBy { it.pkgName } + availableExtensionMapFlow.value = extensions.associateBy { it.pkgName } updatedInstalledExtensionsStatuses(extensions) setupAvailableExtensionsSourcesDataMap(extensions) } @@ -180,7 +180,7 @@ class ExtensionManager( return } - val installedExtensionsMap = _installedExtensionsMapFlow.value.toMutableMap() + val installedExtensionsMap = installedExtensionMapFlow.value.toMutableMap() var changed = false for ((pkgName, extension) in installedExtensionsMap) { val availableExt = availableExtensions.find { it.pkgName == pkgName } @@ -204,7 +204,7 @@ class ExtensionManager( } } if (changed) { - _installedExtensionsMapFlow.value = installedExtensionsMap + installedExtensionMapFlow.value = installedExtensionsMap } updatePendingUpdatesCount() } @@ -228,7 +228,7 @@ class ExtensionManager( * @param extension The extension to be updated. */ fun updateExtension(extension: Extension.Installed): Flow { - val availableExt = _availableExtensionsMapFlow.value[extension.pkgName] ?: return emptyFlow() + val availableExt = availableExtensionMapFlow.value[extension.pkgName] ?: return emptyFlow() return installExtension(availableExt) } @@ -265,11 +265,11 @@ class ExtensionManager( * @param extension the extension to trust */ suspend fun trust(extension: Extension.Untrusted) { - _untrustedExtensionsMapFlow.value[extension.pkgName] ?: return + untrustedExtensionMapFlow.value[extension.pkgName] ?: return trustExtension.trust(extension.pkgName, extension.versionCode, extension.signatureHash) - _untrustedExtensionsMapFlow.value -= extension.pkgName + untrustedExtensionMapFlow.value -= extension.pkgName ExtensionLoader.loadExtensionFromPkgName(context, extension.pkgName) .let { it as? LoadResult.Success } @@ -282,7 +282,7 @@ class ExtensionManager( * @param extension The extension to be registered. */ private fun registerNewExtension(extension: Extension.Installed) { - _installedExtensionsMapFlow.value += extension + installedExtensionMapFlow.value += extension } /** @@ -292,7 +292,7 @@ class ExtensionManager( * @param extension The extension to be registered. */ private fun registerUpdatedExtension(extension: Extension.Installed) { - _installedExtensionsMapFlow.value += extension + installedExtensionMapFlow.value += extension } /** @@ -302,8 +302,8 @@ class ExtensionManager( * @param pkgName The package name of the uninstalled application. */ private fun unregisterExtension(pkgName: String) { - _installedExtensionsMapFlow.value -= pkgName - _untrustedExtensionsMapFlow.value -= pkgName + installedExtensionMapFlow.value -= pkgName + untrustedExtensionMapFlow.value -= pkgName } /** @@ -322,8 +322,8 @@ class ExtensionManager( } override fun onExtensionUntrusted(extension: Extension.Untrusted) { - _installedExtensionsMapFlow.value -= extension.pkgName - _untrustedExtensionsMapFlow.value += extension + installedExtensionMapFlow.value -= extension.pkgName + untrustedExtensionMapFlow.value += extension updatePendingUpdatesCount() } @@ -347,14 +347,14 @@ class ExtensionManager( private fun Extension.Installed.updateExists(availableExtension: Extension.Available? = null): Boolean { val availableExt = availableExtension - ?: _availableExtensionsMapFlow.value[pkgName] + ?: availableExtensionMapFlow.value[pkgName] ?: return false return (availableExt.versionCode > versionCode || availableExt.libVersion > libVersion) } private fun updatePendingUpdatesCount() { - val pendingUpdateCount = _installedExtensionsMapFlow.value.values.count { it.hasUpdate } + val pendingUpdateCount = installedExtensionMapFlow.value.values.count { it.hasUpdate } preferences.extensionUpdatesCount().set(pendingUpdateCount) if (pendingUpdateCount == 0) { ExtensionUpdateNotifier(context).dismiss() diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/model/InstallStep.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/model/InstallStep.kt index d1049689e..cd9b40fad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/model/InstallStep.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/model/InstallStep.kt @@ -1,7 +1,13 @@ package eu.kanade.tachiyomi.extension.model enum class InstallStep { - Idle, Pending, Downloading, Installing, Installed, Error; + Idle, + Pending, + Downloading, + Installing, + Installed, + Error, + ; fun isCompleted(): Boolean { return this == Installed || this == Error || this == Idle diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/delegate/SecureActivityDelegate.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/delegate/SecureActivityDelegate.kt index c3b94d639..20189be6d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/delegate/SecureActivityDelegate.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/delegate/SecureActivityDelegate.kt @@ -97,7 +97,7 @@ class SecureActivityDelegateImpl : SecureActivityDelegate, DefaultLifecycleObser val incognitoModeFlow = preferences.incognitoMode().changes() combine(secureScreenFlow, incognitoModeFlow) { secureScreen, incognitoMode -> secureScreen == SecurityPreferences.SecureScreenMode.ALWAYS || - secureScreen == SecurityPreferences.SecureScreenMode.INCOGNITO && incognitoMode + (secureScreen == SecurityPreferences.SecureScreenMode.INCOGNITO && incognitoMode) } .onEach(activity.window::setSecureScreen) .launchIn(activity.lifecycleScope) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt index feb69c5ce..861c28ff6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt @@ -41,7 +41,7 @@ class ExtensionsScreenModel( private val getExtensions: GetExtensionsByType = Injekt.get(), ) : StateScreenModel(State()) { - private var _currentDownloads = MutableStateFlow>(hashMapOf()) + private val currentDownloads = MutableStateFlow>(hashMapOf()) init { val context = Injekt.get() @@ -62,14 +62,20 @@ class ExtensionsScreenModel( it.name.contains(input, ignoreCase = true) || it.baseUrl.contains(input, ignoreCase = true) || it.id == input.toLongOrNull() - } || extension.name.contains(input, ignoreCase = true) + } || + extension.name.contains(input, ignoreCase = true) } is Extension.Installed -> { extension.sources.any { it.name.contains(input, ignoreCase = true) || it.id == input.toLongOrNull() || - if (it is HttpSource) { it.baseUrl.contains(input, ignoreCase = true) } else false - } || extension.name.contains(input, ignoreCase = true) + if (it is HttpSource) { + it.baseUrl.contains(input, ignoreCase = true) + } else { + false + } + } || + extension.name.contains(input, ignoreCase = true) } is Extension.Untrusted -> extension.name.contains(input, ignoreCase = true) } @@ -80,7 +86,7 @@ class ExtensionsScreenModel( screenModelScope.launchIO { combine( state.map { it.searchQuery }.distinctUntilChanged().debounce(SEARCH_DEBOUNCE_MILLIS), - _currentDownloads, + currentDownloads, getExtensions.subscribe(), ) { query, downloads, (_updates, _installed, _available, _untrusted) -> val searchQuery = query ?: "" @@ -166,11 +172,11 @@ class ExtensionsScreenModel( } private fun addDownloadState(extension: Extension, installStep: InstallStep) { - _currentDownloads.update { it + Pair(extension.pkgName, installStep) } + currentDownloads.update { it + Pair(extension.pkgName, installStep) } } private fun removeDownloadState(extension: Extension) { - _currentDownloads.update { it - extension.pkgName } + currentDownloads.update { it - extension.pkgName } } private suspend fun Flow.collectToInstallUpdate(extension: Extension) = diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt index ff2cb7075..ac708ec2f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt @@ -66,8 +66,8 @@ object HomeScreen : Screen() { private val openTabEvent = Channel() private val showBottomNavEvent = Channel() - private const val TabFadeDuration = 200 - private const val TabNavigatorKey = "HomeTabs" + private const val TAB_FADE_DURATION = 200 + private const val TAB_NAVIGATOR_KEY = "HomeTabs" private val tabs = listOf( LibraryTab, @@ -82,7 +82,7 @@ object HomeScreen : Screen() { val navigator = LocalNavigator.currentOrThrow TabNavigator( tab = LibraryTab, - key = TabNavigatorKey, + key = TAB_NAVIGATOR_KEY, ) { tabNavigator -> // Provide usable navigator to content screen CompositionLocalProvider(LocalNavigator provides navigator) { @@ -124,8 +124,11 @@ object HomeScreen : Screen() { AnimatedContent( targetState = tabNavigator.current, transitionSpec = { - materialFadeThroughIn(initialScale = 1f, durationMillis = TabFadeDuration) togetherWith - materialFadeThroughOut(durationMillis = TabFadeDuration) + materialFadeThroughIn( + initialScale = 1f, + durationMillis = TAB_FADE_DURATION, + ) togetherWith + materialFadeThroughOut(durationMillis = TAB_FADE_DURATION) }, label = "tabContent", ) { 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 286f58239..59121bcaf 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 @@ -258,7 +258,7 @@ class LibraryScreenModel( private fun LibraryMap.applySort( // Map> trackMap: Map>, - loggedInTrackerIds: Set + loggedInTrackerIds: Set, ): LibraryMap { val sortAlphabetically: (LibraryItem, LibraryItem) -> Int = { i1, i2 -> i1.libraryManga.manga.title.lowercase().compareToWithCollator(i2.libraryManga.manga.title.lowercase()) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsScreenModel.kt index bd5867797..388f516ce 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsScreenModel.kt @@ -32,7 +32,7 @@ class LibrarySettingsScreenModel( .stateIn( scope = screenModelScope, started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds), - initialValue = trackerManager.loggedInTrackers() + initialValue = trackerManager.loggedInTrackers(), ) fun toggleFilter(preference: (LibraryPreferences) -> Preference) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt index 7e4ac0932..0279a6975 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt @@ -87,8 +87,8 @@ private class MoreScreenModel( var downloadedOnly by preferences.downloadedOnly().asState(screenModelScope) var incognitoMode by preferences.incognitoMode().asState(screenModelScope) - private var _state: MutableStateFlow = MutableStateFlow(DownloadQueueState.Stopped) - val downloadQueueState: StateFlow = _state.asStateFlow() + private var _downloadQueueState: MutableStateFlow = MutableStateFlow(DownloadQueueState.Stopped) + val downloadQueueState: StateFlow = _downloadQueueState.asStateFlow() init { // Handle running/paused status change and queue progress updating @@ -99,7 +99,7 @@ private class MoreScreenModel( ) { isRunning, downloadQueue -> Pair(isRunning, downloadQueue.size) } .collectLatest { (isDownloading, downloadQueueSize) -> val pendingDownloadExists = downloadQueueSize != 0 - _state.value = when { + _downloadQueueState.value = when { !pendingDownloadExists -> DownloadQueueState.Stopped !isDownloading -> DownloadQueueState.Paused(downloadQueueSize) else -> DownloadQueueState.Downloading(downloadQueueSize) 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 259b45883..f633bdbad 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 @@ -165,13 +165,19 @@ class ReaderViewModel @JvmOverloads constructor( ( manga.downloadedFilterRaw == Manga.CHAPTER_SHOW_DOWNLOADED && !downloadManager.isChapterDownloaded( - it.name, it.scanlator, manga.title, manga.source, + it.name, + it.scanlator, + manga.title, + manga.source, ) ) || ( manga.downloadedFilterRaw == Manga.CHAPTER_SHOW_NOT_DOWNLOADED && downloadManager.isChapterDownloaded( - it.name, it.scanlator, manga.title, manga.source, + it.name, + it.scanlator, + manga.title, + manga.source, ) ) || (manga.bookmarkedFilterRaw == Manga.CHAPTER_SHOW_BOOKMARKED && !it.bookmark) || 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 57def3c12..5cd742ad1 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 @@ -142,7 +142,7 @@ class ReaderPreferences( enum class FlashColor { BLACK, WHITE, - WHITE_BLACK + WHITE_BLACK, } enum class TappingInvertMode( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt index 61e78c161..89d0b2e6e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt @@ -404,7 +404,9 @@ open class ReaderPageImageView @JvmOverloads constructor( ) enum class ZoomStartPosition { - LEFT, CENTER, RIGHT + LEFT, + CENTER, + RIGHT, } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt index 737b3633b..8918cdf58 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt @@ -32,15 +32,16 @@ class ReaderTransitionView @JvmOverloads constructor(context: Context, attrs: At Data( transition = transition, currChapterDownloaded = transition.from.pageLoader?.isLocal == true, - goingToChapterDownloaded = manga.isLocal() || transition.to?.chapter?.let { goingToChapter -> - downloadManager.isChapterDownloaded( - chapterName = goingToChapter.name, - chapterScanlator = goingToChapter.scanlator, - mangaTitle = manga.title, - sourceId = manga.source, - skipCache = true, - ) - } ?: false, + goingToChapterDownloaded = manga.isLocal() || + transition.to?.chapter?.let { goingToChapter -> + downloadManager.isChapterDownloaded( + chapterName = goingToChapter.name, + chapterScanlator = goingToChapter.scanlator, + mangaTitle = manga.title, + sourceId = manga.source, + skipCache = true, + ) + } ?: false, ) } else { null diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt index 5ff4ecaae..7bb89a3e9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt @@ -92,7 +92,9 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { // Add next chapter transition and pages. nextTransition = ChapterTransition.Next(chapters.currChapter, chapters.nextChapter) .also { - if (nextHasMissingChapters || forceTransition || + if ( + nextHasMissingChapters || + forceTransition || chapters.nextChapter?.state !is ReaderChapter.State.Loaded ) { newItems.add(it) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt index f55478862..164c4939d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt @@ -82,7 +82,7 @@ class WebtoonConfig( readerPreferences.webtoonDisableZoomOut() .register( { zoomOutDisabled = it }, - { zoomPropertyChangedListener?.invoke(it) } + { zoomPropertyChangedListener?.invoke(it) }, ) readerPreferences.webtoonDoubleTapZoomEnabled() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt index fe232fe87..95cef7345 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt @@ -182,7 +182,11 @@ class WebtoonRecyclerView @JvmOverloads constructor( setScaleRate(currentScale) - layoutParams.height = if (currentScale < 1) { (originalHeight / currentScale).toInt() } else { originalHeight } + layoutParams.height = if (currentScale < 1) { + (originalHeight / currentScale).toInt() + } else { + originalHeight + } halfHeight = layoutParams.height / 2 if (currentScale != DEFAULT_RATE) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt index 3445f76c1..9d2dac482 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt @@ -79,7 +79,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr .threshold init { - recycler.setItemViewCacheSize(RecyclerViewCacheSize) + recycler.setItemViewCacheSize(RECYCLER_VIEW_CACHE_SIZE) recycler.isVisible = false // Don't let the recycler layout yet recycler.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT) recycler.isFocusable = false @@ -362,4 +362,4 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr } // Double the cache size to reduce rebinds/recycles incurred by the extra layout space on scroll direction changes -private const val RecyclerViewCacheSize = 4 +private const val RECYCLER_VIEW_CACHE_SIZE = 4 diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ChildFirstPathClassLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ChildFirstPathClassLoader.kt index b63dfd032..0823e765d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ChildFirstPathClassLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ChildFirstPathClassLoader.kt @@ -15,7 +15,7 @@ import java.util.Enumeration class ChildFirstPathClassLoader( dexPath: String, librarySearchPath: String?, - parent: ClassLoader + parent: ClassLoader, ) : PathClassLoader(dexPath, librarySearchPath, parent) { private val systemClassLoader: ClassLoader? = getSystemClassLoader() diff --git a/app/src/main/java/mihon/core/migration/MigrationJobFactory.kt b/app/src/main/java/mihon/core/migration/MigrationJobFactory.kt index c452707d5..cfb8db2b6 100644 --- a/app/src/main/java/mihon/core/migration/MigrationJobFactory.kt +++ b/app/src/main/java/mihon/core/migration/MigrationJobFactory.kt @@ -9,20 +9,24 @@ import tachiyomi.core.common.util.system.logcat class MigrationJobFactory( private val migrationContext: MigrationContext, - private val scope: CoroutineScope + private val scope: CoroutineScope, ) { fun create(migrations: List): Deferred = with(scope) { return migrations.sortedBy { it.version } .fold(CompletableDeferred(true)) { acc: Deferred, migration: Migration -> if (!migrationContext.dryrun) { - logcat { "Running migration: { name = ${migration::class.simpleName}, version = ${migration.version} }" } + logcat { + "Running migration: { name = ${migration::class.simpleName}, version = ${migration.version} }" + } async(start = CoroutineStart.UNDISPATCHED) { val prev = acc.await() migration(migrationContext) || prev } } else { - logcat { "(Dry-run) Running migration: { name = ${migration::class.simpleName}, version = ${migration.version} }" } + logcat { + "(Dry-run) Running migration: { name = ${migration::class.simpleName}, version = ${migration.version} }" + } CompletableDeferred(true) } } diff --git a/app/src/main/java/mihon/core/migration/MigrationStrategy.kt b/app/src/main/java/mihon/core/migration/MigrationStrategy.kt index 9fd5f4f91..8033ebc6d 100644 --- a/app/src/main/java/mihon/core/migration/MigrationStrategy.kt +++ b/app/src/main/java/mihon/core/migration/MigrationStrategy.kt @@ -12,7 +12,7 @@ interface MigrationStrategy { class DefaultMigrationStrategy( private val migrationJobFactory: MigrationJobFactory, private val migrationCompletedListener: MigrationCompletedListener, - private val scope: CoroutineScope + private val scope: CoroutineScope, ) : MigrationStrategy { override operator fun invoke(migrations: List): Deferred = with(scope) { @@ -46,7 +46,7 @@ class NoopMigrationStrategy(val state: Boolean) : MigrationStrategy { class VersionRangeMigrationStrategy( private val versions: IntRange, - private val strategy: DefaultMigrationStrategy + private val strategy: DefaultMigrationStrategy, ) : MigrationStrategy { override operator fun invoke(migrations: List): Deferred { diff --git a/app/src/main/java/mihon/core/migration/Migrator.kt b/app/src/main/java/mihon/core/migration/Migrator.kt index 2296aa074..c01a3873e 100644 --- a/app/src/main/java/mihon/core/migration/Migrator.kt +++ b/app/src/main/java/mihon/core/migration/Migrator.kt @@ -17,7 +17,7 @@ object Migrator { new: Int, migrations: List, dryrun: Boolean = false, - onMigrationComplete: () -> Unit + onMigrationComplete: () -> Unit, ) { val migrationContext = MigrationContext(dryrun) val migrationJobFactory = MigrationJobFactory(migrationContext, scope) diff --git a/app/src/main/java/mihon/feature/upcoming/components/calendar/Calendar.kt b/app/src/main/java/mihon/feature/upcoming/components/calendar/Calendar.kt index da511ddad..6b32c7f89 100644 --- a/app/src/main/java/mihon/feature/upcoming/components/calendar/Calendar.kt +++ b/app/src/main/java/mihon/feature/upcoming/components/calendar/Calendar.kt @@ -32,7 +32,7 @@ import java.time.temporal.WeekFields import java.util.Locale private val FontSize = 16.sp -private const val DaysOfWeek = 7 +private const val DAYS_OF_WEEK = 7 @Composable fun Calendar( @@ -54,7 +54,7 @@ fun Calendar( modifier = Modifier .fillMaxWidth() .padding(vertical = MaterialTheme.padding.small) - .padding(start = MaterialTheme.padding.medium) + .padding(start = MaterialTheme.padding.medium), ) CalendarGrid( selectedYearMonth = selectedYearMonth, @@ -72,8 +72,8 @@ private fun CalendarGrid( ) { val localeFirstDayOfWeek = WeekFields.of(Locale.getDefault()).firstDayOfWeek.value val weekDays = remember { - (0 until DaysOfWeek) - .map { DayOfWeek.of((localeFirstDayOfWeek - 1 + it) % DaysOfWeek + 1) } + (0 until DAYS_OF_WEEK) + .map { DayOfWeek.of((localeFirstDayOfWeek - 1 + it) % DAYS_OF_WEEK + 1) } .toImmutableList() } @@ -81,12 +81,12 @@ private fun CalendarGrid( val daysInMonth = selectedYearMonth.lengthOfMonth() VerticalGrid( - columns = SimpleGridCells.Fixed(DaysOfWeek), + columns = SimpleGridCells.Fixed(DAYS_OF_WEEK), modifier = if (isMediumWidthWindow() && !isExpandedWidthWindow()) { Modifier.widthIn(max = 360.dp) } else { Modifier - } + }, ) { weekDays.fastForEach { item -> Text( diff --git a/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarDay.kt b/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarDay.kt index 46ed355ab..3a8f3e6fb 100644 --- a/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarDay.kt +++ b/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarDay.kt @@ -19,9 +19,10 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import tachiyomi.presentation.core.components.material.DISABLED_ALPHA import java.time.LocalDate -private const val MaxEvents = 3 +private const val MAX_EVENTS = 3 @Composable fun CalendarDay( @@ -39,7 +40,7 @@ fun CalendarDay( Modifier.border( border = BorderStroke( width = 1.dp, - color = MaterialTheme.colorScheme.onBackground + color = MaterialTheme.colorScheme.onBackground, ), shape = CircleShape, ) @@ -57,14 +58,14 @@ fun CalendarDay( textAlign = TextAlign.Center, fontSize = 16.sp, color = if (date.isBefore(today)) { - MaterialTheme.colorScheme.onBackground.copy(alpha = 0.38f) + MaterialTheme.colorScheme.onBackground.copy(alpha = DISABLED_ALPHA) } else { MaterialTheme.colorScheme.onBackground }, fontWeight = FontWeight.SemiBold, ) Row(Modifier.offset(y = 12.dp)) { - val size = events.coerceAtMost(MaxEvents) + val size = events.coerceAtMost(MAX_EVENTS) for (index in 0 until size) { CalendarIndicator( index = index, diff --git a/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarHeader.kt b/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarHeader.kt index 55498ebb9..f5dbf5c48 100644 --- a/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarHeader.kt +++ b/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarHeader.kt @@ -63,20 +63,20 @@ fun CalenderHeader( } } -private const val MonthYearChangeAnimationDuration = 200 +private const val MONTH_YEAR_CHANGE_ANIMATION_DURATION = 200 private fun AnimatedContentTransitionScope.getAnimation(): ContentTransform { val movingForward = targetState > initialState val enterTransition = slideInVertically( - animationSpec = tween(durationMillis = MonthYearChangeAnimationDuration), + animationSpec = tween(durationMillis = MONTH_YEAR_CHANGE_ANIMATION_DURATION), ) { height -> if (movingForward) height else -height } + fadeIn( - animationSpec = tween(durationMillis = MonthYearChangeAnimationDuration), + animationSpec = tween(durationMillis = MONTH_YEAR_CHANGE_ANIMATION_DURATION), ) val exitTransition = slideOutVertically( - animationSpec = tween(durationMillis = MonthYearChangeAnimationDuration), + animationSpec = tween(durationMillis = MONTH_YEAR_CHANGE_ANIMATION_DURATION), ) { height -> if (movingForward) -height else height } + fadeOut( - animationSpec = tween(durationMillis = MonthYearChangeAnimationDuration), + animationSpec = tween(durationMillis = MONTH_YEAR_CHANGE_ANIMATION_DURATION), ) return (enterTransition togetherWith exitTransition) .using(SizeTransform(clip = false)) diff --git a/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarIndicator.kt b/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarIndicator.kt index 9aaca69de..f9e223107 100644 --- a/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarIndicator.kt +++ b/app/src/main/java/mihon/feature/upcoming/components/calendar/CalendarIndicator.kt @@ -12,8 +12,8 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -private const val IndicatorScale = 12 -private const val IndicatorAlphaMultiplier = 0.3f +private const val INDICATOR_SCALE = 12 +private const val INDICATOR_ALPHA_MULTIPLIER = 0.3f @Composable fun CalendarIndicator( @@ -26,7 +26,7 @@ fun CalendarIndicator( modifier = modifier .padding(horizontal = 1.dp) .clip(shape = CircleShape) - .background(color = color.copy(alpha = (index + 1) * IndicatorAlphaMultiplier)) - .size(size = size.div(IndicatorScale)), + .background(color = color.copy(alpha = (index + 1) * INDICATOR_ALPHA_MULTIPLIER)) + .size(size = size.div(INDICATOR_SCALE)), ) } diff --git a/app/src/main/res/drawable/ic_glasses_24dp.xml b/app/src/main/res/drawable/ic_glasses_24dp.xml index 581a59914..572c2f06d 100644 --- a/app/src/main/res/drawable/ic_glasses_24dp.xml +++ b/app/src/main/res/drawable/ic_glasses_24dp.xml @@ -6,4 +6,4 @@ - \ No newline at end of file + diff --git a/app/src/main/res/drawable/material_popup_background.xml b/app/src/main/res/drawable/material_popup_background.xml index 09987c415..29bb97167 100644 --- a/app/src/main/res/drawable/material_popup_background.xml +++ b/app/src/main/res/drawable/material_popup_background.xml @@ -12,4 +12,4 @@ - \ No newline at end of file + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index d0fb6fca7..263e7610b 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -445,7 +445,7 @@ @color/nord_surfaceContainerLow @color/nord_surfaceContainerLowest - +