From 6215528c9d60d63b5d4a4b48e96bf54278aa7e46 Mon Sep 17 00:00:00 2001 From: LuftVerbot <97435834+LuftVerbot@users.noreply.github.com> Date: Sun, 19 Nov 2023 15:37:56 +0100 Subject: [PATCH] ktlint format --- app/build.gradle.kts | 6 +- app/src/main/java/aniyomi/util/DataSaver.kt | 29 ++- .../eu/kanade/domain/base/BasePreferences.kt | 9 +- .../anime/interactor/SetAnimeViewerFlags.kt | 2 +- .../entries/anime/interactor/UpdateAnime.kt | 8 +- .../entries/manga/interactor/UpdateManga.kt | 8 +- .../interactor/SyncChaptersWithSource.kt | 26 ++- .../domain/items/chapter/model/Chapter.kt | 2 +- .../items/chapter/model/ChapterFilter.kt | 7 +- .../interactor/SyncEpisodesWithSource.kt | 30 ++- .../domain/items/episode/model/Episode.kt | 2 +- .../items/episode/model/EpisodeFilter.kt | 7 +- .../GetAnimeSourcesWithFavoriteCount.kt | 11 +- .../GetLanguagesWithAnimeSources.kt | 2 +- .../anime/interactor/ToggleAnimeSource.kt | 8 +- .../GetLanguagesWithMangaSources.kt | 2 +- .../GetMangaSourcesWithFavoriteCount.kt | 11 +- .../manga/interactor/ToggleMangaSource.kt | 8 +- .../source/service/SourcePreferences.kt | 37 ++- .../anime/interactor/RefreshAnimeTracks.kt | 6 +- .../domain/track/anime/model/AnimeTrack.kt | 6 +- .../service/DelayedAnimeTrackingUpdateJob.kt | 4 +- .../domain/track/manga/model/MangaTrack.kt | 6 +- .../service/DelayedMangaTrackingUpdateJob.kt | 4 +- .../domain/track/service/TrackPreferences.kt | 5 +- .../java/eu/kanade/domain/ui/UiPreferences.kt | 4 +- .../presentation/browse/BaseBrowseItem.kt | 5 +- .../anime/AnimeExtensionDetailsScreen.kt | 4 +- .../browse/anime/AnimeExtensionsScreen.kt | 5 +- .../browse/anime/AnimeSourcesScreen.kt | 13 +- .../browse/anime/MigrateAnimeSourceScreen.kt | 20 +- .../anime/components/BrowseAnimeIcons.kt | 5 +- .../browse/manga/MangaExtensionsScreen.kt | 5 +- .../browse/manga/MangaSourcesScreen.kt | 13 +- .../browse/manga/MigrateMangaSourceScreen.kt | 20 +- .../manga/components/BrowseMangaIcons.kt | 5 +- .../category/AnimeCategoryScreen.kt | 4 +- .../category/MangaCategoryScreen.kt | 4 +- .../category/components/CategoryDialogs.kt | 2 +- .../kanade/presentation/components/AppBar.kt | 8 +- .../presentation/components/DropdownMenu.kt | 2 +- .../components/RelativeDateHeader.kt | 2 +- .../presentation/components/TabbedDialog.kt | 5 +- .../presentation/components/TabbedScreen.kt | 5 +- .../kanade/presentation/crash/CrashScreen.kt | 5 +- .../entries/EntryBottomActionMenu.kt | 12 +- .../presentation/entries/anime/AnimeScreen.kt | 18 +- .../anime/EpisodeOptionsDialogScreen.kt | 16 +- .../anime/components/AnimeCoverDialog.kt | 4 +- .../anime/components/AnimeEpisodeListItem.kt | 10 +- .../anime/components/AnimeInfoHeader.kt | 40 +++- .../presentation/entries/manga/MangaScreen.kt | 16 +- .../manga/components/MangaChapterListItem.kt | 10 +- .../manga/components/MangaCoverDialog.kt | 4 +- .../manga/components/MangaInfoHeader.kt | 40 +++- .../presentation/extensions/DiskUtil.kt | 4 +- .../history/anime/AnimeHistoryContent.kt | 2 +- .../history/anime/AnimeHistoryItem.kt | 5 +- .../history/anime/AnimeHistoryScreen.kt | 6 +- .../history/manga/MangaHistoryContent.kt | 2 +- .../history/manga/MangaHistoryItem.kt | 5 +- .../history/manga/MangaHistoryScreen.kt | 6 +- .../presentation/library/LibraryTabs.kt | 5 +- .../library/anime/AnimeLibraryContent.kt | 2 +- .../anime/AnimeLibrarySettingsDialog.kt | 8 +- .../library/manga/MangaLibraryContent.kt | 2 +- .../manga/MangaLibrarySettingsDialog.kt | 8 +- .../eu/kanade/presentation/more/MoreScreen.kt | 24 +- .../presentation/more/settings/Preference.kt | 4 +- .../more/settings/PreferenceScreen.kt | 2 +- .../more/settings/screen/Commons.kt | 4 +- .../settings/screen/SettingsAdvancedScreen.kt | 40 +++- .../screen/SettingsAppearanceScreen.kt | 6 +- .../settings/screen/SettingsBackupScreen.kt | 31 ++- .../settings/screen/SettingsBrowseScreen.kt | 4 +- .../settings/screen/SettingsDownloadScreen.kt | 52 ++++- .../settings/screen/SettingsLibraryScreen.kt | 76 +++++-- .../settings/screen/SettingsMainScreen.kt | 10 +- .../settings/screen/SettingsPlayerScreen.kt | 62 +++-- .../settings/screen/SettingsReaderScreen.kt | 42 +++- .../settings/screen/SettingsSearchScreen.kt | 16 +- .../settings/screen/SettingsSecurityScreen.kt | 6 +- .../settings/screen/SettingsTrackingScreen.kt | 25 +- .../more/settings/screen/about/AboutScreen.kt | 21 +- .../advanced/ClearAnimeDatabaseScreen.kt | 8 +- .../screen/advanced/ClearDatabaseScreen.kt | 8 +- .../screen/debug/BackupSchemaScreen.kt | 4 +- .../settings/screen/debug/WorkerInfoScreen.kt | 13 +- .../settings/widget/BasePreferenceWidget.kt | 2 +- .../settings/widget/ListPreferenceWidget.kt | 12 +- .../settings/widget/TriStateListDialog.kt | 12 +- .../more/stats/AnimeStatsScreenContent.kt | 2 +- .../more/stats/MangaStatsScreenContent.kt | 2 +- .../more/storage/StorageScreenContent.kt | 2 +- .../presentation/reader/BottomReaderBar.kt | 4 +- .../presentation/reader/ChapterNavigator.kt | 8 +- .../presentation/reader/ChapterTransition.kt | 31 ++- .../reader/OrientationModeSelectDialog.kt | 4 +- .../reader/ReadingModeSelectDialog.kt | 4 +- .../reader/settings/ReadingModePage.kt | 10 +- .../track/TrackInfoDialogSelector.kt | 22 +- .../track/anime/AnimeTrackInfoDialogHome.kt | 4 +- .../track/anime/AnimeTrackServiceSearch.kt | 12 +- .../track/manga/MangaTrackInfoDialogHome.kt | 4 +- .../track/manga/MangaTrackServiceSearch.kt | 12 +- .../updates/anime/AnimeUpdatesScreen.kt | 2 +- .../updates/anime/AnimeUpdatesUiItem.kt | 27 ++- .../updates/manga/MangaUpdatesScreen.kt | 2 +- .../updates/manga/MangaUpdatesUiItem.kt | 25 +- .../kanade/presentation/util/DurationUtils.kt | 12 +- .../presentation/util/ExceptionFormatter.kt | 14 +- .../webview/WebViewScreenContent.kt | 4 +- app/src/main/java/eu/kanade/tachiyomi/App.kt | 8 +- .../java/eu/kanade/tachiyomi/AppModule.kt | 10 +- .../java/eu/kanade/tachiyomi/Migrations.kt | 74 ++++-- .../tachiyomi/crash/GlobalExceptionHandler.kt | 2 +- .../tachiyomi/data/backup/BackupCreateJob.kt | 18 +- .../data/backup/BackupFileValidator.kt | 4 +- .../tachiyomi/data/backup/BackupManager.kt | 112 +++++++-- .../tachiyomi/data/backup/BackupNotifier.kt | 45 +++- .../tachiyomi/data/backup/BackupRestorer.kt | 125 ++++++++-- .../data/backup/full/models/Backup.kt | 4 +- .../tachiyomi/data/backup/models/Backup.kt | 4 +- .../tachiyomi/data/cache/AnimeCoverCache.kt | 2 +- .../tachiyomi/data/cache/ChapterCache.kt | 4 +- .../tachiyomi/data/cache/EpisodeCache.kt | 4 +- .../tachiyomi/data/cache/MangaCoverCache.kt | 2 +- .../tachiyomi/data/coil/AnimeCoverFetcher.kt | 2 +- .../tachiyomi/data/coil/AnimeCoverKeyer.kt | 2 +- .../tachiyomi/data/coil/MangaCoverFetcher.kt | 2 +- .../tachiyomi/data/coil/MangaCoverKeyer.kt | 2 +- .../data/download/anime/AnimeDownloadCache.kt | 20 +- .../download/anime/AnimeDownloadNotifier.kt | 15 +- .../anime/AnimeDownloadPendingDeleter.kt | 5 +- .../download/anime/AnimeDownloadProvider.kt | 7 +- .../data/download/anime/AnimeDownloader.kt | 91 ++++++-- .../data/download/manga/MangaDownloadCache.kt | 8 +- .../download/manga/MangaDownloadManager.kt | 26 ++- .../download/manga/MangaDownloadNotifier.kt | 11 +- .../manga/MangaDownloadPendingDeleter.kt | 5 +- .../download/manga/MangaDownloadProvider.kt | 7 +- .../data/download/manga/MangaDownloader.kt | 66 ++++-- .../library/anime/AnimeLibraryUpdateJob.kt | 83 +++++-- .../anime/AnimeLibraryUpdateNotifier.kt | 73 ++++-- .../library/manga/MangaLibraryUpdateJob.kt | 83 +++++-- .../manga/MangaLibraryUpdateNotifier.kt | 56 ++++- .../data/notification/NotificationHandler.kt | 21 +- .../data/notification/NotificationReceiver.kt | 213 +++++++++++++++--- .../kanade/tachiyomi/data/saver/ImageSaver.kt | 21 +- .../tachiyomi/data/track/AnimeTrackService.kt | 9 +- .../tachiyomi/data/track/MangaTrackService.kt | 9 +- .../tachiyomi/data/track/anilist/Anilist.kt | 2 +- .../data/track/anilist/AnilistApi.kt | 4 +- .../data/track/anilist/AnilistInterceptor.kt | 2 +- .../data/track/anilist/AnilistModels.kt | 4 +- .../data/track/bangumi/BangumiApi.kt | 14 +- .../tachiyomi/data/track/kavita/Kavita.kt | 2 +- .../tachiyomi/data/track/kavita/KavitaApi.kt | 15 +- .../tachiyomi/data/track/kitsu/Kitsu.kt | 2 +- .../tachiyomi/data/track/kitsu/KitsuApi.kt | 14 +- .../tachiyomi/data/track/kitsu/KitsuModels.kt | 6 +- .../tachiyomi/data/track/komga/Komga.kt | 4 +- .../tachiyomi/data/track/komga/KomgaApi.kt | 14 +- .../data/track/mangaupdates/MangaUpdates.kt | 4 +- .../mangaupdates/MangaUpdatesInterceptor.kt | 2 +- .../data/track/myanimelist/MyAnimeListApi.kt | 40 +++- .../myanimelist/MyAnimeListInterceptor.kt | 2 +- .../data/track/shikimori/ShikimoriApi.kt | 10 +- .../tachiyomi/data/track/simkl/SimklApi.kt | 7 +- .../tachiyomi/data/track/suwayomi/Suwayomi.kt | 8 +- .../data/track/suwayomi/TachideskApi.kt | 9 +- .../data/updater/AppUpdateChecker.kt | 4 +- .../data/updater/AppUpdateNotifier.kt | 30 ++- .../data/updater/AppUpdateService.kt | 15 +- .../extension/anime/AnimeExtensionManager.kt | 31 ++- .../anime/api/AnimeExtensionGithubApi.kt | 4 +- .../anime/installer/InstallerAnime.kt | 2 +- .../PackageInstallerInstallerAnime.kt | 8 +- .../anime/installer/ShizukuInstallerAnime.kt | 4 +- .../util/AnimeExtensionInstallActivity.kt | 2 +- .../util/AnimeExtensionInstallReceiver.kt | 8 +- .../util/AnimeExtensionInstallService.kt | 4 +- .../anime/util/AnimeExtensionInstaller.kt | 14 +- .../anime/util/AnimeExtensionLoader.kt | 31 ++- .../extension/manga/MangaExtensionManager.kt | 15 +- .../manga/api/MangaExtensionGithubApi.kt | 4 +- .../manga/installer/InstallerManga.kt | 2 +- .../PackageInstallerInstallerManga.kt | 8 +- .../manga/installer/ShizukuInstallerManga.kt | 4 +- .../util/MangaExtensionInstallActivity.kt | 2 +- .../util/MangaExtensionInstallReceiver.kt | 8 +- .../util/MangaExtensionInstallService.kt | 4 +- .../manga/util/MangaExtensionInstaller.kt | 14 +- .../manga/util/MangaExtensionLoader.kt | 35 ++- .../source/anime/AndroidAnimeSourceManager.kt | 2 +- .../source/manga/AndroidMangaSourceManager.kt | 2 +- .../ui/base/delegate/ThemingDelegate.kt | 5 +- .../extension/AnimeExtensionsScreenModel.kt | 30 ++- .../anime/extension/AnimeExtensionsTab.kt | 8 +- .../details/AnimeExtensionDetailsScreen.kt | 5 +- .../AnimeExtensionDetailsScreenModel.kt | 5 +- .../details/SourcePreferencesScreen.kt | 9 +- .../anime/migration/AnimeMigrationFlags.kt | 12 +- .../migration/search/MigrateAnimeDialog.kt | 12 +- .../search/MigrateAnimeSearchScreen.kt | 12 +- .../source/AnimeSourcesFilterScreenModel.kt | 2 +- .../anime/source/AnimeSourcesScreenModel.kt | 2 +- .../source/browse/BrowseAnimeSourceScreen.kt | 8 +- .../browse/BrowseAnimeSourceScreenModel.kt | 25 +- .../globalsearch/AnimeSearchScreenModel.kt | 6 +- .../globalsearch/GlobalAnimeSearchScreen.kt | 4 +- .../extension/MangaExtensionsScreenModel.kt | 30 ++- .../manga/extension/MangaExtensionsTab.kt | 4 +- .../details/MangaExtensionDetailsScreen.kt | 5 +- .../MangaExtensionDetailsScreenModel.kt | 5 +- .../details/MangaSourcePreferencesScreen.kt | 9 +- .../manga/migration/MangaMigrationFlags.kt | 12 +- .../migration/search/MigrateMangaDialog.kt | 12 +- .../search/MigrateMangaSearchScreen.kt | 12 +- .../source/MangaSourcesFilterScreenModel.kt | 2 +- .../manga/source/MangaSourcesScreenModel.kt | 2 +- .../source/browse/BrowseMangaSourceScreen.kt | 8 +- .../browse/BrowseMangaSourceScreenModel.kt | 22 +- .../globalsearch/GlobalMangaSearchScreen.kt | 4 +- .../globalsearch/MangaSearchScreenModel.kt | 6 +- .../anime/AnimeCategoryScreenModel.kt | 20 +- .../manga/MangaCategoryScreenModel.kt | 20 +- .../anime/AnimeDownloadHeaderHolder.kt | 5 +- .../anime/AnimeDownloadQueueScreen.kt | 22 +- .../anime/AnimeDownloadQueueScreenModel.kt | 5 +- .../manga/MangaDownloadHeaderHolder.kt | 5 +- .../manga/MangaDownloadQueueScreen.kt | 22 +- .../manga/MangaDownloadQueueScreenModel.kt | 5 +- .../tachiyomi/ui/entries/anime/AnimeScreen.kt | 29 ++- .../ui/entries/anime/AnimeScreenModel.kt | 55 ++++- .../anime/track/AnimeTrackInfoDialog.kt | 40 +++- .../tachiyomi/ui/entries/manga/MangaScreen.kt | 16 +- .../ui/entries/manga/MangaScreenModel.kt | 30 ++- .../manga/track/MangaTrackInfoDialog.kt | 40 +++- .../history/anime/AnimeHistoryScreenModel.kt | 6 +- .../ui/history/anime/AnimeHistoryTab.kt | 13 +- .../history/manga/MangaHistoryScreenModel.kt | 6 +- .../ui/history/manga/MangaHistoryTab.kt | 13 +- .../eu/kanade/tachiyomi/ui/home/HomeScreen.kt | 5 +- .../library/anime/AnimeLibraryScreenModel.kt | 34 ++- .../anime/AnimeLibrarySettingsScreenModel.kt | 6 +- .../ui/library/anime/AnimeLibraryTab.kt | 36 ++- .../library/manga/MangaLibraryScreenModel.kt | 30 ++- .../manga/MangaLibrarySettingsScreenModel.kt | 6 +- .../ui/library/manga/MangaLibraryTab.kt | 44 +++- .../kanade/tachiyomi/ui/main/MainActivity.kt | 33 ++- .../eu/kanade/tachiyomi/ui/more/MoreTab.kt | 9 +- .../tachiyomi/ui/player/ExternalIntents.kt | 37 ++- .../tachiyomi/ui/player/PlayerActivity.kt | 121 ++++++++-- .../tachiyomi/ui/player/PlayerViewModel.kt | 37 ++- .../ui/player/loader/EpisodeLoader.kt | 25 +- .../ui/player/settings/PlayerPreferences.kt | 45 +++- .../settings/PlayerSettingsScreenModel.kt | 9 +- .../settings/dialogs/DefaultDecoderDialog.kt | 5 +- .../settings/dialogs/EpisodeListDialog.kt | 4 +- .../player/settings/dialogs/PlayerDialog.kt | 11 +- .../settings/sheets/PlayerSettingsSheet.kt | 20 +- .../settings/sheets/ScreenshotOptionsSheet.kt | 7 +- .../settings/sheets/StreamsCatalogSheet.kt | 12 +- .../settings/sheets/VideoChaptersSheet.kt | 6 +- .../sheets/subtitle/SubtitleColorPage.kt | 19 +- .../sheets/subtitle/SubtitleDelayPage.kt | 1 - .../sheets/subtitle/SubtitleFontPage.kt | 2 +- .../sheets/subtitle/SubtitleSettingsSheet.kt | 2 +- .../ui/player/viewer/GestureHandler.kt | 45 +++- .../ui/player/viewer/PlayerControlsView.kt | 102 +++++++-- .../tachiyomi/ui/player/viewer/PlayerEnums.kt | 1 - .../ui/player/viewer/components/Seekbar.kt | 5 +- .../tachiyomi/ui/reader/ReaderActivity.kt | 34 ++- .../ui/reader/ReaderNavigationOverlayView.kt | 5 +- .../tachiyomi/ui/reader/ReaderViewModel.kt | 52 ++++- .../tachiyomi/ui/reader/SaveImageNotifier.kt | 6 +- .../ui/reader/loader/ChapterLoader.kt | 20 +- .../ui/reader/loader/DirectoryPageLoader.kt | 2 +- .../ui/reader/loader/DownloadPageLoader.kt | 15 +- .../ui/reader/loader/HttpPageLoader.kt | 15 +- .../ui/reader/loader/RarPageLoader.kt | 2 +- .../ui/reader/loader/ZipPageLoader.kt | 2 +- .../ui/reader/setting/OrientationType.kt | 56 ++++- .../ui/reader/setting/ReaderPreferences.kt | 71 ++++-- .../ui/reader/setting/ReadingModeType.kt | 16 +- .../ui/reader/viewer/ReaderPageImageView.kt | 26 ++- .../reader/viewer/ReaderProgressIndicator.kt | 4 +- .../ui/reader/viewer/ViewerNavigation.kt | 25 +- .../ui/reader/viewer/pager/PagerPageHolder.kt | 10 +- .../ui/reader/viewer/pager/PagerViewer.kt | 6 +- .../viewer/webtoon/WebtoonPageHolder.kt | 9 +- .../viewer/webtoon/WebtoonRecyclerView.kt | 8 +- .../ui/reader/viewer/webtoon/WebtoonViewer.kt | 4 +- .../ui/storage/CommonStorageScreenModel.kt | 2 +- .../updates/anime/AnimeUpdatesScreenModel.kt | 24 +- .../updates/manga/MangaUpdatesScreenModel.kt | 8 +- .../tachiyomi/ui/webview/WebViewActivity.kt | 8 +- .../eu/kanade/tachiyomi/util/AniChartApi.kt | 28 ++- .../eu/kanade/tachiyomi/util/AniSkipApi.kt | 13 +- .../kanade/tachiyomi/util/AnimeExtensions.kt | 4 +- .../eu/kanade/tachiyomi/util/BackupUtil.kt | 19 +- .../kanade/tachiyomi/util/MangaExtensions.kt | 4 +- .../util/chapter/ChapterFilterDownloaded.kt | 8 +- .../util/episode/EpisodeFilterDownloaded.kt | 8 +- .../tachiyomi/util/lang/DateExtensions.kt | 4 +- .../tachiyomi/util/lang/RectFExtensions.kt | 7 +- .../tachiyomi/util/storage/OkioExtensions.kt | 4 +- .../util/system/AnimationExtensions.kt | 6 +- .../util/system/AuthenticatorUtil.kt | 2 +- .../util/system/ContextExtensions.kt | 17 +- .../eu/kanade/tachiyomi/util/system/GLUtil.kt | 7 +- .../util/system/NetworkExtensions.kt | 4 +- .../util/system/NotificationExtensions.kt | 21 +- .../tachiyomi/util/view/ViewExtensions.kt | 7 +- buildSrc/src/main/kotlin/Commands.kt | 6 +- .../src/main/kotlin/LocalesConfigPlugin.kt | 3 +- core-metadata/build.gradle.kts | 1 - .../core/preference/AndroidPreferenceStore.kt | 4 +- .../kanade/tachiyomi/network/DohProviders.kt | 2 +- .../kanade/tachiyomi/network/NetworkHelper.kt | 8 +- .../tachiyomi/network/NetworkPreferences.kt | 5 +- .../tachiyomi/network/OkHttpExtensions.kt | 6 +- .../tachiyomi/network/ProgressResponseBody.kt | 13 +- .../eu/kanade/tachiyomi/network/Requests.kt | 2 +- .../interceptor/CloudflareInterceptor.kt | 4 +- .../interceptor/RateLimitInterceptor.kt | 6 +- .../SpecificHostRateLimitInterceptor.kt | 10 +- .../UncaughtExceptionInterceptor.kt | 2 +- .../network/interceptor/WebViewInterceptor.kt | 6 +- .../tachiyomi/util/lang/StringExtensions.kt | 2 +- .../kanade/tachiyomi/util/storage/EpubFile.kt | 4 +- .../tachiyomi/util/system/ToastExtensions.kt | 6 +- .../tachiyomi/util/system/WebViewUtil.kt | 2 +- .../tachiyomi/core/preference/Preference.kt | 4 +- .../core/util/lang/CoroutinesExtensions.kt | 10 +- .../core/util/lang/RxCoroutineBridge.kt | 4 +- .../tachiyomi/core/util/system/ImageUtil.kt | 30 ++- data/build.gradle.kts | 2 +- .../java/tachiyomi/data/DatabaseAdapter.kt | 4 +- .../data/entries/anime/AnimeMapper.kt | 57 ++++- .../data/entries/anime/AnimeRepositoryImpl.kt | 12 +- .../data/entries/manga/MangaMapper.kt | 57 ++++- .../data/entries/manga/MangaRepositoryImpl.kt | 12 +- .../handlers/anime/AnimeTransactionContext.kt | 12 +- .../handlers/anime/QueryPagingAnimeSource.kt | 2 +- .../handlers/manga/MangaTransactionContext.kt | 12 +- .../handlers/manga/QueryPagingMangaSource.kt | 2 +- .../data/history/anime/AnimeHistoryMapper.kt | 15 +- .../anime/AnimeHistoryRepositoryImpl.kt | 5 +- .../data/history/manga/MangaHistoryMapper.kt | 16 +- .../data/items/chapter/ChapterMapper.kt | 16 +- .../items/chapter/ChapterRepositoryImpl.kt | 16 +- .../data/items/episode/EpisodeMapper.kt | 17 +- .../items/episode/EpisodeRepositoryImpl.kt | 16 +- .../tachiyomi/data/release/GithubRelease.kt | 4 +- .../source/anime/AnimeSourcePagingSource.kt | 6 +- .../source/manga/MangaSourcePagingSource.kt | 4 +- .../data/track/anime/AnimeTrackMapper.kt | 16 +- .../data/track/manga/MangaTrackMapper.kt | 16 +- .../data/updates/anime/AnimeUpdatesMapper.kt | 18 +- .../anime/AnimeUpdatesRepositoryImpl.kt | 6 +- .../data/updates/manga/MangaUpdatesMapper.kt | 17 +- domain/build.gradle.kts | 1 - .../backup/service/BackupPreferences.kt | 5 +- .../anime/interactor/ReorderAnimeCategory.kt | 2 +- .../interactor/SetSortModeForAnimeCategory.kt | 12 +- .../manga/interactor/ReorderMangaCategory.kt | 2 +- .../interactor/SetSortModeForMangaCategory.kt | 12 +- .../download/service/DownloadPreferences.kt | 50 +++- .../anime/interactor/SetAnimeFetchInterval.kt | 22 +- .../domain/entries/anime/model/Anime.kt | 2 +- .../manga/interactor/SetMangaFetchInterval.kt | 22 +- .../domain/entries/manga/model/Manga.kt | 2 +- .../anime/interactor/GetNextEpisodes.kt | 2 +- .../anime/model/AnimeHistoryWithRelations.kt | 2 +- .../manga/interactor/GetNextChapters.kt | 2 +- .../manga/model/MangaHistoryWithRelations.kt | 2 +- .../items/chapter/service/ChapterSorter.kt | 5 +- .../items/episode/service/EpisodeSorter.kt | 5 +- .../domain/items/service/MissingItems.kt | 2 +- .../library/service/LibraryPreferences.kt | 58 ++++- .../interactor/GetApplicationRelease.kt | 22 +- .../anime/interactor/GetAnimeUpdates.kt | 2 +- .../manga/interactor/GetMangaUpdates.kt | 2 +- .../interactor/SetAnimeFetchIntervalTest.kt | 8 +- .../interactor/SetMangaFetchIntervalTest.kt | 8 +- .../domain/library/model/LibraryFlagsTest.kt | 50 +++- .../interactor/GetApplicationReleaseTest.kt | 10 +- .../macrobenchmark/StartupBenchmark.kt | 9 +- .../core/components/AdaptiveSheet.kt | 7 +- .../core/components/VerticalFastScroller.kt | 18 +- .../core/components/WheelPicker.kt | 13 +- .../core/components/material/AlertDialog.kt | 16 +- .../core/components/material/Button.kt | 2 +- .../components/material/NavigationRail.kt | 5 +- .../core/components/material/Scaffold.kt | 13 +- .../presentation/core/screens/EmptyScreen.kt | 2 +- .../components/anime/UpdatesAnimeWidget.kt | 5 +- .../components/manga/UpdatesMangaWidget.kt | 5 +- .../anime/AnimeUpdatesGridGlanceWidget.kt | 9 +- .../anime/TachiyomiAnimeWidgetManager.kt | 5 +- .../manga/MangaUpdatesGridGlanceWidget.kt | 9 +- .../manga/TachiyomiMangaWidgetManager.kt | 5 +- .../tachiyomi/animesource/AnimeSource.kt | 8 +- .../animesource/model/AnimeFilter.kt | 10 +- .../animesource/online/AnimeHttpSource.kt | 21 +- .../eu/kanade/tachiyomi/source/MangaSource.kt | 8 +- .../kanade/tachiyomi/source/model/Filter.kt | 5 +- .../tachiyomi/source/online/HttpSource.kt | 6 +- .../local/entries/anime/LocalAnimeSource.kt | 36 +-- .../local/entries/manga/LocalMangaSource.kt | 48 ++-- .../image/anime/LocalAnimeCoverManager.kt | 4 +- .../image/manga/LocalMangaCoverManager.kt | 4 +- .../io/anime/LocalAnimeSourceFileSystem.kt | 2 +- .../io/manga/LocalMangaSourceFileSystem.kt | 2 +- 416 files changed, 4604 insertions(+), 1402 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9a166a078..9d3a07c15 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,6 +1,6 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.io.FileInputStream import java.util.Properties +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("com.android.application") @@ -281,7 +281,9 @@ androidComponents { beforeVariants { variantBuilder -> // Disables standardBenchmark if (variantBuilder.buildType == "benchmark") { - variantBuilder.enable = variantBuilder.productFlavors.containsAll(listOf("default" to "dev")) + variantBuilder.enable = variantBuilder.productFlavors.containsAll( + listOf("default" to "dev") + ) } } onVariants(selector().withFlavor("default" to "standard")) { diff --git a/app/src/main/java/aniyomi/util/DataSaver.kt b/app/src/main/java/aniyomi/util/DataSaver.kt index ddefbf262..0662f0637 100644 --- a/app/src/main/java/aniyomi/util/DataSaver.kt +++ b/app/src/main/java/aniyomi/util/DataSaver.kt @@ -74,7 +74,13 @@ private class BandwidthHeroDataSaver(preferences: SourcePreferences) : DataSaver override fun compress(imageUrl: String): String { return if (dataSavedServer.isNotBlank() && !imageUrl.contains(dataSavedServer)) { when { - imageUrl.contains(".jpeg", true) || imageUrl.contains(".jpg", true) -> if (ignoreJpg) imageUrl else getUrl(imageUrl) + imageUrl.contains(".jpeg", true) || imageUrl.contains(".jpg", true) -> if (ignoreJpg) { + imageUrl + } else { + getUrl( + imageUrl + ) + } imageUrl.contains(".gif", true) -> if (ignoreGif) imageUrl else getUrl(imageUrl) else -> getUrl(imageUrl) } @@ -100,7 +106,13 @@ private class WsrvNlDataSaver(preferences: SourcePreferences) : DataSaver { override fun compress(imageUrl: String): String { return when { - imageUrl.contains(".jpeg", true) || imageUrl.contains(".jpg", true) -> if (ignoreJpg) imageUrl else getUrl(imageUrl) + imageUrl.contains(".jpeg", true) || imageUrl.contains(".jpg", true) -> if (ignoreJpg) { + imageUrl + } else { + getUrl( + imageUrl + ) + } imageUrl.contains(".gif", true) -> if (ignoreGif) imageUrl else getUrl(imageUrl) else -> getUrl(imageUrl) } @@ -108,7 +120,10 @@ private class WsrvNlDataSaver(preferences: SourcePreferences) : DataSaver { private fun getUrl(imageUrl: String): String { // Network Request sent to wsrv - return "https://wsrv.nl/?url=$imageUrl" + if (imageUrl.contains(".webp", true) || imageUrl.contains(".gif", true)) { + return "https://wsrv.nl/?url=$imageUrl" + if (imageUrl.contains(".webp", true) || imageUrl.contains( + ".gif", + true + )) { if (!format) { // Preserve output image extension for animated images(.webp and .gif) "&q=$quality&n=-1" @@ -140,7 +155,13 @@ private class ReSmushItDataSaver(preferences: SourcePreferences) : DataSaver { override fun compress(imageUrl: String): String { return when { - imageUrl.contains(".jpeg", true) || imageUrl.contains(".jpg", true) -> if (ignoreJpg) imageUrl else getUrl(imageUrl) + imageUrl.contains(".jpeg", true) || imageUrl.contains(".jpg", true) -> if (ignoreJpg) { + imageUrl + } else { + getUrl( + imageUrl + ) + } imageUrl.contains(".gif", true) -> if (ignoreGif) imageUrl else getUrl(imageUrl) else -> getUrl(imageUrl) } diff --git a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt b/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt index 028d2a509..dc575b1fa 100644 --- a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt @@ -20,9 +20,14 @@ class BasePreferences( fun extensionInstaller() = ExtensionInstallerPreference(context, preferenceStore) - fun acraEnabled() = preferenceStore.getBoolean("acra.enable", isPreviewBuildType || isReleaseBuildType) + fun acraEnabled() = preferenceStore.getBoolean( + "acra.enable", + isPreviewBuildType || isReleaseBuildType + ) - fun deviceHasPip() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && context.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) + fun deviceHasPip() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && context.packageManager.hasSystemFeature( + PackageManager.FEATURE_PICTURE_IN_PICTURE + ) enum class ExtensionInstaller(@StringRes val titleResId: Int) { LEGACY(R.string.ext_installer_legacy), diff --git a/app/src/main/java/eu/kanade/domain/entries/anime/interactor/SetAnimeViewerFlags.kt b/app/src/main/java/eu/kanade/domain/entries/anime/interactor/SetAnimeViewerFlags.kt index 2937f867a..5059b5c72 100644 --- a/app/src/main/java/eu/kanade/domain/entries/anime/interactor/SetAnimeViewerFlags.kt +++ b/app/src/main/java/eu/kanade/domain/entries/anime/interactor/SetAnimeViewerFlags.kt @@ -1,9 +1,9 @@ package eu.kanade.domain.entries.anime.interactor +import kotlin.math.pow import tachiyomi.domain.entries.anime.model.Anime import tachiyomi.domain.entries.anime.model.AnimeUpdate import tachiyomi.domain.entries.anime.repository.AnimeRepository -import kotlin.math.pow class SetAnimeViewerFlags( private val animeRepository: AnimeRepository, diff --git a/app/src/main/java/eu/kanade/domain/entries/anime/interactor/UpdateAnime.kt b/app/src/main/java/eu/kanade/domain/entries/anime/interactor/UpdateAnime.kt index c3b845cb4..d8cf6a412 100644 --- a/app/src/main/java/eu/kanade/domain/entries/anime/interactor/UpdateAnime.kt +++ b/app/src/main/java/eu/kanade/domain/entries/anime/interactor/UpdateAnime.kt @@ -3,6 +3,8 @@ package eu.kanade.domain.entries.anime.interactor import eu.kanade.domain.entries.anime.model.hasCustomCover import eu.kanade.tachiyomi.animesource.model.SAnime import eu.kanade.tachiyomi.data.cache.AnimeCoverCache +import java.time.ZonedDateTime +import java.util.Date import tachiyomi.domain.entries.anime.interactor.SetAnimeFetchInterval import tachiyomi.domain.entries.anime.model.Anime import tachiyomi.domain.entries.anime.model.AnimeUpdate @@ -10,8 +12,6 @@ import tachiyomi.domain.entries.anime.repository.AnimeRepository import tachiyomi.source.local.entries.anime.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.time.ZonedDateTime -import java.util.Date class UpdateAnime( private val animeRepository: AnimeRepository, @@ -91,7 +91,9 @@ class UpdateAnime( } suspend fun awaitUpdateCoverLastModified(mangaId: Long): Boolean { - return animeRepository.updateAnime(AnimeUpdate(id = mangaId, coverLastModified = Date().time)) + return animeRepository.updateAnime( + AnimeUpdate(id = mangaId, coverLastModified = Date().time) + ) } suspend fun awaitUpdateFavorite(animeId: Long, favorite: Boolean): Boolean { diff --git a/app/src/main/java/eu/kanade/domain/entries/manga/interactor/UpdateManga.kt b/app/src/main/java/eu/kanade/domain/entries/manga/interactor/UpdateManga.kt index e68c25a60..10aba8d15 100644 --- a/app/src/main/java/eu/kanade/domain/entries/manga/interactor/UpdateManga.kt +++ b/app/src/main/java/eu/kanade/domain/entries/manga/interactor/UpdateManga.kt @@ -3,6 +3,8 @@ package eu.kanade.domain.entries.manga.interactor import eu.kanade.domain.entries.manga.model.hasCustomCover import eu.kanade.tachiyomi.data.cache.MangaCoverCache import eu.kanade.tachiyomi.source.model.SManga +import java.time.ZonedDateTime +import java.util.Date import tachiyomi.domain.entries.manga.interactor.SetMangaFetchInterval import tachiyomi.domain.entries.manga.model.Manga import tachiyomi.domain.entries.manga.model.MangaUpdate @@ -10,8 +12,6 @@ import tachiyomi.domain.entries.manga.repository.MangaRepository import tachiyomi.source.local.entries.manga.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.time.ZonedDateTime -import java.util.Date class UpdateManga( private val mangaRepository: MangaRepository, @@ -91,7 +91,9 @@ class UpdateManga( } suspend fun awaitUpdateCoverLastModified(mangaId: Long): Boolean { - return mangaRepository.updateManga(MangaUpdate(id = mangaId, coverLastModified = Date().time)) + return mangaRepository.updateManga( + MangaUpdate(id = mangaId, coverLastModified = Date().time) + ) } suspend fun awaitUpdateFavorite(mangaId: Long, favorite: Boolean): Boolean { diff --git a/app/src/main/java/eu/kanade/domain/items/chapter/interactor/SyncChaptersWithSource.kt b/app/src/main/java/eu/kanade/domain/items/chapter/interactor/SyncChaptersWithSource.kt index f5a87bede..f31f87f36 100644 --- a/app/src/main/java/eu/kanade/domain/items/chapter/interactor/SyncChaptersWithSource.kt +++ b/app/src/main/java/eu/kanade/domain/items/chapter/interactor/SyncChaptersWithSource.kt @@ -9,6 +9,10 @@ import eu.kanade.tachiyomi.data.download.manga.MangaDownloadProvider import eu.kanade.tachiyomi.source.MangaSource import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.online.HttpSource +import java.lang.Long.max +import java.time.ZonedDateTime +import java.util.Date +import java.util.TreeSet import tachiyomi.data.items.chapter.ChapterSanitizer import tachiyomi.domain.entries.manga.model.Manga import tachiyomi.domain.items.chapter.interactor.GetChapterByMangaId @@ -21,10 +25,6 @@ import tachiyomi.domain.items.chapter.repository.ChapterRepository import tachiyomi.domain.items.chapter.service.ChapterRecognition import tachiyomi.source.local.entries.manga.isLocal import uy.kohesive.injekt.api.get -import java.lang.Long.max -import java.time.ZonedDateTime -import java.util.Date -import java.util.TreeSet class SyncChaptersWithSource( private val downloadManager: MangaDownloadManager, @@ -100,7 +100,11 @@ class SyncChaptersWithSource( } // Recognize chapter number for the chapter. - val chapterNumber = ChapterRecognition.parseChapterNumber(manga.title, chapter.name, chapter.chapterNumber) + val chapterNumber = ChapterRecognition.parseChapterNumber( + manga.title, + chapter.name, + chapter.chapterNumber + ) chapter = chapter.copy(chapterNumber = chapterNumber) val dbChapter = dbChapters.find { it.url == chapter.url } @@ -116,8 +120,16 @@ class SyncChaptersWithSource( toAdd.add(toAddChapter) } else { if (shouldUpdateDbChapter.await(dbChapter, chapter)) { - val shouldRenameChapter = downloadProvider.isChapterDirNameChanged(dbChapter, chapter) && - downloadManager.isChapterDownloaded(dbChapter.name, dbChapter.scanlator, manga.title, manga.source) + val shouldRenameChapter = downloadProvider.isChapterDirNameChanged( + dbChapter, + chapter + ) && + downloadManager.isChapterDownloaded( + dbChapter.name, + dbChapter.scanlator, + manga.title, + manga.source + ) if (shouldRenameChapter) { downloadManager.renameChapter(source, manga, dbChapter, chapter) diff --git a/app/src/main/java/eu/kanade/domain/items/chapter/model/Chapter.kt b/app/src/main/java/eu/kanade/domain/items/chapter/model/Chapter.kt index e9f36f187..80283d3ec 100644 --- a/app/src/main/java/eu/kanade/domain/items/chapter/model/Chapter.kt +++ b/app/src/main/java/eu/kanade/domain/items/chapter/model/Chapter.kt @@ -1,10 +1,10 @@ package eu.kanade.domain.items.chapter.model import data.Chapters +import eu.kanade.tachiyomi.data.database.models.manga.Chapter as DbChapter import eu.kanade.tachiyomi.data.database.models.manga.ChapterImpl import eu.kanade.tachiyomi.source.model.SChapter import tachiyomi.domain.items.chapter.model.Chapter -import eu.kanade.tachiyomi.data.database.models.manga.Chapter as DbChapter // TODO: Remove when all deps are migrated fun Chapter.toSChapter(): SChapter { diff --git a/app/src/main/java/eu/kanade/domain/items/chapter/model/ChapterFilter.kt b/app/src/main/java/eu/kanade/domain/items/chapter/model/ChapterFilter.kt index 06b3b3422..0b8963a94 100644 --- a/app/src/main/java/eu/kanade/domain/items/chapter/model/ChapterFilter.kt +++ b/app/src/main/java/eu/kanade/domain/items/chapter/model/ChapterFilter.kt @@ -23,7 +23,12 @@ fun List.applyFilters(manga: Manga, downloadManager: MangaDownloadManag .filter { chapter -> applyFilter(bookmarkedFilter) { chapter.bookmark } } .filter { chapter -> applyFilter(downloadedFilter) { - val downloaded = downloadManager.isChapterDownloaded(chapter.name, chapter.scanlator, manga.title, manga.source) + val downloaded = downloadManager.isChapterDownloaded( + chapter.name, + chapter.scanlator, + manga.title, + manga.source + ) downloaded || isLocalManga } } diff --git a/app/src/main/java/eu/kanade/domain/items/episode/interactor/SyncEpisodesWithSource.kt b/app/src/main/java/eu/kanade/domain/items/episode/interactor/SyncEpisodesWithSource.kt index a558647ff..ba0360db0 100644 --- a/app/src/main/java/eu/kanade/domain/items/episode/interactor/SyncEpisodesWithSource.kt +++ b/app/src/main/java/eu/kanade/domain/items/episode/interactor/SyncEpisodesWithSource.kt @@ -9,6 +9,10 @@ import eu.kanade.tachiyomi.animesource.model.SEpisode import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource import eu.kanade.tachiyomi.data.download.anime.AnimeDownloadManager import eu.kanade.tachiyomi.data.download.anime.AnimeDownloadProvider +import java.lang.Long.max +import java.time.ZonedDateTime +import java.util.Date +import java.util.TreeSet import tachiyomi.data.items.episode.EpisodeSanitizer import tachiyomi.domain.entries.anime.model.Anime import tachiyomi.domain.items.episode.interactor.GetEpisodeByAnimeId @@ -21,10 +25,6 @@ import tachiyomi.domain.items.episode.repository.EpisodeRepository import tachiyomi.domain.items.episode.service.EpisodeRecognition import tachiyomi.source.local.entries.anime.isLocal import uy.kohesive.injekt.api.get -import java.lang.Long.max -import java.time.ZonedDateTime -import java.util.Date -import java.util.TreeSet class SyncEpisodesWithSource( private val downloadManager: AnimeDownloadManager, @@ -100,7 +100,11 @@ class SyncEpisodesWithSource( } // Recognize episode number for the episode. - val episodeNumber = EpisodeRecognition.parseEpisodeNumber(anime.title, episode.name, episode.episodeNumber) + val episodeNumber = EpisodeRecognition.parseEpisodeNumber( + anime.title, + episode.name, + episode.episodeNumber + ) episode = episode.copy(episodeNumber = episodeNumber) val dbEpisode = dbEpisodes.find { it.url == episode.url } @@ -116,8 +120,16 @@ class SyncEpisodesWithSource( toAdd.add(toAddEpisode) } else { if (shouldUpdateDbEpisode.await(dbEpisode, episode)) { - val shouldRenameEpisode = downloadProvider.isEpisodeDirNameChanged(dbEpisode, episode) && - downloadManager.isEpisodeDownloaded(dbEpisode.name, dbEpisode.scanlator, anime.title, anime.source) + val shouldRenameEpisode = downloadProvider.isEpisodeDirNameChanged( + dbEpisode, + episode + ) && + downloadManager.isEpisodeDownloaded( + dbEpisode.name, + dbEpisode.scanlator, + anime.title, + anime.source + ) if (shouldRenameEpisode) { downloadManager.renameEpisode(source, anime, dbEpisode, episode) @@ -129,7 +141,9 @@ class SyncEpisodesWithSource( sourceOrder = episode.sourceOrder, ) if (episode.dateUpload != 0L) { - toChangeEpisode = toChangeEpisode.copy(dateUpload = sourceEpisode.dateUpload) + toChangeEpisode = toChangeEpisode.copy( + dateUpload = sourceEpisode.dateUpload + ) } toChange.add(toChangeEpisode) } diff --git a/app/src/main/java/eu/kanade/domain/items/episode/model/Episode.kt b/app/src/main/java/eu/kanade/domain/items/episode/model/Episode.kt index 637822347..85742a0a7 100644 --- a/app/src/main/java/eu/kanade/domain/items/episode/model/Episode.kt +++ b/app/src/main/java/eu/kanade/domain/items/episode/model/Episode.kt @@ -2,9 +2,9 @@ package eu.kanade.domain.items.episode.model import dataanime.Episodes import eu.kanade.tachiyomi.animesource.model.SEpisode +import eu.kanade.tachiyomi.data.database.models.anime.Episode as DbEpisode import eu.kanade.tachiyomi.data.database.models.anime.EpisodeImpl import tachiyomi.domain.items.episode.model.Episode -import eu.kanade.tachiyomi.data.database.models.anime.Episode as DbEpisode // TODO: Remove when all deps are migrated fun Episode.toSEpisode(): SEpisode { diff --git a/app/src/main/java/eu/kanade/domain/items/episode/model/EpisodeFilter.kt b/app/src/main/java/eu/kanade/domain/items/episode/model/EpisodeFilter.kt index 11d47e02f..89a6162df 100644 --- a/app/src/main/java/eu/kanade/domain/items/episode/model/EpisodeFilter.kt +++ b/app/src/main/java/eu/kanade/domain/items/episode/model/EpisodeFilter.kt @@ -23,7 +23,12 @@ fun List.applyFilters(anime: Anime, downloadManager: AnimeDownloadManag .filter { episode -> applyFilter(bookmarkedFilter) { episode.bookmark } } .filter { episode -> applyFilter(downloadedFilter) { - val downloaded = downloadManager.isEpisodeDownloaded(episode.name, episode.scanlator, anime.title, anime.source) + val downloaded = downloadManager.isEpisodeDownloaded( + episode.name, + episode.scanlator, + anime.title, + anime.source + ) downloaded || isLocalAnime } } diff --git a/app/src/main/java/eu/kanade/domain/source/anime/interactor/GetAnimeSourcesWithFavoriteCount.kt b/app/src/main/java/eu/kanade/domain/source/anime/interactor/GetAnimeSourcesWithFavoriteCount.kt index 2aede9abe..075041167 100644 --- a/app/src/main/java/eu/kanade/domain/source/anime/interactor/GetAnimeSourcesWithFavoriteCount.kt +++ b/app/src/main/java/eu/kanade/domain/source/anime/interactor/GetAnimeSourcesWithFavoriteCount.kt @@ -2,14 +2,14 @@ package eu.kanade.domain.source.anime.interactor import eu.kanade.domain.source.service.SetMigrateSorting import eu.kanade.domain.source.service.SourcePreferences +import java.text.Collator +import java.util.Collections +import java.util.Locale import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import tachiyomi.domain.source.anime.model.AnimeSource import tachiyomi.domain.source.anime.repository.AnimeSourceRepository import tachiyomi.source.local.entries.anime.LocalAnimeSource -import java.text.Collator -import java.util.Collections -import java.util.Locale class GetAnimeSourcesWithFavoriteCount( private val repository: AnimeSourceRepository, @@ -42,7 +42,10 @@ class GetAnimeSourcesWithFavoriteCount( when { a.first.isStub && b.first.isStub.not() -> -1 b.first.isStub && a.first.isStub.not() -> 1 - else -> collator.compare(a.first.name.lowercase(locale), b.first.name.lowercase(locale)) + else -> collator.compare( + a.first.name.lowercase(locale), + b.first.name.lowercase(locale) + ) } } SetMigrateSorting.Mode.TOTAL -> { diff --git a/app/src/main/java/eu/kanade/domain/source/anime/interactor/GetLanguagesWithAnimeSources.kt b/app/src/main/java/eu/kanade/domain/source/anime/interactor/GetLanguagesWithAnimeSources.kt index 5d82e7eaf..4e53fb116 100644 --- a/app/src/main/java/eu/kanade/domain/source/anime/interactor/GetLanguagesWithAnimeSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/anime/interactor/GetLanguagesWithAnimeSources.kt @@ -2,11 +2,11 @@ package eu.kanade.domain.source.anime.interactor import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.util.system.LocaleHelper +import java.util.SortedMap import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import tachiyomi.domain.source.anime.model.AnimeSource import tachiyomi.domain.source.anime.repository.AnimeSourceRepository -import java.util.SortedMap class GetLanguagesWithAnimeSources( private val repository: AnimeSourceRepository, diff --git a/app/src/main/java/eu/kanade/domain/source/anime/interactor/ToggleAnimeSource.kt b/app/src/main/java/eu/kanade/domain/source/anime/interactor/ToggleAnimeSource.kt index 2446f1324..9cf4a202f 100644 --- a/app/src/main/java/eu/kanade/domain/source/anime/interactor/ToggleAnimeSource.kt +++ b/app/src/main/java/eu/kanade/domain/source/anime/interactor/ToggleAnimeSource.kt @@ -21,7 +21,13 @@ class ToggleAnimeSource( fun await(sourceIds: List, enable: Boolean) { val transformedSourceIds = sourceIds.map { it.toString() } preferences.disabledAnimeSources().getAndSet { disabled -> - if (enable) disabled.minus(transformedSourceIds) else disabled.plus(transformedSourceIds) + if (enable) { + disabled.minus(transformedSourceIds) + } else { + disabled.plus( + transformedSourceIds + ) + } } } diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetLanguagesWithMangaSources.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetLanguagesWithMangaSources.kt index 57c62e9ca..db1765a0b 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetLanguagesWithMangaSources.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetLanguagesWithMangaSources.kt @@ -2,11 +2,11 @@ package eu.kanade.domain.source.manga.interactor import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.util.system.LocaleHelper +import java.util.SortedMap import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import tachiyomi.domain.source.manga.model.Source import tachiyomi.domain.source.manga.repository.MangaSourceRepository -import java.util.SortedMap class GetLanguagesWithMangaSources( private val repository: MangaSourceRepository, diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetMangaSourcesWithFavoriteCount.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetMangaSourcesWithFavoriteCount.kt index 9dc574f40..ebdcd88ed 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetMangaSourcesWithFavoriteCount.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/GetMangaSourcesWithFavoriteCount.kt @@ -2,14 +2,14 @@ package eu.kanade.domain.source.manga.interactor import eu.kanade.domain.source.service.SetMigrateSorting import eu.kanade.domain.source.service.SourcePreferences +import java.text.Collator +import java.util.Collections +import java.util.Locale import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import tachiyomi.domain.source.manga.model.Source import tachiyomi.domain.source.manga.repository.MangaSourceRepository import tachiyomi.source.local.entries.manga.LocalMangaSource -import java.text.Collator -import java.util.Collections -import java.util.Locale class GetMangaSourcesWithFavoriteCount( private val repository: MangaSourceRepository, @@ -42,7 +42,10 @@ class GetMangaSourcesWithFavoriteCount( when { a.first.isStub && b.first.isStub.not() -> -1 b.first.isStub && a.first.isStub.not() -> 1 - else -> collator.compare(a.first.name.lowercase(locale), b.first.name.lowercase(locale)) + else -> collator.compare( + a.first.name.lowercase(locale), + b.first.name.lowercase(locale) + ) } } SetMigrateSorting.Mode.TOTAL -> { diff --git a/app/src/main/java/eu/kanade/domain/source/manga/interactor/ToggleMangaSource.kt b/app/src/main/java/eu/kanade/domain/source/manga/interactor/ToggleMangaSource.kt index 059df32db..68c40e0ce 100644 --- a/app/src/main/java/eu/kanade/domain/source/manga/interactor/ToggleMangaSource.kt +++ b/app/src/main/java/eu/kanade/domain/source/manga/interactor/ToggleMangaSource.kt @@ -21,7 +21,13 @@ class ToggleMangaSource( fun await(sourceIds: List, enable: Boolean) { val transformedSourceIds = sourceIds.map { it.toString() } preferences.disabledMangaSources().getAndSet { disabled -> - if (enable) disabled.minus(transformedSourceIds) else disabled.plus(transformedSourceIds) + if (enable) { + disabled.minus(transformedSourceIds) + } else { + disabled.plus( + transformedSourceIds + ) + } } } diff --git a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt index 026d15430..4981a95b9 100644 --- a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt @@ -11,15 +11,29 @@ class SourcePreferences( // Common options - fun sourceDisplayMode() = preferenceStore.getObject("pref_display_mode_catalogue", LibraryDisplayMode.default, LibraryDisplayMode.Serializer::serialize, LibraryDisplayMode.Serializer::deserialize) + fun sourceDisplayMode() = preferenceStore.getObject( + "pref_display_mode_catalogue", + LibraryDisplayMode.default, + LibraryDisplayMode.Serializer::serialize, + LibraryDisplayMode.Serializer::deserialize + ) - fun enabledLanguages() = preferenceStore.getStringSet("source_languages", LocaleHelper.getDefaultEnabledLanguages()) + fun enabledLanguages() = preferenceStore.getStringSet( + "source_languages", + LocaleHelper.getDefaultEnabledLanguages() + ) fun showNsfwSource() = preferenceStore.getBoolean("show_nsfw_source", true) - fun migrationSortingMode() = preferenceStore.getEnum("pref_migration_sorting", SetMigrateSorting.Mode.ALPHABETICAL) + fun migrationSortingMode() = preferenceStore.getEnum( + "pref_migration_sorting", + SetMigrateSorting.Mode.ALPHABETICAL + ) - fun migrationSortingDirection() = preferenceStore.getEnum("pref_migration_direction", SetMigrateSorting.Direction.ASCENDING) + fun migrationSortingDirection() = preferenceStore.getEnum( + "pref_migration_direction", + SetMigrateSorting.Direction.ASCENDING + ) fun trustedSignatures() = preferenceStore.getStringSet("trusted_signatures", emptySet()) @@ -37,9 +51,15 @@ class SourcePreferences( fun animeExtensionUpdatesCount() = preferenceStore.getInt("animeext_updates_count", 0) fun mangaExtensionUpdatesCount() = preferenceStore.getInt("ext_updates_count", 0) - fun hideInAnimeLibraryItems() = preferenceStore.getBoolean("browse_hide_in_anime_library_items", false) + fun hideInAnimeLibraryItems() = preferenceStore.getBoolean( + "browse_hide_in_anime_library_items", + false + ) - fun hideInMangaLibraryItems() = preferenceStore.getBoolean("browse_hide_in_library_items", false) + fun hideInMangaLibraryItems() = preferenceStore.getBoolean( + "browse_hide_in_library_items", + false + ) // SY --> @@ -59,7 +79,10 @@ class SourcePreferences( fun dataSaverImageQuality() = preferenceStore.getInt("data_saver_image_quality", 80) - fun dataSaverImageFormatJpeg() = preferenceStore.getBoolean("data_saver_image_format_jpeg", false) + fun dataSaverImageFormatJpeg() = preferenceStore.getBoolean( + "data_saver_image_format_jpeg", + false + ) fun dataSaverServer() = preferenceStore.getString("data_saver_server", "") diff --git a/app/src/main/java/eu/kanade/domain/track/anime/interactor/RefreshAnimeTracks.kt b/app/src/main/java/eu/kanade/domain/track/anime/interactor/RefreshAnimeTracks.kt index 0714d01c4..9e14a5b24 100644 --- a/app/src/main/java/eu/kanade/domain/track/anime/interactor/RefreshAnimeTracks.kt +++ b/app/src/main/java/eu/kanade/domain/track/anime/interactor/RefreshAnimeTracks.kt @@ -33,7 +33,11 @@ class RefreshAnimeTracks( if (service?.isLoggedIn == true) { val updatedTrack = service.animeService.refresh(track.toDbTrack()) insertTrack.await(updatedTrack.toDomainTrack()!!) - syncEpisodeProgressWithTrack.await(animeId, track, service.animeService) + syncEpisodeProgressWithTrack.await( + animeId, + track, + service.animeService + ) } null } catch (e: Throwable) { diff --git a/app/src/main/java/eu/kanade/domain/track/anime/model/AnimeTrack.kt b/app/src/main/java/eu/kanade/domain/track/anime/model/AnimeTrack.kt index cd4c488d8..6920327a6 100644 --- a/app/src/main/java/eu/kanade/domain/track/anime/model/AnimeTrack.kt +++ b/app/src/main/java/eu/kanade/domain/track/anime/model/AnimeTrack.kt @@ -1,7 +1,7 @@ package eu.kanade.domain.track.anime.model -import tachiyomi.domain.track.anime.model.AnimeTrack import eu.kanade.tachiyomi.data.database.models.anime.AnimeTrack as DbAnimeTrack +import tachiyomi.domain.track.anime.model.AnimeTrack fun AnimeTrack.copyPersonalFrom(other: AnimeTrack): AnimeTrack { return this.copy( @@ -13,7 +13,9 @@ fun AnimeTrack.copyPersonalFrom(other: AnimeTrack): AnimeTrack { ) } -fun AnimeTrack.toDbTrack(): DbAnimeTrack = eu.kanade.tachiyomi.data.database.models.anime.AnimeTrack.create(syncId).also { +fun AnimeTrack.toDbTrack(): DbAnimeTrack = eu.kanade.tachiyomi.data.database.models.anime.AnimeTrack.create( + syncId +).also { it.id = id it.anime_id = animeId it.media_id = remoteId diff --git a/app/src/main/java/eu/kanade/domain/track/anime/service/DelayedAnimeTrackingUpdateJob.kt b/app/src/main/java/eu/kanade/domain/track/anime/service/DelayedAnimeTrackingUpdateJob.kt index 84e627330..67d96bc0b 100644 --- a/app/src/main/java/eu/kanade/domain/track/anime/service/DelayedAnimeTrackingUpdateJob.kt +++ b/app/src/main/java/eu/kanade/domain/track/anime/service/DelayedAnimeTrackingUpdateJob.kt @@ -12,6 +12,8 @@ import eu.kanade.domain.track.anime.model.toDbTrack import eu.kanade.domain.track.anime.store.DelayedAnimeTrackingStore import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.util.system.workManager +import kotlin.time.Duration.Companion.minutes +import kotlin.time.toJavaDuration import logcat.LogPriority import tachiyomi.core.util.lang.withIOContext import tachiyomi.core.util.system.logcat @@ -19,8 +21,6 @@ import tachiyomi.domain.track.anime.interactor.GetAnimeTracks import tachiyomi.domain.track.anime.interactor.InsertAnimeTrack import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import kotlin.time.Duration.Companion.minutes -import kotlin.time.toJavaDuration class DelayedAnimeTrackingUpdateJob(context: Context, workerParams: WorkerParameters) : CoroutineWorker(context, workerParams) { diff --git a/app/src/main/java/eu/kanade/domain/track/manga/model/MangaTrack.kt b/app/src/main/java/eu/kanade/domain/track/manga/model/MangaTrack.kt index c488dc954..2e8e821fa 100644 --- a/app/src/main/java/eu/kanade/domain/track/manga/model/MangaTrack.kt +++ b/app/src/main/java/eu/kanade/domain/track/manga/model/MangaTrack.kt @@ -1,7 +1,7 @@ package eu.kanade.domain.track.manga.model -import tachiyomi.domain.track.manga.model.MangaTrack import eu.kanade.tachiyomi.data.database.models.manga.MangaTrack as DbMangaTrack +import tachiyomi.domain.track.manga.model.MangaTrack fun MangaTrack.copyPersonalFrom(other: MangaTrack): MangaTrack { return this.copy( @@ -13,7 +13,9 @@ fun MangaTrack.copyPersonalFrom(other: MangaTrack): MangaTrack { ) } -fun MangaTrack.toDbTrack(): DbMangaTrack = eu.kanade.tachiyomi.data.database.models.manga.MangaTrack.create(syncId).also { +fun MangaTrack.toDbTrack(): DbMangaTrack = eu.kanade.tachiyomi.data.database.models.manga.MangaTrack.create( + syncId +).also { it.id = id it.manga_id = mangaId it.media_id = remoteId diff --git a/app/src/main/java/eu/kanade/domain/track/manga/service/DelayedMangaTrackingUpdateJob.kt b/app/src/main/java/eu/kanade/domain/track/manga/service/DelayedMangaTrackingUpdateJob.kt index 153cd2acd..95fccb1fa 100644 --- a/app/src/main/java/eu/kanade/domain/track/manga/service/DelayedMangaTrackingUpdateJob.kt +++ b/app/src/main/java/eu/kanade/domain/track/manga/service/DelayedMangaTrackingUpdateJob.kt @@ -12,6 +12,8 @@ import eu.kanade.domain.track.manga.model.toDbTrack import eu.kanade.domain.track.manga.store.DelayedMangaTrackingStore import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.util.system.workManager +import kotlin.time.Duration.Companion.minutes +import kotlin.time.toJavaDuration import logcat.LogPriority import tachiyomi.core.util.lang.withIOContext import tachiyomi.core.util.system.logcat @@ -19,8 +21,6 @@ import tachiyomi.domain.track.manga.interactor.GetMangaTracks import tachiyomi.domain.track.manga.interactor.InsertMangaTrack import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import kotlin.time.Duration.Companion.minutes -import kotlin.time.toJavaDuration class DelayedMangaTrackingUpdateJob(context: Context, workerParams: WorkerParameters) : CoroutineWorker(context, workerParams) { diff --git a/app/src/main/java/eu/kanade/domain/track/service/TrackPreferences.kt b/app/src/main/java/eu/kanade/domain/track/service/TrackPreferences.kt index 1c320773d..70983bb74 100644 --- a/app/src/main/java/eu/kanade/domain/track/service/TrackPreferences.kt +++ b/app/src/main/java/eu/kanade/domain/track/service/TrackPreferences.kt @@ -25,7 +25,10 @@ class TrackPreferences( fun trackOnAddingToLibrary() = preferenceStore.getBoolean("track_on_adding_to_library", true) - fun showNextEpisodeAiringTime() = preferenceStore.getBoolean("show_next_episode_airing_time", true) + fun showNextEpisodeAiringTime() = preferenceStore.getBoolean( + "show_next_episode_airing_time", + true + ) companion object { fun trackUsername(syncId: Long) = "pref_mangasync_username_$syncId" 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 5de3e963a..b6d71c088 100644 --- a/app/src/main/java/eu/kanade/domain/ui/UiPreferences.kt +++ b/app/src/main/java/eu/kanade/domain/ui/UiPreferences.kt @@ -6,11 +6,11 @@ import eu.kanade.domain.ui.model.TabletUiMode import eu.kanade.domain.ui.model.ThemeMode import eu.kanade.tachiyomi.util.system.DeviceUtil import eu.kanade.tachiyomi.util.system.isDynamicColorAvailable -import tachiyomi.core.preference.PreferenceStore -import tachiyomi.core.preference.getEnum import java.text.DateFormat import java.text.SimpleDateFormat import java.util.Locale +import tachiyomi.core.preference.PreferenceStore +import tachiyomi.core.preference.getEnum class UiPreferences( private val preferenceStore: PreferenceStore, diff --git a/app/src/main/java/eu/kanade/presentation/browse/BaseBrowseItem.kt b/app/src/main/java/eu/kanade/presentation/browse/BaseBrowseItem.kt index 795b418a5..3f5e0cfa5 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/BaseBrowseItem.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/BaseBrowseItem.kt @@ -25,7 +25,10 @@ fun BaseBrowseItem( onClick = onClickItem, onLongClick = onLongClickItem, ) - .padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small), + .padding( + horizontal = MaterialTheme.padding.medium, + vertical = MaterialTheme.padding.small + ), verticalAlignment = Alignment.CenterVertically, ) { icon() diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionDetailsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionDetailsScreen.kt index 8446cbc2e..fef1357f6 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionDetailsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionDetailsScreen.kt @@ -236,7 +236,9 @@ private fun DetailsHeader( textAlign = TextAlign.Center, ) - val strippedPkgName = extension.pkgName.substringAfter("eu.kanade.tachiyomi.animeextension.") + val strippedPkgName = extension.pkgName.substringAfter( + "eu.kanade.tachiyomi.animeextension." + ) Text( text = strippedPkgName, diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt index 34ee8ed49..044e587b1 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt @@ -295,7 +295,10 @@ private fun AnimeExtensionItemContent( ProvideTextStyle(value = MaterialTheme.typography.bodySmall) { if (extension is AnimeExtension.Installed && extension.lang.isNotEmpty()) { Text( - text = LocaleHelper.getSourceDisplayName(extension.lang, LocalContext.current), + text = LocaleHelper.getSourceDisplayName( + extension.lang, + LocalContext.current + ), ) } diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesScreen.kt index 2e1f8a705..235b5ebc3 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesScreen.kt @@ -101,7 +101,10 @@ private fun AnimeSourceHeader( Text( text = LocaleHelper.getSourceDisplayName(language, context), modifier = modifier - .padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small), + .padding( + horizontal = MaterialTheme.padding.medium, + vertical = MaterialTheme.padding.small + ), style = MaterialTheme.typography.header, ) } @@ -144,7 +147,13 @@ private fun AnimeSourcePinButton( onClick: () -> Unit, ) { val icon = if (isPinned) Icons.Filled.PushPin else Icons.Outlined.PushPin - val tint = if (isPinned) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onBackground.copy(alpha = SecondaryItemAlpha) + val tint = if (isPinned) { + MaterialTheme.colorScheme.primary + } else { + MaterialTheme.colorScheme.onBackground.copy( + alpha = SecondaryItemAlpha + ) + } val description = if (isPinned) R.string.action_unpin else R.string.action_pin IconButton(onClick = onClick) { Icon( diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeSourceScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeSourceScreen.kt index 5bd1c8a67..0340cf99a 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeSourceScreen.kt @@ -102,14 +102,26 @@ private fun MigrateAnimeSourceList( IconButton(onClick = onToggleSortingMode) { when (sortingMode) { - SetMigrateSorting.Mode.ALPHABETICAL -> Icon(Icons.Outlined.SortByAlpha, contentDescription = stringResource(R.string.action_sort_alpha)) - SetMigrateSorting.Mode.TOTAL -> Icon(Icons.Outlined.Numbers, contentDescription = stringResource(R.string.action_sort_count)) + SetMigrateSorting.Mode.ALPHABETICAL -> Icon( + Icons.Outlined.SortByAlpha, + contentDescription = stringResource(R.string.action_sort_alpha) + ) + SetMigrateSorting.Mode.TOTAL -> Icon( + Icons.Outlined.Numbers, + contentDescription = stringResource(R.string.action_sort_count) + ) } } IconButton(onClick = onToggleSortingDirection) { when (sortingDirection) { - SetMigrateSorting.Direction.ASCENDING -> Icon(Icons.Outlined.ArrowUpward, contentDescription = stringResource(R.string.action_asc)) - SetMigrateSorting.Direction.DESCENDING -> Icon(Icons.Outlined.ArrowDownward, contentDescription = stringResource(R.string.action_desc)) + SetMigrateSorting.Direction.ASCENDING -> Icon( + Icons.Outlined.ArrowUpward, + contentDescription = stringResource(R.string.action_asc) + ) + SetMigrateSorting.Direction.DESCENDING -> Icon( + Icons.Outlined.ArrowDownward, + contentDescription = stringResource(R.string.action_desc) + ) } } } diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/components/BrowseAnimeIcons.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/components/BrowseAnimeIcons.kt index af457964d..87bca92c5 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/components/BrowseAnimeIcons.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/components/BrowseAnimeIcons.kt @@ -127,7 +127,10 @@ private fun AnimeExtension.getIcon(density: Int = DisplayMetrics.DENSITY_DEFAULT return produceState>(initialValue = Result.Loading, this) { withIOContext { value = try { - val appInfo = AnimeExtensionLoader.getAnimeExtensionPackageInfoFromPkgName(context, pkgName)!!.applicationInfo + val appInfo = AnimeExtensionLoader.getAnimeExtensionPackageInfoFromPkgName( + context, + pkgName + )!!.applicationInfo val appResources = context.packageManager.getResourcesForApplication(appInfo) Result.Success( appResources.getDrawableForDensity(appInfo.icon, density, null)!! diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt index dd33b6d21..2625b33bd 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt @@ -296,7 +296,10 @@ private fun ExtensionItemContent( ProvideTextStyle(value = MaterialTheme.typography.bodySmall) { if (extension is MangaExtension.Installed && extension.lang.isNotEmpty()) { Text( - text = LocaleHelper.getSourceDisplayName(extension.lang, LocalContext.current), + text = LocaleHelper.getSourceDisplayName( + extension.lang, + LocalContext.current + ), ) } diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt index 60d75aac8..18befa6ef 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt @@ -101,7 +101,10 @@ private fun SourceHeader( Text( text = LocaleHelper.getSourceDisplayName(language, context), modifier = modifier - .padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small), + .padding( + horizontal = MaterialTheme.padding.medium, + vertical = MaterialTheme.padding.small + ), style = MaterialTheme.typography.header, ) } @@ -144,7 +147,13 @@ private fun SourcePinButton( onClick: () -> Unit, ) { val icon = if (isPinned) Icons.Filled.PushPin else Icons.Outlined.PushPin - val tint = if (isPinned) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onBackground.copy(alpha = SecondaryItemAlpha) + val tint = if (isPinned) { + MaterialTheme.colorScheme.primary + } else { + MaterialTheme.colorScheme.onBackground.copy( + alpha = SecondaryItemAlpha + ) + } val description = if (isPinned) R.string.action_unpin else R.string.action_pin IconButton(onClick = onClick) { Icon( diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaSourceScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaSourceScreen.kt index 7d91678d1..e41ef56c3 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaSourceScreen.kt @@ -102,14 +102,26 @@ private fun MigrateSourceList( IconButton(onClick = onToggleSortingMode) { when (sortingMode) { - SetMigrateSorting.Mode.ALPHABETICAL -> Icon(Icons.Outlined.SortByAlpha, contentDescription = stringResource(R.string.action_sort_alpha)) - SetMigrateSorting.Mode.TOTAL -> Icon(Icons.Outlined.Numbers, contentDescription = stringResource(R.string.action_sort_count)) + SetMigrateSorting.Mode.ALPHABETICAL -> Icon( + Icons.Outlined.SortByAlpha, + contentDescription = stringResource(R.string.action_sort_alpha) + ) + SetMigrateSorting.Mode.TOTAL -> Icon( + Icons.Outlined.Numbers, + contentDescription = stringResource(R.string.action_sort_count) + ) } } IconButton(onClick = onToggleSortingDirection) { when (sortingDirection) { - SetMigrateSorting.Direction.ASCENDING -> Icon(Icons.Outlined.ArrowUpward, contentDescription = stringResource(R.string.action_asc)) - SetMigrateSorting.Direction.DESCENDING -> Icon(Icons.Outlined.ArrowDownward, contentDescription = stringResource(R.string.action_desc)) + SetMigrateSorting.Direction.ASCENDING -> Icon( + Icons.Outlined.ArrowUpward, + contentDescription = stringResource(R.string.action_asc) + ) + SetMigrateSorting.Direction.DESCENDING -> Icon( + Icons.Outlined.ArrowDownward, + contentDescription = stringResource(R.string.action_desc) + ) } } } diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/components/BrowseMangaIcons.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/components/BrowseMangaIcons.kt index fe163fd23..630caffba 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/components/BrowseMangaIcons.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/components/BrowseMangaIcons.kt @@ -127,7 +127,10 @@ private fun MangaExtension.getIcon(density: Int = DisplayMetrics.DENSITY_DEFAULT return produceState>(initialValue = Result.Loading, this) { withIOContext { value = try { - val appInfo = MangaExtensionLoader.getMangaExtensionPackageInfoFromPkgName(context, pkgName)!!.applicationInfo + val appInfo = MangaExtensionLoader.getMangaExtensionPackageInfoFromPkgName( + context, + pkgName + )!!.applicationInfo val appResources = context.packageManager.getResourcesForApplication(appInfo) Result.Success( appResources.getDrawableForDensity(appInfo.icon, density, null)!! diff --git a/app/src/main/java/eu/kanade/presentation/category/AnimeCategoryScreen.kt b/app/src/main/java/eu/kanade/presentation/category/AnimeCategoryScreen.kt index c92e0ac57..7ff264b67 100644 --- a/app/src/main/java/eu/kanade/presentation/category/AnimeCategoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/category/AnimeCategoryScreen.kt @@ -48,7 +48,9 @@ fun AnimeCategoryScreen( CategoryContent( categories = state.categories, lazyListState = lazyListState, - paddingValues = contentPadding + topSmallPaddingValues + PaddingValues(horizontal = MaterialTheme.padding.medium), + paddingValues = contentPadding + topSmallPaddingValues + PaddingValues( + horizontal = MaterialTheme.padding.medium + ), onClickRename = onClickRename, onClickHide = onClickHide, onClickDelete = onClickDelete, diff --git a/app/src/main/java/eu/kanade/presentation/category/MangaCategoryScreen.kt b/app/src/main/java/eu/kanade/presentation/category/MangaCategoryScreen.kt index 3945d7198..64c6f26c6 100644 --- a/app/src/main/java/eu/kanade/presentation/category/MangaCategoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/category/MangaCategoryScreen.kt @@ -48,7 +48,9 @@ fun MangaCategoryScreen( CategoryContent( categories = state.categories, lazyListState = lazyListState, - paddingValues = contentPadding + topSmallPaddingValues + PaddingValues(horizontal = MaterialTheme.padding.medium), + paddingValues = contentPadding + topSmallPaddingValues + PaddingValues( + horizontal = MaterialTheme.padding.medium + ), onClickRename = onClickRename, onClickHide = onClickHide, onClickDelete = onClickDelete, diff --git a/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt b/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt index c7c7c4faa..779fa844f 100644 --- a/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt +++ b/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt @@ -15,9 +15,9 @@ import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.res.stringResource import eu.kanade.tachiyomi.R +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import tachiyomi.domain.category.model.Category -import kotlin.time.Duration.Companion.seconds @Composable fun CategoryCreateDialog( diff --git a/app/src/main/java/eu/kanade/presentation/components/AppBar.kt b/app/src/main/java/eu/kanade/presentation/components/AppBar.kt index 565b92635..51d66b580 100644 --- a/app/src/main/java/eu/kanade/presentation/components/AppBar.kt +++ b/app/src/main/java/eu/kanade/presentation/components/AppBar.kt @@ -234,7 +234,9 @@ fun AppBarActions( ) { Icon( Icons.Outlined.MoreVert, - contentDescription = stringResource(R.string.abc_action_menu_overflow_description), + contentDescription = stringResource( + R.string.abc_action_menu_overflow_description + ), ) } } @@ -325,7 +327,9 @@ fun SearchToolbar( placeholder = { Text( modifier = Modifier.secondaryItemAlpha(), - text = (placeholderText ?: stringResource(R.string.action_search_hint)), + text = (placeholderText ?: stringResource( + R.string.action_search_hint + )), maxLines = 1, overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.titleMedium.copy( diff --git a/app/src/main/java/eu/kanade/presentation/components/DropdownMenu.kt b/app/src/main/java/eu/kanade/presentation/components/DropdownMenu.kt index 69d7f5682..89fda1ee1 100644 --- a/app/src/main/java/eu/kanade/presentation/components/DropdownMenu.kt +++ b/app/src/main/java/eu/kanade/presentation/components/DropdownMenu.kt @@ -7,6 +7,7 @@ import androidx.compose.material.icons.outlined.ArrowLeft import androidx.compose.material.icons.outlined.ArrowRight import androidx.compose.material.icons.outlined.RadioButtonChecked import androidx.compose.material.icons.outlined.RadioButtonUnchecked +import androidx.compose.material3.DropdownMenu as ComposeDropdownMenu import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -23,7 +24,6 @@ import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import androidx.compose.ui.window.PopupProperties import eu.kanade.tachiyomi.R -import androidx.compose.material3.DropdownMenu as ComposeDropdownMenu @Composable fun DropdownMenu( diff --git a/app/src/main/java/eu/kanade/presentation/components/RelativeDateHeader.kt b/app/src/main/java/eu/kanade/presentation/components/RelativeDateHeader.kt index 89bb61b4f..2a962f86a 100644 --- a/app/src/main/java/eu/kanade/presentation/components/RelativeDateHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/components/RelativeDateHeader.kt @@ -5,9 +5,9 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import eu.kanade.tachiyomi.util.lang.toRelativeString -import tachiyomi.presentation.core.components.ListGroupHeader import java.text.DateFormat import java.util.Date +import tachiyomi.presentation.core.components.ListGroupHeader @Composable fun RelativeDateHeader( 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 3b070402f..1ce514b7b 100644 --- a/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt @@ -63,7 +63,10 @@ fun TabbedDialog( TabRow( modifier = Modifier.weight(1f), selectedTabIndex = pagerState.currentPage, - indicator = { TabIndicator(it[pagerState.currentPage], pagerState.currentPageOffsetFraction) }, + indicator = { TabIndicator( + it[pagerState.currentPage], + pagerState.currentPageOffsetFraction + ) }, divider = {}, ) { tabTitles.fastForEachIndexed { i, tab -> diff --git a/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt b/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt index 48e5123de..44361ef0e 100644 --- a/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt @@ -98,7 +98,10 @@ fun TabbedScreen( Tab( selected = state.currentPage == index, onClick = { scope.launch { state.animateScrollToPage(index) } }, - text = { TabText(text = stringResource(tab.titleRes), badgeCount = tab.badgeNumber) }, + text = { TabText( + text = stringResource(tab.titleRes), + badgeCount = tab.badgeNumber + ) }, unselectedContentColor = MaterialTheme.colorScheme.onSurface, ) } diff --git a/app/src/main/java/eu/kanade/presentation/crash/CrashScreen.kt b/app/src/main/java/eu/kanade/presentation/crash/CrashScreen.kt index 3ed6d15fc..40ef54c40 100644 --- a/app/src/main/java/eu/kanade/presentation/crash/CrashScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/crash/CrashScreen.kt @@ -33,7 +33,10 @@ fun CrashScreen( InfoScreen( icon = Icons.Outlined.BugReport, headingText = stringResource(R.string.crash_screen_title), - subtitleText = stringResource(R.string.crash_screen_description, stringResource(R.string.app_name)), + subtitleText = stringResource( + R.string.crash_screen_description, + stringResource(R.string.app_name) + ), acceptText = stringResource(R.string.pref_dump_crash_logs), onAcceptClick = { scope.launch { diff --git a/app/src/main/java/eu/kanade/presentation/entries/EntryBottomActionMenu.kt b/app/src/main/java/eu/kanade/presentation/entries/EntryBottomActionMenu.kt index 657026781..efe567320 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/EntryBottomActionMenu.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/EntryBottomActionMenu.kt @@ -56,13 +56,13 @@ import androidx.compose.ui.unit.dp import eu.kanade.presentation.components.EntryDownloadDropdownMenu import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.player.settings.PlayerPreferences +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import kotlin.time.Duration.Companion.seconds @Composable fun EntryBottomActionMenu( @@ -88,7 +88,10 @@ fun EntryBottomActionMenu( val playerPreferences: PlayerPreferences = Injekt.get() Surface( modifier = modifier, - shape = MaterialTheme.shapes.large.copy(bottomEnd = ZeroCornerSize, bottomStart = ZeroCornerSize), + shape = MaterialTheme.shapes.large.copy( + bottomEnd = ZeroCornerSize, + bottomStart = ZeroCornerSize + ), tonalElevation = 3.dp, ) { val haptic = LocalHapticFeedback.current @@ -265,7 +268,10 @@ fun LibraryBottomActionMenu( val scope = rememberCoroutineScope() Surface( modifier = modifier, - shape = MaterialTheme.shapes.large.copy(bottomEnd = ZeroCornerSize, bottomStart = ZeroCornerSize), + shape = MaterialTheme.shapes.large.copy( + bottomEnd = ZeroCornerSize, + bottomStart = ZeroCornerSize + ), tonalElevation = 3.dp, ) { val haptic = LocalHapticFeedback.current diff --git a/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt b/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt index e8f402e47..94a575939 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt @@ -76,6 +76,9 @@ import eu.kanade.tachiyomi.ui.entries.anime.AnimeScreenModel import eu.kanade.tachiyomi.ui.entries.anime.EpisodeItem import eu.kanade.tachiyomi.util.lang.toRelativeString import eu.kanade.tachiyomi.util.system.copyToClipboard +import java.text.DateFormat +import java.util.Date +import java.util.concurrent.TimeUnit import kotlinx.coroutines.delay import tachiyomi.domain.entries.anime.model.Anime import tachiyomi.domain.items.episode.model.Episode @@ -89,9 +92,6 @@ import tachiyomi.presentation.core.components.material.PullRefresh import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.util.isScrolledToEnd import tachiyomi.presentation.core.util.isScrollingUp -import java.text.DateFormat -import java.util.Date -import java.util.concurrent.TimeUnit @Composable fun AnimeScreen( @@ -651,7 +651,10 @@ fun AnimeScreenLargeImpl( } Text(text = stringResource(id)) }, - icon = { Icon(imageVector = Icons.Filled.PlayArrow, contentDescription = null) }, + icon = { Icon( + imageVector = Icons.Filled.PlayArrow, + contentDescription = null + ) }, onClick = onContinueWatching, expanded = episodeListState.isScrollingUp() || episodeListState.isScrolledToEnd(), ) @@ -883,7 +886,12 @@ private fun LazyListScope.sharedEpisodeItems( onEpisodeItemClick( episodeItem = episodeItem, episodes = episodes, - onToggleSelection = { onEpisodeSelected(episodeItem, !episodeItem.selected, true, false) }, + onToggleSelection = { onEpisodeSelected( + episodeItem, + !episodeItem.selected, + true, + false + ) }, onEpisodeClicked = onEpisodeClicked, ) }, diff --git a/app/src/main/java/eu/kanade/presentation/entries/anime/EpisodeOptionsDialogScreen.kt b/app/src/main/java/eu/kanade/presentation/entries/anime/EpisodeOptionsDialogScreen.kt index 8ea702c0f..78e94a6b3 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/anime/EpisodeOptionsDialogScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/anime/EpisodeOptionsDialogScreen.kt @@ -231,7 +231,13 @@ private fun VideoList( ) val downloadEpisode: (Boolean) -> Unit = { - downloadManager.downloadEpisodes(anime, listOf(episode), true, it, selectedVideo) + downloadManager.downloadEpisodes( + anime, + listOf(episode), + true, + it, + selectedVideo + ) } QualityOptions( @@ -243,7 +249,13 @@ private fun VideoList( }, onExtPlayerClicked = { scope.launch { - MainActivity.startPlayerActivity(context, anime.id, episode.id, true, selectedVideo) + MainActivity.startPlayerActivity( + context, + anime.id, + episode.id, + true, + selectedVideo + ) } }, ) diff --git a/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeCoverDialog.kt b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeCoverDialog.kt index 9f56d92e4..547977117 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeCoverDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeCoverDialog.kt @@ -122,7 +122,9 @@ fun AnimeCoverDialog( ) { Icon( imageVector = Icons.Outlined.Edit, - contentDescription = stringResource(R.string.action_edit_cover), + contentDescription = stringResource( + R.string.action_edit_cover + ), ) } DropdownMenu( diff --git a/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeEpisodeListItem.kt b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeEpisodeListItem.kt index 5d61aff94..794a5cac7 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeEpisodeListItem.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeEpisodeListItem.kt @@ -51,13 +51,13 @@ import androidx.compose.ui.unit.sp import eu.kanade.presentation.entries.DotSeparatorText import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.anime.model.AnimeDownload +import kotlin.math.absoluteValue import me.saket.swipe.SwipeableActionsBox import me.saket.swipe.rememberSwipeableActionsState import tachiyomi.domain.library.service.LibraryPreferences import tachiyomi.presentation.core.components.material.ReadItemAlpha import tachiyomi.presentation.core.components.material.SecondaryItemAlpha import tachiyomi.presentation.core.util.selectedBackground -import kotlin.math.absoluteValue @Composable fun AnimeEpisodeListItem( @@ -156,9 +156,13 @@ fun AnimeEpisodeListItem( if (bookmark) { Icon( imageVector = Icons.Filled.Bookmark, - contentDescription = stringResource(R.string.action_filter_bookmarked), + contentDescription = stringResource( + R.string.action_filter_bookmarked + ), modifier = Modifier - .sizeIn(maxHeight = with(LocalDensity.current) { textHeight.toDp() - 2.dp }), + .sizeIn( + maxHeight = with(LocalDensity.current) { textHeight.toDp() - 2.dp } + ), tint = MaterialTheme.colorScheme.primary, ) } diff --git a/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeInfoHeader.kt b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeInfoHeader.kt index de4deaf63..79be9a9fb 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeInfoHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeInfoHeader.kt @@ -81,13 +81,13 @@ import eu.kanade.presentation.entries.ItemCover import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.animesource.model.SAnime import eu.kanade.tachiyomi.util.system.copyToClipboard +import kotlin.math.absoluteValue +import kotlin.math.roundToInt import tachiyomi.domain.entries.anime.model.Anime import tachiyomi.presentation.core.components.material.TextButton import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.util.clickableNoIndication import tachiyomi.presentation.core.util.secondaryItemAlpha -import kotlin.math.absoluteValue -import kotlin.math.roundToInt private val whitespaceLineRegex = Regex("[\\r\\n]{2,}", setOf(RegexOption.MULTILINE)) @@ -193,7 +193,11 @@ fun AnimeActionRow( ) if (onEditIntervalClicked != null && fetchInterval != null) { AnimeActionButton( - title = pluralStringResource(id = R.plurals.day, count = fetchInterval.absoluteValue, fetchInterval.absoluteValue), + title = pluralStringResource( + id = R.plurals.day, + count = fetchInterval.absoluteValue, + fetchInterval.absoluteValue + ), icon = Icons.Default.HourglassEmpty, color = if (isUserIntervalMode) MaterialTheme.colorScheme.primary else defaultActionButtonColor, onClick = onEditIntervalClicked, @@ -204,7 +208,11 @@ fun AnimeActionRow( title = if (trackingCount == 0) { stringResource(R.string.manga_tracking_tab) } else { - pluralStringResource(id = R.plurals.num_trackers, count = trackingCount, trackingCount) + pluralStringResource( + id = R.plurals.num_trackers, + count = trackingCount, + trackingCount + ) }, icon = if (trackingCount == 0) Icons.Outlined.Sync else Icons.Outlined.Done, color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary, @@ -237,7 +245,9 @@ fun ExpandableAnimeDescription( mutableStateOf(defaultExpandState) } val desc = - description.takeIf { !it.isNullOrBlank() } ?: stringResource(R.string.description_placeholder) + description.takeIf { !it.isNullOrBlank() } ?: stringResource( + R.string.description_placeholder + ) val trimmedDescription = remember(desc) { desc .replace(whitespaceLineRegex, "\n") @@ -415,7 +425,9 @@ private fun AnimeAndSourceTitlesLarge( SAnime.ONGOING.toLong() -> stringResource(R.string.ongoing) SAnime.COMPLETED.toLong() -> stringResource(R.string.completed) SAnime.LICENSED.toLong() -> stringResource(R.string.licensed) - SAnime.PUBLISHING_FINISHED.toLong() -> stringResource(R.string.publishing_finished) + SAnime.PUBLISHING_FINISHED.toLong() -> stringResource( + R.string.publishing_finished + ) SAnime.CANCELLED.toLong() -> stringResource(R.string.cancelled) SAnime.ON_HIATUS.toLong() -> stringResource(R.string.on_hiatus) else -> stringResource(R.string.unknown) @@ -548,7 +560,9 @@ private fun AnimeAndSourceTitlesSmall( SAnime.ONGOING.toLong() -> stringResource(R.string.ongoing) SAnime.COMPLETED.toLong() -> stringResource(R.string.completed) SAnime.LICENSED.toLong() -> stringResource(R.string.licensed) - SAnime.PUBLISHING_FINISHED.toLong() -> stringResource(R.string.publishing_finished) + SAnime.PUBLISHING_FINISHED.toLong() -> stringResource( + R.string.publishing_finished + ) SAnime.CANCELLED.toLong() -> stringResource(R.string.cancelled) SAnime.ON_HIATUS.toLong() -> stringResource(R.string.on_hiatus) else -> stringResource(R.string.unknown) @@ -612,7 +626,9 @@ private fun AnimeSummary( style = MaterialTheme.typography.bodyMedium, ) }.map { it.measure(constraints) } - expandedHeight = expandedPlaceable.maxByOrNull { it.height }?.height?.coerceAtLeast(shrunkHeight) ?: 0 + expandedHeight = expandedPlaceable.maxByOrNull { it.height }?.height?.coerceAtLeast( + shrunkHeight + ) ?: 0 val actualPlaceable = subcompose("description") { SelectionContainer { @@ -635,9 +651,13 @@ private fun AnimeSummary( val image = AnimatedImageVector.animatedVectorResource(R.drawable.anim_caret_down) Icon( painter = rememberAnimatedVectorPainter(image, !expanded), - contentDescription = stringResource(if (expanded) R.string.manga_info_collapse else R.string.manga_info_expand), + contentDescription = stringResource( + if (expanded) R.string.manga_info_collapse else R.string.manga_info_expand + ), tint = MaterialTheme.colorScheme.onBackground, - modifier = Modifier.background(Brush.radialGradient(colors = colors.asReversed())), + modifier = Modifier.background( + Brush.radialGradient(colors = colors.asReversed()) + ), ) } }.map { it.measure(Constraints.fixed(width = constraints.maxWidth, height = scrimHeight)) } diff --git a/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt index ec82976e7..d60222115 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt @@ -71,6 +71,8 @@ import eu.kanade.tachiyomi.ui.entries.manga.ChapterItem import eu.kanade.tachiyomi.ui.entries.manga.MangaScreenModel import eu.kanade.tachiyomi.util.lang.toRelativeString import eu.kanade.tachiyomi.util.system.copyToClipboard +import java.text.DateFormat +import java.util.Date import tachiyomi.domain.entries.manga.model.Manga import tachiyomi.domain.items.chapter.model.Chapter import tachiyomi.domain.items.service.missingItemsCount @@ -83,8 +85,6 @@ import tachiyomi.presentation.core.components.material.PullRefresh import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.util.isScrolledToEnd import tachiyomi.presentation.core.util.isScrollingUp -import java.text.DateFormat -import java.util.Date @Composable fun MangaScreen( @@ -593,7 +593,10 @@ fun MangaScreenLargeImpl( } Text(text = stringResource(id)) }, - icon = { Icon(imageVector = Icons.Filled.PlayArrow, contentDescription = null) }, + icon = { Icon( + imageVector = Icons.Filled.PlayArrow, + contentDescription = null + ) }, onClick = onContinueReading, expanded = chapterListState.isScrollingUp() || chapterListState.isScrolledToEnd(), ) @@ -791,7 +794,12 @@ private fun LazyListScope.sharedChapterItems( onChapterItemClick( chapterItem = chapterItem, chapters = chapters, - onToggleSelection = { onChapterSelected(chapterItem, !chapterItem.selected, true, false) }, + onToggleSelection = { onChapterSelected( + chapterItem, + !chapterItem.selected, + true, + false + ) }, onChapterClicked = onChapterClicked, ) }, diff --git a/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaChapterListItem.kt b/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaChapterListItem.kt index c01ae3b1c..57fcda892 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaChapterListItem.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaChapterListItem.kt @@ -50,13 +50,13 @@ import androidx.compose.ui.unit.sp import eu.kanade.presentation.entries.DotSeparatorText import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.manga.model.MangaDownload +import kotlin.math.absoluteValue import me.saket.swipe.SwipeableActionsBox import me.saket.swipe.rememberSwipeableActionsState import tachiyomi.domain.library.service.LibraryPreferences import tachiyomi.presentation.core.components.material.ReadItemAlpha import tachiyomi.presentation.core.components.material.SecondaryItemAlpha import tachiyomi.presentation.core.util.selectedBackground -import kotlin.math.absoluteValue @Composable fun MangaChapterListItem( @@ -155,9 +155,13 @@ fun MangaChapterListItem( if (bookmark) { Icon( imageVector = Icons.Filled.Bookmark, - contentDescription = stringResource(R.string.action_filter_bookmarked), + contentDescription = stringResource( + R.string.action_filter_bookmarked + ), modifier = Modifier - .sizeIn(maxHeight = with(LocalDensity.current) { textHeight.toDp() - 2.dp }), + .sizeIn( + maxHeight = with(LocalDensity.current) { textHeight.toDp() - 2.dp } + ), tint = MaterialTheme.colorScheme.primary, ) } diff --git a/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaCoverDialog.kt b/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaCoverDialog.kt index 31df9d512..45bed4f6d 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaCoverDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaCoverDialog.kt @@ -122,7 +122,9 @@ fun MangaCoverDialog( ) { Icon( imageVector = Icons.Outlined.Edit, - contentDescription = stringResource(R.string.action_edit_cover), + contentDescription = stringResource( + R.string.action_edit_cover + ), ) } DropdownMenu( diff --git a/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt b/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt index 6ac341e86..eac26d5a9 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt @@ -81,13 +81,13 @@ import eu.kanade.presentation.entries.ItemCover import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.util.system.copyToClipboard +import kotlin.math.absoluteValue +import kotlin.math.roundToInt import tachiyomi.domain.entries.manga.model.Manga import tachiyomi.presentation.core.components.material.TextButton import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.util.clickableNoIndication import tachiyomi.presentation.core.util.secondaryItemAlpha -import kotlin.math.absoluteValue -import kotlin.math.roundToInt private val whitespaceLineRegex = Regex("[\\r\\n]{2,}", setOf(RegexOption.MULTILINE)) @@ -193,7 +193,11 @@ fun MangaActionRow( ) if (onEditIntervalClicked != null && fetchInterval != null) { MangaActionButton( - title = pluralStringResource(id = R.plurals.day, count = fetchInterval.absoluteValue, fetchInterval.absoluteValue), + title = pluralStringResource( + id = R.plurals.day, + count = fetchInterval.absoluteValue, + fetchInterval.absoluteValue + ), icon = Icons.Default.HourglassEmpty, color = if (isUserIntervalMode) MaterialTheme.colorScheme.primary else defaultActionButtonColor, onClick = onEditIntervalClicked, @@ -204,7 +208,11 @@ fun MangaActionRow( title = if (trackingCount == 0) { stringResource(R.string.manga_tracking_tab) } else { - pluralStringResource(id = R.plurals.num_trackers, count = trackingCount, trackingCount) + pluralStringResource( + id = R.plurals.num_trackers, + count = trackingCount, + trackingCount + ) }, icon = if (trackingCount == 0) Icons.Outlined.Sync else Icons.Outlined.Done, color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary, @@ -237,7 +245,9 @@ fun ExpandableMangaDescription( mutableStateOf(defaultExpandState) } val desc = - description.takeIf { !it.isNullOrBlank() } ?: stringResource(R.string.description_placeholder) + description.takeIf { !it.isNullOrBlank() } ?: stringResource( + R.string.description_placeholder + ) val trimmedDescription = remember(desc) { desc .replace(whitespaceLineRegex, "\n") @@ -415,7 +425,9 @@ private fun MangaAndSourceTitlesLarge( SManga.ONGOING.toLong() -> stringResource(R.string.ongoing) SManga.COMPLETED.toLong() -> stringResource(R.string.completed) SManga.LICENSED.toLong() -> stringResource(R.string.licensed) - SManga.PUBLISHING_FINISHED.toLong() -> stringResource(R.string.publishing_finished) + SManga.PUBLISHING_FINISHED.toLong() -> stringResource( + R.string.publishing_finished + ) SManga.CANCELLED.toLong() -> stringResource(R.string.cancelled) SManga.ON_HIATUS.toLong() -> stringResource(R.string.on_hiatus) else -> stringResource(R.string.unknown) @@ -548,7 +560,9 @@ private fun MangaAndSourceTitlesSmall( SManga.ONGOING.toLong() -> stringResource(R.string.ongoing) SManga.COMPLETED.toLong() -> stringResource(R.string.completed) SManga.LICENSED.toLong() -> stringResource(R.string.licensed) - SManga.PUBLISHING_FINISHED.toLong() -> stringResource(R.string.publishing_finished) + SManga.PUBLISHING_FINISHED.toLong() -> stringResource( + R.string.publishing_finished + ) SManga.CANCELLED.toLong() -> stringResource(R.string.cancelled) SManga.ON_HIATUS.toLong() -> stringResource(R.string.on_hiatus) else -> stringResource(R.string.unknown) @@ -612,7 +626,9 @@ private fun MangaSummary( style = MaterialTheme.typography.bodyMedium, ) }.map { it.measure(constraints) } - expandedHeight = expandedPlaceable.maxByOrNull { it.height }?.height?.coerceAtLeast(shrunkHeight) ?: 0 + expandedHeight = expandedPlaceable.maxByOrNull { it.height }?.height?.coerceAtLeast( + shrunkHeight + ) ?: 0 val actualPlaceable = subcompose("description") { SelectionContainer { @@ -635,9 +651,13 @@ private fun MangaSummary( val image = AnimatedImageVector.animatedVectorResource(R.drawable.anim_caret_down) Icon( painter = rememberAnimatedVectorPainter(image, !expanded), - contentDescription = stringResource(if (expanded) R.string.manga_info_collapse else R.string.manga_info_expand), + contentDescription = stringResource( + if (expanded) R.string.manga_info_collapse else R.string.manga_info_expand + ), tint = MaterialTheme.colorScheme.onBackground, - modifier = Modifier.background(Brush.radialGradient(colors = colors.asReversed())), + modifier = Modifier.background( + Brush.radialGradient(colors = colors.asReversed()) + ), ) } }.map { it.measure(Constraints.fixed(width = constraints.maxWidth, height = scrimHeight)) } diff --git a/app/src/main/java/eu/kanade/presentation/extensions/DiskUtil.kt b/app/src/main/java/eu/kanade/presentation/extensions/DiskUtil.kt index f0581e099..9ee9ad115 100644 --- a/app/src/main/java/eu/kanade/presentation/extensions/DiskUtil.kt +++ b/app/src/main/java/eu/kanade/presentation/extensions/DiskUtil.kt @@ -11,7 +11,9 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil */ @Composable fun DiskUtil.RequestStoragePermission() { - val permissionState = rememberPermissionState(permission = Manifest.permission.WRITE_EXTERNAL_STORAGE) + val permissionState = rememberPermissionState( + permission = Manifest.permission.WRITE_EXTERNAL_STORAGE + ) LaunchedEffect(Unit) { permissionState.launchPermissionRequest() } diff --git a/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryContent.kt b/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryContent.kt index e8daba532..d68179152 100644 --- a/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryContent.kt +++ b/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryContent.kt @@ -9,11 +9,11 @@ import eu.kanade.domain.ui.UiPreferences import eu.kanade.presentation.components.RelativeDateHeader import eu.kanade.presentation.history.anime.AnimeHistoryItem import eu.kanade.presentation.history.anime.AnimeHistoryUiModel +import java.text.DateFormat import tachiyomi.domain.history.anime.model.AnimeHistoryWithRelations import tachiyomi.presentation.core.components.FastScrollLazyColumn import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.text.DateFormat @Composable fun AnimeHistoryContent( diff --git a/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryItem.kt b/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryItem.kt index 0676f634b..ea45dceb6 100644 --- a/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryItem.kt +++ b/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryItem.kt @@ -41,7 +41,10 @@ fun AnimeHistoryItem( modifier = modifier .clickable(onClick = onClickResume) .height(HISTORY_ITEM_HEIGHT) - .padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small), + .padding( + horizontal = MaterialTheme.padding.medium, + vertical = MaterialTheme.padding.small + ), verticalAlignment = Alignment.CenterVertically, ) { ItemCover.Book( diff --git a/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt index e14985a7d..8c75a2228 100644 --- a/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt @@ -9,11 +9,11 @@ import androidx.compose.ui.Modifier import eu.kanade.presentation.animehistory.components.AnimeHistoryContent import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.history.anime.AnimeHistoryScreenModel +import java.util.Date import tachiyomi.domain.history.anime.model.AnimeHistoryWithRelations import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen import tachiyomi.presentation.core.screens.LoadingScreen -import java.util.Date @Composable fun AnimeHistoryScreen( @@ -47,7 +47,9 @@ fun AnimeHistoryScreen( contentPadding = contentPadding, onClickCover = { history -> onClickCover(history.animeId) }, onClickResume = { history -> onClickResume(history.animeId, history.episodeId) }, - onClickDelete = { item -> onDialogChange(AnimeHistoryScreenModel.Dialog.Delete(item)) }, + onClickDelete = { item -> onDialogChange( + AnimeHistoryScreenModel.Dialog.Delete(item) + ) }, ) } } diff --git a/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryContent.kt b/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryContent.kt index 2bf47c83a..2b0683cc9 100644 --- a/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryContent.kt +++ b/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryContent.kt @@ -7,11 +7,11 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import eu.kanade.domain.ui.UiPreferences import eu.kanade.presentation.components.RelativeDateHeader +import java.text.DateFormat import tachiyomi.domain.history.manga.model.MangaHistoryWithRelations import tachiyomi.presentation.core.components.FastScrollLazyColumn import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.text.DateFormat @Composable fun MangaHistoryContent( diff --git a/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryItem.kt b/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryItem.kt index 10d4c54aa..b73795eab 100644 --- a/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryItem.kt +++ b/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryItem.kt @@ -41,7 +41,10 @@ fun MangaHistoryItem( modifier = modifier .clickable(onClick = onClickResume) .height(HISTORY_ITEM_HEIGHT) - .padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small), + .padding( + horizontal = MaterialTheme.padding.medium, + vertical = MaterialTheme.padding.small + ), verticalAlignment = Alignment.CenterVertically, ) { ItemCover.Book( diff --git a/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt index 21c0601fb..4cfe410cc 100644 --- a/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt @@ -8,11 +8,11 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.history.manga.MangaHistoryScreenModel +import java.util.Date import tachiyomi.domain.history.manga.model.MangaHistoryWithRelations import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen import tachiyomi.presentation.core.screens.LoadingScreen -import java.util.Date @Composable fun MangaHistoryScreen( @@ -46,7 +46,9 @@ fun MangaHistoryScreen( contentPadding = contentPadding, onClickCover = { history -> onClickCover(history.mangaId) }, onClickResume = { history -> onClickResume(history.mangaId, history.chapterId) }, - onClickDelete = { item -> onDialogChange(MangaHistoryScreenModel.Dialog.Delete(item)) }, + onClickDelete = { item -> onDialogChange( + MangaHistoryScreenModel.Dialog.Delete(item) + ) }, ) } } diff --git a/app/src/main/java/eu/kanade/presentation/library/LibraryTabs.kt b/app/src/main/java/eu/kanade/presentation/library/LibraryTabs.kt index 6d7ff5bf8..47a8894bc 100644 --- a/app/src/main/java/eu/kanade/presentation/library/LibraryTabs.kt +++ b/app/src/main/java/eu/kanade/presentation/library/LibraryTabs.kt @@ -24,7 +24,10 @@ fun LibraryTabs( ScrollableTabRow( selectedTabIndex = pagerState.currentPage, edgePadding = 0.dp, - indicator = { TabIndicator(it[pagerState.currentPage], pagerState.currentPageOffsetFraction) }, + indicator = { TabIndicator( + it[pagerState.currentPage], + pagerState.currentPageOffsetFraction + ) }, // TODO: use default when width is fixed upstream // https://issuetracker.google.com/issues/242879624 divider = {}, diff --git a/app/src/main/java/eu/kanade/presentation/library/anime/AnimeLibraryContent.kt b/app/src/main/java/eu/kanade/presentation/library/anime/AnimeLibraryContent.kt index 2bd366daf..20f032957 100644 --- a/app/src/main/java/eu/kanade/presentation/library/anime/AnimeLibraryContent.kt +++ b/app/src/main/java/eu/kanade/presentation/library/anime/AnimeLibraryContent.kt @@ -18,13 +18,13 @@ import androidx.compose.ui.platform.LocalLayoutDirection import eu.kanade.core.preference.PreferenceMutableState import eu.kanade.presentation.library.LibraryTabs import eu.kanade.tachiyomi.ui.library.anime.AnimeLibraryItem +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import kotlinx.coroutines.launch import tachiyomi.domain.category.model.Category import tachiyomi.domain.library.anime.LibraryAnime import tachiyomi.domain.library.model.LibraryDisplayMode import tachiyomi.presentation.core.components.material.PullRefresh -import kotlin.time.Duration.Companion.seconds @Composable fun AnimeLibraryContent( diff --git a/app/src/main/java/eu/kanade/presentation/library/anime/AnimeLibrarySettingsDialog.kt b/app/src/main/java/eu/kanade/presentation/library/anime/AnimeLibrarySettingsDialog.kt index e22648e54..d89ee9034 100644 --- a/app/src/main/java/eu/kanade/presentation/library/anime/AnimeLibrarySettingsDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/library/anime/AnimeLibrarySettingsDialog.kt @@ -115,7 +115,9 @@ private fun ColumnScope.FilterPage( } 1 -> { val service = trackServices[0] - val filterTracker by screenModel.libraryPreferences.filterTrackedAnime(service.id.toInt()).collectAsState() + val filterTracker by screenModel.libraryPreferences.filterTrackedAnime( + service.id.toInt() + ).collectAsState() TriStateItem( label = stringResource(R.string.action_filter_tracked), state = filterTracker, @@ -125,7 +127,9 @@ private fun ColumnScope.FilterPage( else -> { HeadingItem(R.string.action_filter_tracked) trackServices.map { service -> - val filterTracker by screenModel.libraryPreferences.filterTrackedAnime(service.id.toInt()).collectAsState() + val filterTracker by screenModel.libraryPreferences.filterTrackedAnime( + service.id.toInt() + ).collectAsState() TriStateItem( label = service.name, state = filterTracker, diff --git a/app/src/main/java/eu/kanade/presentation/library/manga/MangaLibraryContent.kt b/app/src/main/java/eu/kanade/presentation/library/manga/MangaLibraryContent.kt index 98d030ffe..eb8e06308 100644 --- a/app/src/main/java/eu/kanade/presentation/library/manga/MangaLibraryContent.kt +++ b/app/src/main/java/eu/kanade/presentation/library/manga/MangaLibraryContent.kt @@ -18,13 +18,13 @@ import androidx.compose.ui.platform.LocalLayoutDirection import eu.kanade.core.preference.PreferenceMutableState import eu.kanade.presentation.library.LibraryTabs import eu.kanade.tachiyomi.ui.library.manga.MangaLibraryItem +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import kotlinx.coroutines.launch import tachiyomi.domain.category.model.Category import tachiyomi.domain.library.manga.LibraryManga import tachiyomi.domain.library.model.LibraryDisplayMode import tachiyomi.presentation.core.components.material.PullRefresh -import kotlin.time.Duration.Companion.seconds @Composable fun MangaLibraryContent( diff --git a/app/src/main/java/eu/kanade/presentation/library/manga/MangaLibrarySettingsDialog.kt b/app/src/main/java/eu/kanade/presentation/library/manga/MangaLibrarySettingsDialog.kt index 601a59af1..7cd3d14dd 100644 --- a/app/src/main/java/eu/kanade/presentation/library/manga/MangaLibrarySettingsDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/library/manga/MangaLibrarySettingsDialog.kt @@ -115,7 +115,9 @@ private fun ColumnScope.FilterPage( } 1 -> { val service = trackServices[0] - val filterTracker by screenModel.libraryPreferences.filterTrackedManga(service.id.toInt()).collectAsState() + val filterTracker by screenModel.libraryPreferences.filterTrackedManga( + service.id.toInt() + ).collectAsState() TriStateItem( label = stringResource(R.string.action_filter_tracked), state = filterTracker, @@ -125,7 +127,9 @@ private fun ColumnScope.FilterPage( else -> { HeadingItem(R.string.action_filter_tracked) trackServices.map { service -> - val filterTracker by screenModel.libraryPreferences.filterTrackedManga(service.id.toInt()).collectAsState() + val filterTracker by screenModel.libraryPreferences.filterTrackedManga( + service.id.toInt() + ).collectAsState() TriStateItem( label = service.name, state = filterTracker, diff --git a/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt b/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt index 48e903882..c965e6761 100644 --- a/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt @@ -62,14 +62,18 @@ fun MoreScreen( topBar = { Column( modifier = Modifier.windowInsetsPadding( - WindowInsets.systemBars.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal), + WindowInsets.systemBars.only( + WindowInsetsSides.Top + WindowInsetsSides.Horizontal + ), ), ) { if (isFDroid) { WarningBanner( textRes = R.string.fdroid_warning, modifier = Modifier.clickable { - uriHandler.openUri("https://aniyomi.org/help/faq/#how-do-i-migrate-from-the-f-droid-version") + uriHandler.openUri( + "https://aniyomi.org/help/faq/#how-do-i-migrate-from-the-f-droid-version" + ) }, ) } @@ -136,17 +140,21 @@ fun MoreScreen( stringResource(R.string.paused) } else { "${stringResource(R.string.paused)} • ${ - pluralStringResource( - id = R.plurals.download_queue_summary, - count = pending, - pending, - ) + pluralStringResource( + id = R.plurals.download_queue_summary, + count = pending, + pending, + ) }" } } is DownloadQueueState.Downloading -> { val pending = downloadQueueState.pending - pluralStringResource(id = R.plurals.download_queue_summary, count = pending, pending) + pluralStringResource( + id = R.plurals.download_queue_summary, + count = pending, + pending + ) } }, icon = Icons.Outlined.GetApp, diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/Preference.kt b/app/src/main/java/eu/kanade/presentation/more/settings/Preference.kt index 814730a35..475d7c398 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/Preference.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/Preference.kt @@ -73,7 +73,9 @@ sealed class Preference { val entries: Map, ) : PreferenceItem() { internal fun internalSet(newValue: Any) = pref.set(newValue as T) - internal suspend fun internalOnValueChanged(newValue: Any) = onValueChanged(newValue as T) + internal suspend fun internalOnValueChanged(newValue: Any) = onValueChanged( + newValue as T + ) @Composable internal fun internalSubtitleProvider(value: Any?, entries: Map) = diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceScreen.kt index 236719024..36570a815 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceScreen.kt @@ -13,9 +13,9 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.util.fastForEachIndexed import eu.kanade.presentation.more.settings.screen.SearchableSettings import eu.kanade.presentation.more.settings.widget.PreferenceGroupHeader +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import tachiyomi.presentation.core.components.ScrollbarLazyColumn -import kotlin.time.Duration.Companion.seconds /** * Preference Screen composable which contains a list of [Preference] items diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/Commons.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/Commons.kt index 641a48f35..73a8c0854 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/Commons.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/Commons.kt @@ -31,7 +31,9 @@ fun getCategoriesLabel( val includedItemsText = when { // Some selected, but not all - includedCategories.isNotEmpty() && includedCategories.size != allCategories.size -> includedCategories.joinToString { it.visualName(context) } + includedCategories.isNotEmpty() && includedCategories.size != allCategories.size -> includedCategories.joinToString { it.visualName( + context + ) } // All explicitly selected includedCategories.size == allCategories.size -> stringResource(R.string.all) allExcluded -> stringResource(R.string.none) 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 40bd9d423..887dec12a 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 @@ -62,6 +62,7 @@ import eu.kanade.tachiyomi.util.system.isShizukuInstalled import eu.kanade.tachiyomi.util.system.powerManager import eu.kanade.tachiyomi.util.system.setDefaultSettings import eu.kanade.tachiyomi.util.system.toast +import java.io.File import kotlinx.coroutines.launch import logcat.LogPriority import okhttp3.Headers @@ -73,7 +74,6 @@ import tachiyomi.domain.library.service.LibraryPreferences import tachiyomi.presentation.core.util.collectAsState import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.File object SettingsAdvancedScreen : SearchableSettings { @@ -175,7 +175,9 @@ object SettingsAdvancedScreen : SearchableSettings { } context.startActivity(intent) } catch (e: ActivityNotFoundException) { - context.toast(R.string.battery_optimization_setting_activity_not_found) + context.toast( + R.string.battery_optimization_setting_activity_not_found + ) } } else { context.toast(R.string.battery_optimization_disabled) @@ -209,13 +211,19 @@ object SettingsAdvancedScreen : SearchableSettings { preferenceItems = listOf( Preference.PreferenceItem.TextPreference( title = stringResource(R.string.pref_clear_chapter_cache), - subtitle = stringResource(R.string.used_cache_both, readableAnimeSize, readableSize), + subtitle = stringResource( + R.string.used_cache_both, + readableAnimeSize, + readableSize + ), onClick = { scope.launchNonCancellable { try { val deletedFiles = chapterCache.clear() + episodeCache.clear() withUIContext { - context.toast(context.getString(R.string.cache_deleted, deletedFiles)) + context.toast( + context.getString(R.string.cache_deleted, deletedFiles) + ) readableSizeSema++ } } catch (e: Throwable) { @@ -353,8 +361,14 @@ object SettingsAdvancedScreen : SearchableSettings { Preference.PreferenceItem.TextPreference( title = stringResource(R.string.pref_refresh_library_covers), onClick = { - MangaLibraryUpdateJob.startNow(context, target = MangaLibraryUpdateJob.Target.COVERS) - AnimeLibraryUpdateJob.startNow(context, target = AnimeLibraryUpdateJob.Target.COVERS) + MangaLibraryUpdateJob.startNow( + context, + target = MangaLibraryUpdateJob.Target.COVERS + ) + AnimeLibraryUpdateJob.startNow( + context, + target = AnimeLibraryUpdateJob.Target.COVERS + ) }, ), Preference.PreferenceItem.TextPreference( @@ -362,8 +376,14 @@ object SettingsAdvancedScreen : SearchableSettings { subtitle = stringResource(R.string.pref_refresh_library_tracking_summary), enabled = trackManager.hasLoggedServices(), onClick = { - MangaLibraryUpdateJob.startNow(context, target = MangaLibraryUpdateJob.Target.TRACKING) - AnimeLibraryUpdateJob.startNow(context, target = AnimeLibraryUpdateJob.Target.TRACKING) + MangaLibraryUpdateJob.startNow( + context, + target = MangaLibraryUpdateJob.Target.TRACKING + ) + AnimeLibraryUpdateJob.startNow( + context, + target = AnimeLibraryUpdateJob.Target.TRACKING + ) }, ), Preference.PreferenceItem.TextPreference( @@ -401,7 +421,9 @@ object SettingsAdvancedScreen : SearchableSettings { AlertDialog( onDismissRequest = dismiss, title = { Text(text = stringResource(R.string.ext_installer_shizuku)) }, - text = { Text(text = stringResource(R.string.ext_installer_shizuku_unavailable_dialog)) }, + text = { Text( + text = stringResource(R.string.ext_installer_shizuku_unavailable_dialog) + ) }, dismissButton = { TextButton(onClick = dismiss) { Text(text = stringResource(R.string.action_cancel)) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt index bed35bc53..37a860d6c 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt @@ -26,6 +26,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.home.HomeScreen import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.util.system.toast +import java.util.Date import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.merge @@ -34,7 +35,6 @@ import tachiyomi.domain.library.service.LibraryPreferences import tachiyomi.presentation.core.util.collectAsState import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.Date object SettingsAppearanceScreen : SearchableSettings { @@ -122,7 +122,9 @@ object SettingsAppearanceScreen : SearchableSettings { uiPreferences: UiPreferences, ): Preference.PreferenceGroup { val langs = remember { getLangs(context) } - var currentLanguage by remember { mutableStateOf(AppCompatDelegate.getApplicationLocales().get(0)?.toLanguageTag() ?: "") } + var currentLanguage by remember { mutableStateOf( + AppCompatDelegate.getApplicationLocales().get(0)?.toLanguageTag() ?: "" + ) } val now = remember { Date().time } LaunchedEffect(currentLanguage) { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupScreen.kt index 16f1e74a7..e81d20c8a 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupScreen.kt @@ -197,8 +197,16 @@ object SettingsBackupScreen : SearchableSettings { } } } - if (!state.isScrolledToStart()) HorizontalDivider(modifier = Modifier.align(Alignment.TopCenter)) - if (!state.isScrolledToEnd()) HorizontalDivider(modifier = Modifier.align(Alignment.BottomCenter)) + if (!state.isScrolledToStart()) { + HorizontalDivider( + modifier = Modifier.align(Alignment.TopCenter) + ) + } + if (!state.isScrolledToEnd()) { + HorizontalDivider( + modifier = Modifier.align(Alignment.BottomCenter) + ) + } } }, dismissButton = { @@ -282,7 +290,9 @@ object SettingsBackupScreen : SearchableSettings { val msg = buildString { append(stringResource(R.string.backup_restore_content_full)) if (err.sources.isNotEmpty()) { - append("\n\n").append(stringResource(R.string.backup_restore_missing_sources)) + append("\n\n").append( + stringResource(R.string.backup_restore_missing_sources) + ) err.sources.joinTo( this, separator = "\n- ", @@ -290,7 +300,9 @@ object SettingsBackupScreen : SearchableSettings { ) } if (err.trackers.isNotEmpty()) { - append("\n\n").append(stringResource(R.string.backup_restore_missing_trackers)) + append("\n\n").append( + stringResource(R.string.backup_restore_missing_trackers) + ) err.trackers.joinTo( this, separator = "\n- ", @@ -321,7 +333,10 @@ object SettingsBackupScreen : SearchableSettings { object : ActivityResultContracts.GetContent() { override fun createIntent(context: Context, input: String): Intent { val intent = super.createIntent(context, input) - return Intent.createChooser(intent, context.getString(R.string.file_select_backup)) + return Intent.createChooser( + intent, + context.getString(R.string.file_select_backup) + ) } }, ) { @@ -338,7 +353,11 @@ object SettingsBackupScreen : SearchableSettings { return@rememberLauncherForActivityResult } - error = MissingRestoreComponents(it, results.missingSources, results.missingTrackers) + error = MissingRestoreComponents( + it, + results.missingSources, + results.missingTrackers + ) } } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt index ceefbdb32..d042653e7 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt @@ -52,7 +52,9 @@ object SettingsBrowseScreen : SearchableSettings { ) }, ), - Preference.PreferenceItem.InfoPreference(stringResource(R.string.parental_controls_info)), + Preference.PreferenceItem.InfoPreference( + stringResource(R.string.parental_controls_info) + ), ), ), ) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt index 34b9ef93b..cbd3a72b7 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt @@ -24,6 +24,7 @@ import eu.kanade.presentation.category.visualName import eu.kanade.presentation.more.settings.Preference import eu.kanade.presentation.more.settings.widget.TriStateListDialog import eu.kanade.tachiyomi.R +import java.io.File import kotlinx.coroutines.runBlocking import tachiyomi.domain.category.anime.interactor.GetAnimeCategories import tachiyomi.domain.category.manga.interactor.GetMangaCategories @@ -32,7 +33,6 @@ import tachiyomi.domain.download.service.DownloadPreferences import tachiyomi.presentation.core.util.collectAsState import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.File object SettingsDownloadScreen : SearchableSettings { @@ -44,9 +44,13 @@ object SettingsDownloadScreen : SearchableSettings { @Composable override fun getPreferences(): List { val getCategories = remember { Injekt.get() } - val allCategories by getCategories.subscribe().collectAsState(initial = runBlocking { getCategories.await() }) + val allCategories by getCategories.subscribe().collectAsState( + initial = runBlocking { getCategories.await() } + ) val getAnimeCategories = remember { Injekt.get() } - val allAnimeCategories by getAnimeCategories.subscribe().collectAsState(initial = runBlocking { getAnimeCategories.await() }) + val allAnimeCategories by getAnimeCategories.subscribe().collectAsState( + initial = runBlocking { getAnimeCategories.await() } + ) val downloadPreferences = remember { Injekt.get() } val basePreferences = remember { Injekt.get() } @@ -82,7 +86,10 @@ object SettingsDownloadScreen : SearchableSettings { allAnimeCategories = allAnimeCategories, ), getDownloadAheadGroup(downloadPreferences = downloadPreferences), - getExternalDownloaderGroup(downloadPreferences = downloadPreferences, basePreferences = basePreferences), + getExternalDownloaderGroup( + downloadPreferences = downloadPreferences, + basePreferences = basePreferences + ), ) } @@ -236,8 +243,12 @@ object SettingsDownloadScreen : SearchableSettings { itemLabel = { it.visualName }, onDismissRequest = { showAnimeDialog = false }, onValueChanged = { newIncluded, newExcluded -> - downloadNewEpisodeCategoriesPref.set(newIncluded.fastMap { it.id.toString() }.toSet()) - downloadNewEpisodeCategoriesExcludePref.set(newExcluded.fastMap { it.id.toString() }.toSet()) + downloadNewEpisodeCategoriesPref.set( + newIncluded.fastMap { it.id.toString() }.toSet() + ) + downloadNewEpisodeCategoriesExcludePref.set( + newExcluded.fastMap { it.id.toString() }.toSet() + ) showAnimeDialog = false }, ) @@ -262,8 +273,12 @@ object SettingsDownloadScreen : SearchableSettings { itemLabel = { it.visualName }, onDismissRequest = { showDialog = false }, onValueChanged = { newIncluded, newExcluded -> - downloadNewChapterCategoriesPref.set(newIncluded.fastMap { it.id.toString() }.toSet()) - downloadNewChapterCategoriesExcludePref.set(newExcluded.fastMap { it.id.toString() }.toSet()) + downloadNewChapterCategoriesPref.set( + newIncluded.fastMap { it.id.toString() }.toSet() + ) + downloadNewChapterCategoriesExcludePref.set( + newExcluded.fastMap { it.id.toString() }.toSet() + ) showDialog = false }, ) @@ -318,7 +333,11 @@ object SettingsDownloadScreen : SearchableSettings { if (it == 0) { stringResource(R.string.disabled) } else { - pluralStringResource(id = R.plurals.next_unread_chapters, count = it, it) + pluralStringResource( + id = R.plurals.next_unread_chapters, + count = it, + it + ) } }, ), @@ -329,17 +348,26 @@ object SettingsDownloadScreen : SearchableSettings { if (it == 0) { stringResource(R.string.disabled) } else { - pluralStringResource(id = R.plurals.next_unseen_episodes, count = it, it) + pluralStringResource( + id = R.plurals.next_unseen_episodes, + count = it, + it + ) } }, ), - Preference.PreferenceItem.InfoPreference(stringResource(R.string.download_ahead_info)), + Preference.PreferenceItem.InfoPreference( + stringResource(R.string.download_ahead_info) + ), ), ) } @Composable - private fun getExternalDownloaderGroup(downloadPreferences: DownloadPreferences, basePreferences: BasePreferences): Preference.PreferenceGroup { + private fun getExternalDownloaderGroup( + downloadPreferences: DownloadPreferences, + basePreferences: BasePreferences + ): Preference.PreferenceGroup { val useExternalDownloader = downloadPreferences.useExternalDownloader() val externalDownloaderPreference = downloadPreferences.externalDownloaderSelection() diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt index deab75fd8..2202de7ff 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt @@ -295,10 +295,16 @@ object SettingsLibraryScreen : SearchableSettings { pref = libraryPreferences.autoUpdateItemRestrictions(), title = stringResource(R.string.pref_library_update_manga_restriction), entries = mapOf( - ENTRY_HAS_UNVIEWED to stringResource(R.string.pref_update_only_completely_read), + ENTRY_HAS_UNVIEWED to stringResource( + R.string.pref_update_only_completely_read + ), ENTRY_NON_VIEWED to stringResource(R.string.pref_update_only_started), - ENTRY_NON_COMPLETED to stringResource(R.string.pref_update_only_non_completed), - ENTRY_OUTSIDE_RELEASE_PERIOD to stringResource(R.string.pref_update_only_in_release_period), + ENTRY_NON_COMPLETED to stringResource( + R.string.pref_update_only_non_completed + ), + ENTRY_OUTSIDE_RELEASE_PERIOD to stringResource( + R.string.pref_update_only_in_release_period + ), ), ), Preference.PreferenceItem.SwitchPreference( @@ -320,20 +326,36 @@ object SettingsLibraryScreen : SearchableSettings { pref = libraryPreferences.swipeChapterStartAction(), title = stringResource(R.string.pref_chapter_swipe_start), entries = mapOf( - LibraryPreferences.ChapterSwipeAction.Disabled to stringResource(R.string.action_disable), - LibraryPreferences.ChapterSwipeAction.ToggleBookmark to stringResource(R.string.action_bookmark), - LibraryPreferences.ChapterSwipeAction.ToggleRead to stringResource(R.string.action_mark_as_read), - LibraryPreferences.ChapterSwipeAction.Download to stringResource(R.string.action_download), + LibraryPreferences.ChapterSwipeAction.Disabled to stringResource( + R.string.action_disable + ), + LibraryPreferences.ChapterSwipeAction.ToggleBookmark to stringResource( + R.string.action_bookmark + ), + LibraryPreferences.ChapterSwipeAction.ToggleRead to stringResource( + R.string.action_mark_as_read + ), + LibraryPreferences.ChapterSwipeAction.Download to stringResource( + R.string.action_download + ), ), ), Preference.PreferenceItem.ListPreference( pref = libraryPreferences.swipeChapterEndAction(), title = stringResource(R.string.pref_chapter_swipe_end), entries = mapOf( - LibraryPreferences.ChapterSwipeAction.Disabled to stringResource(R.string.action_disable), - LibraryPreferences.ChapterSwipeAction.ToggleBookmark to stringResource(R.string.action_bookmark), - LibraryPreferences.ChapterSwipeAction.ToggleRead to stringResource(R.string.action_mark_as_read), - LibraryPreferences.ChapterSwipeAction.Download to stringResource(R.string.action_download), + LibraryPreferences.ChapterSwipeAction.Disabled to stringResource( + R.string.action_disable + ), + LibraryPreferences.ChapterSwipeAction.ToggleBookmark to stringResource( + R.string.action_bookmark + ), + LibraryPreferences.ChapterSwipeAction.ToggleRead to stringResource( + R.string.action_mark_as_read + ), + LibraryPreferences.ChapterSwipeAction.Download to stringResource( + R.string.action_download + ), ), ), ), @@ -351,20 +373,36 @@ object SettingsLibraryScreen : SearchableSettings { pref = libraryPreferences.swipeEpisodeStartAction(), title = stringResource(R.string.pref_episode_swipe_start), entries = mapOf( - LibraryPreferences.EpisodeSwipeAction.Disabled to stringResource(R.string.action_disable), - LibraryPreferences.EpisodeSwipeAction.ToggleBookmark to stringResource(R.string.action_bookmark_episode), - LibraryPreferences.EpisodeSwipeAction.ToggleSeen to stringResource(R.string.action_mark_as_seen), - LibraryPreferences.EpisodeSwipeAction.Download to stringResource(R.string.action_download), + LibraryPreferences.EpisodeSwipeAction.Disabled to stringResource( + R.string.action_disable + ), + LibraryPreferences.EpisodeSwipeAction.ToggleBookmark to stringResource( + R.string.action_bookmark_episode + ), + LibraryPreferences.EpisodeSwipeAction.ToggleSeen to stringResource( + R.string.action_mark_as_seen + ), + LibraryPreferences.EpisodeSwipeAction.Download to stringResource( + R.string.action_download + ), ), ), Preference.PreferenceItem.ListPreference( pref = libraryPreferences.swipeEpisodeEndAction(), title = stringResource(R.string.pref_episode_swipe_end), entries = mapOf( - LibraryPreferences.EpisodeSwipeAction.Disabled to stringResource(R.string.action_disable), - LibraryPreferences.EpisodeSwipeAction.ToggleBookmark to stringResource(R.string.action_bookmark_episode), - LibraryPreferences.EpisodeSwipeAction.ToggleSeen to stringResource(R.string.action_mark_as_seen), - LibraryPreferences.EpisodeSwipeAction.Download to stringResource(R.string.action_download), + LibraryPreferences.EpisodeSwipeAction.Disabled to stringResource( + R.string.action_disable + ), + LibraryPreferences.EpisodeSwipeAction.ToggleBookmark to stringResource( + R.string.action_bookmark_episode + ), + LibraryPreferences.EpisodeSwipeAction.ToggleSeen to stringResource( + R.string.action_mark_as_seen + ), + LibraryPreferences.EpisodeSwipeAction.Download to stringResource( + R.string.action_download + ), ), ), ), diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt index 8aefd7fb6..9da4e530b 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt @@ -40,6 +40,7 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.core.graphics.ColorUtils +import cafe.adriel.voyager.core.screen.Screen as VoyagerScreen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.navigator.currentOrThrow @@ -52,7 +53,6 @@ import eu.kanade.presentation.util.LocalBackPress import eu.kanade.presentation.util.Screen import eu.kanade.tachiyomi.R import tachiyomi.presentation.core.components.material.Scaffold -import cafe.adriel.voyager.core.screen.Screen as VoyagerScreen object SettingsMainScreen : Screen() { @Composable @@ -146,7 +146,9 @@ object SettingsMainScreen : Screen() { .clip(RoundedCornerShape(24.dp)) .then( if (selected) { - Modifier.background(MaterialTheme.colorScheme.surfaceVariant) + Modifier.background( + MaterialTheme.colorScheme.surfaceVariant + ) } else { Modifier }, @@ -247,7 +249,9 @@ object SettingsMainScreen : Screen() { titleRes = R.string.pref_category_about, subtitleRes = 0, formatSubtitle = { - "${stringResource(R.string.app_name)} ${AboutScreen.getVersionName(withBuildDate = false)}" + "${stringResource(R.string.app_name)} ${AboutScreen.getVersionName( + withBuildDate = false + )}" }, icon = Icons.Outlined.Info, screen = AboutScreen, diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsPlayerScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsPlayerScreen.kt index 0446dc4c7..17dc4a662 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsPlayerScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsPlayerScreen.kt @@ -77,7 +77,10 @@ object SettingsPlayerScreen : SearchableSettings { getOrientationGroup(playerPreferences = playerPreferences), getSeekingGroup(playerPreferences = playerPreferences), if (deviceSupportsPip) getPipGroup(playerPreferences = playerPreferences) else null, - getExternalPlayerGroup(playerPreferences = playerPreferences, basePreferences = basePreferences), + getExternalPlayerGroup( + playerPreferences = playerPreferences, + basePreferences = basePreferences + ), ) } @@ -147,13 +150,27 @@ object SettingsPlayerScreen : SearchableSettings { pref = defaultPlayerOrientationType, title = stringResource(R.string.pref_default_player_orientation), entries = mapOf( - ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR to stringResource(R.string.rotation_free), - ActivityInfo.SCREEN_ORIENTATION_PORTRAIT to stringResource(R.string.rotation_portrait), - ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT to stringResource(R.string.rotation_reverse_portrait), - ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE to stringResource(R.string.rotation_landscape), - ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE to stringResource(R.string.rotation_reverse_landscape), - ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT to stringResource(R.string.rotation_sensor_portrait), - ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE to stringResource(R.string.rotation_sensor_landscape), + ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR to stringResource( + R.string.rotation_free + ), + ActivityInfo.SCREEN_ORIENTATION_PORTRAIT to stringResource( + R.string.rotation_portrait + ), + ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT to stringResource( + R.string.rotation_reverse_portrait + ), + ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE to stringResource( + R.string.rotation_landscape + ), + ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE to stringResource( + R.string.rotation_reverse_landscape + ), + ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT to stringResource( + R.string.rotation_sensor_portrait + ), + ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE to stringResource( + R.string.rotation_sensor_landscape + ), ), ), Preference.PreferenceItem.SwitchPreference( @@ -164,18 +181,30 @@ object SettingsPlayerScreen : SearchableSettings { pref = defaultPlayerOrientationPortrait, title = stringResource(R.string.pref_default_portrait_orientation), entries = mapOf( - ActivityInfo.SCREEN_ORIENTATION_PORTRAIT to stringResource(R.string.rotation_portrait), - ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT to stringResource(R.string.rotation_reverse_portrait), - ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT to stringResource(R.string.rotation_sensor_portrait), + ActivityInfo.SCREEN_ORIENTATION_PORTRAIT to stringResource( + R.string.rotation_portrait + ), + ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT to stringResource( + R.string.rotation_reverse_portrait + ), + ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT to stringResource( + R.string.rotation_sensor_portrait + ), ), ), Preference.PreferenceItem.ListPreference( pref = defaultPlayerOrientationLandscape, title = stringResource(R.string.pref_default_landscape_orientation), entries = mapOf( - ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE to stringResource(R.string.rotation_landscape), - ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE to stringResource(R.string.rotation_reverse_landscape), - ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE to stringResource(R.string.rotation_sensor_landscape), + ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE to stringResource( + R.string.rotation_landscape + ), + ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE to stringResource( + R.string.rotation_reverse_landscape + ), + ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE to stringResource( + R.string.rotation_sensor_landscape + ), ), ), ), @@ -309,7 +338,10 @@ object SettingsPlayerScreen : SearchableSettings { } @Composable - private fun getExternalPlayerGroup(playerPreferences: PlayerPreferences, basePreferences: BasePreferences): Preference.PreferenceGroup { + private fun getExternalPlayerGroup( + playerPreferences: PlayerPreferences, + basePreferences: BasePreferences + ): Preference.PreferenceGroup { val alwaysUseExternalPlayer = playerPreferences.alwaysUseExternalPlayer() val externalPlayerPreference = playerPreferences.externalPlayerPreference() diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt index 619e69003..9ff124efe 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt @@ -14,10 +14,10 @@ import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType import eu.kanade.tachiyomi.util.system.isReleaseBuildType +import java.text.NumberFormat import tachiyomi.presentation.core.util.collectAsState import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.text.NumberFormat object SettingsReaderScreen : SearchableSettings { @@ -176,9 +176,15 @@ object SettingsReaderScreen : SearchableSettings { title = stringResource(R.string.pref_read_with_tapping_inverted), entries = mapOf( ReaderPreferences.TappingInvertMode.NONE to stringResource(R.string.none), - ReaderPreferences.TappingInvertMode.HORIZONTAL to stringResource(R.string.tapping_inverted_horizontal), - ReaderPreferences.TappingInvertMode.VERTICAL to stringResource(R.string.tapping_inverted_vertical), - ReaderPreferences.TappingInvertMode.BOTH to stringResource(R.string.tapping_inverted_both), + ReaderPreferences.TappingInvertMode.HORIZONTAL to stringResource( + R.string.tapping_inverted_horizontal + ), + ReaderPreferences.TappingInvertMode.VERTICAL to stringResource( + R.string.tapping_inverted_vertical + ), + ReaderPreferences.TappingInvertMode.BOTH to stringResource( + R.string.tapping_inverted_both + ), ), enabled = navMode != 5, ), @@ -268,9 +274,15 @@ object SettingsReaderScreen : SearchableSettings { title = stringResource(R.string.pref_read_with_tapping_inverted), entries = mapOf( ReaderPreferences.TappingInvertMode.NONE to stringResource(R.string.none), - ReaderPreferences.TappingInvertMode.HORIZONTAL to stringResource(R.string.tapping_inverted_horizontal), - ReaderPreferences.TappingInvertMode.VERTICAL to stringResource(R.string.tapping_inverted_vertical), - ReaderPreferences.TappingInvertMode.BOTH to stringResource(R.string.tapping_inverted_both), + ReaderPreferences.TappingInvertMode.HORIZONTAL to stringResource( + R.string.tapping_inverted_horizontal + ), + ReaderPreferences.TappingInvertMode.VERTICAL to stringResource( + R.string.tapping_inverted_vertical + ), + ReaderPreferences.TappingInvertMode.BOTH to stringResource( + R.string.tapping_inverted_both + ), ), enabled = navMode != 5, ), @@ -289,10 +301,18 @@ object SettingsReaderScreen : SearchableSettings { pref = readerPreferences.readerHideThreshold(), title = stringResource(R.string.pref_hide_threshold), entries = mapOf( - ReaderPreferences.ReaderHideThreshold.HIGHEST to stringResource(R.string.pref_highest), - ReaderPreferences.ReaderHideThreshold.HIGH to stringResource(R.string.pref_high), - ReaderPreferences.ReaderHideThreshold.LOW to stringResource(R.string.pref_low), - ReaderPreferences.ReaderHideThreshold.LOWEST to stringResource(R.string.pref_lowest), + ReaderPreferences.ReaderHideThreshold.HIGHEST to stringResource( + R.string.pref_highest + ), + ReaderPreferences.ReaderHideThreshold.HIGH to stringResource( + R.string.pref_high + ), + ReaderPreferences.ReaderHideThreshold.LOW to stringResource( + R.string.pref_low + ), + ReaderPreferences.ReaderHideThreshold.LOWEST to stringResource( + R.string.pref_lowest + ), ), ), Preference.PreferenceItem.SwitchPreference( diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt index fa1b46043..d61167c1b 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt @@ -48,6 +48,7 @@ import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp +import cafe.adriel.voyager.core.screen.Screen as VoyagerScreen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow import eu.kanade.presentation.components.UpIcon @@ -57,7 +58,6 @@ import eu.kanade.tachiyomi.R import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen import tachiyomi.presentation.core.util.runOnEnterKeyPressed -import cafe.adriel.voyager.core.screen.Screen as VoyagerScreen class SettingsSearchScreen : Screen() { @Composable @@ -87,7 +87,9 @@ class SettingsSearchScreen : Screen() { focusRequester.requestFocus() } - var textFieldValue by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(TextFieldValue()) } + var textFieldValue by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf( + TextFieldValue() + ) } Scaffold( topBar = { Column { @@ -112,7 +114,9 @@ class SettingsSearchScreen : Screen() { .copy(color = MaterialTheme.colorScheme.onSurface), singleLine = true, keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search), - keyboardActions = KeyboardActions(onSearch = { focusManager.clearFocus() }), + keyboardActions = KeyboardActions( + onSearch = { focusManager.clearFocus() } + ), cursorBrush = SolidColor(MaterialTheme.colorScheme.primary), decorationBox = { if (textFieldValue.text.isEmpty()) { @@ -201,7 +205,11 @@ private fun SearchResult( SearchResultItem( route = settingsData.route, title = p.title, - breadcrumbs = getLocalizedBreadcrumb(path = settingsData.title, node = categoryTitle, isLtr = isLtr), + breadcrumbs = getLocalizedBreadcrumb( + path = settingsData.title, + node = categoryTitle, + isLtr = isLtr + ), highlightKey = p.title, ) } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSecurityScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSecurityScreen.kt index 6dcbaa1ed..5cc4e2157 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSecurityScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSecurityScreen.kt @@ -54,7 +54,11 @@ object SettingsSecurityScreen : SearchableSettings { when (it) { -1 -> stringResource(R.string.lock_never) 0 -> stringResource(R.string.lock_always) - else -> pluralStringResource(id = R.plurals.lock_after_mins, count = it, it) + else -> pluralStringResource( + id = R.plurals.lock_after_mins, + count = it, + it + ) } }, onValueChanged = { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsTrackingScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsTrackingScreen.kt index f6a95f21c..9d041627a 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsTrackingScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsTrackingScreen.kt @@ -139,13 +139,19 @@ object SettingsTrackingScreen : SearchableSettings { Preference.PreferenceItem.TrackingPreference( title = trackManager.myAnimeList.name, service = trackManager.myAnimeList, - login = { context.openInBrowser(MyAnimeListApi.authUrl(), forceDefaultBrowser = true) }, + login = { context.openInBrowser( + MyAnimeListApi.authUrl(), + forceDefaultBrowser = true + ) }, logout = { dialog = LogoutDialog(trackManager.myAnimeList) }, ), Preference.PreferenceItem.TrackingPreference( title = trackManager.aniList.name, service = trackManager.aniList, - login = { context.openInBrowser(AnilistApi.authUrl(), forceDefaultBrowser = true) }, + login = { context.openInBrowser( + AnilistApi.authUrl(), + forceDefaultBrowser = true + ) }, logout = { dialog = LogoutDialog(trackManager.aniList) }, ), Preference.PreferenceItem.TrackingPreference( @@ -163,19 +169,28 @@ object SettingsTrackingScreen : SearchableSettings { Preference.PreferenceItem.TrackingPreference( title = trackManager.shikimori.name, service = trackManager.shikimori, - login = { context.openInBrowser(ShikimoriApi.authUrl(), forceDefaultBrowser = true) }, + login = { context.openInBrowser( + ShikimoriApi.authUrl(), + forceDefaultBrowser = true + ) }, logout = { dialog = LogoutDialog(trackManager.shikimori) }, ), Preference.PreferenceItem.TrackingPreference( title = trackManager.simkl.name, service = trackManager.simkl, - login = { context.openInBrowser(SimklApi.authUrl(), forceDefaultBrowser = true) }, + login = { context.openInBrowser( + SimklApi.authUrl(), + forceDefaultBrowser = true + ) }, logout = { dialog = LogoutDialog(trackManager.simkl) }, ), Preference.PreferenceItem.TrackingPreference( title = trackManager.bangumi.name, service = trackManager.bangumi, - login = { context.openInBrowser(BangumiApi.authUrl(), forceDefaultBrowser = true) }, + login = { context.openInBrowser( + BangumiApi.authUrl(), + forceDefaultBrowser = true + ) }, logout = { dialog = LogoutDialog(trackManager.bangumi) }, ), Preference.PreferenceItem.InfoPreference(stringResource(R.string.tracking_info)), diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/AboutScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/AboutScreen.kt index ca8401ce3..61fb17f24 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/AboutScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/AboutScreen.kt @@ -42,6 +42,10 @@ import eu.kanade.tachiyomi.util.CrashLogUtil import eu.kanade.tachiyomi.util.lang.toDateTimestampString import eu.kanade.tachiyomi.util.system.copyToClipboard import eu.kanade.tachiyomi.util.system.toast +import java.text.DateFormat +import java.text.SimpleDateFormat +import java.util.Locale +import java.util.TimeZone import kotlinx.coroutines.launch import logcat.LogPriority import tachiyomi.core.util.lang.withIOContext @@ -53,10 +57,6 @@ import tachiyomi.presentation.core.components.ScrollbarLazyColumn import tachiyomi.presentation.core.components.material.Scaffold import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.text.DateFormat -import java.text.SimpleDateFormat -import java.util.Locale -import java.util.TimeZone object AboutScreen : Screen() { @@ -147,7 +147,9 @@ object AboutScreen : Screen() { item { TextPreferenceWidget( title = stringResource(R.string.help_translate), - onPreferenceClick = { uriHandler.openUri("https://aniyomi.org/help/contribution/#translation") }, + onPreferenceClick = { uriHandler.openUri( + "https://aniyomi.org/help/contribution/#translation" + ) }, ) } @@ -209,7 +211,10 @@ object AboutScreen : Screen() { val updateChecker = AppUpdateChecker() withUIContext { try { - when (val result = withIOContext { updateChecker.checkForUpdate(context, forceCheck = true) }) { + when (val result = withIOContext { updateChecker.checkForUpdate( + context, + forceCheck = true + ) }) { is GetApplicationRelease.Result.NewUpdate -> { onAvailableUpdate(result) } @@ -272,7 +277,9 @@ object AboutScreen : Screen() { ) outputDf.timeZone = TimeZone.getDefault() - buildTime!!.toDateTimestampString(UiPreferences.dateFormat(Injekt.get().dateFormat().get())) + buildTime!!.toDateTimestampString( + UiPreferences.dateFormat(Injekt.get().dateFormat().get()) + ) } catch (e: Exception) { BuildConfig.BUILD_TIME } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearAnimeDatabaseScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearAnimeDatabaseScreen.kt index 754639de1..66a0ccd69 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearAnimeDatabaseScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearAnimeDatabaseScreen.kt @@ -144,7 +144,9 @@ class ClearAnimeDatabaseScreen : Screen() { source = sourceWithCount.source, count = sourceWithCount.count, isSelected = s.selection.contains(sourceWithCount.id), - onClickSelect = { model.toggleSelection(sourceWithCount.source) }, + onClickSelect = { model.toggleSelection( + sourceWithCount.source + ) }, ) } } @@ -205,7 +207,9 @@ class ClearAnimeDatabaseScreen : Screen() { } } -private class ClearAnimeDatabaseScreenModel : StateScreenModel(State.Loading) { +private class ClearAnimeDatabaseScreenModel : StateScreenModel( + State.Loading +) { private val getSourcesWithNonLibraryAnime: GetAnimeSourcesWithNonLibraryAnime = Injekt.get() private val database: AnimeDatabase = Injekt.get() diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearDatabaseScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearDatabaseScreen.kt index a1c4eb57e..6534c9eee 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearDatabaseScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearDatabaseScreen.kt @@ -144,7 +144,9 @@ class ClearDatabaseScreen : Screen() { source = sourceWithCount.source, count = sourceWithCount.count, isSelected = s.selection.contains(sourceWithCount.id), - onClickSelect = { model.toggleSelection(sourceWithCount.source) }, + onClickSelect = { model.toggleSelection( + sourceWithCount.source + ) }, ) } } @@ -205,7 +207,9 @@ class ClearDatabaseScreen : Screen() { } } -private class ClearDatabaseScreenModel : StateScreenModel(State.Loading) { +private class ClearDatabaseScreenModel : StateScreenModel( + State.Loading +) { private val getSourcesWithNonLibraryManga: GetMangaSourcesWithNonLibraryManga = Injekt.get() private val database: Database = Injekt.get() 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 bc8905050..8331dc909 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 @@ -39,7 +39,9 @@ class BackupSchemaScreen : Screen() { val context = LocalContext.current val navigator = LocalNavigator.currentOrThrow - val schema = remember { ProtoBufSchemaGenerator.generateSchemaText(Backup.serializer().descriptor) } + val schema = remember { ProtoBufSchemaGenerator.generateSchemaText( + Backup.serializer().descriptor + ) } Scaffold( topBar = { 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 ff318a9b4..4296d8235 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 @@ -75,7 +75,10 @@ class WorkerInfoScreen : Screen() { title = stringResource(R.string.action_copy_to_clipboard), icon = Icons.Default.ContentCopy, onClick = { - context.copyToClipboard(title, enqueued + finished + running) + context.copyToClipboard( + title, + enqueued + finished + running + ) }, ), ), @@ -123,7 +126,13 @@ class WorkerInfoScreen : Screen() { private val workManager = context.workManager val finished = workManager - .getWorkInfosLiveData(WorkQuery.fromStates(WorkInfo.State.SUCCEEDED, WorkInfo.State.FAILED, WorkInfo.State.CANCELLED)) + .getWorkInfosLiveData( + WorkQuery.fromStates( + WorkInfo.State.SUCCEEDED, + WorkInfo.State.FAILED, + WorkInfo.State.CANCELLED + ) + ) .asFlow() .map(::constructString) .stateIn(ioCoroutineScope, SharingStarted.WhileSubscribed(), "") diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/BasePreferenceWidget.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/BasePreferenceWidget.kt index 4af36dc03..d3bb28d1d 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/BasePreferenceWidget.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/BasePreferenceWidget.kt @@ -32,8 +32,8 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import eu.kanade.presentation.more.settings.LocalPreferenceHighlighted import eu.kanade.presentation.more.settings.LocalPreferenceMinHeight -import kotlinx.coroutines.delay import kotlin.time.Duration.Companion.seconds +import kotlinx.coroutines.delay @Composable internal fun BasePreferenceWidget( diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt index 0742140f6..0d09f7d7d 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt @@ -69,8 +69,16 @@ fun ListPreferenceWidget( } } } - if (!state.isScrolledToStart()) HorizontalDivider(modifier = Modifier.align(Alignment.TopCenter)) - if (!state.isScrolledToEnd()) HorizontalDivider(modifier = Modifier.align(Alignment.BottomCenter)) + if (!state.isScrolledToStart()) { + HorizontalDivider( + modifier = Modifier.align(Alignment.TopCenter) + ) + } + if (!state.isScrolledToEnd()) { + HorizontalDivider( + modifier = Modifier.align(Alignment.BottomCenter) + ) + } } }, confirmButton = { 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 87e3d7da0..bee46c9b1 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 @@ -115,8 +115,16 @@ fun TriStateListDialog( } } - if (!listState.isScrolledToStart()) HorizontalDivider(modifier = Modifier.align(Alignment.TopCenter)) - if (!listState.isScrolledToEnd()) HorizontalDivider(modifier = Modifier.align(Alignment.BottomCenter)) + if (!listState.isScrolledToStart()) { + HorizontalDivider( + modifier = Modifier.align(Alignment.TopCenter) + ) + } + if (!listState.isScrolledToEnd()) { + HorizontalDivider( + modifier = Modifier.align(Alignment.BottomCenter) + ) + } } } }, diff --git a/app/src/main/java/eu/kanade/presentation/more/stats/AnimeStatsScreenContent.kt b/app/src/main/java/eu/kanade/presentation/more/stats/AnimeStatsScreenContent.kt index 94435ecdf..c1c79c403 100644 --- a/app/src/main/java/eu/kanade/presentation/more/stats/AnimeStatsScreenContent.kt +++ b/app/src/main/java/eu/kanade/presentation/more/stats/AnimeStatsScreenContent.kt @@ -20,10 +20,10 @@ import eu.kanade.presentation.more.stats.components.StatsSection import eu.kanade.presentation.more.stats.data.StatsData import eu.kanade.presentation.util.toDurationString import eu.kanade.tachiyomi.R -import tachiyomi.presentation.core.components.material.padding import java.util.Locale import kotlin.time.DurationUnit import kotlin.time.toDuration +import tachiyomi.presentation.core.components.material.padding @Composable fun AnimeStatsScreenContent( diff --git a/app/src/main/java/eu/kanade/presentation/more/stats/MangaStatsScreenContent.kt b/app/src/main/java/eu/kanade/presentation/more/stats/MangaStatsScreenContent.kt index 6df431aac..ca692d21e 100644 --- a/app/src/main/java/eu/kanade/presentation/more/stats/MangaStatsScreenContent.kt +++ b/app/src/main/java/eu/kanade/presentation/more/stats/MangaStatsScreenContent.kt @@ -20,10 +20,10 @@ import eu.kanade.presentation.more.stats.components.StatsSection import eu.kanade.presentation.more.stats.data.StatsData import eu.kanade.presentation.util.toDurationString import eu.kanade.tachiyomi.R -import tachiyomi.presentation.core.components.material.padding import java.util.Locale import kotlin.time.DurationUnit import kotlin.time.toDuration +import tachiyomi.presentation.core.components.material.padding @Composable fun MangaStatsScreenContent( diff --git a/app/src/main/java/eu/kanade/presentation/more/storage/StorageScreenContent.kt b/app/src/main/java/eu/kanade/presentation/more/storage/StorageScreenContent.kt index 49ed79ad2..7900be879 100644 --- a/app/src/main/java/eu/kanade/presentation/more/storage/StorageScreenContent.kt +++ b/app/src/main/java/eu/kanade/presentation/more/storage/StorageScreenContent.kt @@ -19,10 +19,10 @@ import androidx.compose.ui.tooling.preview.Devices import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import eu.kanade.presentation.util.isTabletUi +import kotlin.random.Random import tachiyomi.domain.category.model.Category import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.screens.LoadingScreen -import kotlin.random.Random @Composable fun StorageScreenContent( diff --git a/app/src/main/java/eu/kanade/presentation/reader/BottomReaderBar.kt b/app/src/main/java/eu/kanade/presentation/reader/BottomReaderBar.kt index e88692ff0..a88895938 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/BottomReaderBar.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/BottomReaderBar.kt @@ -54,7 +54,9 @@ fun BottomReaderBar( IconButton(onClick = onClickCropBorder) { Icon( - painter = painterResource(if (cropEnabled) R.drawable.ic_crop_24dp else R.drawable.ic_crop_off_24dp), + painter = painterResource( + if (cropEnabled) R.drawable.ic_crop_24dp else R.drawable.ic_crop_off_24dp + ), contentDescription = stringResource(R.string.pref_crop_borders), ) } diff --git a/app/src/main/java/eu/kanade/presentation/reader/ChapterNavigator.kt b/app/src/main/java/eu/kanade/presentation/reader/ChapterNavigator.kt index 270068e54..00d3f68ff 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/ChapterNavigator.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/ChapterNavigator.kt @@ -77,7 +77,9 @@ fun ChapterNavigator( ) { Icon( imageVector = Icons.Outlined.SkipPrevious, - contentDescription = stringResource(if (isRtl) R.string.action_next_chapter else R.string.action_previous_chapter), + contentDescription = stringResource( + if (isRtl) R.string.action_next_chapter else R.string.action_previous_chapter + ), ) } @@ -128,7 +130,9 @@ fun ChapterNavigator( ) { Icon( imageVector = Icons.Outlined.SkipNext, - contentDescription = stringResource(if (isRtl) R.string.action_previous_chapter else R.string.action_next_chapter), + contentDescription = stringResource( + if (isRtl) R.string.action_previous_chapter else R.string.action_next_chapter + ), ) } } 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 978fc3d10..1a2a1add8 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/ChapterTransition.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/ChapterTransition.kt @@ -67,7 +67,10 @@ fun ChapterTransition( bottomChapter = currChapter, bottomChapterDownloaded = currChapterDownloaded, fallbackLabel = stringResource(R.string.transition_no_previous), - chapterGap = calculateChapterGap(currChapter.toDomainChapter(), goingToChapter?.toDomainChapter()), + chapterGap = calculateChapterGap( + currChapter.toDomainChapter(), + goingToChapter?.toDomainChapter() + ), ) } is ChapterTransition.Next -> { @@ -79,7 +82,10 @@ fun ChapterTransition( bottomChapter = goingToChapter, bottomChapterDownloaded = goingToChapterDownloaded, fallbackLabel = stringResource(R.string.transition_no_next), - chapterGap = calculateChapterGap(goingToChapter?.toDomainChapter(), currChapter.toDomainChapter()), + chapterGap = calculateChapterGap( + goingToChapter?.toDomainChapter(), + currChapter.toDomainChapter() + ), ) } } @@ -193,7 +199,11 @@ private fun ChapterGapWarning( ) Text( - text = pluralStringResource(R.plurals.missing_chapters_warning, count = gapCount, gapCount), + text = pluralStringResource( + R.plurals.missing_chapters_warning, + count = gapCount, + gapCount + ), style = MaterialTheme.typography.bodyMedium, ) } @@ -312,7 +322,10 @@ private fun TransitionTextPreview() { TachiyomiTheme { Surface(modifier = Modifier.padding(48.dp)) { ChapterTransition( - transition = ChapterTransition.Next(ReaderChapter(FakeChapter), ReaderChapter(FakeChapter)), + transition = ChapterTransition.Next( + ReaderChapter(FakeChapter), + ReaderChapter(FakeChapter) + ), currChapterDownloaded = false, goingToChapterDownloaded = true, ) @@ -326,7 +339,10 @@ private fun TransitionTextLongTitlePreview() { TachiyomiTheme { Surface(modifier = Modifier.padding(48.dp)) { ChapterTransition( - transition = ChapterTransition.Next(ReaderChapter(FakeChapterLongTitle), ReaderChapter(FakeChapter)), + transition = ChapterTransition.Next( + ReaderChapter(FakeChapterLongTitle), + ReaderChapter(FakeChapter) + ), currChapterDownloaded = true, goingToChapterDownloaded = true, ) @@ -340,7 +356,10 @@ private fun TransitionTextWithGapPreview() { TachiyomiTheme { Surface(modifier = Modifier.padding(48.dp)) { ChapterTransition( - transition = ChapterTransition.Next(ReaderChapter(FakeChapter), ReaderChapter(FakeGapChapter)), + transition = ChapterTransition.Next( + ReaderChapter(FakeChapter), + ReaderChapter(FakeGapChapter) + ), currChapterDownloaded = true, goingToChapterDownloaded = false, ) diff --git a/app/src/main/java/eu/kanade/presentation/reader/OrientationModeSelectDialog.kt b/app/src/main/java/eu/kanade/presentation/reader/OrientationModeSelectDialog.kt index 480ac8b55..ff641ee25 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/OrientationModeSelectDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/OrientationModeSelectDialog.kt @@ -30,7 +30,9 @@ fun OrientationModeSelectDialog( onChange: (Int) -> Unit, ) { val manga by screenModel.mangaFlow.collectAsState() - val orientationType = remember(manga) { OrientationType.fromPreference(manga?.orientationType?.toInt()) } + val orientationType = remember(manga) { OrientationType.fromPreference( + manga?.orientationType?.toInt() + ) } AdaptiveSheet( onDismissRequest = onDismissRequest, diff --git a/app/src/main/java/eu/kanade/presentation/reader/ReadingModeSelectDialog.kt b/app/src/main/java/eu/kanade/presentation/reader/ReadingModeSelectDialog.kt index 4377ca2a4..5a47883e7 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/ReadingModeSelectDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/ReadingModeSelectDialog.kt @@ -30,7 +30,9 @@ fun ReadingModeSelectDialog( onChange: (Int) -> Unit, ) { val manga by screenModel.mangaFlow.collectAsState() - val readingMode = remember(manga) { ReadingModeType.fromPreference(manga?.readingModeType?.toInt()) } + val readingMode = remember(manga) { ReadingModeType.fromPreference( + manga?.readingModeType?.toInt() + ) } AdaptiveSheet( onDismissRequest = onDismissRequest, diff --git a/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt b/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt index 016ea7af7..2329814d2 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt @@ -17,12 +17,12 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer import eu.kanade.tachiyomi.util.system.isReleaseBuildType +import java.text.NumberFormat import tachiyomi.presentation.core.components.CheckboxItem import tachiyomi.presentation.core.components.HeadingItem import tachiyomi.presentation.core.components.SettingsChipRow import tachiyomi.presentation.core.components.SliderItem import tachiyomi.presentation.core.util.collectAsState -import java.text.NumberFormat private val readingModeOptions = ReadingModeType.entries.map { it.stringRes to it } private val orientationTypeOptions = OrientationType.entries.map { it.stringRes to it } @@ -33,7 +33,9 @@ internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel) HeadingItem(R.string.pref_category_for_this_series) val manga by screenModel.mangaFlow.collectAsState() - val readingMode = remember(manga) { ReadingModeType.fromPreference(manga?.readingModeType?.toInt()) } + val readingMode = remember(manga) { ReadingModeType.fromPreference( + manga?.readingModeType?.toInt() + ) } SettingsChipRow(R.string.pref_category_reading_mode) { readingModeOptions.map { (stringRes, it) -> FilterChip( @@ -44,7 +46,9 @@ internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel) } } - val orientationType = remember(manga) { OrientationType.fromPreference(manga?.orientationType?.toInt()) } + val orientationType = remember(manga) { OrientationType.fromPreference( + manga?.orientationType?.toInt() + ) } SettingsChipRow(R.string.rotation_type) { orientationTypeOptions.map { (stringRes, it) -> FilterChip( diff --git a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt index 862ba2ce8..5bab1e8ec 100644 --- a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt +++ b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt @@ -81,8 +81,16 @@ fun TrackStatusSelector( } } } - if (!state.isScrolledToStart()) HorizontalDivider(modifier = Modifier.align(Alignment.TopCenter)) - if (!state.isScrolledToEnd()) HorizontalDivider(modifier = Modifier.align(Alignment.BottomCenter)) + if (!state.isScrolledToStart()) { + HorizontalDivider( + modifier = Modifier.align(Alignment.TopCenter) + ) + } + if (!state.isScrolledToEnd()) { + HorizontalDivider( + modifier = Modifier.align(Alignment.BottomCenter) + ) + } }, onConfirm = onConfirm, onDismissRequest = onDismissRequest, @@ -165,7 +173,10 @@ fun TrackDateSelector( modifier = Modifier .fillMaxWidth() .padding(start = 12.dp, top = 8.dp, end = 12.dp, bottom = 24.dp), - horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small, Alignment.End), + horizontalArrangement = Arrangement.spacedBy( + MaterialTheme.padding.small, + Alignment.End + ), ) { if (onRemove != null) { TextButton(onClick = onRemove) { @@ -205,7 +216,10 @@ fun BaseSelector( buttons = { Row( modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small, Alignment.End), + horizontalArrangement = Arrangement.spacedBy( + MaterialTheme.padding.small, + Alignment.End + ), ) { if (thirdButton != null) { thirdButton() diff --git a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt index d39b6aa6b..43ef54a91 100644 --- a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt +++ b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt @@ -90,7 +90,9 @@ fun AnimeTrackInfoDialogHome( .takeIf { supportsScoring && item.track.score != 0.0 }, onScoreClick = { onScoreClick(item) } .takeIf { supportsScoring }, - startDate = remember(item.track.startDate) { dateFormat.format(item.track.startDate) } + startDate = remember(item.track.startDate) { dateFormat.format( + item.track.startDate + ) } .takeIf { supportsReadingDates && item.track.startDate != 0L }, onStartDateClick = { onStartDateEdit(item) } // TODO .takeIf { supportsReadingDates }, diff --git a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackServiceSearch.kt b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackServiceSearch.kt index 81b2b72de..7a7e0b0d5 100644 --- a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackServiceSearch.kt +++ b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackServiceSearch.kt @@ -95,7 +95,9 @@ fun AnimeTrackServiceSearch( .copy(color = MaterialTheme.colorScheme.onSurface), singleLine = true, keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search), - keyboardActions = KeyboardActions(onSearch = { dispatchQueryAndClearFocus() }), + keyboardActions = KeyboardActions( + onSearch = { dispatchQueryAndClearFocus() } + ), cursorBrush = SolidColor(MaterialTheme.colorScheme.primary), decorationBox = { if (query.text.isEmpty()) { @@ -170,9 +172,13 @@ fun AnimeTrackServiceSearch( SearchResultItem( title = it.title, coverUrl = it.cover_url, - type = it.publishing_type.toLowerCase(Locale.current).capitalize(Locale.current), + type = it.publishing_type.toLowerCase(Locale.current).capitalize( + Locale.current + ), startDate = it.start_date, - status = it.publishing_status.toLowerCase(Locale.current).capitalize(Locale.current), + status = it.publishing_status.toLowerCase(Locale.current).capitalize( + Locale.current + ), description = it.summary.trim(), selected = it == selected, onClick = { onSelectedChange(it) }, diff --git a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt index 6e4797ba9..231202838 100644 --- a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt +++ b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt @@ -101,7 +101,9 @@ fun MangaTrackInfoDialogHome( .takeIf { supportsScoring && item.track.score != 0.0 }, onScoreClick = { onScoreClick(item) } .takeIf { supportsScoring }, - startDate = remember(item.track.startDate) { dateFormat.format(item.track.startDate) } + startDate = remember(item.track.startDate) { dateFormat.format( + item.track.startDate + ) } .takeIf { supportsReadingDates && item.track.startDate != 0L }, onStartDateClick = { onStartDateEdit(item) } // TODO .takeIf { supportsReadingDates }, diff --git a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackServiceSearch.kt b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackServiceSearch.kt index 95dfc76a8..3ffa7c7d9 100644 --- a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackServiceSearch.kt +++ b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackServiceSearch.kt @@ -112,7 +112,9 @@ fun MangaTrackServiceSearch( .copy(color = MaterialTheme.colorScheme.onSurface), singleLine = true, keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search), - keyboardActions = KeyboardActions(onSearch = { dispatchQueryAndClearFocus() }), + keyboardActions = KeyboardActions( + onSearch = { dispatchQueryAndClearFocus() } + ), cursorBrush = SolidColor(MaterialTheme.colorScheme.primary), decorationBox = { if (query.text.isEmpty()) { @@ -187,9 +189,13 @@ fun MangaTrackServiceSearch( SearchResultItem( title = it.title, coverUrl = it.cover_url, - type = it.publishing_type.toLowerCase(Locale.current).capitalize(Locale.current), + type = it.publishing_type.toLowerCase(Locale.current).capitalize( + Locale.current + ), startDate = it.start_date, - status = it.publishing_status.toLowerCase(Locale.current).capitalize(Locale.current), + status = it.publishing_status.toLowerCase(Locale.current).capitalize( + Locale.current + ), description = it.summary.trim(), selected = it == selected, onClick = { onSelectedChange(it) }, diff --git a/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesScreen.kt b/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesScreen.kt index f699f34a6..2d0090fa1 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesScreen.kt @@ -23,6 +23,7 @@ import eu.kanade.tachiyomi.data.download.anime.model.AnimeDownload import eu.kanade.tachiyomi.ui.player.settings.PlayerPreferences import eu.kanade.tachiyomi.ui.updates.anime.AnimeUpdatesItem import eu.kanade.tachiyomi.ui.updates.anime.AnimeUpdatesScreenModel +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import kotlinx.coroutines.launch import tachiyomi.presentation.core.components.FastScrollLazyColumn @@ -32,7 +33,6 @@ import tachiyomi.presentation.core.screens.EmptyScreen import tachiyomi.presentation.core.screens.LoadingScreen import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import kotlin.time.Duration.Companion.seconds @Composable fun AnimeUpdateScreen( diff --git a/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesUiItem.kt b/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesUiItem.kt index c211e6073..876e42d29 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesUiItem.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesUiItem.kt @@ -43,14 +43,14 @@ import eu.kanade.presentation.entries.anime.components.EpisodeDownloadIndicator import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.anime.model.AnimeDownload import eu.kanade.tachiyomi.ui.updates.anime.AnimeUpdatesItem +import java.util.Date +import java.util.concurrent.TimeUnit +import kotlin.time.Duration.Companion.minutes import tachiyomi.domain.updates.anime.model.AnimeUpdatesWithRelations import tachiyomi.presentation.core.components.ListGroupHeader import tachiyomi.presentation.core.components.material.ReadItemAlpha import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.util.selectedBackground -import java.util.Date -import java.util.concurrent.TimeUnit -import kotlin.time.Duration.Companion.minutes @OptIn(ExperimentalFoundationApi::class) fun LazyListScope.animeUpdatesLastUpdatedItem( @@ -69,11 +69,17 @@ fun LazyListScope.animeUpdatesLastUpdatedItem( Box( modifier = Modifier .animateItemPlacement() - .padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small), + .padding( + horizontal = MaterialTheme.padding.medium, + vertical = MaterialTheme.padding.small + ), ) { Text( text = if (time.isNullOrEmpty()) { - stringResource(R.string.updates_last_update_info, stringResource(R.string.updates_last_update_info_just_now)) + stringResource( + R.string.updates_last_update_info, + stringResource(R.string.updates_last_update_info_just_now) + ) } else { stringResource(R.string.updates_last_update_info, time) }, @@ -134,7 +140,12 @@ fun LazyListScope.animeUpdatesUiItems( }, onClick = { when { - selectionMode -> onUpdateSelected(updatesItem, !updatesItem.selected, true, false) + selectionMode -> onUpdateSelected( + updatesItem, + !updatesItem.selected, + true, + false + ) else -> onClickUpdate(updatesItem, false) } }, @@ -219,7 +230,9 @@ fun AnimeUpdatesUiItem( imageVector = Icons.Filled.Bookmark, contentDescription = stringResource(R.string.action_filter_bookmarked), modifier = Modifier - .sizeIn(maxHeight = with(LocalDensity.current) { textHeight.toDp() - 2.dp }), + .sizeIn( + maxHeight = with(LocalDensity.current) { textHeight.toDp() - 2.dp } + ), tint = MaterialTheme.colorScheme.primary, ) Spacer(modifier = Modifier.width(2.dp)) diff --git a/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesScreen.kt b/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesScreen.kt index b68084aab..b28a930b4 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesScreen.kt @@ -22,6 +22,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.manga.model.MangaDownload import eu.kanade.tachiyomi.ui.updates.manga.MangaUpdatesItem import eu.kanade.tachiyomi.ui.updates.manga.MangaUpdatesScreenModel +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import kotlinx.coroutines.launch import tachiyomi.presentation.core.components.FastScrollLazyColumn @@ -29,7 +30,6 @@ import tachiyomi.presentation.core.components.material.PullRefresh import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen import tachiyomi.presentation.core.screens.LoadingScreen -import kotlin.time.Duration.Companion.seconds @Composable fun MangaUpdateScreen( diff --git a/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesUiItem.kt b/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesUiItem.kt index f81133df9..94ac4d2c7 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesUiItem.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesUiItem.kt @@ -43,13 +43,13 @@ import eu.kanade.presentation.entries.manga.components.ChapterDownloadIndicator import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.manga.model.MangaDownload import eu.kanade.tachiyomi.ui.updates.manga.MangaUpdatesItem +import java.util.Date +import kotlin.time.Duration.Companion.minutes import tachiyomi.domain.updates.manga.model.MangaUpdatesWithRelations import tachiyomi.presentation.core.components.ListGroupHeader import tachiyomi.presentation.core.components.material.ReadItemAlpha import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.util.selectedBackground -import java.util.Date -import kotlin.time.Duration.Companion.minutes @OptIn(ExperimentalFoundationApi::class) fun LazyListScope.mangaUpdatesLastUpdatedItem( @@ -68,11 +68,17 @@ fun LazyListScope.mangaUpdatesLastUpdatedItem( Box( modifier = Modifier .animateItemPlacement() - .padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small), + .padding( + horizontal = MaterialTheme.padding.medium, + vertical = MaterialTheme.padding.small + ), ) { Text( text = if (time.isNullOrEmpty()) { - stringResource(R.string.updates_last_update_info, stringResource(R.string.updates_last_update_info_just_now)) + stringResource( + R.string.updates_last_update_info, + stringResource(R.string.updates_last_update_info_just_now) + ) } else { stringResource(R.string.updates_last_update_info, time) }, @@ -132,7 +138,12 @@ fun LazyListScope.mangaUpdatesUiItems( }, onClick = { when { - selectionMode -> onUpdateSelected(updatesItem, !updatesItem.selected, true, false) + selectionMode -> onUpdateSelected( + updatesItem, + !updatesItem.selected, + true, + false + ) else -> onClickUpdate(updatesItem) } }, @@ -216,7 +227,9 @@ fun MangaUpdatesUiItem( imageVector = Icons.Filled.Bookmark, contentDescription = stringResource(R.string.action_filter_bookmarked), modifier = Modifier - .sizeIn(maxHeight = with(LocalDensity.current) { textHeight.toDp() - 2.dp }), + .sizeIn( + maxHeight = with(LocalDensity.current) { textHeight.toDp() - 2.dp } + ), tint = MaterialTheme.colorScheme.primary, ) Spacer(modifier = Modifier.width(2.dp)) diff --git a/app/src/main/java/eu/kanade/presentation/util/DurationUtils.kt b/app/src/main/java/eu/kanade/presentation/util/DurationUtils.kt index 644f5ca13..03749f420 100644 --- a/app/src/main/java/eu/kanade/presentation/util/DurationUtils.kt +++ b/app/src/main/java/eu/kanade/presentation/util/DurationUtils.kt @@ -9,8 +9,16 @@ fun Duration.toDurationString(context: Context, fallback: String): String { buildList(4) { if (days != 0L) add(context.getString(R.string.day_short, days)) if (hours != 0) add(context.getString(R.string.hour_short, hours)) - if (minutes != 0 && (days == 0L || hours == 0)) add(context.getString(R.string.minute_short, minutes)) - if (seconds != 0 && days == 0L && hours == 0) add(context.getString(R.string.seconds_short, seconds)) + if (minutes != 0 && (days == 0L || hours == 0)) { + add( + context.getString(R.string.minute_short, minutes) + ) + } + if (seconds != 0 && days == 0L && hours == 0) { + add( + context.getString(R.string.seconds_short, seconds) + ) + } }.joinToString(" ").ifBlank { fallback } } } diff --git a/app/src/main/java/eu/kanade/presentation/util/ExceptionFormatter.kt b/app/src/main/java/eu/kanade/presentation/util/ExceptionFormatter.kt index 62bf8b146..2ac5c79b5 100644 --- a/app/src/main/java/eu/kanade/presentation/util/ExceptionFormatter.kt +++ b/app/src/main/java/eu/kanade/presentation/util/ExceptionFormatter.kt @@ -5,11 +5,11 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.animesource.online.LicensedEntryItemsException import eu.kanade.tachiyomi.network.HttpException import eu.kanade.tachiyomi.util.system.isOnline +import java.net.UnknownHostException import tachiyomi.domain.items.chapter.model.NoChaptersException import tachiyomi.domain.items.episode.model.NoEpisodesException import tachiyomi.domain.source.anime.model.AnimeSourceNotInstalledException import tachiyomi.domain.source.manga.model.SourceNotInstalledException -import java.net.UnknownHostException context(Context) val Throwable.formattedMessage: String @@ -23,9 +23,15 @@ val Throwable.formattedMessage: String getString(R.string.exception_unknown_host, message) } } - is NoChaptersException, is NoEpisodesException -> return getString(R.string.no_results_found) - is SourceNotInstalledException, is AnimeSourceNotInstalledException -> return getString(R.string.loader_not_implemented_error) - is LicensedEntryItemsException -> return getString(R.string.licensed_manga_chapters_error) + is NoChaptersException, is NoEpisodesException -> return getString( + R.string.no_results_found + ) + is SourceNotInstalledException, is AnimeSourceNotInstalledException -> return getString( + R.string.loader_not_implemented_error + ) + is LicensedEntryItemsException -> return getString( + R.string.licensed_manga_chapters_error + ) } return when (val className = this::class.simpleName) { "Exception", "IOException" -> message ?: className diff --git a/app/src/main/java/eu/kanade/presentation/webview/WebViewScreenContent.kt b/app/src/main/java/eu/kanade/presentation/webview/WebViewScreenContent.kt index 8e8fb56e7..d94b8fafc 100644 --- a/app/src/main/java/eu/kanade/presentation/webview/WebViewScreenContent.kt +++ b/app/src/main/java/eu/kanade/presentation/webview/WebViewScreenContent.kt @@ -175,7 +175,9 @@ fun WebViewScreenContent( WarningBanner( textRes = R.string.information_cloudflare_help, modifier = Modifier.clickable { - uriHandler.openUri("https://aniyomi.org/docs/guides/troubleshooting/#solving-cloudflare-issues") + uriHandler.openUri( + "https://aniyomi.org/docs/guides/troubleshooting/#solving-cloudflare-issues" + ) }, ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 2d77989f0..01196ef19 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -46,6 +46,7 @@ import eu.kanade.tachiyomi.util.system.cancelNotification import eu.kanade.tachiyomi.util.system.isPreviewBuildType import eu.kanade.tachiyomi.util.system.isReleaseBuildType import eu.kanade.tachiyomi.util.system.notify +import java.security.Security import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -63,7 +64,6 @@ import tachiyomi.presentation.widget.entries.manga.TachiyomiMangaWidgetManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy -import java.security.Security class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory { @@ -213,7 +213,11 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory { if (BuildConfig.ACRA_URI.isNotEmpty() && isPreviewBuildType || isReleaseBuildType) { initAcra { buildConfigClass = BuildConfig::class.java - excludeMatchingSharedPreferencesKeys = listOf(".*username.*", ".*password.*", ".*token.*") + excludeMatchingSharedPreferencesKeys = listOf( + ".*username.*", + ".*password.*", + ".*token.*" + ) reportFormat = StringFormat.JSON httpSender { diff --git a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt index e192e11c8..5192e5183 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt @@ -154,9 +154,15 @@ class AppModule(val app: Application) : InjektModule { ) } - addSingletonFactory { AndroidMangaDatabaseHandler(get(), sqlDriverManga) } + addSingletonFactory { AndroidMangaDatabaseHandler( + get(), + sqlDriverManga + ) } - addSingletonFactory { AndroidAnimeDatabaseHandler(get(), sqlDriverAnime) } + addSingletonFactory { AndroidAnimeDatabaseHandler( + get(), + sqlDriverAnime + ) } addSingletonFactory { Json { diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index 310c73675..410998a17 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.util.system.DeviceUtil import eu.kanade.tachiyomi.util.system.isReleaseBuildType import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.workManager +import java.io.File import tachiyomi.core.preference.PreferenceStore import tachiyomi.core.preference.TriState import tachiyomi.core.preference.getAndSet @@ -29,7 +30,6 @@ import tachiyomi.core.preference.plusAssign import tachiyomi.domain.backup.service.BackupPreferences import tachiyomi.domain.library.service.LibraryPreferences import tachiyomi.domain.library.service.LibraryPreferences.Companion.ENTRY_NON_COMPLETED -import java.io.File object Migrations { @@ -108,7 +108,10 @@ object Migrations { } if (oldVersion < 44) { // Reset sorting preference if using removed sort by source - val oldMangaSortingMode = prefs.getInt(libraryPreferences.mangaSortingMode().key(), 0) + val oldMangaSortingMode = prefs.getInt( + libraryPreferences.mangaSortingMode().key(), + 0 + ) if (oldMangaSortingMode == 5) { // SOURCE = 5 prefs.edit { @@ -116,7 +119,10 @@ object Migrations { } } - val oldAnimeSortingMode = prefs.getInt(libraryPreferences.animeSortingMode().key(), 0) + val oldAnimeSortingMode = prefs.getInt( + libraryPreferences.animeSortingMode().key(), + 0 + ) if (oldAnimeSortingMode == 5) { // SOURCE = 5 prefs.edit { @@ -135,13 +141,22 @@ object Migrations { } } prefs.edit { - putInt(libraryPreferences.filterDownloadedManga().key(), convertBooleanPrefToTriState("pref_filter_downloaded_key")) + putInt( + libraryPreferences.filterDownloadedManga().key(), + convertBooleanPrefToTriState("pref_filter_downloaded_key") + ) remove("pref_filter_downloaded_key") - putInt(libraryPreferences.filterUnread().key(), convertBooleanPrefToTriState("pref_filter_unread_key")) + putInt( + libraryPreferences.filterUnread().key(), + convertBooleanPrefToTriState("pref_filter_unread_key") + ) remove("pref_filter_unread_key") - putInt(libraryPreferences.filterCompletedManga().key(), convertBooleanPrefToTriState("pref_filter_completed_key")) + putInt( + libraryPreferences.filterCompletedManga().key(), + convertBooleanPrefToTriState("pref_filter_completed_key") + ) remove("pref_filter_completed_key") } } @@ -208,8 +223,14 @@ object Migrations { AnimeLibraryUpdateJob.setupTask(context) } if (oldVersion < 64) { - val oldMangaSortingMode = prefs.getInt(libraryPreferences.mangaSortingMode().key(), 0) - val oldAnimeSortingMode = prefs.getInt(libraryPreferences.animeSortingMode().key(), 0) + val oldMangaSortingMode = prefs.getInt( + libraryPreferences.mangaSortingMode().key(), + 0 + ) + val oldAnimeSortingMode = prefs.getInt( + libraryPreferences.animeSortingMode().key(), + 0 + ) val oldSortingDirection = prefs.getBoolean("library_sorting_ascending", true) val newMangaSortingMode = when (oldMangaSortingMode) { @@ -268,7 +289,10 @@ object Migrations { } } if (oldVersion < 72) { - val oldUpdateOngoingOnly = prefs.getBoolean("pref_update_only_non_completed_key", true) + val oldUpdateOngoingOnly = prefs.getBoolean( + "pref_update_only_non_completed_key", + true + ) if (!oldUpdateOngoingOnly) { libraryPreferences.autoUpdateItemRestrictions() -= ENTRY_NON_COMPLETED } @@ -276,10 +300,14 @@ object Migrations { if (oldVersion < 75) { val oldSecureScreen = prefs.getBoolean("secure_screen", false) if (oldSecureScreen) { - securityPreferences.secureScreen().set(SecurityPreferences.SecureScreenMode.ALWAYS) + securityPreferences.secureScreen().set( + SecurityPreferences.SecureScreenMode.ALWAYS + ) } if (DeviceUtil.isMiui && basePreferences.extensionInstaller().get() == BasePreferences.ExtensionInstaller.PACKAGEINSTALLER) { - basePreferences.extensionInstaller().set(BasePreferences.ExtensionInstaller.LEGACY) + basePreferences.extensionInstaller().set( + BasePreferences.ExtensionInstaller.LEGACY + ) } } if (oldVersion < 76) { @@ -295,13 +323,19 @@ object Migrations { if (oldVersion < 81) { // Handle renamed enum values prefs.edit { - val newMangaSortingMode = when (val oldSortingMode = prefs.getString(libraryPreferences.mangaSortingMode().key(), "ALPHABETICAL")) { + val newMangaSortingMode = when (val oldSortingMode = prefs.getString( + libraryPreferences.mangaSortingMode().key(), + "ALPHABETICAL" + )) { "LAST_CHECKED" -> "LAST_MANGA_UPDATE" "UNREAD" -> "UNREAD_COUNT" "DATE_FETCHED" -> "CHAPTER_FETCH_DATE" else -> oldSortingMode } - val newAnimeSortingMode = when (val oldSortingMode = prefs.getString(libraryPreferences.animeSortingMode().key(), "ALPHABETICAL")) { + val newAnimeSortingMode = when (val oldSortingMode = prefs.getString( + libraryPreferences.animeSortingMode().key(), + "ALPHABETICAL" + )) { "LAST_CHECKED" -> "LAST_MANGA_UPDATE" "UNREAD" -> "UNREAD_COUNT" "DATE_FETCHED" -> "CHAPTER_FETCH_DATE" @@ -313,8 +347,14 @@ object Migrations { } if (oldVersion < 82) { prefs.edit { - val mangasort = prefs.getString(libraryPreferences.mangaSortingMode().key(), null) ?: return@edit - val animesort = prefs.getString(libraryPreferences.animeSortingMode().key(), null) ?: return@edit + val mangasort = prefs.getString( + libraryPreferences.mangaSortingMode().key(), + null + ) ?: return@edit + val animesort = prefs.getString( + libraryPreferences.animeSortingMode().key(), + null + ) ?: return@edit val direction = prefs.getString("library_sorting_ascending", "ASCENDING")!! putString(libraryPreferences.mangaSortingMode().key(), "$mangasort,$direction") putString(libraryPreferences.animeSortingMode().key(), "$animesort,$direction") @@ -439,7 +479,9 @@ object Migrations { else -> TriState.DISABLED } - preferenceStore.getEnum("${key}_v2", TriState.DISABLED).set(newValue) + preferenceStore.getEnum("${key}_v2", TriState.DISABLED).set( + newValue + ) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/crash/GlobalExceptionHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/crash/GlobalExceptionHandler.kt index 8f28fbf7b..89bcf6277 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/crash/GlobalExceptionHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/crash/GlobalExceptionHandler.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.crash import android.content.Context import android.content.Intent +import kotlin.system.exitProcess import kotlinx.serialization.KSerializer import kotlinx.serialization.descriptors.PrimitiveKind import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor @@ -11,7 +12,6 @@ import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.Json import logcat.LogPriority import tachiyomi.core.util.system.logcat -import kotlin.system.exitProcess class GlobalExceptionHandler private constructor( private val applicationContext: Context, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateJob.kt index fa7f769e4..4a22ba031 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateJob.kt @@ -18,14 +18,14 @@ import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.util.system.cancelNotification import eu.kanade.tachiyomi.util.system.isRunning import eu.kanade.tachiyomi.util.system.workManager +import java.util.concurrent.TimeUnit +import kotlin.time.Duration.Companion.minutes +import kotlin.time.toJavaDuration import logcat.LogPriority import tachiyomi.core.util.system.logcat import tachiyomi.domain.backup.service.BackupPreferences import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.concurrent.TimeUnit -import kotlin.time.Duration.Companion.minutes -import kotlin.time.toJavaDuration class BackupCreateJob(private val context: Context, workerParams: WorkerParameters) : CoroutineWorker(context, workerParams) { @@ -49,7 +49,11 @@ class BackupCreateJob(private val context: Context, workerParams: WorkerParamete return try { val location = BackupManager(context).createBackup(uri, flags, isAutoBackup) - if (!isAutoBackup) notifier.showBackupComplete(UniFile.fromUri(context, location.toUri())) + if (!isAutoBackup) { + notifier.showBackupComplete( + UniFile.fromUri(context, location.toUri()) + ) + } Result.success() } catch (e: Exception) { logcat(LogPriority.ERROR, e) @@ -100,7 +104,11 @@ class BackupCreateJob(private val context: Context, workerParams: WorkerParamete ) .build() - context.workManager.enqueueUniquePeriodicWork(TAG_AUTO, ExistingPeriodicWorkPolicy.UPDATE, request) + context.workManager.enqueueUniquePeriodicWork( + TAG_AUTO, + ExistingPeriodicWorkPolicy.UPDATE, + request + ) } else { context.workManager.cancelUniqueWork(TAG_AUTO) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupFileValidator.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupFileValidator.kt index d28dcd111..a0499777a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupFileValidator.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupFileValidator.kt @@ -30,7 +30,9 @@ class BackupFileValidator( } if (backup.backupManga.isEmpty() && backup.backupAnime.isEmpty()) { - throw IllegalStateException(context.getString(R.string.invalid_backup_file_missing_manga)) + throw IllegalStateException( + context.getString(R.string.invalid_backup_file_missing_manga) + ) } val sources = backup.backupSources.associate { it.sourceId to it.name } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt index 198a81b44..89159c2b0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt @@ -58,6 +58,10 @@ import eu.kanade.tachiyomi.source.anime.model.copyFrom import eu.kanade.tachiyomi.source.manga.getPreferenceKey import eu.kanade.tachiyomi.source.manga.model.copyFrom import eu.kanade.tachiyomi.util.system.hasPermission +import java.io.File +import java.io.FileOutputStream +import java.util.Date +import kotlin.math.max import kotlinx.serialization.protobuf.ProtoBuf import logcat.LogPriority import okio.buffer @@ -85,10 +89,6 @@ import tachiyomi.domain.source.anime.service.AnimeSourceManager import tachiyomi.domain.source.manga.service.MangaSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.File -import java.io.FileOutputStream -import java.util.Date -import kotlin.math.max class BackupManager( private val context: Context, @@ -268,7 +268,10 @@ class BackupManager( // Check if user wants chapter information in backup if (options and BACKUP_CHAPTER_MASK == BACKUP_CHAPTER) { // Backup all the chapters - val chapters = mangaHandler.awaitList { chaptersQueries.getChaptersByMangaId(manga.id, backupChapterMapper) } + val chapters = mangaHandler.awaitList { chaptersQueries.getChaptersByMangaId( + manga.id, + backupChapterMapper + ) } if (chapters.isNotEmpty()) { mangaObject.chapters = chapters } @@ -285,7 +288,10 @@ class BackupManager( // Check if user wants track information in backup if (options and BACKUP_TRACK_MASK == BACKUP_TRACK) { - val tracks = mangaHandler.awaitList { manga_syncQueries.getTracksByMangaId(manga.id, backupTrackMapper) } + val tracks = mangaHandler.awaitList { manga_syncQueries.getTracksByMangaId( + manga.id, + backupTrackMapper + ) } if (tracks.isNotEmpty()) { mangaObject.tracking = tracks } @@ -296,7 +302,9 @@ class BackupManager( val historyByMangaId = getMangaHistory.await(manga.id) if (historyByMangaId.isNotEmpty()) { val history = historyByMangaId.map { history -> - val chapter = mangaHandler.awaitOne { chaptersQueries.getChapterById(history.chapterId) } + val chapter = mangaHandler.awaitOne { chaptersQueries.getChapterById( + history.chapterId + ) } BackupHistory(chapter.url, history.readAt?.time ?: 0L, history.readDuration) } if (history.isNotEmpty()) { @@ -322,7 +330,10 @@ class BackupManager( // Check if user wants chapter information in backup if (options and BACKUP_CHAPTER_MASK == BACKUP_CHAPTER) { // Backup all the chapters - val episodes = animeHandler.awaitList { episodesQueries.getEpisodesByAnimeId(anime.id, backupEpisodeMapper) } + val episodes = animeHandler.awaitList { episodesQueries.getEpisodesByAnimeId( + anime.id, + backupEpisodeMapper + ) } if (episodes.isNotEmpty()) { animeObject.episodes = episodes } @@ -339,7 +350,10 @@ class BackupManager( // Check if user wants track information in backup if (options and BACKUP_TRACK_MASK == BACKUP_TRACK) { - val tracks = animeHandler.awaitList { anime_syncQueries.getTracksByAnimeId(anime.id, backupAnimeTrackMapper) } + val tracks = animeHandler.awaitList { anime_syncQueries.getTracksByAnimeId( + anime.id, + backupAnimeTrackMapper + ) } if (tracks.isNotEmpty()) { animeObject.tracking = tracks } @@ -350,7 +364,9 @@ class BackupManager( val historyByAnimeId = getAnimeHistory.await(anime.id) if (historyByAnimeId.isNotEmpty()) { val history = historyByAnimeId.map { history -> - val episode = animeHandler.awaitOne { episodesQueries.getEpisodeById(history.episodeId) } + val episode = animeHandler.awaitOne { episodesQueries.getEpisodeById( + history.episodeId + ) } BackupAnimeHistory(episode.url, history.seenAt?.time ?: 0L) } if (history.isNotEmpty()) { @@ -574,7 +590,11 @@ class BackupManager( * @param manga the manga whose categories have to be restored. * @param categories the categories to restore. */ - internal suspend fun restoreCategories(manga: Manga, categories: List, backupCategories: List) { + internal suspend fun restoreCategories( + manga: Manga, + categories: List, + backupCategories: List + ) { val dbCategories = getMangaCategories.await() val mangaCategoriesToUpdate = mutableListOf>() @@ -607,7 +627,11 @@ class BackupManager( * @param anime the anime whose categories have to be restored. * @param categories the categories to restore. */ - internal suspend fun restoreAnimeCategories(anime: Anime, categories: List, backupCategories: List) { + internal suspend fun restoreAnimeCategories( + anime: Anime, + categories: List, + backupCategories: List + ) { val dbCategories = getAnimeCategories.await() val animeCategoriesToUpdate = mutableListOf>() @@ -692,10 +716,14 @@ class BackupManager( // List containing history to be updated val toUpdate = mutableListOf() for ((url, lastSeen) in history) { - var dbHistory = animeHandler.awaitOneOrNull { animehistoryQueries.getHistoryByEpisodeUrl(url) } + var dbHistory = animeHandler.awaitOneOrNull { animehistoryQueries.getHistoryByEpisodeUrl( + url + ) } // Check if history already in database and update if (dbHistory != null) { - dbHistory = dbHistory.copy(last_seen = Date(max(lastSeen, dbHistory.last_seen?.time ?: 0L))) + dbHistory = dbHistory.copy( + last_seen = Date(max(lastSeen, dbHistory.last_seen?.time ?: 0L)) + ) toUpdate.add( AnimeHistoryUpdate( episodeId = dbHistory.episode_id, @@ -732,7 +760,10 @@ class BackupManager( * @param manga the manga whose sync have to be restored. * @param tracks the track list to restore. */ - internal suspend fun restoreTracking(manga: Manga, tracks: List) { + internal suspend fun restoreTracking( + manga: Manga, + tracks: List + ) { // Get tracks from database val dbTracks = mangaHandler.awaitList { manga_syncQueries.getTracksByMangaId(manga.id) } val toUpdate = mutableListOf() @@ -753,7 +784,12 @@ class BackupManager( if (track.libraryId != dbTrack.library_id) { temp = temp.copy(library_id = track.libraryId) } - temp = temp.copy(last_chapter_read = max(dbTrack.last_chapter_read, track.lastChapterRead)) + temp = temp.copy( + last_chapter_read = max( + dbTrack.last_chapter_read, + track.lastChapterRead + ) + ) isInDatabase = true toUpdate.add(temp) break @@ -815,7 +851,10 @@ class BackupManager( * @param anime the anime whose sync have to be restored. * @param tracks the track list to restore. */ - internal suspend fun restoreAnimeTracking(anime: Anime, tracks: List) { + internal suspend fun restoreAnimeTracking( + anime: Anime, + tracks: List + ) { // Get tracks from database val dbTracks = animeHandler.awaitList { anime_syncQueries.getTracksByAnimeId(anime.id) } val toUpdate = mutableListOf() @@ -836,7 +875,12 @@ class BackupManager( if (track.libraryId != dbTrack.library_id) { temp = temp.copy(library_id = track.libraryId) } - temp = temp.copy(last_episode_seen = max(dbTrack.last_episode_seen, track.lastEpisodeSeen)) + temp = temp.copy( + last_episode_seen = max( + dbTrack.last_episode_seen, + track.lastEpisodeSeen + ) + ) isInDatabase = true toUpdate.add(temp) break @@ -892,7 +936,10 @@ class BackupManager( } } - internal suspend fun restoreChapters(manga: Manga, chapters: List) { + internal suspend fun restoreChapters( + manga: Manga, + chapters: List + ) { val dbChapters = mangaHandler.awaitList { chaptersQueries.getChaptersByMangaId(manga.id!!) } val processed = chapters.map { chapter -> @@ -902,7 +949,10 @@ class BackupManager( updatedChapter = updatedChapter.copy(id = dbChapter._id) updatedChapter = updatedChapter.copyFrom(dbChapter) if (dbChapter.read && !updatedChapter.read) { - updatedChapter = updatedChapter.copy(read = true, lastPageRead = dbChapter.last_page_read) + updatedChapter = updatedChapter.copy( + read = true, + lastPageRead = dbChapter.last_page_read + ) } else if (chapter.lastPageRead == 0L && dbChapter.last_page_read != 0L) { updatedChapter = updatedChapter.copy(lastPageRead = dbChapter.last_page_read) } @@ -919,7 +969,10 @@ class BackupManager( newChapters[false]?.let { insertChapters(it) } } - internal suspend fun restoreEpisodes(anime: Anime, episodes: List) { + internal suspend fun restoreEpisodes( + anime: Anime, + episodes: List + ) { val dbEpisodes = animeHandler.awaitList { episodesQueries.getEpisodesByAnimeId(anime.id!!) } val processed = episodes.map { episode -> @@ -929,9 +982,14 @@ class BackupManager( updatedEpisode = updatedEpisode.copy(id = dbEpisode._id) updatedEpisode = updatedEpisode.copyFrom(dbEpisode) if (dbEpisode.seen && !updatedEpisode.seen) { - updatedEpisode = updatedEpisode.copy(seen = true, lastSecondSeen = dbEpisode.last_second_seen) + updatedEpisode = updatedEpisode.copy( + seen = true, + lastSecondSeen = dbEpisode.last_second_seen + ) } else if (updatedEpisode.lastSecondSeen == 0L && dbEpisode.last_second_seen != 0L) { - updatedEpisode = updatedEpisode.copy(lastSecondSeen = dbEpisode.last_second_seen) + updatedEpisode = updatedEpisode.copy( + lastSecondSeen = dbEpisode.last_second_seen + ) } if (!updatedEpisode.bookmark && dbEpisode.bookmark) { updatedEpisode = updatedEpisode.copy(bookmark = true) @@ -1134,7 +1192,9 @@ class BackupManager( /** * Updates a list of chapters with known database ids */ - private suspend fun updateKnownChapters(chapters: List) { + private suspend fun updateKnownChapters( + chapters: List + ) { mangaHandler.await(true) { chapters.forEach { chapter -> chaptersQueries.update( @@ -1158,7 +1218,9 @@ class BackupManager( /** * Updates a list of episodes with known database ids */ - private suspend fun updateKnownEpisodes(episodes: List) { + private suspend fun updateKnownEpisodes( + episodes: List + ) { animeHandler.await(true) { episodes.forEach { episode -> episodesQueries.update( diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt index 51dd130d9..dff1d9fdf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt @@ -12,15 +12,17 @@ import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.cancelNotification import eu.kanade.tachiyomi.util.system.notificationBuilder import eu.kanade.tachiyomi.util.system.notify -import uy.kohesive.injekt.injectLazy import java.io.File import java.util.concurrent.TimeUnit +import uy.kohesive.injekt.injectLazy class BackupNotifier(private val context: Context) { private val preferences: SecurityPreferences by injectLazy() - private val progressNotificationBuilder = context.notificationBuilder(Notifications.CHANNEL_BACKUP_RESTORE_PROGRESS) { + private val progressNotificationBuilder = context.notificationBuilder( + Notifications.CHANNEL_BACKUP_RESTORE_PROGRESS + ) { setLargeIcon(BitmapFactory.decodeResource(context.resources, R.mipmap.ic_launcher)) setSmallIcon(R.drawable.ic_ani) setAutoCancel(false) @@ -28,7 +30,9 @@ class BackupNotifier(private val context: Context) { setOnlyAlertOnce(true) } - private val completeNotificationBuilder = context.notificationBuilder(Notifications.CHANNEL_BACKUP_RESTORE_COMPLETE) { + private val completeNotificationBuilder = context.notificationBuilder( + Notifications.CHANNEL_BACKUP_RESTORE_COMPLETE + ) { setLargeIcon(BitmapFactory.decodeResource(context.resources, R.mipmap.ic_launcher)) setSmallIcon(R.drawable.ic_ani) setAutoCancel(false) @@ -72,14 +76,23 @@ class BackupNotifier(private val context: Context) { addAction( R.drawable.ic_share_24dp, context.getString(R.string.action_share), - NotificationReceiver.shareBackupPendingBroadcast(context, unifile.uri, Notifications.ID_BACKUP_COMPLETE), + NotificationReceiver.shareBackupPendingBroadcast( + context, + unifile.uri, + Notifications.ID_BACKUP_COMPLETE + ), ) show(Notifications.ID_BACKUP_COMPLETE) } } - fun showRestoreProgress(content: String = "", contentTitle: String = context.getString(R.string.restoring_backup), progress: Int = 0, maxAmount: Int = 100): NotificationCompat.Builder { + fun showRestoreProgress( + content: String = "", + contentTitle: String = context.getString(R.string.restoring_backup), + progress: Int = 0, + maxAmount: Int = 100 + ): NotificationCompat.Builder { val builder = with(progressNotificationBuilder) { setContentTitle(contentTitle) @@ -94,7 +107,10 @@ class BackupNotifier(private val context: Context) { addAction( R.drawable.ic_close_24dp, context.getString(R.string.action_cancel), - NotificationReceiver.cancelRestorePendingBroadcast(context, Notifications.ID_RESTORE_PROGRESS), + NotificationReceiver.cancelRestorePendingBroadcast( + context, + Notifications.ID_RESTORE_PROGRESS + ), ) } @@ -114,7 +130,13 @@ class BackupNotifier(private val context: Context) { } } - fun showRestoreComplete(time: Long, errorCount: Int, path: String?, file: String?, contentTitle: String = context.getString(R.string.restore_completed)) { + fun showRestoreComplete( + time: Long, + errorCount: Int, + path: String?, + file: String?, + contentTitle: String = context.getString(R.string.restore_completed) + ) { context.cancelNotification(Notifications.ID_RESTORE_PROGRESS) val timeString = context.getString( @@ -127,7 +149,14 @@ class BackupNotifier(private val context: Context) { with(completeNotificationBuilder) { setContentTitle(contentTitle) - setContentText(context.resources.getQuantityString(R.plurals.restore_completed_message, errorCount, timeString, errorCount)) + setContentText( + context.resources.getQuantityString( + R.plurals.restore_completed_message, + errorCount, + timeString, + errorCount + ) + ) clearActions() if (errorCount > 0 && !path.isNullOrEmpty() && !file.isNullOrEmpty()) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestorer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestorer.kt index f09f1cec6..f57286bf3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestorer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestorer.kt @@ -27,6 +27,11 @@ import eu.kanade.tachiyomi.data.backup.models.StringSetPreferenceValue import eu.kanade.tachiyomi.util.BackupUtil import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.createFileInCacheDir +import java.io.File +import java.text.SimpleDateFormat +import java.time.ZonedDateTime +import java.util.Date +import java.util.Locale import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.isActive import tachiyomi.core.util.system.logcat @@ -42,11 +47,6 @@ import tachiyomi.domain.track.anime.model.AnimeTrack import tachiyomi.domain.track.manga.model.MangaTrack import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.File -import java.text.SimpleDateFormat -import java.time.ZonedDateTime -import java.util.Date -import java.util.Locale class BackupRestorer( private val context: Context, @@ -92,7 +92,13 @@ class BackupRestorer( val logFile = writeErrorLog() if (sync) { - notifier.showRestoreComplete(time, errors.size, logFile.parent, logFile.name, contentTitle = context.getString(R.string.library_sync_complete)) + notifier.showRestoreComplete( + time, + errors.size, + logFile.parent, + logFile.name, + contentTitle = context.getString(R.string.library_sync_complete) + ) } else { notifier.showRestoreComplete(time, errors.size, logFile.parent, logFile.name) } @@ -137,7 +143,10 @@ class BackupRestorer( val backupMaps = backup.backupBrokenSources.map { BackupSource(it.name, it.sourceId) } + backup.backupSources sourceMapping = backupMaps.associate { it.sourceId to it.name } - val backupAnimeMaps = backup.backupBrokenAnimeSources.map { BackupAnimeSource(it.name, it.sourceId) } + backup.backupAnimeSources + val backupAnimeMaps = backup.backupBrokenAnimeSources.map { BackupAnimeSource( + it.name, + it.sourceId + ) } + backup.backupAnimeSources animeSourceMapping = backupAnimeMaps.associate { it.sourceId to it.name } now = ZonedDateTime.now() @@ -186,17 +195,31 @@ class BackupRestorer( backupManager.restoreCategories(backupCategories) restoreProgress += 1 - showRestoreProgress(restoreProgress, restoreAmount, context.getString(R.string.manga_categories), context.getString(R.string.restoring_backup)) + showRestoreProgress( + restoreProgress, + restoreAmount, + context.getString(R.string.manga_categories), + context.getString(R.string.restoring_backup) + ) } private suspend fun restoreAnimeCategories(backupCategories: List) { backupManager.restoreAnimeCategories(backupCategories) restoreProgress += 1 - showRestoreProgress(restoreProgress, restoreAmount, context.getString(R.string.anime_categories), context.getString(R.string.restoring_backup)) + showRestoreProgress( + restoreProgress, + restoreAmount, + context.getString(R.string.anime_categories), + context.getString(R.string.restoring_backup) + ) } - private suspend fun restoreManga(backupManga: BackupManga, backupCategories: List, sync: Boolean) { + private suspend fun restoreManga( + backupManga: BackupManga, + backupCategories: List, + sync: Boolean + ) { val manga = backupManga.getMangaImpl() val chapters = backupManga.getChaptersImpl() val categories = backupManga.categories.map { it.toInt() } @@ -214,7 +237,14 @@ class BackupRestorer( // Copy information from manga already in database val updateManga = backupManager.restoreExistingManga(manga, dbManga) // Fetch rest of manga information - restoreNewManga(updateManga, chapters, categories, history, tracks, backupCategories) + restoreNewManga( + updateManga, + chapters, + categories, + history, + tracks, + backupCategories + ) } updateManga.awaitUpdateFetchInterval(restoredManga, now, currentMangaFetchWindow) } catch (e: Exception) { @@ -224,9 +254,19 @@ class BackupRestorer( restoreProgress += 1 if (sync) { - showRestoreProgress(restoreProgress, restoreAmount, manga.title, context.getString(R.string.syncing_library)) + showRestoreProgress( + restoreProgress, + restoreAmount, + manga.title, + context.getString(R.string.syncing_library) + ) } else { - showRestoreProgress(restoreProgress, restoreAmount, manga.title, context.getString(R.string.restoring_backup)) + showRestoreProgress( + restoreProgress, + restoreAmount, + manga.title, + context.getString(R.string.restoring_backup) + ) } } @@ -264,13 +304,23 @@ class BackupRestorer( return backupManga } - private suspend fun restoreExtras(manga: Manga, categories: List, history: List, tracks: List, backupCategories: List) { + private suspend fun restoreExtras( + manga: Manga, + categories: List, + history: List, + tracks: List, + backupCategories: List + ) { backupManager.restoreCategories(manga, categories, backupCategories) backupManager.restoreHistory(history) backupManager.restoreTracking(manga, tracks) } - private suspend fun restoreAnime(backupAnime: BackupAnime, backupCategories: List, sync: Boolean) { + private suspend fun restoreAnime( + backupAnime: BackupAnime, + backupCategories: List, + sync: Boolean + ) { val anime = backupAnime.getAnimeImpl() val episodes = backupAnime.getEpisodesImpl() val categories = backupAnime.categories.map { it.toInt() } @@ -288,7 +338,14 @@ class BackupRestorer( // Copy information from anime already in database val updateAnime = backupManager.restoreExistingAnime(anime, dbAnime) // Fetch rest of anime information - restoreNewAnime(updateAnime, episodes, categories, history, tracks, backupCategories) + restoreNewAnime( + updateAnime, + episodes, + categories, + history, + tracks, + backupCategories + ) } updateAnime.awaitUpdateFetchInterval(restoredAnime, now, currentAnimeFetchWindow) } catch (e: Exception) { @@ -298,9 +355,19 @@ class BackupRestorer( restoreProgress += 1 if (sync) { - showRestoreProgress(restoreProgress, restoreAmount, anime.title, context.getString(R.string.syncing_library)) + showRestoreProgress( + restoreProgress, + restoreAmount, + anime.title, + context.getString(R.string.syncing_library) + ) } else { - showRestoreProgress(restoreProgress, restoreAmount, anime.title, context.getString(R.string.restoring_backup)) + showRestoreProgress( + restoreProgress, + restoreAmount, + anime.title, + context.getString(R.string.restoring_backup) + ) } } @@ -338,13 +405,22 @@ class BackupRestorer( return backupAnime } - private suspend fun restoreExtras(anime: Anime, categories: List, history: List, tracks: List, backupCategories: List) { + private suspend fun restoreExtras( + anime: Anime, + categories: List, + history: List, + tracks: List, + backupCategories: List + ) { backupManager.restoreAnimeCategories(anime, categories, backupCategories) backupManager.restoreAnimeHistory(history) backupManager.restoreAnimeTracking(anime, tracks) } - private fun restorePreferences(preferences: List, sharedPrefs: SharedPreferences) { + private fun restorePreferences( + preferences: List, + sharedPrefs: SharedPreferences + ) { preferences.forEach { pref -> when (pref.value) { is IntPreferenceValue -> { @@ -396,8 +472,13 @@ class BackupRestorer( val file = File(context.cacheDir, "${it.pkgName}.apk") file.writeBytes(it.apk) val intent = Intent(Intent.ACTION_VIEW) - .setDataAndType(file.getUriCompat(context), "application/vnd.android.package-archive") - .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION) + .setDataAndType( + file.getUriCompat(context), + "application/vnd.android.package-archive" + ) + .setFlags( + Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION + ) context.startActivity(intent) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/Backup.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/Backup.kt index 3da71d26a..fe2c7e1c4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/Backup.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/Backup.kt @@ -7,11 +7,11 @@ import eu.kanade.tachiyomi.data.backup.models.BackupManga import eu.kanade.tachiyomi.data.backup.models.BackupSource import eu.kanade.tachiyomi.data.backup.models.BrokenBackupAnimeSource import eu.kanade.tachiyomi.data.backup.models.BrokenBackupSource -import kotlinx.serialization.Serializable -import kotlinx.serialization.protobuf.ProtoNumber import java.text.SimpleDateFormat import java.util.Date import java.util.Locale +import kotlinx.serialization.Serializable +import kotlinx.serialization.protobuf.ProtoNumber @Serializable data class Backup( diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/Backup.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/Backup.kt index 48bcc0a39..51baa18d6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/Backup.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/Backup.kt @@ -1,10 +1,10 @@ package eu.kanade.tachiyomi.data.backup.models -import kotlinx.serialization.Serializable -import kotlinx.serialization.protobuf.ProtoNumber import java.text.SimpleDateFormat import java.util.Date import java.util.Locale +import kotlinx.serialization.Serializable +import kotlinx.serialization.protobuf.ProtoNumber @Serializable data class Backup( diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/AnimeCoverCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/cache/AnimeCoverCache.kt index 6cc57f60b..238acc9b7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/AnimeCoverCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/AnimeCoverCache.kt @@ -2,10 +2,10 @@ package eu.kanade.tachiyomi.data.cache import android.content.Context import eu.kanade.tachiyomi.util.storage.DiskUtil -import tachiyomi.domain.entries.anime.model.Anime import java.io.File import java.io.IOException import java.io.InputStream +import tachiyomi.domain.entries.anime.model.Anime /** * Class used to create cover cache. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt index 594eaa81a..e76d537a8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt @@ -6,6 +6,8 @@ import com.jakewharton.disklrucache.DiskLruCache import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.saveTo +import java.io.File +import java.io.IOException import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json @@ -14,8 +16,6 @@ import okio.buffer import okio.sink import tachiyomi.domain.items.chapter.model.Chapter import uy.kohesive.injekt.injectLazy -import java.io.File -import java.io.IOException /** * Class used to create chapter cache diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/EpisodeCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/cache/EpisodeCache.kt index fc59c425a..ee54ceb79 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/EpisodeCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/EpisodeCache.kt @@ -6,6 +6,8 @@ import com.jakewharton.disklrucache.DiskLruCache import eu.kanade.tachiyomi.animesource.model.Video import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.saveTo +import java.io.File +import java.io.IOException import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import okhttp3.Response @@ -13,8 +15,6 @@ import okio.buffer import okio.sink import tachiyomi.domain.items.episode.model.Episode import uy.kohesive.injekt.injectLazy -import java.io.File -import java.io.IOException /** * Class used to create episode cache diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/MangaCoverCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/cache/MangaCoverCache.kt index 95ab118c7..146f75439 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/MangaCoverCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/MangaCoverCache.kt @@ -2,10 +2,10 @@ package eu.kanade.tachiyomi.data.cache import android.content.Context import eu.kanade.tachiyomi.util.storage.DiskUtil -import tachiyomi.domain.entries.manga.model.Manga import java.io.File import java.io.IOException import java.io.InputStream +import tachiyomi.domain.entries.manga.model.Manga /** * Class used to create cover cache. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/coil/AnimeCoverFetcher.kt b/app/src/main/java/eu/kanade/tachiyomi/data/coil/AnimeCoverFetcher.kt index ffe377657..2851b5241 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/coil/AnimeCoverFetcher.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/coil/AnimeCoverFetcher.kt @@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource import eu.kanade.tachiyomi.data.cache.AnimeCoverCache import eu.kanade.tachiyomi.data.coil.AnimeCoverFetcher.Companion.USE_CUSTOM_COVER import eu.kanade.tachiyomi.network.await +import java.io.File import logcat.LogPriority import okhttp3.CacheControl import okhttp3.Call @@ -29,7 +30,6 @@ import tachiyomi.domain.entries.anime.model.Anime import tachiyomi.domain.entries.anime.model.AnimeCover import tachiyomi.domain.source.anime.service.AnimeSourceManager import uy.kohesive.injekt.injectLazy -import java.io.File /** * A [Fetcher] that fetches cover image for [Anime] object. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/coil/AnimeCoverKeyer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/coil/AnimeCoverKeyer.kt index 8f2e90974..baa77cdd3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/coil/AnimeCoverKeyer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/coil/AnimeCoverKeyer.kt @@ -4,10 +4,10 @@ import coil.key.Keyer import coil.request.Options import eu.kanade.domain.entries.anime.model.hasCustomCover import eu.kanade.tachiyomi.data.cache.AnimeCoverCache +import tachiyomi.domain.entries.anime.model.Anime as DomainAnime import tachiyomi.domain.entries.anime.model.AnimeCover import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import tachiyomi.domain.entries.anime.model.Anime as DomainAnime class AnimeKeyer : Keyer { override fun key(data: DomainAnime, options: Options): String { 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 c182df801..b4abee12c 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 @@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.data.cache.MangaCoverCache import eu.kanade.tachiyomi.data.coil.MangaCoverFetcher.Companion.USE_CUSTOM_COVER import eu.kanade.tachiyomi.network.await import eu.kanade.tachiyomi.source.online.HttpSource +import java.io.File import logcat.LogPriority import okhttp3.CacheControl import okhttp3.Call @@ -29,7 +30,6 @@ import tachiyomi.domain.entries.manga.model.Manga import tachiyomi.domain.entries.manga.model.MangaCover import tachiyomi.domain.source.manga.service.MangaSourceManager import uy.kohesive.injekt.injectLazy -import java.io.File /** * A [Fetcher] that fetches cover image for [Manga] object. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/coil/MangaCoverKeyer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/coil/MangaCoverKeyer.kt index 650cf5ba9..9cb682d00 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/coil/MangaCoverKeyer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/coil/MangaCoverKeyer.kt @@ -4,10 +4,10 @@ import coil.key.Keyer import coil.request.Options import eu.kanade.domain.entries.manga.model.hasCustomCover import eu.kanade.tachiyomi.data.cache.MangaCoverCache +import tachiyomi.domain.entries.manga.model.Manga as DomainManga import tachiyomi.domain.entries.manga.model.MangaCover import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import tachiyomi.domain.entries.manga.model.Manga as DomainManga class MangaKeyer : Keyer { override fun key(data: DomainManga, options: Options): String { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt index f7616a718..7ba662651 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt @@ -6,6 +6,10 @@ import com.hippo.unifile.UniFile import eu.kanade.tachiyomi.animesource.AnimeSource import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager import eu.kanade.tachiyomi.util.size +import java.io.File +import java.util.concurrent.ConcurrentHashMap +import kotlin.time.Duration.Companion.hours +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -39,10 +43,6 @@ import tachiyomi.domain.items.episode.model.Episode import tachiyomi.domain.source.anime.service.AnimeSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.File -import java.util.concurrent.ConcurrentHashMap -import kotlin.time.Duration.Companion.hours -import kotlin.time.Duration.Companion.seconds /** * Cache where we dump the downloads directory from the filesystem. This class is needed because @@ -333,7 +333,9 @@ class AnimeDownloadCache( } } - val sourceMap = sources.associate { provider.getSourceDirName(it).lowercase() to it.id } + val sourceMap = sources.associate { + provider.getSourceDirName(it).lowercase() to it.id + } val sourceDirs = rootDownloadsDir.dir.listFiles().orEmpty() .filter { it.isDirectory && !it.name.isNullOrBlank() } @@ -364,9 +366,13 @@ class AnimeDownloadCache( // Folder of images it.isDirectory -> it.name // MP4 files - it.isFile && it.name?.endsWith(".mp4") == true -> it.name!!.substringBeforeLast(".mp4") + it.isFile && it.name?.endsWith(".mp4") == true -> it.name!!.substringBeforeLast( + ".mp4", + ) // MKV files - it.isFile && it.name?.endsWith(".mkv") == true -> it.name!!.substringBeforeLast(".mkv") + it.isFile && it.name?.endsWith(".mkv") == true -> it.name!!.substringBeforeLast( + ".mkv", + ) // Anything else is irrelevant else -> null } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadNotifier.kt index 946492dda..b8bc39f7b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadNotifier.kt @@ -14,8 +14,8 @@ import eu.kanade.tachiyomi.util.lang.chop import eu.kanade.tachiyomi.util.system.notificationBuilder import eu.kanade.tachiyomi.util.system.notificationManager import eu.kanade.tachiyomi.util.system.notify -import uy.kohesive.injekt.injectLazy import java.util.regex.Pattern +import uy.kohesive.injekt.injectLazy /** * DownloadNotifier is used to show notifications when downloading one or multiple chapters. @@ -73,7 +73,9 @@ internal class AnimeDownloadNotifier(private val context: Context) { setSmallIcon(android.R.drawable.stat_sys_download) clearActions() // Open download manager when clicked - setContentIntent(NotificationHandler.openAnimeDownloadManagerPendingActivity(context)) + setContentIntent( + NotificationHandler.openAnimeDownloadManagerPendingActivity(context) + ) isDownloading = true // Pause action addAction( @@ -95,7 +97,10 @@ internal class AnimeDownloadNotifier(private val context: Context) { } else { val title = download.anime.title.chop(15) val quotedTitle = Pattern.quote(title) - val episode = download.episode.name.replaceFirst("$quotedTitle[\\s]*[-]*[\\s]*".toRegex(RegexOption.IGNORE_CASE), "") + val episode = download.episode.name.replaceFirst( + "$quotedTitle[\\s]*[-]*[\\s]*".toRegex(RegexOption.IGNORE_CASE), + "" + ) setContentTitle("$title - $episode".chop(30)) setContentText(downloadingProgressText) } @@ -188,7 +193,9 @@ internal class AnimeDownloadNotifier(private val context: Context) { // Create notification with(errorNotificationBuilder) { setContentTitle( - animeTitle?.plus(": $episode") ?: context.getString(R.string.download_notifier_downloader_title), + animeTitle?.plus(": $episode") ?: context.getString( + R.string.download_notifier_downloader_title + ), ) setContentText(error ?: context.getString(R.string.download_notifier_unknown_error)) setSmallIcon(R.drawable.ic_warning_white_24dp) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadPendingDeleter.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadPendingDeleter.kt index 7befe2ef1..edfbf1ac9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadPendingDeleter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadPendingDeleter.kt @@ -24,7 +24,10 @@ class AnimeDownloadPendingDeleter( /** * Preferences used to store the list of episodes to delete. */ - private val preferences = context.getSharedPreferences("episodes_to_delete", Context.MODE_PRIVATE) + private val preferences = context.getSharedPreferences( + "episodes_to_delete", + Context.MODE_PRIVATE + ) /** * Last added episode, used to avoid decoding from the preference too often. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadProvider.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadProvider.kt index 2ef9324d3..4d4186b6b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadProvider.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadProvider.kt @@ -90,7 +90,12 @@ class AnimeDownloadProvider( * @param animeTitle the title of the anime to query. * @param source the source of the episode. */ - fun findEpisodeDir(episodeName: String, episodeScanlator: String?, animeTitle: String, source: AnimeSource): UniFile? { + fun findEpisodeDir( + episodeName: String, + episodeScanlator: String?, + animeTitle: String, + source: AnimeSource + ): UniFile? { val animeDir = findAnimeDir(animeTitle, source) return getValidEpisodeDirNames(episodeName, episodeScanlator).asSequence() .mapNotNull { animeDir?.findFile(it, true) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloader.kt index 6d35679d8..db731cfef 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloader.kt @@ -23,6 +23,9 @@ import eu.kanade.tachiyomi.data.library.anime.AnimeLibraryUpdateNotifier import eu.kanade.tachiyomi.data.notification.NotificationHandler import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.toFFmpegString +import java.io.File +import java.util.Locale +import kotlin.coroutines.cancellation.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -56,9 +59,6 @@ import tachiyomi.domain.source.anime.service.AnimeSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy -import java.io.File -import java.util.Locale -import kotlin.coroutines.cancellation.CancellationException /** * This class is the one in charge of downloading episodes. @@ -289,7 +289,13 @@ class AnimeDownloader( * @param episodes the list of episodes to download. * @param autoStart whether to start the downloader after enqueing the episodes. */ - fun queueEpisodes(anime: Anime, episodes: List, autoStart: Boolean, changeDownloader: Boolean = false, video: Video? = null) = launchIO { + fun queueEpisodes( + anime: Anime, + episodes: List, + autoStart: Boolean, + changeDownloader: Boolean = false, + video: Video? = null + ) = launchIO { if (episodes.isEmpty()) { return@launchIO } @@ -363,7 +369,10 @@ class AnimeDownloader( return } - val episodeDirname = provider.getEpisodeDirName(download.episode.name, download.episode.scanlator) + val episodeDirname = provider.getEpisodeDirName( + download.episode.name, + download.episode.scanlator + ) val tmpDir = animeDir.createDirectory(episodeDirname + TMP_DIR_SUFFIX) notifier.onProgressChange(download) @@ -431,7 +440,11 @@ class AnimeDownloader( * @param download the download of the video. * @param tmpDir the temporary directory of the download. */ - private suspend fun getOrAnimeDownloadVideo(video: Video, download: AnimeDownload, tmpDir: UniFile): Video { + private suspend fun getOrAnimeDownloadVideo( + video: Video, + download: AnimeDownload, + tmpDir: UniFile + ): Video { // If the video URL is empty, do nothing if (video.videoUrl == null) { return video @@ -451,12 +464,18 @@ class AnimeDownloader( // If the video is already downloaded, do nothing. Otherwise download from network val file = when { videoFile != null -> videoFile - episodeCache.isImageInCache(video.videoUrl!!) -> copyVideoFromCache(episodeCache.getVideoFile(video.videoUrl!!), tmpDir, filename) + episodeCache.isImageInCache(video.videoUrl!!) -> copyVideoFromCache( + episodeCache.getVideoFile(video.videoUrl!!), + tmpDir, + filename + ) else -> { if (preferences.useExternalDownloader().get() == download.changeDownloader) { downloadVideo(video, download, tmpDir, filename) } else { - val betterFileName = DiskUtil.buildValidFilename("${download.anime.title} - ${download.episode.name}") + val betterFileName = DiskUtil.buildValidFilename( + "${download.anime.title} - ${download.episode.name}" + ) downloadVideoExternal(video, download.source, tmpDir, betterFileName) } } @@ -485,7 +504,12 @@ class AnimeDownloader( * @param tmpDir the temporary directory of the download. * @param filename the filename of the video. */ - private suspend fun downloadVideo(video: Video, download: AnimeDownload, tmpDir: UniFile, filename: String): UniFile { + private suspend fun downloadVideo( + video: Video, + download: AnimeDownload, + tmpDir: UniFile, + filename: String + ): UniFile { video.status = Video.State.DOWNLOAD_IMAGE video.progress = 0 var tries = 0 @@ -513,7 +537,12 @@ class AnimeDownloader( return video.videoUrl?.toHttpUrl()?.encodedPath?.endsWith(".m3u8") ?: false } - private suspend fun ffmpegDownload(video: Video, download: AnimeDownload, tmpDir: UniFile, filename: String): UniFile = coroutineScope { + private suspend fun ffmpegDownload( + video: Video, + download: AnimeDownload, + tmpDir: UniFile, + filename: String + ): UniFile = coroutineScope { isFFmpegRunning = true val headers = video.headers ?: download.source.headers val headerOptions = headers.joinToString("", "-headers '", "'") { @@ -524,7 +553,9 @@ class AnimeDownloader( val ffmpegOptions = getFFmpegOptions(video, headerOptions, ffmpegFilename()) val ffprobeCommand = { file: String, ffprobeHeaders: String? -> - FFmpegKitConfig.parseArguments("${ffprobeHeaders?.plus(" ") ?: ""}-v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 \"$file\"") + FFmpegKitConfig.parseArguments( + "${ffprobeHeaders?.plus(" ") ?: ""}-v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 \"$file\"" + ) } var duration = 0L var nextLineIsDuration = false @@ -629,7 +660,12 @@ class AnimeDownloader( return hours * 3600000L + minutes * 60000L + fullSeconds * 1000L + hundredths * 10L } - private suspend fun newDownload(video: Video, download: AnimeDownload, tmpDir: UniFile, filename: String): UniFile { + private suspend fun newDownload( + video: Video, + download: AnimeDownload, + tmpDir: UniFile, + filename: String + ): UniFile { // Check if the download is paused before starting while (isPaused) { delay(1000) // This is a pause check delay, adjust the timing as needed. @@ -682,7 +718,12 @@ class AnimeDownloader( * @param tmpDir the temporary directory of the download. * @param filename the filename of the video. */ - private fun downloadVideoExternal(video: Video, source: AnimeHttpSource, tmpDir: UniFile, filename: String): UniFile { + private fun downloadVideoExternal( + video: Video, + source: AnimeHttpSource, + tmpDir: UniFile, + filename: String + ): UniFile { video.status = Video.State.DOWNLOAD_IMAGE video.progress = 0 @@ -695,12 +736,17 @@ class AnimeDownloader( val pkgName = preferences.externalDownloaderSelection().get() val intent: Intent if (!pkgName.isNullOrEmpty()) { - intent = pm.getLaunchIntentForPackage(pkgName) ?: throw Exception("Launch intent not found") + intent = pm.getLaunchIntentForPackage(pkgName) ?: throw Exception( + "Launch intent not found" + ) when { // 1DM pkgName.startsWith("idm.internet.download.manager") -> { intent.apply { - component = ComponentName(pkgName, "idm.internet.download.manager.Downloader") + component = ComponentName( + pkgName, + "idm.internet.download.manager.Downloader" + ) action = Intent.ACTION_VIEW data = Uri.parse(video.videoUrl) putExtra("extra_filename", filename) @@ -710,13 +756,22 @@ class AnimeDownloader( pkgName.startsWith("com.dv.adm") -> { val headers = (video.headers ?: source.headers).toList() val bundle = Bundle() - headers.forEach { a -> bundle.putString(a.first, a.second.replace("http", "h_ttp")) } + headers.forEach { a -> bundle.putString( + a.first, + a.second.replace("http", "h_ttp") + ) } intent.apply { component = ComponentName(pkgName, "$pkgName.AEditor") action = Intent.ACTION_VIEW - putExtra("com.dv.get.ACTION_LIST_ADD", "${Uri.parse(video.videoUrl)}$filename.mp4") - putExtra("com.dv.get.ACTION_LIST_PATH", tmpDir.filePath!!.substringBeforeLast("_")) + putExtra( + "com.dv.get.ACTION_LIST_ADD", + "${Uri.parse(video.videoUrl)}$filename.mp4" + ) + putExtra( + "com.dv.get.ACTION_LIST_PATH", + tmpDir.filePath!!.substringBeforeLast("_") + ) putExtra("android.media.intent.extra.HTTP_HEADERS", bundle) } file.delete() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt index 83e6ccedd..67ba8e36e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt @@ -8,6 +8,10 @@ import com.hippo.unifile.UniFile import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager import eu.kanade.tachiyomi.source.MangaSource import eu.kanade.tachiyomi.util.size +import java.io.File +import java.util.concurrent.ConcurrentHashMap +import kotlin.time.Duration.Companion.hours +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -50,10 +54,6 @@ import tachiyomi.domain.items.chapter.model.Chapter import tachiyomi.domain.source.manga.service.MangaSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.File -import java.util.concurrent.ConcurrentHashMap -import kotlin.time.Duration.Companion.hours -import kotlin.time.Duration.Companion.seconds /** * Cache where we dump the downloads directory from the filesystem. This class is needed because diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadManager.kt index e11c0f83b..163b17202 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadManager.kt @@ -158,7 +158,12 @@ class MangaDownloadManager( * @return the list of pages from the chapter. */ fun buildPageList(source: MangaSource, manga: Manga, chapter: Chapter): List { - val chapterDir = provider.findChapterDir(chapter.name, chapter.scanlator, manga.title, source) + val chapterDir = provider.findChapterDir( + chapter.name, + chapter.scanlator, + manga.title, + source + ) val files = chapterDir?.listFiles().orEmpty() .filter { "image" in it.type.orEmpty() } @@ -187,7 +192,13 @@ class MangaDownloadManager( sourceId: Long, skipCache: Boolean = false, ): Boolean { - return cache.isChapterDownloaded(chapterName, chapterScanlator, mangaTitle, sourceId, skipCache) + return cache.isChapterDownloaded( + chapterName, + chapterScanlator, + mangaTitle, + sourceId, + skipCache + ) } /** @@ -360,7 +371,12 @@ class MangaDownloadManager( * @param oldChapter the existing chapter with the old name. * @param newChapter the target chapter with the new name. */ - suspend fun renameChapter(source: MangaSource, manga: Manga, oldChapter: Chapter, newChapter: Chapter) { + suspend fun renameChapter( + source: MangaSource, + manga: Manga, + oldChapter: Chapter, + newChapter: Chapter + ) { val oldNames = provider.getValidChapterDirNames(oldChapter.name, oldChapter.scanlator) val mangaDir = provider.getMangaDir(manga.title, source) @@ -386,7 +402,9 @@ class MangaDownloadManager( private suspend fun getChaptersToDelete(chapters: List, manga: Manga): List { // Retrieve the categories that are set to exclude from being deleted on read - val categoriesToExclude = downloadPreferences.removeExcludeCategories().get().map(String::toLong) + val categoriesToExclude = downloadPreferences.removeExcludeCategories().get().map( + String::toLong + ) val categoriesForManga = getCategories.await(manga.id) .map { it.id } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadNotifier.kt index 22befe300..ad6c20d6a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadNotifier.kt @@ -14,8 +14,8 @@ import eu.kanade.tachiyomi.util.lang.chop import eu.kanade.tachiyomi.util.system.cancelNotification import eu.kanade.tachiyomi.util.system.notificationBuilder import eu.kanade.tachiyomi.util.system.notify -import uy.kohesive.injekt.injectLazy import java.util.regex.Pattern +import uy.kohesive.injekt.injectLazy /** * DownloadNotifier is used to show notifications when downloading one or multiple chapters. @@ -95,7 +95,10 @@ internal class MangaDownloadNotifier(private val context: Context) { } else { val title = download.manga.title.chop(15) val quotedTitle = Pattern.quote(title) - val chapter = download.chapter.name.replaceFirst("$quotedTitle[\\s]*[-]*[\\s]*".toRegex(RegexOption.IGNORE_CASE), "") + val chapter = download.chapter.name.replaceFirst( + "$quotedTitle[\\s]*[-]*[\\s]*".toRegex(RegexOption.IGNORE_CASE), + "" + ) setContentTitle("$title - $chapter".chop(30)) setContentText(downloadingProgressText) } @@ -187,7 +190,9 @@ internal class MangaDownloadNotifier(private val context: Context) { // Create notification with(errorNotificationBuilder) { setContentTitle( - mangaTitle?.plus(": $chapter") ?: context.getString(R.string.download_notifier_downloader_title), + mangaTitle?.plus(": $chapter") ?: context.getString( + R.string.download_notifier_downloader_title + ), ) setContentText(error ?: context.getString(R.string.download_notifier_unknown_error)) setSmallIcon(R.drawable.ic_warning_white_24dp) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadPendingDeleter.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadPendingDeleter.kt index ab945ab73..ee09b3226 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadPendingDeleter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadPendingDeleter.kt @@ -24,7 +24,10 @@ class MangaDownloadPendingDeleter( /** * Preferences used to store the list of chapters to delete. */ - private val preferences = context.getSharedPreferences("chapters_to_delete", Context.MODE_PRIVATE) + private val preferences = context.getSharedPreferences( + "chapters_to_delete", + Context.MODE_PRIVATE + ) /** * Last added chapter, used to avoid decoding from the preference too often. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadProvider.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadProvider.kt index f9b12f82c..84e506934 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadProvider.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadProvider.kt @@ -90,7 +90,12 @@ class MangaDownloadProvider( * @param mangaTitle the title of the manga to query. * @param source the source of the chapter. */ - fun findChapterDir(chapterName: String, chapterScanlator: String?, mangaTitle: String, source: MangaSource): UniFile? { + fun findChapterDir( + chapterName: String, + chapterScanlator: String?, + mangaTitle: String, + source: MangaSource + ): UniFile? { val mangaDir = findMangaDir(mangaTitle, source) return getValidChapterDirNames(chapterName, chapterScanlator).asSequence() .mapNotNull { mangaDir?.findFile(it, true) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt index c362ebb71..30c532a1b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloader.kt @@ -18,6 +18,11 @@ import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.DiskUtil.NOMEDIA_FILE import eu.kanade.tachiyomi.util.storage.saveTo +import java.io.BufferedOutputStream +import java.io.File +import java.util.zip.CRC32 +import java.util.zip.ZipEntry +import java.util.zip.ZipOutputStream import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -60,11 +65,6 @@ import tachiyomi.domain.items.chapter.model.Chapter import tachiyomi.domain.source.manga.service.MangaSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.BufferedOutputStream -import java.io.File -import java.util.zip.CRC32 -import java.util.zip.ZipEntry -import java.util.zip.ZipOutputStream /** * This class is the one in charge of downloading chapters. @@ -315,7 +315,10 @@ class MangaDownloader( notifier.onWarning( context.getString(R.string.download_queue_size_warning), WARNING_NOTIF_TIMEOUT_MS, - NotificationHandler.openUrl(context, MangaLibraryUpdateNotifier.HELP_WARNING_URL), + NotificationHandler.openUrl( + context, + MangaLibraryUpdateNotifier.HELP_WARNING_URL + ), ) } } @@ -335,11 +338,18 @@ class MangaDownloader( val availSpace = DiskUtil.getAvailableStorageSpace(mangaDir) if (availSpace != -1L && availSpace < MIN_DISK_SPACE) { download.status = MangaDownload.State.ERROR - notifier.onError(context.getString(R.string.download_insufficient_space), download.chapter.name, download.manga.title) + notifier.onError( + context.getString(R.string.download_insufficient_space), + download.chapter.name, + download.manga.title + ) return } - val chapterDirname = provider.getChapterDirName(download.chapter.name, download.chapter.scanlator) + val chapterDirname = provider.getChapterDirName( + download.chapter.name, + download.chapter.scanlator + ) val tmpDir = mangaDir.createDirectory(chapterDirname + TMP_DIR_SUFFIX) try { @@ -352,7 +362,12 @@ class MangaDownloader( throw Exception(context.getString(R.string.page_list_empty_error)) } // Don't trust index from source - val reIndexedPages = pages.mapIndexed { index, page -> Page(index, page.url, page.imageUrl, page.uri) } + val reIndexedPages = pages.mapIndexed { index, page -> Page( + index, + page.url, + page.imageUrl, + page.uri + ) } download.pages = reIndexedPages reIndexedPages } @@ -434,7 +449,12 @@ class MangaDownloader( * @param download the download of the page. * @param tmpDir the temporary directory of the download. */ - private suspend fun getOrDownloadImage(page: Page, download: MangaDownload, tmpDir: UniFile, dataSaver: DataSaver) { + private suspend fun getOrDownloadImage( + page: Page, + download: MangaDownload, + tmpDir: UniFile, + dataSaver: DataSaver + ) { // If the image URL is empty, do nothing if (page.imageUrl == null) { return @@ -448,13 +468,19 @@ class MangaDownloader( tmpFile?.delete() // Try to find the image file - val imageFile = tmpDir.listFiles()?.firstOrNull { it.name!!.startsWith("$filename.") || it.name!!.startsWith("${filename}__001") } + val imageFile = tmpDir.listFiles()?.firstOrNull { it.name!!.startsWith("$filename.") || it.name!!.startsWith( + "${filename}__001" + ) } try { // If the image is already downloaded, do nothing. Otherwise download from network val file = when { imageFile != null -> imageFile - chapterCache.isImageInCache(page.imageUrl!!) -> copyImageFromCache(chapterCache.getImageFile(page.imageUrl!!), tmpDir, filename) + chapterCache.isImageInCache(page.imageUrl!!) -> copyImageFromCache( + chapterCache.getImageFile(page.imageUrl!!), + tmpDir, + filename + ) else -> downloadImage(page, download.source, tmpDir, filename, dataSaver) } @@ -480,7 +506,13 @@ class MangaDownloader( * @param tmpDir the temporary directory of the download. * @param filename the filename of the image. */ - private suspend fun downloadImage(page: Page, source: HttpSource, tmpDir: UniFile, filename: String, dataSaver: DataSaver): UniFile { + private suspend fun downloadImage( + page: Page, + source: HttpSource, + tmpDir: UniFile, + filename: String, + dataSaver: DataSaver + ): UniFile { page.status = Page.State.DOWNLOAD_IMAGE page.progress = 0 return flow { @@ -552,8 +584,12 @@ class MangaDownloader( try { val filenamePrefix = String.format("%03d", page.number) - val imageFile = tmpDir.listFiles()?.firstOrNull { it.name.orEmpty().startsWith(filenamePrefix) } - ?: error(context.getString(R.string.download_notifier_split_page_not_found, page.number)) + val imageFile = tmpDir.listFiles()?.firstOrNull { it.name.orEmpty().startsWith( + filenamePrefix + ) } + ?: error( + context.getString(R.string.download_notifier_split_page_not_found, page.number) + ) // If the original page was previously split, then skip if (imageFile.name.orEmpty().startsWith("${filenamePrefix}__")) return diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/anime/AnimeLibraryUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/anime/AnimeLibraryUpdateJob.kt index 10516866f..4affb8780 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/anime/AnimeLibraryUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/anime/AnimeLibraryUpdateJob.kt @@ -33,6 +33,13 @@ import eu.kanade.tachiyomi.util.system.createFileInCacheDir import eu.kanade.tachiyomi.util.system.isConnectedToWifi import eu.kanade.tachiyomi.util.system.isRunning import eu.kanade.tachiyomi.util.system.workManager +import java.io.File +import java.time.ZonedDateTime +import java.util.Date +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicBoolean +import java.util.concurrent.atomic.AtomicInteger import kotlinx.coroutines.CancellationException import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll @@ -68,13 +75,6 @@ import tachiyomi.domain.source.anime.model.AnimeSourceNotInstalledException import tachiyomi.domain.source.anime.service.AnimeSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.File -import java.time.ZonedDateTime -import java.util.Date -import java.util.concurrent.CopyOnWriteArrayList -import java.util.concurrent.TimeUnit -import java.util.concurrent.atomic.AtomicBoolean -import java.util.concurrent.atomic.AtomicInteger class AnimeLibraryUpdateJob(private val context: Context, workerParams: WorkerParameters) : CoroutineWorker(context, workerParams) { @@ -239,19 +239,39 @@ class AnimeLibraryUpdateJob(private val context: Context, workerParams: WorkerPa ) { when { anime.updateStrategy != UpdateStrategy.ALWAYS_UPDATE -> - skippedUpdates.add(anime to context.getString(R.string.skipped_reason_not_always_update)) + skippedUpdates.add( + anime to context.getString( + R.string.skipped_reason_not_always_update + ) + ) ENTRY_NON_COMPLETED in restrictions && anime.status.toInt() == SAnime.COMPLETED -> - skippedUpdates.add(anime to context.getString(R.string.skipped_reason_completed)) + skippedUpdates.add( + anime to context.getString( + R.string.skipped_reason_completed + ) + ) ENTRY_HAS_UNVIEWED in restrictions && libraryAnime.unseenCount != 0L -> - skippedUpdates.add(anime to context.getString(R.string.skipped_reason_not_caught_up)) + skippedUpdates.add( + anime to context.getString( + R.string.skipped_reason_not_caught_up + ) + ) ENTRY_NON_VIEWED in restrictions && libraryAnime.totalEpisodes > 0L && !libraryAnime.hasStarted -> - skippedUpdates.add(anime to context.getString(R.string.skipped_reason_not_started)) + skippedUpdates.add( + anime to context.getString( + R.string.skipped_reason_not_started + ) + ) ENTRY_OUTSIDE_RELEASE_PERIOD in restrictions && anime.nextUpdate > fetchWindow.second -> - skippedUpdates.add(anime to context.getString(R.string.skipped_reason_not_in_release_period)) + skippedUpdates.add( + anime to context.getString( + R.string.skipped_reason_not_in_release_period + ) + ) else -> { try { @@ -260,7 +280,10 @@ class AnimeLibraryUpdateJob(private val context: Context, workerParams: WorkerPa if (newEpisodes.isNotEmpty()) { val categoryIds = getCategories.await(anime.id).map { it.id } - if (anime.shouldDownloadNewEpisodes(categoryIds, downloadPreferences)) { + if (anime.shouldDownloadNewEpisodes( + categoryIds, + downloadPreferences + )) { downloadEpisodes(anime, newEpisodes) hasDownloads.set(true) } @@ -268,13 +291,19 @@ class AnimeLibraryUpdateJob(private val context: Context, workerParams: WorkerPa libraryPreferences.newAnimeUpdatesCount().getAndSet { it + newEpisodes.size } // Convert to the anime that contains new chapters - newUpdates.add(anime to newEpisodes.toTypedArray()) + newUpdates.add( + anime to newEpisodes.toTypedArray() + ) } } catch (e: Throwable) { val errorMessage = when (e) { - is NoEpisodesException -> context.getString(R.string.no_episodes_error) + is NoEpisodesException -> context.getString( + R.string.no_episodes_error + ) // failedUpdates will already have the source, don't need to copy it into the message - is AnimeSourceNotInstalledException -> context.getString(R.string.loader_not_implemented_error) + is AnimeSourceNotInstalledException -> context.getString( + R.string.loader_not_implemented_error + ) else -> e.message } failedUpdates.add(anime to errorMessage) @@ -374,7 +403,11 @@ class AnimeLibraryUpdateJob(private val context: Context, workerParams: WorkerPa val source = sourceManager.get(anime.source) ?: return@withUpdateNotification try { val networkAnime = source.getAnimeDetails(anime.toSAnime()) - val updatedAnime = anime.prepUpdateCover(coverCache, networkAnime, true) + val updatedAnime = anime.prepUpdateCover( + coverCache, + networkAnime, + true + ) .copyFrom(networkAnime) try { updateAnime.await(updatedAnime.toAnimeUpdate()) @@ -408,7 +441,11 @@ class AnimeLibraryUpdateJob(private val context: Context, workerParams: WorkerPa ensureActive() val anime = libraryAnime.anime - notifier.showProgressNotification(listOf(anime), progressCount++, animeToUpdate.size) + notifier.showProgressNotification( + listOf(anime), + progressCount++, + animeToUpdate.size + ) refreshAnimeTracks(anime.id) } @@ -461,7 +498,9 @@ class AnimeLibraryUpdateJob(private val context: Context, workerParams: WorkerPa if (errors.isNotEmpty()) { val file = context.createFileInCacheDir("aniyomi_update_errors.txt") file.bufferedWriter().use { out -> - out.write(context.getString(R.string.library_errors_help, ERROR_LOG_HELP_URL) + "\n\n") + out.write( + context.getString(R.string.library_errors_help, ERROR_LOG_HELP_URL) + "\n\n" + ) // Error file format: // ! Error // # Source @@ -541,7 +580,11 @@ class AnimeLibraryUpdateJob(private val context: Context, workerParams: WorkerPa .setBackoffCriteria(BackoffPolicy.LINEAR, 10, TimeUnit.MINUTES) .build() - context.workManager.enqueueUniquePeriodicWork(WORK_NAME_AUTO, ExistingPeriodicWorkPolicy.UPDATE, request) + context.workManager.enqueueUniquePeriodicWork( + WORK_NAME_AUTO, + ExistingPeriodicWorkPolicy.UPDATE, + request + ) } else { context.workManager.cancelUniqueWork(WORK_NAME_AUTO) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/anime/AnimeLibraryUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/anime/AnimeLibraryUpdateNotifier.kt index 70e48e8bb..b054b3009 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/anime/AnimeLibraryUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/anime/AnimeLibraryUpdateNotifier.kt @@ -59,7 +59,11 @@ class AnimeLibraryUpdateNotifier(private val context: Context) { setLargeIcon(notificationBitmap) setOngoing(true) setOnlyAlertOnce(true) - addAction(R.drawable.ic_close_24dp, context.getString(R.string.action_cancel), cancelIntent) + addAction( + R.drawable.ic_close_24dp, + context.getString(R.string.action_cancel), + cancelIntent + ) } } @@ -96,7 +100,11 @@ class AnimeLibraryUpdateNotifier(private val context: Context) { Notifications.CHANNEL_LIBRARY_PROGRESS, ) { setContentTitle(context.getString(R.string.label_warning)) - setStyle(NotificationCompat.BigTextStyle().bigText(context.getString(R.string.notification_size_warning))) + setStyle( + NotificationCompat.BigTextStyle().bigText( + context.getString(R.string.notification_size_warning) + ) + ) setSmallIcon(R.drawable.ic_warning_white_24dp) setTimeoutAfter(AnimeDownloader.WARNING_NOTIF_TIMEOUT_MS) setContentIntent(NotificationHandler.openUrl(context, HELP_WARNING_URL)) @@ -140,7 +148,9 @@ class AnimeLibraryUpdateNotifier(private val context: Context) { Notifications.ID_LIBRARY_SKIPPED, Notifications.CHANNEL_LIBRARY_SKIPPED, ) { - setContentTitle(context.resources.getString(R.string.notification_update_skipped, skipped)) + setContentTitle( + context.resources.getString(R.string.notification_update_skipped, skipped) + ) setContentText(context.getString(R.string.learn_more)) setSmallIcon(R.drawable.ic_ani) setContentIntent(NotificationHandler.openUrl(context, HELP_SKIPPED_ANIME_URL)) @@ -162,7 +172,13 @@ class AnimeLibraryUpdateNotifier(private val context: Context) { if (updates.size == 1 && !preferences.hideNotificationContent().get()) { setContentText(updates.first().first.title.chop(NOTIF_ANIME_TITLE_MAX_LEN)) } else { - setContentText(context.resources.getQuantityString(R.plurals.notification_new_episodes_summary, updates.size, updates.size)) + setContentText( + context.resources.getQuantityString( + R.plurals.notification_new_episodes_summary, + updates.size, + updates.size + ) + ) if (!preferences.hideNotificationContent().get()) { setStyle( @@ -192,7 +208,10 @@ class AnimeLibraryUpdateNotifier(private val context: Context) { launchUI { context.notify( updates.map { (anime, episodes) -> - NotificationManagerCompat.NotificationWithIdAndTag(anime.id.hashCode(), createNewEpisodesNotification(anime, episodes)) + NotificationManagerCompat.NotificationWithIdAndTag( + anime.id.hashCode(), + createNewEpisodesNotification(anime, episodes) + ) }, ) } @@ -219,7 +238,9 @@ class AnimeLibraryUpdateNotifier(private val context: Context) { priority = NotificationCompat.PRIORITY_HIGH // Open first episode on tap - setContentIntent(NotificationReceiver.openEpisodePendingActivity(context, anime, episodes.first())) + setContentIntent( + NotificationReceiver.openEpisodePendingActivity(context, anime, episodes.first()) + ) setAutoCancel(true) // Mark episodes as read action @@ -288,17 +309,28 @@ class AnimeLibraryUpdateNotifier(private val context: Context) { // No sensible episode numbers to show (i.e. no episodes have parsed episode number) 0 -> { // "1 new episode" or "5 new episodes" - context.resources.getQuantityString(R.plurals.notification_episodes_generic, episodes.size, episodes.size) + context.resources.getQuantityString( + R.plurals.notification_episodes_generic, + episodes.size, + episodes.size + ) } // Only 1 episode has a parsed episode number 1 -> { val remaining = episodes.size - displayableEpisodeNumbers.size if (remaining == 0) { // "Episode 2.5" - context.resources.getString(R.string.notification_episodes_single, displayableEpisodeNumbers.first()) + context.resources.getString( + R.string.notification_episodes_single, + displayableEpisodeNumbers.first() + ) } else { // "Episode 2.5 and 10 more" - context.resources.getString(R.string.notification_episodes_single_and_more, displayableEpisodeNumbers.first(), remaining) + context.resources.getString( + R.string.notification_episodes_single_and_more, + displayableEpisodeNumbers.first(), + remaining + ) } } // Everything else (i.e. multiple parsed episode numbers) @@ -307,11 +339,21 @@ class AnimeLibraryUpdateNotifier(private val context: Context) { if (shouldTruncate) { // "Episodes 1, 2.5, 3, 4, 5 and 10 more" val remaining = displayableEpisodeNumbers.size - NOTIF_MAX_EPISODES - val joinedEpisodeNumbers = displayableEpisodeNumbers.take(NOTIF_MAX_EPISODES).joinToString(", ") - context.resources.getQuantityString(R.plurals.notification_episodes_multiple_and_more, remaining, joinedEpisodeNumbers, remaining) + val joinedEpisodeNumbers = displayableEpisodeNumbers.take(NOTIF_MAX_EPISODES).joinToString( + ", " + ) + context.resources.getQuantityString( + R.plurals.notification_episodes_multiple_and_more, + remaining, + joinedEpisodeNumbers, + remaining + ) } else { // "Episodes 1, 2.5, 3" - context.resources.getString(R.string.notification_episodes_multiple, displayableEpisodeNumbers.joinToString(", ")) + context.resources.getString( + R.string.notification_episodes_multiple, + displayableEpisodeNumbers.joinToString(", ") + ) } } } @@ -325,7 +367,12 @@ class AnimeLibraryUpdateNotifier(private val context: Context) { flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP action = Constants.SHORTCUT_UPDATES } - return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getActivity( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } companion object { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/manga/MangaLibraryUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/manga/MangaLibraryUpdateJob.kt index 4f668af11..5761ef8c2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/manga/MangaLibraryUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/manga/MangaLibraryUpdateJob.kt @@ -33,6 +33,13 @@ import eu.kanade.tachiyomi.util.system.createFileInCacheDir import eu.kanade.tachiyomi.util.system.isConnectedToWifi import eu.kanade.tachiyomi.util.system.isRunning import eu.kanade.tachiyomi.util.system.workManager +import java.io.File +import java.time.ZonedDateTime +import java.util.Date +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicBoolean +import java.util.concurrent.atomic.AtomicInteger import kotlinx.coroutines.CancellationException import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll @@ -68,13 +75,6 @@ import tachiyomi.domain.source.manga.model.SourceNotInstalledException import tachiyomi.domain.source.manga.service.MangaSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.File -import java.time.ZonedDateTime -import java.util.Date -import java.util.concurrent.CopyOnWriteArrayList -import java.util.concurrent.TimeUnit -import java.util.concurrent.atomic.AtomicBoolean -import java.util.concurrent.atomic.AtomicInteger class MangaLibraryUpdateJob(private val context: Context, workerParams: WorkerParameters) : CoroutineWorker(context, workerParams) { @@ -239,19 +239,39 @@ class MangaLibraryUpdateJob(private val context: Context, workerParams: WorkerPa ) { when { manga.updateStrategy != UpdateStrategy.ALWAYS_UPDATE -> - skippedUpdates.add(manga to context.getString(R.string.skipped_reason_not_always_update)) + skippedUpdates.add( + manga to context.getString( + R.string.skipped_reason_not_always_update + ) + ) ENTRY_NON_COMPLETED in restrictions && manga.status.toInt() == SManga.COMPLETED -> - skippedUpdates.add(manga to context.getString(R.string.skipped_reason_completed)) + skippedUpdates.add( + manga to context.getString( + R.string.skipped_reason_completed + ) + ) ENTRY_HAS_UNVIEWED in restrictions && libraryManga.unreadCount != 0L -> - skippedUpdates.add(manga to context.getString(R.string.skipped_reason_not_caught_up)) + skippedUpdates.add( + manga to context.getString( + R.string.skipped_reason_not_caught_up + ) + ) ENTRY_NON_VIEWED in restrictions && libraryManga.totalChapters > 0L && !libraryManga.hasStarted -> - skippedUpdates.add(manga to context.getString(R.string.skipped_reason_not_started)) + skippedUpdates.add( + manga to context.getString( + R.string.skipped_reason_not_started + ) + ) ENTRY_OUTSIDE_RELEASE_PERIOD in restrictions && manga.nextUpdate > fetchWindow.second -> - skippedUpdates.add(manga to context.getString(R.string.skipped_reason_not_in_release_period)) + skippedUpdates.add( + manga to context.getString( + R.string.skipped_reason_not_in_release_period + ) + ) else -> { try { @@ -260,7 +280,10 @@ class MangaLibraryUpdateJob(private val context: Context, workerParams: WorkerPa if (newChapters.isNotEmpty()) { val categoryIds = getCategories.await(manga.id).map { it.id } - if (manga.shouldDownloadNewChapters(categoryIds, downloadPreferences)) { + if (manga.shouldDownloadNewChapters( + categoryIds, + downloadPreferences + )) { downloadChapters(manga, newChapters) hasDownloads.set(true) } @@ -268,13 +291,19 @@ class MangaLibraryUpdateJob(private val context: Context, workerParams: WorkerPa libraryPreferences.newMangaUpdatesCount().getAndSet { it + newChapters.size } // Convert to the manga that contains new chapters - newUpdates.add(manga to newChapters.toTypedArray()) + newUpdates.add( + manga to newChapters.toTypedArray() + ) } } catch (e: Throwable) { val errorMessage = when (e) { - is NoChaptersException -> context.getString(R.string.no_chapters_error) + is NoChaptersException -> context.getString( + R.string.no_chapters_error + ) // failedUpdates will already have the source, don't need to copy it into the message - is SourceNotInstalledException -> context.getString(R.string.loader_not_implemented_error) + is SourceNotInstalledException -> context.getString( + R.string.loader_not_implemented_error + ) else -> e.message } failedUpdates.add(manga to errorMessage) @@ -374,7 +403,11 @@ class MangaLibraryUpdateJob(private val context: Context, workerParams: WorkerPa val source = sourceManager.get(manga.source) ?: return@withUpdateNotification try { val networkManga = source.getMangaDetails(manga.toSManga()) - val updatedManga = manga.prepUpdateCover(coverCache, networkManga, true) + val updatedManga = manga.prepUpdateCover( + coverCache, + networkManga, + true + ) .copyFrom(networkManga) try { updateManga.await(updatedManga.toMangaUpdate()) @@ -408,7 +441,11 @@ class MangaLibraryUpdateJob(private val context: Context, workerParams: WorkerPa ensureActive() val manga = libraryManga.manga - notifier.showProgressNotification(listOf(manga), progressCount++, mangaToUpdate.size) + notifier.showProgressNotification( + listOf(manga), + progressCount++, + mangaToUpdate.size + ) refreshMangaTracks(manga.id) } @@ -461,7 +498,9 @@ class MangaLibraryUpdateJob(private val context: Context, workerParams: WorkerPa if (errors.isNotEmpty()) { val file = context.createFileInCacheDir("tachiyomi_update_errors.txt") file.bufferedWriter().use { out -> - out.write(context.getString(R.string.library_errors_help, ERROR_LOG_HELP_URL) + "\n\n") + out.write( + context.getString(R.string.library_errors_help, ERROR_LOG_HELP_URL) + "\n\n" + ) // Error file format: // ! Error // # Source @@ -540,7 +579,11 @@ class MangaLibraryUpdateJob(private val context: Context, workerParams: WorkerPa .setBackoffCriteria(BackoffPolicy.LINEAR, 10, TimeUnit.MINUTES) .build() - context.workManager.enqueueUniquePeriodicWork(WORK_NAME_AUTO, ExistingPeriodicWorkPolicy.UPDATE, request) + context.workManager.enqueueUniquePeriodicWork( + WORK_NAME_AUTO, + ExistingPeriodicWorkPolicy.UPDATE, + request + ) } else { context.workManager.cancelUniqueWork(WORK_NAME_AUTO) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/manga/MangaLibraryUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/manga/MangaLibraryUpdateNotifier.kt index 2150ac845..f974be0c2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/manga/MangaLibraryUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/manga/MangaLibraryUpdateNotifier.kt @@ -59,7 +59,11 @@ class MangaLibraryUpdateNotifier(private val context: Context) { setLargeIcon(notificationBitmap) setOngoing(true) setOnlyAlertOnce(true) - addAction(R.drawable.ic_close_24dp, context.getString(R.string.action_cancel), cancelIntent) + addAction( + R.drawable.ic_close_24dp, + context.getString(R.string.action_cancel), + cancelIntent + ) } } @@ -143,7 +147,9 @@ class MangaLibraryUpdateNotifier(private val context: Context) { Notifications.ID_LIBRARY_SKIPPED, Notifications.CHANNEL_LIBRARY_SKIPPED, ) { - setContentTitle(context.resources.getString(R.string.notification_update_skipped, skipped)) + setContentTitle( + context.resources.getString(R.string.notification_update_skipped, skipped) + ) setContentText(context.getString(R.string.learn_more)) setSmallIcon(R.drawable.ic_ani) setContentIntent(NotificationHandler.openUrl(context, HELP_SKIPPED_MANGA_URL)) @@ -165,7 +171,13 @@ class MangaLibraryUpdateNotifier(private val context: Context) { if (updates.size == 1 && !preferences.hideNotificationContent().get()) { setContentText(updates.first().first.title.chop(NOTIF_MANGA_TITLE_MAX_LEN)) } else { - setContentText(context.resources.getQuantityString(R.plurals.notification_new_chapters_summary, updates.size, updates.size)) + setContentText( + context.resources.getQuantityString( + R.plurals.notification_new_chapters_summary, + updates.size, + updates.size + ) + ) if (!preferences.hideNotificationContent().get()) { setStyle( @@ -195,7 +207,10 @@ class MangaLibraryUpdateNotifier(private val context: Context) { launchUI { context.notify( updates.map { (manga, chapters) -> - NotificationManagerCompat.NotificationWithIdAndTag(manga.id.hashCode(), createNewChaptersNotification(manga, chapters)) + NotificationManagerCompat.NotificationWithIdAndTag( + manga.id.hashCode(), + createNewChaptersNotification(manga, chapters) + ) }, ) } @@ -297,17 +312,28 @@ class MangaLibraryUpdateNotifier(private val context: Context) { // No sensible chapter numbers to show (i.e. no chapters have parsed chapter number) 0 -> { // "1 new chapter" or "5 new chapters" - context.resources.getQuantityString(R.plurals.notification_chapters_generic, chapters.size, chapters.size) + context.resources.getQuantityString( + R.plurals.notification_chapters_generic, + chapters.size, + chapters.size + ) } // Only 1 chapter has a parsed chapter number 1 -> { val remaining = chapters.size - displayableChapterNumbers.size if (remaining == 0) { // "Chapter 2.5" - context.resources.getString(R.string.notification_chapters_single, displayableChapterNumbers.first()) + context.resources.getString( + R.string.notification_chapters_single, + displayableChapterNumbers.first() + ) } else { // "Chapter 2.5 and 10 more" - context.resources.getString(R.string.notification_chapters_single_and_more, displayableChapterNumbers.first(), remaining) + context.resources.getString( + R.string.notification_chapters_single_and_more, + displayableChapterNumbers.first(), + remaining + ) } } // Everything else (i.e. multiple parsed chapter numbers) @@ -316,11 +342,21 @@ class MangaLibraryUpdateNotifier(private val context: Context) { if (shouldTruncate) { // "Chapters 1, 2.5, 3, 4, 5 and 10 more" val remaining = displayableChapterNumbers.size - NOTIF_MAX_CHAPTERS - val joinedChapterNumbers = displayableChapterNumbers.take(NOTIF_MAX_CHAPTERS).joinToString(", ") - context.resources.getQuantityString(R.plurals.notification_chapters_multiple_and_more, remaining, joinedChapterNumbers, remaining) + val joinedChapterNumbers = displayableChapterNumbers.take(NOTIF_MAX_CHAPTERS).joinToString( + ", " + ) + context.resources.getQuantityString( + R.plurals.notification_chapters_multiple_and_more, + remaining, + joinedChapterNumbers, + remaining + ) } else { // "Chapters 1, 2.5, 3" - context.resources.getString(R.string.notification_chapters_multiple, displayableChapterNumbers.joinToString(", ")) + context.resources.getString( + R.string.notification_chapters_multiple, + displayableChapterNumbers.joinToString(", ") + ) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationHandler.kt index 29d8148df..6d6f069ad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationHandler.kt @@ -23,7 +23,12 @@ object NotificationHandler { flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP action = Constants.SHORTCUT_DOWNLOADS } - return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getActivity( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -50,7 +55,12 @@ object NotificationHandler { setDataAndType(uri, "image/*") flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION } - return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getActivity( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -69,6 +79,11 @@ object NotificationHandler { fun openUrl(context: Context, url: String): PendingIntent { val notificationIntent = Intent(Intent.ACTION_VIEW, url.toUri()) - return PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getActivity( + context, + 0, + notificationIntent, + PendingIntent.FLAG_IMMUTABLE + ) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt index 876e3969b..49bf56959 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt @@ -7,6 +7,7 @@ import android.content.Intent import android.net.Uri import android.os.Build import androidx.core.net.toUri +import eu.kanade.tachiyomi.BuildConfig.APPLICATION_ID as ID import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.core.Constants import eu.kanade.tachiyomi.data.backup.BackupRestoreJob @@ -25,6 +26,7 @@ import eu.kanade.tachiyomi.util.system.getParcelableExtraCompat import eu.kanade.tachiyomi.util.system.notificationManager import eu.kanade.tachiyomi.util.system.toShareIntent import eu.kanade.tachiyomi.util.system.toast +import java.io.File import kotlinx.coroutines.runBlocking import tachiyomi.core.util.lang.launchIO import tachiyomi.domain.download.service.DownloadPreferences @@ -45,8 +47,6 @@ import tachiyomi.domain.source.manga.service.MangaSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy -import java.io.File -import eu.kanade.tachiyomi.BuildConfig.APPLICATION_ID as ID /** * Global [BroadcastReceiver] that runs on UI thread @@ -67,7 +67,10 @@ class NotificationReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { when (intent.action) { // Dismiss notification - ACTION_DISMISS_NOTIFICATION -> dismissNotification(context, intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1)) + ACTION_DISMISS_NOTIFICATION -> dismissNotification( + context, + intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1) + ) // Resume the download service ACTION_RESUME_DOWNLOADS -> mangaDownloadManager.startDownloads() // Pause the download service @@ -127,7 +130,11 @@ class NotificationReceiver : BroadcastReceiver() { ACTION_MARK_AS_READ -> { val notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1) if (notificationId > -1) { - dismissNotification(context, notificationId, intent.getIntExtra(EXTRA_GROUP_ID, 0)) + dismissNotification( + context, + notificationId, + intent.getIntExtra(EXTRA_GROUP_ID, 0) + ) } val urls = intent.getStringArrayExtra(EXTRA_CHAPTER_URL) ?: return val mangaId = intent.getLongExtra(EXTRA_MANGA_ID, -1) @@ -139,7 +146,11 @@ class NotificationReceiver : BroadcastReceiver() { ACTION_MARK_AS_SEEN -> { val notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1) if (notificationId > -1) { - dismissNotification(context, notificationId, intent.getIntExtra(EXTRA_GROUP_ID, 0)) + dismissNotification( + context, + notificationId, + intent.getIntExtra(EXTRA_GROUP_ID, 0) + ) } val urls = intent.getStringArrayExtra(EXTRA_CHAPTER_URL) ?: return val animeId = intent.getLongExtra(EXTRA_MANGA_ID, -1) @@ -151,7 +162,11 @@ class NotificationReceiver : BroadcastReceiver() { ACTION_DOWNLOAD_CHAPTER -> { val notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1) if (notificationId > -1) { - dismissNotification(context, notificationId, intent.getIntExtra(EXTRA_GROUP_ID, 0)) + dismissNotification( + context, + notificationId, + intent.getIntExtra(EXTRA_GROUP_ID, 0) + ) } val urls = intent.getStringArrayExtra(EXTRA_CHAPTER_URL) ?: return val mangaId = intent.getLongExtra(EXTRA_MANGA_ID, -1) @@ -163,7 +178,11 @@ class NotificationReceiver : BroadcastReceiver() { ACTION_DOWNLOAD_EPISODE -> { val notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1) if (notificationId > -1) { - dismissNotification(context, notificationId, intent.getIntExtra(EXTRA_GROUP_ID, 0)) + dismissNotification( + context, + notificationId, + intent.getIntExtra(EXTRA_GROUP_ID, 0) + ) } val urls = intent.getStringArrayExtra(EXTRA_CHAPTER_URL) ?: return val animeId = intent.getLongExtra(EXTRA_MANGA_ID, -1) @@ -432,7 +451,12 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_RESUME_DOWNLOADS } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -445,7 +469,12 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_PAUSE_DOWNLOADS } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -458,7 +487,12 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_CLEAR_DOWNLOADS } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -471,7 +505,12 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_RESUME_ANIME_DOWNLOADS } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -484,7 +523,12 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_PAUSE_ANIME_DOWNLOADS } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -497,7 +541,12 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_CLEAR_ANIME_DOWNLOADS } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -512,7 +561,12 @@ class NotificationReceiver : BroadcastReceiver() { action = ACTION_DISMISS_NOTIFICATION putExtra(EXTRA_NOTIFICATION_ID, notificationId) } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -522,7 +576,11 @@ class NotificationReceiver : BroadcastReceiver() { * @param notificationId id of notification * @return [PendingIntent] */ - internal fun dismissNotification(context: Context, notificationId: Int, groupId: Int? = null) { + internal fun dismissNotification( + context: Context, + notificationId: Int, + groupId: Int? = null + ) { /* Group notifications always have at least 2 notifications: - Group summary notification @@ -567,7 +625,12 @@ class NotificationReceiver : BroadcastReceiver() { putExtra(EXTRA_FILE_LOCATION, path) putExtra(EXTRA_NOTIFICATION_ID, notificationId) } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -578,13 +641,22 @@ class NotificationReceiver : BroadcastReceiver() { * @param notificationId id of notification * @return [PendingIntent] */ - internal fun deleteImagePendingBroadcast(context: Context, path: String, notificationId: Int): PendingIntent { + internal fun deleteImagePendingBroadcast( + context: Context, + path: String, + notificationId: Int + ): PendingIntent { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_DELETE_IMAGE putExtra(EXTRA_FILE_LOCATION, path) putExtra(EXTRA_NOTIFICATION_ID, notificationId) } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -596,7 +668,12 @@ class NotificationReceiver : BroadcastReceiver() { */ internal fun openEpisodePendingActivity(context: Context, anime: Anime, episode: Episode): PendingIntent { val newIntent = PlayerActivity.newIntent(context, anime.id, episode.id) - return PendingIntent.getActivity(context, anime.id.hashCode(), newIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getActivity( + context, + anime.id.hashCode(), + newIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -612,7 +689,12 @@ class NotificationReceiver : BroadcastReceiver() { .putExtra(Constants.ANIME_EXTRA, anime.id) .putExtra("notificationId", anime.id.hashCode()) .putExtra("groupId", groupId) - return PendingIntent.getActivity(context, anime.id.hashCode(), newIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getActivity( + context, + anime.id.hashCode(), + newIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -634,7 +716,12 @@ class NotificationReceiver : BroadcastReceiver() { putExtra(EXTRA_NOTIFICATION_ID, anime.id.hashCode()) putExtra(EXTRA_GROUP_ID, groupId) } - return PendingIntent.getBroadcast(context, anime.id.hashCode(), newIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + anime.id.hashCode(), + newIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -646,7 +733,12 @@ class NotificationReceiver : BroadcastReceiver() { */ internal fun openChapterPendingActivity(context: Context, manga: Manga, chapter: Chapter): PendingIntent { val newIntent = ReaderActivity.newIntent(context, manga.id, chapter.id) - return PendingIntent.getActivity(context, manga.id.hashCode(), newIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getActivity( + context, + manga.id.hashCode(), + newIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -662,7 +754,12 @@ class NotificationReceiver : BroadcastReceiver() { .putExtra(Constants.MANGA_EXTRA, manga.id) .putExtra("notificationId", manga.id.hashCode()) .putExtra("groupId", groupId) - return PendingIntent.getActivity(context, manga.id.hashCode(), newIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getActivity( + context, + manga.id.hashCode(), + newIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -684,7 +781,12 @@ class NotificationReceiver : BroadcastReceiver() { putExtra(EXTRA_NOTIFICATION_ID, manga.id.hashCode()) putExtra(EXTRA_GROUP_ID, groupId) } - return PendingIntent.getBroadcast(context, manga.id.hashCode(), newIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + manga.id.hashCode(), + newIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -706,7 +808,12 @@ class NotificationReceiver : BroadcastReceiver() { putExtra(EXTRA_NOTIFICATION_ID, manga.id.hashCode()) putExtra(EXTRA_GROUP_ID, groupId) } - return PendingIntent.getBroadcast(context, manga.id.hashCode(), newIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + manga.id.hashCode(), + newIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -728,7 +835,12 @@ class NotificationReceiver : BroadcastReceiver() { putExtra(EXTRA_NOTIFICATION_ID, anime.id.hashCode()) putExtra(EXTRA_GROUP_ID, groupId) } - return PendingIntent.getBroadcast(context, anime.id.hashCode(), newIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + anime.id.hashCode(), + newIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -741,7 +853,12 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_CANCEL_LIBRARY_UPDATE } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -754,7 +871,12 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_CANCEL_ANIMELIB_UPDATE } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -764,7 +886,12 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_CANCEL_APP_UPDATE_DOWNLOAD } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -778,7 +905,12 @@ class NotificationReceiver : BroadcastReceiver() { action = Constants.SHORTCUT_EXTENSIONS addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) } - return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getActivity( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -792,7 +924,12 @@ class NotificationReceiver : BroadcastReceiver() { action = Constants.SHORTCUT_ANIMEEXTENSIONS addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) } - return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getActivity( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -809,7 +946,12 @@ class NotificationReceiver : BroadcastReceiver() { putExtra(EXTRA_URI, uri) putExtra(EXTRA_NOTIFICATION_ID, notificationId) } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } /** @@ -840,7 +982,12 @@ class NotificationReceiver : BroadcastReceiver() { action = ACTION_CANCEL_RESTORE putExtra(EXTRA_NOTIFICATION_ID, notificationId) } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + return PendingIntent.getBroadcast( + context, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt index 9656c0fd9..4a2be16b3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt @@ -15,14 +15,14 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.cacheImageDir import eu.kanade.tachiyomi.util.storage.getUriCompat -import logcat.LogPriority -import okio.IOException -import tachiyomi.core.util.system.ImageUtil -import tachiyomi.core.util.system.logcat import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.File import java.io.InputStream +import logcat.LogPriority +import okio.IOException +import tachiyomi.core.util.system.ImageUtil +import tachiyomi.core.util.system.logcat class ImageSaver( val context: Context, @@ -42,7 +42,9 @@ class ImageSaver( val pictureDir = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY) - val folderRelativePath = "${Environment.DIRECTORY_PICTURES}/${context.getString(R.string.app_name)}/" + val folderRelativePath = "${Environment.DIRECTORY_PICTURES}/${context.getString( + R.string.app_name + )}/" val imageLocation = (image.location as Location.Pictures).relativePath val contentValues = contentValuesOf( @@ -111,9 +113,14 @@ class ImageSaver( ).use { cursor -> if (cursor != null && cursor.count >= 1) { cursor.moveToFirst().let { - val id = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns._ID)) + val id = cursor.getLong( + cursor.getColumnIndexOrThrow(MediaStore.MediaColumns._ID) + ) - return ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id) + return ContentUris.withAppendedId( + MediaStore.Images.Media.EXTERNAL_CONTENT_URI, + id + ) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/AnimeTrackService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/AnimeTrackService.kt index c5aa6fec7..66dd397ce 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/AnimeTrackService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/AnimeTrackService.kt @@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.data.database.models.anime.AnimeTrack import eu.kanade.tachiyomi.data.track.model.AnimeTrackSearch import eu.kanade.tachiyomi.util.lang.convertEpochMillisZone import eu.kanade.tachiyomi.util.system.toast +import java.time.ZoneOffset import logcat.LogPriority import tachiyomi.core.util.lang.withIOContext import tachiyomi.core.util.lang.withUIContext @@ -15,11 +16,10 @@ import tachiyomi.core.util.system.logcat import tachiyomi.domain.history.anime.interactor.GetAnimeHistory import tachiyomi.domain.items.episode.interactor.GetEpisodeByAnimeId import tachiyomi.domain.track.anime.interactor.InsertAnimeTrack +import tachiyomi.domain.track.anime.model.AnimeTrack as DomainAnimeTrack import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy -import java.time.ZoneOffset -import tachiyomi.domain.track.anime.model.AnimeTrack as DomainAnimeTrack private val insertTrack: InsertAnimeTrack by injectLazy() private val syncEpisodeProgressWithTrack: SyncEpisodeProgressWithTrack by injectLazy() @@ -83,7 +83,10 @@ interface AnimeTrackService { track = track.copy( lastEpisodeSeen = latestLocalSeenEpisodeNumber, ) - setRemoteLastEpisodeSeen(track.toDbTrack(), latestLocalSeenEpisodeNumber.toInt()) + setRemoteLastEpisodeSeen( + track.toDbTrack(), + latestLocalSeenEpisodeNumber.toInt() + ) } if (track.startDate <= 0) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/MangaTrackService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/MangaTrackService.kt index 815544565..4284e20b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/MangaTrackService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/MangaTrackService.kt @@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.data.database.models.manga.MangaTrack import eu.kanade.tachiyomi.data.track.model.MangaTrackSearch import eu.kanade.tachiyomi.util.lang.convertEpochMillisZone import eu.kanade.tachiyomi.util.system.toast +import java.time.ZoneOffset import logcat.LogPriority import tachiyomi.core.util.lang.withIOContext import tachiyomi.core.util.lang.withUIContext @@ -15,11 +16,10 @@ import tachiyomi.core.util.system.logcat import tachiyomi.domain.history.manga.interactor.GetMangaHistory import tachiyomi.domain.items.chapter.interactor.GetChapterByMangaId import tachiyomi.domain.track.manga.interactor.InsertMangaTrack +import tachiyomi.domain.track.manga.model.MangaTrack as DomainTrack import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy -import java.time.ZoneOffset -import tachiyomi.domain.track.manga.model.MangaTrack as DomainTrack private val insertTrack: InsertMangaTrack by injectLazy() private val syncChapterProgressWithTrack: SyncChapterProgressWithTrack by injectLazy() @@ -83,7 +83,10 @@ interface MangaTrackService { track = track.copy( lastChapterRead = latestLocalReadChapterNumber, ) - setRemoteLastChapterRead(track.toDbTrack(), latestLocalReadChapterNumber.toInt()) + setRemoteLastChapterRead( + track.toDbTrack(), + latestLocalReadChapterNumber.toInt() + ) } if (track.startDate <= 0) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt index 4e6543d2e..96114b877 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt @@ -15,9 +15,9 @@ import eu.kanade.tachiyomi.data.track.model.MangaTrackSearch import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import uy.kohesive.injekt.injectLazy import tachiyomi.domain.track.anime.model.AnimeTrack as DomainAnimeTrack import tachiyomi.domain.track.manga.model.MangaTrack as DomainTrack +import uy.kohesive.injekt.injectLazy class Anilist(id: Long) : TrackService(id, "AniList"), MangaTrackService, AnimeTrackService, DeletableMangaTrackService, DeletableAnimeTrackService { 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 fffcb1b3d..29bd3b097 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 @@ -11,6 +11,8 @@ import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.network.jsonMime import eu.kanade.tachiyomi.network.parseAs +import java.util.Calendar +import kotlin.time.Duration.Companion.minutes import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonNull import kotlinx.serialization.json.JsonObject @@ -28,8 +30,6 @@ import okhttp3.OkHttpClient import okhttp3.RequestBody.Companion.toRequestBody import tachiyomi.core.util.lang.withIOContext import uy.kohesive.injekt.injectLazy -import java.util.Calendar -import kotlin.time.Duration.Companion.minutes class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistInterceptor.kt index 8c21070c4..e1c095a51 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistInterceptor.kt @@ -1,8 +1,8 @@ package eu.kanade.tachiyomi.data.track.anilist +import java.io.IOException import okhttp3.Interceptor import okhttp3.Response -import java.io.IOException class AnilistInterceptor(val anilist: Anilist, private var token: String?) : Interceptor { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt index d1a1d7ae6..729b6218c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt @@ -6,10 +6,10 @@ import eu.kanade.tachiyomi.data.database.models.manga.MangaTrack import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.model.AnimeTrackSearch import eu.kanade.tachiyomi.data.track.model.MangaTrackSearch -import kotlinx.serialization.Serializable -import uy.kohesive.injekt.injectLazy import java.text.SimpleDateFormat import java.util.Locale +import kotlinx.serialization.Serializable +import uy.kohesive.injekt.injectLazy data class ALManga( val media_id: Long, 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 da1f89834..f085daf72 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 @@ -11,6 +11,8 @@ import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.parseAs +import java.net.URLEncoder +import java.nio.charset.StandardCharsets import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObject @@ -26,8 +28,6 @@ import okhttp3.OkHttpClient import okhttp3.Request import tachiyomi.core.util.lang.withIOContext import uy.kohesive.injekt.injectLazy -import java.net.URLEncoder -import java.nio.charset.StandardCharsets class BangumiApi(private val client: OkHttpClient, interceptor: BangumiInterceptor) { @@ -111,7 +111,10 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept suspend fun search(search: String): List { return withIOContext { - val url = "$apiUrl/search/subject/${URLEncoder.encode(search, StandardCharsets.UTF_8.name())}" + val url = "$apiUrl/search/subject/${URLEncoder.encode( + search, + StandardCharsets.UTF_8.name() + )}" .toUri() .buildUpon() .appendQueryParameter("max_results", "20") @@ -135,7 +138,10 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept suspend fun searchAnime(search: String): List { return withIOContext { - val url = "$apiUrl/search/subject/${URLEncoder.encode(search, StandardCharsets.UTF_8.name())}" + val url = "$apiUrl/search/subject/${URLEncoder.encode( + search, + StandardCharsets.UTF_8.name() + )}" .toUri() .buildUpon() .appendQueryParameter("max_results", "20") diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kavita/Kavita.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kavita/Kavita.kt index 15d221c2d..5c8160c8e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kavita/Kavita.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kavita/Kavita.kt @@ -11,8 +11,8 @@ import eu.kanade.tachiyomi.data.track.MangaTrackService import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.model.MangaTrackSearch import eu.kanade.tachiyomi.source.MangaSource -import tachiyomi.domain.entries.manga.model.Manga import java.security.MessageDigest +import tachiyomi.domain.entries.manga.model.Manga import tachiyomi.domain.track.manga.model.MangaTrack as DomainTrack class Kavita(private val context: Context, id: Long) : TrackService(id, "Kavita"), EnhancedMangaTrackService, MangaTrackService { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kavita/KavitaApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kavita/KavitaApi.kt index 739e10aa9..6becbc3e4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kavita/KavitaApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kavita/KavitaApi.kt @@ -6,6 +6,8 @@ import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.parseAs +import java.io.IOException +import java.net.SocketTimeoutException import kotlinx.serialization.json.Json import logcat.LogPriority import okhttp3.Dns @@ -15,8 +17,6 @@ import okhttp3.RequestBody.Companion.toRequestBody import tachiyomi.core.util.lang.withIOContext import tachiyomi.core.util.system.logcat import uy.kohesive.injekt.injectLazy -import java.io.IOException -import java.net.SocketTimeoutException class KavitaApi(private val client: OkHttpClient, interceptor: KavitaInterceptor) { @@ -164,8 +164,15 @@ class KavitaApi(private val client: OkHttpClient, interceptor: KavitaInterceptor } suspend fun updateProgress(track: MangaTrack): MangaTrack { - val requestUrl = "${getApiFromUrl(track.tracking_url)}/Tachiyomi/mark-chapter-until-as-read?seriesId=${getIdFromUrl(track.tracking_url)}&chapterNumber=${track.last_chapter_read}" - authClient.newCall(POST(requestUrl, body = "{}".toRequestBody("application/json; charset=utf-8".toMediaTypeOrNull()))) + val requestUrl = "${getApiFromUrl(track.tracking_url)}/Tachiyomi/mark-chapter-until-as-read?seriesId=${getIdFromUrl( + track.tracking_url + )}&chapterNumber=${track.last_chapter_read}" + authClient.newCall( + POST( + requestUrl, + body = "{}".toRequestBody("application/json; charset=utf-8".toMediaTypeOrNull()) + ) + ) .awaitSuccess() return getTrackSearch(track.tracking_url) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt index ddc2bf7aa..398b14bbe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt @@ -12,11 +12,11 @@ import eu.kanade.tachiyomi.data.track.MangaTrackService import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.model.AnimeTrackSearch import eu.kanade.tachiyomi.data.track.model.MangaTrackSearch +import java.text.DecimalFormat import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import uy.kohesive.injekt.injectLazy -import java.text.DecimalFormat class Kitsu(id: Long) : TrackService(id, "Kitsu"), AnimeTrackService, MangaTrackService, DeletableMangaTrackService, DeletableAnimeTrackService { 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 6772c977b..50519c4b8 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 @@ -11,6 +11,8 @@ import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.jsonMime import eu.kanade.tachiyomi.network.parseAs +import java.net.URLEncoder +import java.nio.charset.StandardCharsets import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.buildJsonObject @@ -29,8 +31,6 @@ import okhttp3.RequestBody import okhttp3.RequestBody.Companion.toRequestBody import tachiyomi.core.util.lang.withIOContext import uy.kohesive.injekt.injectLazy -import java.net.URLEncoder -import java.nio.charset.StandardCharsets class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) { @@ -277,7 +277,10 @@ 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())}$algoliaFilter" + ) } with(json) { @@ -308,7 +311,10 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) private suspend fun algoliaSearchAnime(key: String, query: String): List { return withIOContext { val jsonObject = buildJsonObject { - put("params", "query=${URLEncoder.encode(query, StandardCharsets.UTF_8.name())}$algoliaFilterAnime") + put( + "params", + "query=${URLEncoder.encode(query, StandardCharsets.UTF_8.name())}$algoliaFilterAnime" + ) } with(json) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuModels.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuModels.kt index 9f4e29d67..693e20820 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuModels.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuModels.kt @@ -6,6 +6,9 @@ import eu.kanade.tachiyomi.data.database.models.manga.MangaTrack import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.model.AnimeTrackSearch import eu.kanade.tachiyomi.data.track.model.MangaTrackSearch +import java.text.SimpleDateFormat +import java.util.Date +import java.util.Locale import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.contentOrNull @@ -14,9 +17,6 @@ import kotlinx.serialization.json.intOrNull import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive import kotlinx.serialization.json.long -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale class KitsuSearchManga(obj: JsonObject) { val id = obj["id"]!!.jsonPrimitive.long diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt index bc3d5f8f6..2f2b8a893 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt @@ -71,7 +71,9 @@ class Komga(id: Long) : TrackService(id, "Komga"), EnhancedMangaTrackService, Ma return track } - override suspend fun searchManga(query: String): List = throw Exception("Not used") + override suspend fun searchManga(query: String): List = throw Exception( + "Not used" + ) override suspend fun refresh(track: MangaTrack): MangaTrack { val remoteTrack = api.getTrackSearch(track.tracking_url) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/KomgaApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/KomgaApi.kt index 751de87c4..7e95264aa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/KomgaApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/KomgaApi.kt @@ -41,7 +41,11 @@ class KomgaApi(private val client: OkHttpClient) { } val progress = client - .newCall(GET("${url.replace("/api/v1/series/", "/api/v2/series/")}/read-progress/tachiyomi")) + .newCall( + GET( + "${url.replace("/api/v1/series/", "/api/v2/series/")}/read-progress/tachiyomi" + ) + ) .awaitSuccess().let { with(json) { if (url.contains("/api/v1/series/")) { @@ -77,7 +81,9 @@ class KomgaApi(private val client: OkHttpClient) { } client.newCall( Request.Builder() - .url("${track.tracking_url.replace("/api/v1/series/", "/api/v2/series/")}/read-progress/tachiyomi") + .url( + "${track.tracking_url.replace("/api/v1/series/", "/api/v2/series/")}/read-progress/tachiyomi" + ) .put(payload.toRequestBody("application/json".toMediaType())) .build(), ) @@ -91,7 +97,9 @@ class KomgaApi(private val client: OkHttpClient) { it.publishing_status = metadata.status } - private fun ReadListDto.toTrack(): MangaTrackSearch = MangaTrackSearch.create(TrackManager.KOMGA).also { + private fun ReadListDto.toTrack(): MangaTrackSearch = MangaTrackSearch.create( + TrackManager.KOMGA + ).also { it.title = name } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdates.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdates.kt index a68a4e08b..c7cc4d92e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdates.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdates.kt @@ -95,7 +95,9 @@ class MangaUpdates(id: Long) : TrackService(id, "MangaUpdates"), MangaTrackServi } override suspend fun login(username: String, password: String) { - val authenticated = api.authenticate(username, password) ?: throw Throwable("Unable to login") + val authenticated = api.authenticate(username, password) ?: throw Throwable( + "Unable to login" + ) saveCredentials(authenticated.uid.toString(), authenticated.sessionToken) interceptor.newAuth(authenticated.sessionToken) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdatesInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdatesInterceptor.kt index 2b283c3b8..187265f43 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdatesInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdatesInterceptor.kt @@ -1,8 +1,8 @@ package eu.kanade.tachiyomi.data.track.mangaupdates +import java.io.IOException import okhttp3.Interceptor import okhttp3.Response -import java.io.IOException class MangaUpdatesInterceptor( mangaUpdates: MangaUpdates, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt index 372185e05..7de84c463 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt @@ -12,6 +12,8 @@ import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.parseAs import eu.kanade.tachiyomi.util.PkceUtil +import java.text.SimpleDateFormat +import java.util.Locale import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.serialization.json.Json @@ -31,8 +33,6 @@ import okhttp3.Request import okhttp3.RequestBody import tachiyomi.core.util.lang.withIOContext import uy.kohesive.injekt.injectLazy -import java.text.SimpleDateFormat -import java.util.Locale class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListInterceptor) { @@ -125,7 +125,10 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI return withIOContext { val url = "$baseApiUrl/manga".toUri().buildUpon() .appendPath(id.toString()) - .appendQueryParameter("fields", "id,title,synopsis,num_chapters,main_picture,status,media_type,start_date") + .appendQueryParameter( + "fields", + "id,title,synopsis,num_chapters,main_picture,status,media_type,start_date" + ) .build() with(json) { authClient.newCall(GET(url.toString())) @@ -162,7 +165,10 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI return withIOContext { val url = "$baseApiUrl/anime".toUri().buildUpon() .appendPath(id.toString()) - .appendQueryParameter("fields", "id,title,synopsis,num_episodes,main_picture,status,media_type,start_date") + .appendQueryParameter( + "fields", + "id,title,synopsis,num_episodes,main_picture,status,media_type,start_date" + ) .build() with(json) { authClient.newCall(GET(url.toString())) @@ -281,7 +287,10 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI return withIOContext { val uri = "$baseApiUrl/manga".toUri().buildUpon() .appendPath(track.media_id.toString()) - .appendQueryParameter("fields", "num_chapters,my_list_status{start_date,finish_date}") + .appendQueryParameter( + "fields", + "num_chapters,my_list_status{start_date,finish_date}" + ) .build() with(json) { authClient.newCall(GET(uri.toString())) @@ -301,7 +310,10 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI return withIOContext { val uri = "$baseApiUrl/anime".toUri().buildUpon() .appendPath(track.media_id.toString()) - .appendQueryParameter("fields", "num_episodes,my_list_status{start_date,finish_date}") + .appendQueryParameter( + "fields", + "num_episodes,my_list_status{start_date,finish_date}" + ) .build() with(json) { authClient.newCall(GET(uri.toString())) @@ -396,7 +408,13 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI val obj = response.jsonObject return track.apply { val isRereading = obj["is_rereading"]!!.jsonPrimitive.boolean - status = if (isRereading) MyAnimeList.REREADING else getStatus(obj["status"]?.jsonPrimitive?.content) + status = if (isRereading) { + MyAnimeList.REREADING + } else { + getStatus( + obj["status"]?.jsonPrimitive?.content + ) + } last_chapter_read = obj["num_chapters_read"]!!.jsonPrimitive.float score = obj["score"]!!.jsonPrimitive.int.toFloat() obj["start_date"]?.let { @@ -412,7 +430,13 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI val obj = response.jsonObject return track.apply { val isRereading = obj["is_rewatching"]!!.jsonPrimitive.boolean - status = if (isRereading) MyAnimeList.REWATCHING else getStatus(obj["status"]!!.jsonPrimitive.content) + status = if (isRereading) { + MyAnimeList.REWATCHING + } else { + getStatus( + obj["status"]!!.jsonPrimitive.content + ) + } last_episode_seen = obj["num_episodes_watched"]!!.jsonPrimitive.float score = obj["score"]!!.jsonPrimitive.int.toFloat() obj["start_date"]?.let { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt index a8ec37708..d866ab455 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt @@ -1,11 +1,11 @@ package eu.kanade.tachiyomi.data.track.myanimelist import eu.kanade.tachiyomi.network.parseAs +import java.io.IOException import kotlinx.serialization.json.Json import okhttp3.Interceptor import okhttp3.Response import uy.kohesive.injekt.injectLazy -import java.io.IOException class MyAnimeListInterceptor(private val myanimelist: MyAnimeList, private var token: String?) : Interceptor { 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 be9b51cf8..c811e29db 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 @@ -64,7 +64,10 @@ class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInter } } - suspend fun updateLibManga(track: MangaTrack, user_id: String): MangaTrack = addLibManga(track, user_id) + suspend fun updateLibManga(track: MangaTrack, user_id: String): MangaTrack = addLibManga( + track, + user_id + ) suspend fun deleteLibManga(track: MangaTrack): MangaTrack { return withIOContext { @@ -105,7 +108,10 @@ class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInter } } - suspend fun updateLibAnime(track: AnimeTrack, user_id: String): AnimeTrack = addLibAnime(track, user_id) + suspend fun updateLibAnime(track: AnimeTrack, user_id: String): AnimeTrack = addLibAnime( + track, + user_id + ) suspend fun deleteLibAnime(track: AnimeTrack): AnimeTrack { return withIOContext { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/simkl/SimklApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/simkl/SimklApi.kt index b99a9a50a..79b31c808 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/simkl/SimklApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/simkl/SimklApi.kt @@ -180,7 +180,12 @@ class SimklApi(private val client: OkHttpClient, interceptor: SimklInterceptor) } } - private fun jsonToAnimeTrack(obj: JsonObject, typeName: String, type: String, statusString: String): AnimeTrack { + private fun jsonToAnimeTrack( + obj: JsonObject, + typeName: String, + type: String, + statusString: String + ): AnimeTrack { return AnimeTrack.create(TrackManager.SIMKL).apply { title = obj[typeName]!!.jsonObject["title"]!!.jsonPrimitive.content val id = obj[typeName]!!.jsonObject["ids"]!!.jsonObject["simkl"]!!.jsonPrimitive.long diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/suwayomi/Suwayomi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/suwayomi/Suwayomi.kt index 312de69e1..632dbc4dd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/suwayomi/Suwayomi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/suwayomi/Suwayomi.kt @@ -82,7 +82,9 @@ class Suwayomi(id: Long) : TrackService(id, "Suwayomi"), EnhancedMangaTrackServi saveCredentials("user", "pass") } - override fun getAcceptedSources(): List = listOf("eu.kanade.tachiyomi.extension.all.tachidesk.Tachidesk") + override fun getAcceptedSources(): List = listOf( + "eu.kanade.tachiyomi.extension.all.tachidesk.Tachidesk" + ) override suspend fun match(manga: DomainManga): MangaTrackSearch? = try { @@ -91,7 +93,9 @@ class Suwayomi(id: Long) : TrackService(id, "Suwayomi"), EnhancedMangaTrackServi null } - override fun isTrackFrom(track: DomainTrack, manga: DomainManga, source: MangaSource?): Boolean = source?.let { accept(it) } == true + override fun isTrackFrom(track: DomainTrack, manga: DomainManga, source: MangaSource?): Boolean = source?.let { accept( + it + ) } == true override fun migrateTrack(track: DomainTrack, manga: DomainManga, newSource: MangaSource): DomainTrack? = if (accept(newSource)) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/suwayomi/TachideskApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/suwayomi/TachideskApi.kt index e2d48a7ac..a3e28294c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/suwayomi/TachideskApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/suwayomi/TachideskApi.kt @@ -10,6 +10,8 @@ import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.PUT import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.parseAs +import java.nio.charset.Charset +import java.security.MessageDigest import kotlinx.serialization.json.Json import okhttp3.Credentials import okhttp3.Dns @@ -20,8 +22,6 @@ import tachiyomi.core.util.lang.withIOContext import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy -import java.nio.charset.Charset -import java.security.MessageDigest class TachideskApi { @@ -113,7 +113,10 @@ class TachideskApi { private fun getPrefBaseUrl(): String = preferences.getString(ADDRESS_TITLE, ADDRESS_DEFAULT)!! private fun getPrefBaseLogin(): String = preferences.getString(LOGIN_TITLE, LOGIN_DEFAULT)!! - private fun getPrefBasePassword(): String = preferences.getString(PASSWORD_TITLE, PASSWORD_DEFAULT)!! + private fun getPrefBasePassword(): String = preferences.getString( + PASSWORD_TITLE, + PASSWORD_DEFAULT + )!! companion object { private const val ADDRESS_TITLE = "Server URL Address" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt index 41e44fef6..10a48c734 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt @@ -25,7 +25,9 @@ class AppUpdateChecker { ) when (result) { - is GetApplicationRelease.Result.NewUpdate -> AppUpdateNotifier(context).promptUpdate(result.release) + is GetApplicationRelease.Result.NewUpdate -> AppUpdateNotifier(context).promptUpdate( + result.release + ) is GetApplicationRelease.Result.ThirdPartyInstallation -> AppUpdateNotifier(context).promptFdroidUpdate() else -> {} } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt index 4582adf9a..c8edad52c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt @@ -37,12 +37,22 @@ internal class AppUpdateNotifier(private val context: Context) { val updateIntent = Intent(context, AppUpdateService::class.java).run { putExtra(AppUpdateService.EXTRA_DOWNLOAD_URL, release.getDownloadLink()) putExtra(AppUpdateService.EXTRA_DOWNLOAD_TITLE, release.version) - PendingIntent.getService(context, 0, this, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + PendingIntent.getService( + context, + 0, + this, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } val releaseIntent = Intent(Intent.ACTION_VIEW, release.releaseLink.toUri()).run { flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP - PendingIntent.getActivity(context, release.hashCode(), this, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + PendingIntent.getActivity( + context, + release.hashCode(), + this, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } with(notificationBuilder) { @@ -74,7 +84,9 @@ internal class AppUpdateNotifier(private val context: Context) { fun onDownloadStarted(title: String? = null): NotificationCompat.Builder { with(notificationBuilder) { title?.let { setContentTitle(title) } - setContentText(context.getString(R.string.update_check_notification_download_in_progress)) + setContentText( + context.getString(R.string.update_check_notification_download_in_progress) + ) setSmallIcon(android.R.drawable.stat_sys_download) setOngoing(true) @@ -126,7 +138,10 @@ internal class AppUpdateNotifier(private val context: Context) { addAction( R.drawable.ic_close_24dp, context.getString(R.string.action_cancel), - NotificationReceiver.dismissNotificationPendingBroadcast(context, Notifications.ID_APP_UPDATE_PROMPT), + NotificationReceiver.dismissNotificationPendingBroadcast( + context, + Notifications.ID_APP_UPDATE_PROMPT + ), ) } notificationBuilder.show(Notifications.ID_APP_UPDATE_PROMPT) @@ -143,7 +158,12 @@ internal class AppUpdateNotifier(private val context: Context) { setContentTitle(context.getString(R.string.update_check_notification_update_available)) setContentText(context.getString(R.string.update_check_fdroid_migration_info)) setSmallIcon(R.drawable.ic_ani) - setContentIntent(NotificationHandler.openUrl(context, "https://aniyomi.org/help/faq/#how-do-i-migrate-from-the-f-droid-version")) + setContentIntent( + NotificationHandler.openUrl( + context, + "https://aniyomi.org/help/faq/#how-do-i-migrate-from-the-f-droid-version" + ) + ) } notificationBuilder.show(Notifications.ID_APP_UPDATE_PROMPT) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateService.kt index 1d53e338e..d1d6a71a6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateService.kt @@ -19,6 +19,7 @@ import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.storage.saveTo import eu.kanade.tachiyomi.util.system.acquireWakeLock import eu.kanade.tachiyomi.util.system.isServiceRunning +import java.io.File import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -28,7 +29,6 @@ import kotlinx.coroutines.launch import okhttp3.internal.http2.ErrorCode import okhttp3.internal.http2.StreamResetException import uy.kohesive.injekt.injectLazy -import java.io.File class AppUpdateService : Service() { @@ -160,7 +160,11 @@ class AppUpdateService : Service() { * @param context the application context. * @param url the url to the new update. */ - fun start(context: Context, url: String, title: String? = context.getString(R.string.app_name)) { + fun start( + context: Context, + url: String, + title: String? = context.getString(R.string.app_name) + ) { if (isRunning(context)) return Intent(context, AppUpdateService::class.java).apply { @@ -188,7 +192,12 @@ class AppUpdateService : Service() { internal fun downloadApkPendingService(context: Context, url: String): PendingIntent { return Intent(context, AppUpdateService::class.java).run { putExtra(EXTRA_DOWNLOAD_URL, url) - PendingIntent.getService(context, 0, this, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + PendingIntent.getService( + context, + 0, + this, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/AnimeExtensionManager.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/AnimeExtensionManager.kt index 1b4cbe9c1..d3e19341b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/AnimeExtensionManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/AnimeExtensionManager.kt @@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.extension.anime.util.AnimeExtensionInstallReceiver import eu.kanade.tachiyomi.extension.anime.util.AnimeExtensionInstaller import eu.kanade.tachiyomi.extension.anime.util.AnimeExtensionLoader import eu.kanade.tachiyomi.util.system.toast +import java.util.Locale import kotlinx.coroutines.async import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -26,7 +27,6 @@ import tachiyomi.core.util.system.logcat import tachiyomi.domain.source.anime.model.StubAnimeSource import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.Locale /** * The manager of anime extensions installed as another apk which extend the available sources. It handles @@ -58,7 +58,9 @@ class AnimeExtensionManager( private val iconMap = mutableMapOf() - private val _installedAnimeExtensionsFlow = MutableStateFlow(emptyList()) + private val _installedAnimeExtensionsFlow = MutableStateFlow( + emptyList() + ) val installedExtensionsFlow = _installedAnimeExtensionsFlow.asStateFlow() private var subLanguagesEnabledOnFirstRun = preferences.enabledLanguages().isSet() @@ -74,12 +76,16 @@ class AnimeExtensionManager( return null } - private val _availableAnimeExtensionsFlow = MutableStateFlow(emptyList()) + private val _availableAnimeExtensionsFlow = MutableStateFlow( + emptyList() + ) val availableExtensionsFlow = _availableAnimeExtensionsFlow.asStateFlow() private var availableAnimeExtensionsSourcesData: Map = emptyMap() - private fun setupAvailableAnimeExtensionsSourcesDataMap(animeextensions: List) { + private fun setupAvailableAnimeExtensionsSourcesDataMap( + animeextensions: List + ) { if (animeextensions.isEmpty()) return availableAnimeExtensionsSourcesData = animeextensions .flatMap { ext -> ext.sources.map { it.toStubSource() } } @@ -88,7 +94,9 @@ class AnimeExtensionManager( fun getSourceData(id: Long) = availableAnimeExtensionsSourcesData[id] - private val _untrustedAnimeExtensionsFlow = MutableStateFlow(emptyList()) + private val _untrustedAnimeExtensionsFlow = MutableStateFlow( + emptyList() + ) val untrustedExtensionsFlow = _untrustedAnimeExtensionsFlow.asStateFlow() init { @@ -167,7 +175,9 @@ class AnimeExtensionManager( * * @param availableAnimeExtensions The list of animeextensions given by the [api]. */ - private fun updatedInstalledAnimeExtensionsStatuses(availableAnimeExtensions: List) { + private fun updatedInstalledAnimeExtensionsStatuses( + availableAnimeExtensions: List + ) { if (availableAnimeExtensions.isEmpty()) { preferences.animeExtensionUpdatesCount().set(0) return @@ -267,7 +277,10 @@ class AnimeExtensionManager( launchNow { nowTrustedAnimeExtensions .map { animeextension -> - async { AnimeExtensionLoader.loadExtensionFromPkgName(context, animeextension.pkgName) }.await() + async { AnimeExtensionLoader.loadExtensionFromPkgName( + context, + animeextension.pkgName + ) }.await() } .filterIsInstance() .forEach { registerNewExtension(it.extension) } @@ -353,7 +366,9 @@ class AnimeExtensionManager( } } - private fun AnimeExtension.Installed.updateExists(availableAnimeExtension: AnimeExtension.Available? = null): Boolean { + private fun AnimeExtension.Installed.updateExists( + availableAnimeExtension: AnimeExtension.Available? = null + ): Boolean { val availableExt = availableAnimeExtension ?: _availableAnimeExtensionsFlow.value.find { it.pkgName == pkgName } if (isUnofficial || availableExt == null) return false diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/api/AnimeExtensionGithubApi.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/api/AnimeExtensionGithubApi.kt index a3d97749c..d43504b02 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/api/AnimeExtensionGithubApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/api/AnimeExtensionGithubApi.kt @@ -10,6 +10,8 @@ import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.parseAs +import java.util.Date +import kotlin.time.Duration.Companion.days import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json import logcat.LogPriority @@ -18,8 +20,6 @@ import tachiyomi.core.preference.PreferenceStore import tachiyomi.core.util.lang.withIOContext import tachiyomi.core.util.system.logcat import uy.kohesive.injekt.injectLazy -import java.util.Date -import kotlin.time.Duration.Companion.days internal class AnimeExtensionGithubApi { diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/InstallerAnime.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/InstallerAnime.kt index eaa6c45e5..9e0bd6914 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/InstallerAnime.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/InstallerAnime.kt @@ -10,9 +10,9 @@ import androidx.annotation.CallSuper import androidx.localbroadcastmanager.content.LocalBroadcastManager import eu.kanade.tachiyomi.extension.InstallStep import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager -import uy.kohesive.injekt.injectLazy import java.util.Collections import java.util.concurrent.atomic.AtomicReference +import uy.kohesive.injekt.injectLazy /** * Base implementation class for extension installer. To be used inside a foreground [Service]. diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/PackageInstallerInstallerAnime.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/PackageInstallerInstallerAnime.kt index fb6bfb11c..e201680ef 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/PackageInstallerInstallerAnime.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/PackageInstallerInstallerAnime.kt @@ -50,9 +50,13 @@ class PackageInstallerInstallerAnime(private val service: Service) : InstallerAn super.processEntry(entry) activeSession = null try { - val installParams = PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL) + val installParams = PackageInstaller.SessionParams( + PackageInstaller.SessionParams.MODE_FULL_INSTALL + ) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - installParams.setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED) + installParams.setRequireUserAction( + PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED + ) } activeSession = entry to packageInstaller.createSession(installParams) val fileSize = service.getUriSize(entry.uri) ?: throw IllegalStateException() diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/ShizukuInstallerAnime.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/ShizukuInstallerAnime.kt index d175a2f9d..9c1668186 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/ShizukuInstallerAnime.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/installer/ShizukuInstallerAnime.kt @@ -7,6 +7,8 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.extension.InstallStep import eu.kanade.tachiyomi.util.system.getUriSize import eu.kanade.tachiyomi.util.system.toast +import java.io.BufferedReader +import java.io.InputStream import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob @@ -15,8 +17,6 @@ import kotlinx.coroutines.launch import logcat.LogPriority import rikka.shizuku.Shizuku import tachiyomi.core.util.system.logcat -import java.io.BufferedReader -import java.io.InputStream class ShizukuInstallerAnime(private val service: Service) : InstallerAnime(service) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallActivity.kt index 692f52bbe..f4258a584 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallActivity.kt @@ -7,9 +7,9 @@ import eu.kanade.tachiyomi.extension.InstallStep import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager import eu.kanade.tachiyomi.util.system.hasMiuiPackageInstaller import eu.kanade.tachiyomi.util.system.toast +import kotlin.time.Duration.Companion.seconds import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import kotlin.time.Duration.Companion.seconds /** * Activity used to install extensions, because we can only receive the result of the installation diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallReceiver.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallReceiver.kt index 7afb11807..5d648e497 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallReceiver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallReceiver.kt @@ -60,9 +60,13 @@ internal class AnimeExtensionInstallReceiver(private val listener: Listener) : launchNow { when (val result = getExtensionFromIntent(context, intent)) { - is AnimeLoadResult.Success -> listener.onExtensionInstalled(result.extension) + is AnimeLoadResult.Success -> listener.onExtensionInstalled( + result.extension + ) - is AnimeLoadResult.Untrusted -> listener.onExtensionUntrusted(result.extension) + is AnimeLoadResult.Untrusted -> listener.onExtensionUntrusted( + result.extension + ) else -> {} } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallService.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallService.kt index 000f4f35b..68e8b614c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstallService.kt @@ -46,7 +46,9 @@ class AnimeExtensionInstallService : Service() { if (installer == null) { installer = when (installerUsed) { - BasePreferences.ExtensionInstaller.PACKAGEINSTALLER -> PackageInstallerInstallerAnime(this) + BasePreferences.ExtensionInstaller.PACKAGEINSTALLER -> PackageInstallerInstallerAnime( + this + ) BasePreferences.ExtensionInstaller.SHIZUKU -> ShizukuInstallerAnime(this) else -> { logcat(LogPriority.ERROR) { "Not implemented for installer $installerUsed" } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstaller.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstaller.kt index 19437d615..df1400b73 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstaller.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionInstaller.kt @@ -17,6 +17,8 @@ import eu.kanade.tachiyomi.extension.anime.installer.InstallerAnime import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.isPackageInstalled +import java.io.File +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -31,8 +33,6 @@ import tachiyomi.core.util.lang.withUIContext import tachiyomi.core.util.system.logcat import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.File -import kotlin.time.Duration.Companion.seconds /** * The installer which installs, updates and uninstalls the extensions. @@ -83,7 +83,11 @@ internal class AnimeExtensionInstaller(private val context: Context) { val request = DownloadManager.Request(downloadUri) .setTitle(extension.name) .setMimeType(APK_MIME) - .setDestinationInExternalFilesDir(context, Environment.DIRECTORY_DOWNLOADS, downloadUri.lastPathSegment) + .setDestinationInExternalFilesDir( + context, + Environment.DIRECTORY_DOWNLOADS, + downloadUri.lastPathSegment + ) .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) val id = downloadManager.enqueue(request) @@ -155,7 +159,9 @@ internal class AnimeExtensionInstaller(private val context: Context) { val intent = Intent(context, AnimeExtensionInstallActivity::class.java) .setDataAndType(uri, APK_MIME) .putExtra(EXTRA_DOWNLOAD_ID, downloadId) - .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION) + .setFlags( + Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION + ) context.startActivity(intent) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionLoader.kt index 3e826945b..addb844c3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/util/AnimeExtensionLoader.kt @@ -15,13 +15,13 @@ import eu.kanade.tachiyomi.animesource.AnimeSourceFactory import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension import eu.kanade.tachiyomi.extension.anime.model.AnimeLoadResult import eu.kanade.tachiyomi.util.lang.Hash +import java.io.File import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking import logcat.LogPriority import tachiyomi.core.util.system.logcat import uy.kohesive.injekt.injectLazy -import java.io.File /** * Class that handles the loading of the extensions installed in the system. @@ -62,9 +62,15 @@ internal object AnimeExtensionLoader { private fun getPrivateExtensionDir(context: Context) = File(context.filesDir, "exts") fun installPrivateExtensionFile(context: Context, file: File): Boolean { - val extension = context.packageManager.getPackageArchiveInfo(file.absolutePath, PACKAGE_FLAGS) + val extension = context.packageManager.getPackageArchiveInfo( + file.absolutePath, + PACKAGE_FLAGS + ) ?.takeIf { isPackageAnExtension(it) } ?: return false - val currentExtension = getAnimeExtensionPackageInfoFromPkgName(context, extension.packageName) + val currentExtension = getAnimeExtensionPackageInfoFromPkgName( + context, + extension.packageName + ) if (currentExtension != null) { if (PackageInfoCompat.getLongVersionCode(extension) < @@ -86,7 +92,10 @@ internal object AnimeExtensionLoader { } } - val target = File(getPrivateExtensionDir(context), "${extension.packageName}.$PRIVATE_EXTENSION_EXTENSION") + val target = File( + getPrivateExtensionDir(context), + "${extension.packageName}.$PRIVATE_EXTENSION_EXTENSION" + ) return try { file.copyTo(target, overwrite = true) if (currentExtension != null) { @@ -115,7 +124,9 @@ internal object AnimeExtensionLoader { val pkgManager = context.packageManager val installedPkgs = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - pkgManager.getInstalledPackages(PackageManager.PackageInfoFlags.of(PACKAGE_FLAGS.toLong())) + pkgManager.getInstalledPackages( + PackageManager.PackageInfoFlags.of(PACKAGE_FLAGS.toLong()) + ) } else { pkgManager.getInstalledPackages(PACKAGE_FLAGS) } @@ -178,9 +189,15 @@ internal object AnimeExtensionLoader { } private fun getAnimeExtensionInfoFromPkgName(context: Context, pkgName: String): AnimeExtensionInfo? { - val privateExtensionFile = File(getPrivateExtensionDir(context), "$pkgName.$PRIVATE_EXTENSION_EXTENSION") + val privateExtensionFile = File( + getPrivateExtensionDir(context), + "$pkgName.$PRIVATE_EXTENSION_EXTENSION" + ) val privatePkg = if (privateExtensionFile.isFile) { - context.packageManager.getPackageArchiveInfo(privateExtensionFile.absolutePath, PACKAGE_FLAGS) + context.packageManager.getPackageArchiveInfo( + privateExtensionFile.absolutePath, + PACKAGE_FLAGS + ) ?.takeIf { isPackageAnExtension(it) } ?.let { it.applicationInfo.fixBasePaths(privateExtensionFile.absolutePath) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/MangaExtensionManager.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/MangaExtensionManager.kt index 3146c5755..b5a3520d4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/MangaExtensionManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/MangaExtensionManager.kt @@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.extension.manga.util.MangaExtensionInstallReceiver import eu.kanade.tachiyomi.extension.manga.util.MangaExtensionInstaller import eu.kanade.tachiyomi.extension.manga.util.MangaExtensionLoader import eu.kanade.tachiyomi.util.system.toast +import java.util.Locale import kotlinx.coroutines.async import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -26,7 +27,6 @@ import tachiyomi.core.util.system.logcat import tachiyomi.domain.source.manga.model.StubMangaSource import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.Locale /** * The manager of extensions installed as another apk which extend the available sources. It handles @@ -167,7 +167,9 @@ class MangaExtensionManager( * * @param availableExtensions The list of extensions given by the [api]. */ - private fun updatedInstalledExtensionsStatuses(availableExtensions: List) { + private fun updatedInstalledExtensionsStatuses( + availableExtensions: List + ) { if (availableExtensions.isEmpty()) { preferences.mangaExtensionUpdatesCount().set(0) return @@ -267,7 +269,10 @@ class MangaExtensionManager( launchNow { nowTrustedExtensions .map { extension -> - async { MangaExtensionLoader.loadMangaExtensionFromPkgName(context, extension.pkgName) }.await() + async { MangaExtensionLoader.loadMangaExtensionFromPkgName( + context, + extension.pkgName + ) }.await() } .filterIsInstance() .forEach { registerNewExtension(it.extension) } @@ -353,7 +358,9 @@ class MangaExtensionManager( } } - private fun MangaExtension.Installed.updateExists(availableExtension: MangaExtension.Available? = null): Boolean { + private fun MangaExtension.Installed.updateExists( + availableExtension: MangaExtension.Available? = null + ): Boolean { val availableExt = availableExtension ?: _availableExtensionsFlow.value.find { it.pkgName == pkgName } if (isUnofficial || availableExt == null) return false diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionGithubApi.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionGithubApi.kt index 97a839f5e..40845429c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionGithubApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionGithubApi.kt @@ -10,6 +10,8 @@ import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.parseAs +import java.util.Date +import kotlin.time.Duration.Companion.days import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json import logcat.LogPriority @@ -18,8 +20,6 @@ import tachiyomi.core.preference.PreferenceStore import tachiyomi.core.util.lang.withIOContext import tachiyomi.core.util.system.logcat import uy.kohesive.injekt.injectLazy -import java.util.Date -import kotlin.time.Duration.Companion.days internal class MangaExtensionGithubApi { diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/InstallerManga.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/InstallerManga.kt index 37c9edbbc..d9500240f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/InstallerManga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/InstallerManga.kt @@ -10,9 +10,9 @@ import androidx.annotation.CallSuper import androidx.localbroadcastmanager.content.LocalBroadcastManager import eu.kanade.tachiyomi.extension.InstallStep import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager -import uy.kohesive.injekt.injectLazy import java.util.Collections import java.util.concurrent.atomic.AtomicReference +import uy.kohesive.injekt.injectLazy /** * Base implementation class for extension installer. To be used inside a foreground [Service]. diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/PackageInstallerInstallerManga.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/PackageInstallerInstallerManga.kt index 6eb719eeb..8ec064a02 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/PackageInstallerInstallerManga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/PackageInstallerInstallerManga.kt @@ -50,9 +50,13 @@ class PackageInstallerInstallerManga(private val service: Service) : InstallerMa super.processEntry(entry) activeSession = null try { - val installParams = PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL) + val installParams = PackageInstaller.SessionParams( + PackageInstaller.SessionParams.MODE_FULL_INSTALL + ) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - installParams.setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED) + installParams.setRequireUserAction( + PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED + ) } activeSession = entry to packageInstaller.createSession(installParams) val fileSize = service.getUriSize(entry.uri) ?: throw IllegalStateException() diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/ShizukuInstallerManga.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/ShizukuInstallerManga.kt index de292ba94..e5c18da41 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/ShizukuInstallerManga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/installer/ShizukuInstallerManga.kt @@ -7,6 +7,8 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.extension.InstallStep import eu.kanade.tachiyomi.util.system.getUriSize import eu.kanade.tachiyomi.util.system.toast +import java.io.BufferedReader +import java.io.InputStream import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob @@ -15,8 +17,6 @@ import kotlinx.coroutines.launch import logcat.LogPriority import rikka.shizuku.Shizuku import tachiyomi.core.util.system.logcat -import java.io.BufferedReader -import java.io.InputStream class ShizukuInstallerManga(private val service: Service) : InstallerManga(service) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallActivity.kt index 743c8f274..648cbed0a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallActivity.kt @@ -7,9 +7,9 @@ import eu.kanade.tachiyomi.extension.InstallStep import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager import eu.kanade.tachiyomi.util.system.hasMiuiPackageInstaller import eu.kanade.tachiyomi.util.system.toast +import kotlin.time.Duration.Companion.seconds import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import kotlin.time.Duration.Companion.seconds /** * Activity used to install extensions, because we can only receive the result of the installation diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallReceiver.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallReceiver.kt index a930f4a16..c677fbdc9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallReceiver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallReceiver.kt @@ -60,9 +60,13 @@ internal class MangaExtensionInstallReceiver(private val listener: Listener) : launchNow { when (val result = getExtensionFromIntent(context, intent)) { - is MangaLoadResult.Success -> listener.onExtensionInstalled(result.extension) + is MangaLoadResult.Success -> listener.onExtensionInstalled( + result.extension + ) - is MangaLoadResult.Untrusted -> listener.onExtensionUntrusted(result.extension) + is MangaLoadResult.Untrusted -> listener.onExtensionUntrusted( + result.extension + ) else -> {} } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallService.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallService.kt index e3c0bc0b6..b7dcd814c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstallService.kt @@ -46,7 +46,9 @@ class MangaExtensionInstallService : Service() { if (installer == null) { installer = when (installerUsed) { - BasePreferences.ExtensionInstaller.PACKAGEINSTALLER -> PackageInstallerInstallerManga(this) + BasePreferences.ExtensionInstaller.PACKAGEINSTALLER -> PackageInstallerInstallerManga( + this + ) BasePreferences.ExtensionInstaller.SHIZUKU -> ShizukuInstallerManga(this) else -> { logcat(LogPriority.ERROR) { "Not implemented for installer $installerUsed" } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstaller.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstaller.kt index ce8276942..a510888bb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstaller.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionInstaller.kt @@ -17,6 +17,8 @@ import eu.kanade.tachiyomi.extension.manga.installer.InstallerManga import eu.kanade.tachiyomi.extension.manga.model.MangaExtension import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.isPackageInstalled +import java.io.File +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -31,8 +33,6 @@ import tachiyomi.core.util.lang.withUIContext import tachiyomi.core.util.system.logcat import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.File -import kotlin.time.Duration.Companion.seconds /** * The installer which installs, updates and uninstalls the extensions. @@ -83,7 +83,11 @@ internal class MangaExtensionInstaller(private val context: Context) { val request = DownloadManager.Request(downloadUri) .setTitle(extension.name) .setMimeType(APK_MIME) - .setDestinationInExternalFilesDir(context, Environment.DIRECTORY_DOWNLOADS, downloadUri.lastPathSegment) + .setDestinationInExternalFilesDir( + context, + Environment.DIRECTORY_DOWNLOADS, + downloadUri.lastPathSegment + ) .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) val id = downloadManager.enqueue(request) @@ -155,7 +159,9 @@ internal class MangaExtensionInstaller(private val context: Context) { val intent = Intent(context, MangaExtensionInstallActivity::class.java) .setDataAndType(uri, APK_MIME) .putExtra(EXTRA_DOWNLOAD_ID, downloadId) - .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION) + .setFlags( + Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION + ) context.startActivity(intent) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionLoader.kt index 2cb7d5216..efba794d2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionLoader.kt @@ -16,13 +16,13 @@ import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.MangaSource import eu.kanade.tachiyomi.source.SourceFactory import eu.kanade.tachiyomi.util.lang.Hash +import java.io.File import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking import logcat.LogPriority import tachiyomi.core.util.system.logcat import uy.kohesive.injekt.injectLazy -import java.io.File /** * Class that handles the loading of the extensions. Supports two kinds of extensions: @@ -74,9 +74,15 @@ internal object MangaExtensionLoader { private fun getPrivateExtensionDir(context: Context) = File(context.filesDir, "exts") fun installPrivateExtensionFile(context: Context, file: File): Boolean { - val extension = context.packageManager.getPackageArchiveInfo(file.absolutePath, PACKAGE_FLAGS) + val extension = context.packageManager.getPackageArchiveInfo( + file.absolutePath, + PACKAGE_FLAGS + ) ?.takeIf { isPackageAnExtension(it) } ?: return false - val currentExtension = getMangaExtensionPackageInfoFromPkgName(context, extension.packageName) + val currentExtension = getMangaExtensionPackageInfoFromPkgName( + context, + extension.packageName + ) if (currentExtension != null) { if (PackageInfoCompat.getLongVersionCode(extension) < @@ -98,7 +104,10 @@ internal object MangaExtensionLoader { } } - val target = File(getPrivateExtensionDir(context), "${extension.packageName}.$PRIVATE_EXTENSION_EXTENSION") + val target = File( + getPrivateExtensionDir(context), + "${extension.packageName}.$PRIVATE_EXTENSION_EXTENSION" + ) return try { file.copyTo(target, overwrite = true) if (currentExtension != null) { @@ -127,7 +136,9 @@ internal object MangaExtensionLoader { val pkgManager = context.packageManager val installedPkgs = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - pkgManager.getInstalledPackages(PackageManager.PackageInfoFlags.of(PACKAGE_FLAGS.toLong())) + pkgManager.getInstalledPackages( + PackageManager.PackageInfoFlags.of(PACKAGE_FLAGS.toLong()) + ) } else { pkgManager.getInstalledPackages(PACKAGE_FLAGS) } @@ -190,9 +201,15 @@ internal object MangaExtensionLoader { } private fun getMangaExtensionInfoFromPkgName(context: Context, pkgName: String): MangaExtensionInfo? { - val privateExtensionFile = File(getPrivateExtensionDir(context), "$pkgName.$PRIVATE_EXTENSION_EXTENSION") + val privateExtensionFile = File( + getPrivateExtensionDir(context), + "$pkgName.$PRIVATE_EXTENSION_EXTENSION" + ) val privatePkg = if (privateExtensionFile.isFile) { - context.packageManager.getPackageArchiveInfo(privateExtensionFile.absolutePath, PACKAGE_FLAGS) + context.packageManager.getPackageArchiveInfo( + privateExtensionFile.absolutePath, + PACKAGE_FLAGS + ) ?.takeIf { isPackageAnExtension(it) } ?.let { it.applicationInfo.fixBasePaths(privateExtensionFile.absolutePath) @@ -233,7 +250,9 @@ internal object MangaExtensionLoader { val appInfo = pkgInfo.applicationInfo val pkgName = pkgInfo.packageName - val extName = pkgManager.getApplicationLabel(appInfo).toString().substringAfter("Tachiyomi: ") + val extName = pkgManager.getApplicationLabel(appInfo).toString().substringAfter( + "Tachiyomi: " + ) val versionName = pkgInfo.versionName val versionCode = PackageInfoCompat.getLongVersionCode(pkgInfo) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/anime/AndroidAnimeSourceManager.kt b/app/src/main/java/eu/kanade/tachiyomi/source/anime/AndroidAnimeSourceManager.kt index ba4d0f92a..2fbc2a715 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/anime/AndroidAnimeSourceManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/anime/AndroidAnimeSourceManager.kt @@ -6,6 +6,7 @@ import eu.kanade.tachiyomi.animesource.AnimeSource import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource import eu.kanade.tachiyomi.data.download.anime.AnimeDownloadManager import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager +import java.util.concurrent.ConcurrentHashMap import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -22,7 +23,6 @@ import tachiyomi.source.local.entries.anime.LocalAnimeSource import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy -import java.util.concurrent.ConcurrentHashMap class AndroidAnimeSourceManager( private val context: Context, diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/manga/AndroidMangaSourceManager.kt b/app/src/main/java/eu/kanade/tachiyomi/source/manga/AndroidMangaSourceManager.kt index 58822c651..2ecdd595b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/manga/AndroidMangaSourceManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/manga/AndroidMangaSourceManager.kt @@ -6,6 +6,7 @@ import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.MangaSource import eu.kanade.tachiyomi.source.online.HttpSource +import java.util.concurrent.ConcurrentHashMap import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -22,7 +23,6 @@ import tachiyomi.source.local.entries.manga.LocalMangaSource import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy -import java.util.concurrent.ConcurrentHashMap class AndroidMangaSourceManager( private val context: Context, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/delegate/ThemingDelegate.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/delegate/ThemingDelegate.kt index 92727bc03..4fb792f02 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/delegate/ThemingDelegate.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/delegate/ThemingDelegate.kt @@ -79,7 +79,10 @@ interface ThemingDelegate { class ThemingDelegateImpl : ThemingDelegate { override fun applyAppTheme(activity: Activity) { val uiPreferences = Injekt.get() - ThemingDelegate.getThemeResIds(uiPreferences.appTheme().get(), uiPreferences.themeDarkAmoled().get()) + ThemingDelegate.getThemeResIds( + uiPreferences.appTheme().get(), + uiPreferences.themeDarkAmoled().get() + ) .forEach(activity::setTheme) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsScreenModel.kt index ea179fdb6..455c52b09 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsScreenModel.kt @@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.extension.InstallStep import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension import eu.kanade.tachiyomi.util.system.LocaleHelper +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -30,7 +31,6 @@ import kotlinx.coroutines.flow.update import tachiyomi.core.util.lang.launchIO import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import kotlin.time.Duration.Companion.seconds class AnimeExtensionsScreenModel( preferences: SourcePreferences = Injekt.get(), @@ -65,10 +65,18 @@ class AnimeExtensionsScreenModel( extension.sources.any { it.name.contains(input, ignoreCase = true) || it.id == input.toLongOrNull() || - if (it is AnimeHttpSource) { it.baseUrl.contains(input, ignoreCase = true) } else false + if (it is AnimeHttpSource) { it.baseUrl.contains( + input, + ignoreCase = true + ) } else { + false + } } || extension.name.contains(input, ignoreCase = true) } - is AnimeExtension.Untrusted -> extension.name.contains(input, ignoreCase = true) + is AnimeExtension.Untrusted -> extension.name.contains( + input, + ignoreCase = true + ) } } } @@ -84,13 +92,19 @@ class AnimeExtensionsScreenModel( val itemsGroups: ItemGroups = mutableMapOf() - val updates = _updates.filter(queryFilter(searchQuery)).map(extensionMapper(downloads)) + val updates = _updates.filter(queryFilter(searchQuery)).map( + extensionMapper(downloads) + ) if (updates.isNotEmpty()) { itemsGroups[AnimeExtensionUiModel.Header.Resource(R.string.ext_updates_pending)] = updates } - val installed = _installed.filter(queryFilter(searchQuery)).map(extensionMapper(downloads)) - val untrusted = _untrusted.filter(queryFilter(searchQuery)).map(extensionMapper(downloads)) + val installed = _installed.filter(queryFilter(searchQuery)).map( + extensionMapper(downloads) + ) + val untrusted = _untrusted.filter(queryFilter(searchQuery)).map( + extensionMapper(downloads) + ) if (installed.isNotEmpty() || untrusted.isNotEmpty()) { itemsGroups[AnimeExtensionUiModel.Header.Resource(R.string.ext_installed)] = installed + untrusted } @@ -100,7 +114,9 @@ class AnimeExtensionsScreenModel( .groupBy { it.lang } .toSortedMap(LocaleHelper.comparator) .map { (lang, exts) -> - AnimeExtensionUiModel.Header.Text(LocaleHelper.getSourceDisplayName(lang, context)) to exts.map(extensionMapper(downloads)) + AnimeExtensionUiModel.Header.Text( + LocaleHelper.getSourceDisplayName(lang, context) + ) to exts.map(extensionMapper(downloads)) } if (languagesWithExtensions.isNotEmpty()) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsTab.kt index ff9d3cdb2..2bc7d4d88 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsTab.kt @@ -30,7 +30,9 @@ fun animeExtensionsTab( AppBar.Action( title = stringResource(R.string.action_filter), icon = Icons.Outlined.Translate, - onClick = { navigator.push(eu.kanade.tachiyomi.ui.browse.anime.extension.AnimeExtensionFilterScreen()) }, + onClick = { navigator.push( + eu.kanade.tachiyomi.ui.browse.anime.extension.AnimeExtensionFilterScreen() + ) }, ), ), content = { contentPadding, _ -> @@ -40,7 +42,9 @@ fun animeExtensionsTab( searchQuery = state.searchQuery, onLongClickItem = { extension -> when (extension) { - is AnimeExtension.Available -> extensionsScreenModel.installExtension(extension) + is AnimeExtension.Available -> extensionsScreenModel.installExtension( + extension + ) else -> extensionsScreenModel.uninstallExtension(extension) } }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreen.kt index 1e48494c7..eb58d5066 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreen.kt @@ -21,7 +21,10 @@ data class AnimeExtensionDetailsScreen( @Composable override fun Content() { val context = LocalContext.current - val screenModel = rememberScreenModel { AnimeExtensionDetailsScreenModel(pkgName = pkgName, context = context) } + val screenModel = rememberScreenModel { AnimeExtensionDetailsScreenModel( + pkgName = pkgName, + context = context + ) } val state by screenModel.state.collectAsState() if (state.isLoading) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreenModel.kt index b0ca80a7c..651104128 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreenModel.kt @@ -68,7 +68,10 @@ class AnimeExtensionDetailsScreenModel( { !it.enabled }, { item -> item.source.name.takeIf { item.labelAsName } - ?: LocaleHelper.getSourceDisplayName(item.source.lang, context).lowercase() + ?: LocaleHelper.getSourceDisplayName( + item.source.lang, + context + ).lowercase() }, ), ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/SourcePreferencesScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/SourcePreferencesScreen.kt index faec7db75..de34a5855 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/SourcePreferencesScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/SourcePreferencesScreen.kt @@ -56,7 +56,9 @@ class SourcePreferencesScreen(val sourceId: Long) : Screen() { Scaffold( topBar = { TopAppBar( - title = { Text(text = Injekt.get().getOrStub(sourceId).toString()) }, + title = { Text( + text = Injekt.get().getOrStub(sourceId).toString() + ) }, navigationIcon = { IconButton(onClick = navigator::pop) { UpIcon() @@ -138,7 +140,10 @@ class SourcePreferencesFragment : PreferenceFragmentCompat() { check(source is ConfigurableAnimeSource) - val sharedPreferences = requireContext().getSharedPreferences(source.getPreferenceKey(), Context.MODE_PRIVATE) + val sharedPreferences = requireContext().getSharedPreferences( + source.getPreferenceKey(), + Context.MODE_PRIVATE + ) val dataStore = SharedPreferencesDataStore(sharedPreferences) preferenceManager.preferenceDataStore = dataStore diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/AnimeMigrationFlags.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/AnimeMigrationFlags.kt index 0d698b1b6..a0b6b10c6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/AnimeMigrationFlags.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/AnimeMigrationFlags.kt @@ -58,10 +58,18 @@ object AnimeMigrationFlags { if (anime != null) { if (anime.hasCustomCover(coverCache)) { - flags += AnimeMigrationFlag.create(CUSTOM_COVER, defaultSelectedBitMap, R.string.custom_cover) + flags += AnimeMigrationFlag.create( + CUSTOM_COVER, + defaultSelectedBitMap, + R.string.custom_cover + ) } if (downloadCache.getDownloadCount(anime) > 0) { - flags += AnimeMigrationFlag.create(DELETE_DOWNLOADED, defaultSelectedBitMap, R.string.delete_downloaded) + flags += AnimeMigrationFlag.create( + DELETE_DOWNLOADED, + defaultSelectedBitMap, + R.string.delete_downloaded + ) } } return flags diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/MigrateAnimeDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/MigrateAnimeDialog.kt index a4936b0be..2028f9729 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/MigrateAnimeDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/MigrateAnimeDialog.kt @@ -40,6 +40,7 @@ import eu.kanade.tachiyomi.data.download.anime.AnimeDownloadManager import eu.kanade.tachiyomi.data.track.EnhancedAnimeTrackService import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.ui.browse.anime.migration.AnimeMigrationFlags +import java.util.Date import kotlinx.coroutines.flow.update import tachiyomi.core.preference.Preference import tachiyomi.core.preference.PreferenceStore @@ -58,7 +59,6 @@ import tachiyomi.domain.track.anime.interactor.InsertAnimeTrack import tachiyomi.presentation.core.screens.LoadingScreen import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.Date @Composable internal fun MigrateAnimeDialog( @@ -99,7 +99,10 @@ internal fun MigrateAnimeDialog( .clickable(onClick = onChange), verticalAlignment = Alignment.CenterVertically, ) { - Checkbox(checked = selectedFlags[index], onCheckedChange = { onChange() }) + Checkbox( + checked = selectedFlags[index], + onCheckedChange = { onChange() } + ) Text(text = context.getString(flag.titleId)) } } @@ -300,7 +303,10 @@ internal class MigrateAnimeDialogScreenModel( // Update custom cover (recheck if custom cover exists) if (migrateCustomCover && oldAnime.hasCustomCover()) { - coverCache.setCustomCoverToCache(newAnime, coverCache.getCustomCoverFile(oldAnime.id).inputStream()) + coverCache.setCustomCoverToCache( + newAnime, + coverCache.getCustomCoverFile(oldAnime.id).inputStream() + ) } updateAnime.await( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/MigrateAnimeSearchScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/MigrateAnimeSearchScreen.kt index 1d946c895..923a5a5d6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/MigrateAnimeSearchScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/MigrateAnimeSearchScreen.kt @@ -19,7 +19,9 @@ class MigrateAnimeSearchScreen(private val animeId: Long) : Screen() { val screenModel = rememberScreenModel { MigrateAnimeSearchScreenModel(animeId = animeId) } val state by screenModel.state.collectAsState() - val dialogScreenModel = rememberScreenModel { AnimeMigrateSearchScreenDialogScreenModel(animeId = animeId) } + val dialogScreenModel = rememberScreenModel { AnimeMigrateSearchScreenDialogScreenModel( + animeId = animeId + ) } val dialogState by dialogScreenModel.state.collectAsState() MigrateAnimeSearchScreen( @@ -32,9 +34,13 @@ class MigrateAnimeSearchScreen(private val animeId: Long) : Screen() { onChangeSearchFilter = screenModel::setSourceFilter, onToggleResults = screenModel::toggleFilterResults, onClickSource = { - navigator.push(AnimeSourceSearchScreen(dialogState.anime!!, it.id, state.searchQuery)) + navigator.push( + AnimeSourceSearchScreen(dialogState.anime!!, it.id, state.searchQuery) + ) }, - onClickItem = { dialogScreenModel.setDialog((AnimeMigrateSearchScreenDialogScreenModel.Dialog.Migrate(it))) }, + onClickItem = { dialogScreenModel.setDialog( + (AnimeMigrateSearchScreenDialogScreenModel.Dialog.Migrate(it)) + ) }, onLongClickItem = { navigator.push(AnimeScreen(it.id, true)) }, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreenModel.kt index 113ca7d44..f1d250f3b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreenModel.kt @@ -7,6 +7,7 @@ import eu.kanade.domain.source.anime.interactor.GetLanguagesWithAnimeSources import eu.kanade.domain.source.anime.interactor.ToggleAnimeSource import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.source.service.ToggleLanguage +import java.util.SortedMap import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.combine @@ -15,7 +16,6 @@ import kotlinx.coroutines.launch import tachiyomi.domain.source.anime.model.AnimeSource import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.SortedMap class AnimeSourcesFilterScreenModel( private val preferences: SourcePreferences = Injekt.get(), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesScreenModel.kt index 64f3777c5..86817ac7f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesScreenModel.kt @@ -11,6 +11,7 @@ import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.presentation.browse.anime.AnimeSourceUiModel import eu.kanade.tachiyomi.util.system.LAST_USED_KEY import eu.kanade.tachiyomi.util.system.PINNED_KEY +import java.util.TreeMap import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collectLatest @@ -23,7 +24,6 @@ import tachiyomi.domain.source.anime.model.AnimeSource import tachiyomi.domain.source.anime.model.Pin import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.TreeMap class AnimeSourcesScreenModel( private val preferences: BasePreferences = Injekt.get(), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreen.kt index 733c2fde7..a7a5747a0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreen.kt @@ -79,7 +79,9 @@ data class BrowseAnimeSourceScreen( val navigator = LocalNavigator.currentOrThrow val navigateUp: () -> Unit = { when { - !state.isUserQuery && state.toolbarQuery != null -> screenModel.setToolbarQuery(null) + !state.isUserQuery && state.toolbarQuery != null -> screenModel.setToolbarQuery( + null + ) else -> navigator.pop() } } @@ -214,7 +216,9 @@ data class BrowseAnimeSourceScreen( scope.launchIO { val duplicateAnime = screenModel.getDuplicateAnimelibAnime(anime) when { - anime.favorite -> screenModel.setDialog(BrowseAnimeSourceScreenModel.Dialog.RemoveAnime(anime)) + anime.favorite -> screenModel.setDialog( + BrowseAnimeSourceScreenModel.Dialog.RemoveAnime(anime) + ) duplicateAnime != null -> screenModel.setDialog( BrowseAnimeSourceScreenModel.Dialog.AddDuplicateAnime( anime, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreenModel.kt index 0461dfce8..44a009a90 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreenModel.kt @@ -22,12 +22,14 @@ import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.track.anime.model.toDomainTrack import eu.kanade.presentation.util.ioCoroutineScope import eu.kanade.tachiyomi.animesource.AnimeCatalogueSource +import eu.kanade.tachiyomi.animesource.model.AnimeFilter as AnimeSourceModelFilter import eu.kanade.tachiyomi.animesource.model.AnimeFilterList import eu.kanade.tachiyomi.data.cache.AnimeCoverCache import eu.kanade.tachiyomi.data.track.EnhancedAnimeTrackService import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.util.removeCovers +import java.util.Date import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.emptyFlow @@ -59,8 +61,6 @@ import tachiyomi.domain.source.anime.service.AnimeSourceManager import tachiyomi.domain.track.anime.interactor.InsertAnimeTrack import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.Date -import eu.kanade.tachiyomi.animesource.model.AnimeFilter as AnimeSourceModelFilter class BrowseAnimeSourceScreenModel( private val sourceId: Long, @@ -302,7 +302,11 @@ class BrowseAnimeSourceScreenModel( (service as TrackService).animeService.bind(track) insertTrack.await(track.toDomainTrack()!!) - syncEpisodeProgressWithTrack.await(anime.id, track.toDomainTrack()!!, service.animeService) + syncEpisodeProgressWithTrack.await( + anime.id, + track.toDomainTrack()!!, + service.animeService + ) } } catch (e: Exception) { logcat( @@ -355,9 +359,18 @@ class BrowseAnimeSourceScreenModel( } sealed class Listing(open val query: String?, open val filters: AnimeFilterList) { - data object Popular : Listing(query = GetRemoteAnime.QUERY_POPULAR, filters = AnimeFilterList()) - data object Latest : Listing(query = GetRemoteAnime.QUERY_LATEST, filters = AnimeFilterList()) - data class Search(override val query: String?, override val filters: AnimeFilterList) : Listing(query = query, filters = filters) + data object Popular : Listing( + query = GetRemoteAnime.QUERY_POPULAR, + filters = AnimeFilterList() + ) + data object Latest : Listing( + query = GetRemoteAnime.QUERY_LATEST, + filters = AnimeFilterList() + ) + data class Search(override val query: String?, override val filters: AnimeFilterList) : Listing( + query = query, + filters = filters + ) companion object { fun valueOf(query: String?): Listing { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/AnimeSearchScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/AnimeSearchScreenModel.kt index dd5ff6ed3..d51382aa4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/AnimeSearchScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/AnimeSearchScreenModel.kt @@ -9,6 +9,7 @@ import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.presentation.util.ioCoroutineScope import eu.kanade.tachiyomi.animesource.AnimeCatalogueSource import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager +import java.util.concurrent.Executors import kotlinx.coroutines.Job import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.async @@ -26,7 +27,6 @@ import tachiyomi.domain.entries.anime.model.Anime import tachiyomi.domain.source.anime.service.AnimeSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.concurrent.Executors abstract class AnimeSearchScreenModel( initialState: State = State(), @@ -123,7 +123,9 @@ abstract class AnimeSearchScreenModel( // Reuse previous results if possible if (sameQuery) { val existingResults = state.value.items - updateItems(sources.associateWith { existingResults[it] ?: AnimeSearchItemResult.Loading }) + updateItems( + sources.associateWith { existingResults[it] ?: AnimeSearchItemResult.Loading } + ) } else { updateItems(sources.associateWith { AnimeSearchItemResult.Loading }) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/GlobalAnimeSearchScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/GlobalAnimeSearchScreen.kt index fa79b4ee8..17b33d388 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/GlobalAnimeSearchScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/GlobalAnimeSearchScreen.kt @@ -33,7 +33,9 @@ class GlobalAnimeSearchScreen( } val state by screenModel.state.collectAsState() var showSingleLoadingScreen by remember { - mutableStateOf(searchQuery.isNotEmpty() && !extensionFilter.isNullOrEmpty() && state.total == 1) + mutableStateOf( + searchQuery.isNotEmpty() && !extensionFilter.isNullOrEmpty() && state.total == 1 + ) } if (showSingleLoadingScreen) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsScreenModel.kt index a7552fbdd..802db014a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsScreenModel.kt @@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager import eu.kanade.tachiyomi.extension.manga.model.MangaExtension import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.system.LocaleHelper +import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -30,7 +31,6 @@ import kotlinx.coroutines.flow.update import tachiyomi.core.util.lang.launchIO import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import kotlin.time.Duration.Companion.seconds class MangaExtensionsScreenModel( preferences: SourcePreferences = Injekt.get(), @@ -65,10 +65,18 @@ class MangaExtensionsScreenModel( 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 + if (it is HttpSource) { it.baseUrl.contains( + input, + ignoreCase = true + ) } else { + false + } } || extension.name.contains(input, ignoreCase = true) } - is MangaExtension.Untrusted -> extension.name.contains(input, ignoreCase = true) + is MangaExtension.Untrusted -> extension.name.contains( + input, + ignoreCase = true + ) } } } @@ -84,13 +92,19 @@ class MangaExtensionsScreenModel( val itemsGroups: ItemGroups = mutableMapOf() - val updates = _updates.filter(queryFilter(searchQuery)).map(extensionMapper(downloads)) + val updates = _updates.filter(queryFilter(searchQuery)).map( + extensionMapper(downloads) + ) if (updates.isNotEmpty()) { itemsGroups[MangaExtensionUiModel.Header.Resource(R.string.ext_updates_pending)] = updates } - val installed = _installed.filter(queryFilter(searchQuery)).map(extensionMapper(downloads)) - val untrusted = _untrusted.filter(queryFilter(searchQuery)).map(extensionMapper(downloads)) + val installed = _installed.filter(queryFilter(searchQuery)).map( + extensionMapper(downloads) + ) + val untrusted = _untrusted.filter(queryFilter(searchQuery)).map( + extensionMapper(downloads) + ) if (installed.isNotEmpty() || untrusted.isNotEmpty()) { itemsGroups[MangaExtensionUiModel.Header.Resource(R.string.ext_installed)] = installed + untrusted } @@ -100,7 +114,9 @@ class MangaExtensionsScreenModel( .groupBy { it.lang } .toSortedMap(LocaleHelper.comparator) .map { (lang, exts) -> - MangaExtensionUiModel.Header.Text(LocaleHelper.getSourceDisplayName(lang, context)) to exts.map(extensionMapper(downloads)) + MangaExtensionUiModel.Header.Text( + LocaleHelper.getSourceDisplayName(lang, context) + ) to exts.map(extensionMapper(downloads)) } if (languagesWithExtensions.isNotEmpty()) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsTab.kt index 20a3b4ecd..258bc5778 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsTab.kt @@ -40,7 +40,9 @@ fun mangaExtensionsTab( searchQuery = state.searchQuery, onLongClickItem = { extension -> when (extension) { - is MangaExtension.Available -> extensionsScreenModel.installExtension(extension) + is MangaExtension.Available -> extensionsScreenModel.installExtension( + extension + ) else -> extensionsScreenModel.uninstallExtension(extension) } }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreen.kt index 5fc1ac1cf..338d658c1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreen.kt @@ -21,7 +21,10 @@ data class MangaExtensionDetailsScreen( @Composable override fun Content() { val context = LocalContext.current - val screenModel = rememberScreenModel { MangaExtensionDetailsScreenModel(pkgName = pkgName, context = context) } + val screenModel = rememberScreenModel { MangaExtensionDetailsScreenModel( + pkgName = pkgName, + context = context + ) } val state by screenModel.state.collectAsState() if (state.isLoading) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreenModel.kt index 5a28206da..4403ff4a5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreenModel.kt @@ -68,7 +68,10 @@ class MangaExtensionDetailsScreenModel( { !it.enabled }, { item -> item.source.name.takeIf { item.labelAsName } - ?: LocaleHelper.getSourceDisplayName(item.source.lang, context).lowercase() + ?: LocaleHelper.getSourceDisplayName( + item.source.lang, + context + ).lowercase() }, ), ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaSourcePreferencesScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaSourcePreferencesScreen.kt index 8abe666a0..3285de066 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaSourcePreferencesScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaSourcePreferencesScreen.kt @@ -56,7 +56,9 @@ class MangaSourcePreferencesScreen(val sourceId: Long) : Screen() { Scaffold( topBar = { TopAppBar( - title = { Text(text = Injekt.get().getOrStub(sourceId).toString()) }, + title = { Text( + text = Injekt.get().getOrStub(sourceId).toString() + ) }, navigationIcon = { IconButton(onClick = navigator::pop) { UpIcon() @@ -138,7 +140,10 @@ class MangaSourcePreferencesFragment : PreferenceFragmentCompat() { check(source is ConfigurableSource) - val sharedPreferences = requireContext().getSharedPreferences(source.getPreferenceKey(), Context.MODE_PRIVATE) + val sharedPreferences = requireContext().getSharedPreferences( + source.getPreferenceKey(), + Context.MODE_PRIVATE + ) val dataStore = SharedPreferencesDataStore(sharedPreferences) preferenceManager.preferenceDataStore = dataStore diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/MangaMigrationFlags.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/MangaMigrationFlags.kt index cf32ae03f..83ad92ce8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/MangaMigrationFlags.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/MangaMigrationFlags.kt @@ -58,10 +58,18 @@ object MangaMigrationFlags { if (manga != null) { if (manga.hasCustomCover(coverCache)) { - flags += MangaMigrationFlag.create(CUSTOM_COVER, defaultSelectedBitMap, R.string.custom_cover) + flags += MangaMigrationFlag.create( + CUSTOM_COVER, + defaultSelectedBitMap, + R.string.custom_cover + ) } if (downloadCache.getDownloadCount(manga) > 0) { - flags += MangaMigrationFlag.create(DELETE_DOWNLOADED, defaultSelectedBitMap, R.string.delete_downloaded) + flags += MangaMigrationFlag.create( + DELETE_DOWNLOADED, + defaultSelectedBitMap, + R.string.delete_downloaded + ) } } return flags diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MigrateMangaDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MigrateMangaDialog.kt index df74a7b8d..a54247893 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MigrateMangaDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MigrateMangaDialog.kt @@ -40,6 +40,7 @@ import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.source.MangaSource import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.ui.browse.manga.migration.MangaMigrationFlags +import java.util.Date import kotlinx.coroutines.flow.update import tachiyomi.core.preference.Preference import tachiyomi.core.preference.PreferenceStore @@ -58,7 +59,6 @@ import tachiyomi.domain.track.manga.interactor.InsertMangaTrack import tachiyomi.presentation.core.screens.LoadingScreen import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.Date @Composable internal fun MigrateMangaDialog( @@ -99,7 +99,10 @@ internal fun MigrateMangaDialog( .clickable(onClick = onChange), verticalAlignment = Alignment.CenterVertically, ) { - Checkbox(checked = selectedFlags[index], onCheckedChange = { onChange() }) + Checkbox( + checked = selectedFlags[index], + onCheckedChange = { onChange() } + ) Text(text = context.getString(flag.titleId)) } } @@ -300,7 +303,10 @@ internal class MigrateMangaDialogScreenModel( // Update custom cover (recheck if custom cover exists) if (migrateCustomCover && oldManga.hasCustomCover()) { - coverCache.setCustomCoverToCache(newManga, coverCache.getCustomCoverFile(oldManga.id).inputStream()) + coverCache.setCustomCoverToCache( + newManga, + coverCache.getCustomCoverFile(oldManga.id).inputStream() + ) } updateManga.await( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MigrateMangaSearchScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MigrateMangaSearchScreen.kt index e467aa48a..00ee5c432 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MigrateMangaSearchScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MigrateMangaSearchScreen.kt @@ -19,7 +19,9 @@ class MigrateSearchScreen(private val mangaId: Long) : Screen() { val screenModel = rememberScreenModel { MigrateSearchScreenModel(mangaId = mangaId) } val state by screenModel.state.collectAsState() - val dialogScreenModel = rememberScreenModel { MangaMigrateSearchScreenDialogScreenModel(mangaId = mangaId) } + val dialogScreenModel = rememberScreenModel { MangaMigrateSearchScreenDialogScreenModel( + mangaId = mangaId + ) } val dialogState by dialogScreenModel.state.collectAsState() MigrateMangaSearchScreen( @@ -32,9 +34,13 @@ class MigrateSearchScreen(private val mangaId: Long) : Screen() { onChangeSearchFilter = screenModel::setSourceFilter, onToggleResults = screenModel::toggleFilterResults, onClickSource = { - navigator.push(MangaSourceSearchScreen(dialogState.manga!!, it.id, state.searchQuery)) + navigator.push( + MangaSourceSearchScreen(dialogState.manga!!, it.id, state.searchQuery) + ) }, - onClickItem = { dialogScreenModel.setDialog(MangaMigrateSearchScreenDialogScreenModel.Dialog.Migrate(it)) }, + onClickItem = { dialogScreenModel.setDialog( + MangaMigrateSearchScreenDialogScreenModel.Dialog.Migrate(it) + ) }, onLongClickItem = { navigator.push(MangaScreen(it.id, true)) }, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreenModel.kt index b1a5b865f..525d76401 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreenModel.kt @@ -7,6 +7,7 @@ import eu.kanade.domain.source.manga.interactor.GetLanguagesWithMangaSources import eu.kanade.domain.source.manga.interactor.ToggleMangaSource import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.source.service.ToggleLanguage +import java.util.SortedMap import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.combine @@ -15,7 +16,6 @@ import kotlinx.coroutines.launch import tachiyomi.domain.source.manga.model.Source import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.SortedMap class SourcesFilterScreenModel( private val preferences: SourcePreferences = Injekt.get(), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt index 13b14bfcd..28fc071fc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt @@ -13,6 +13,7 @@ import eu.kanade.domain.source.service.SourcePreferences.DataSaver import eu.kanade.presentation.browse.manga.MangaSourceUiModel import eu.kanade.tachiyomi.util.system.LAST_USED_KEY import eu.kanade.tachiyomi.util.system.PINNED_KEY +import java.util.TreeMap import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collectLatest @@ -27,7 +28,6 @@ import tachiyomi.domain.source.manga.model.Pin import tachiyomi.domain.source.manga.model.Source import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.TreeMap class MangaSourcesScreenModel( private val preferences: BasePreferences = Injekt.get(), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreen.kt index 8722a2bb4..e8a6e83c9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreen.kt @@ -79,7 +79,9 @@ data class BrowseMangaSourceScreen( val navigator = LocalNavigator.currentOrThrow val navigateUp: () -> Unit = { when { - !state.isUserQuery && state.toolbarQuery != null -> screenModel.setToolbarQuery(null) + !state.isUserQuery && state.toolbarQuery != null -> screenModel.setToolbarQuery( + null + ) else -> navigator.pop() } } @@ -214,7 +216,9 @@ data class BrowseMangaSourceScreen( scope.launchIO { val duplicateManga = screenModel.getDuplicateLibraryManga(manga) when { - manga.favorite -> screenModel.setDialog(BrowseMangaSourceScreenModel.Dialog.RemoveManga(manga)) + manga.favorite -> screenModel.setDialog( + BrowseMangaSourceScreenModel.Dialog.RemoveManga(manga) + ) duplicateManga != null -> screenModel.setDialog( BrowseMangaSourceScreenModel.Dialog.AddDuplicateManga( manga, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreenModel.kt index 4bbc4b8e0..695207a2c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreenModel.kt @@ -25,8 +25,10 @@ import eu.kanade.tachiyomi.data.track.EnhancedMangaTrackService import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.source.CatalogueSource +import eu.kanade.tachiyomi.source.model.Filter as SourceModelFilter import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.util.removeCovers +import java.util.Date import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.emptyFlow @@ -57,8 +59,6 @@ import tachiyomi.domain.source.manga.service.MangaSourceManager import tachiyomi.domain.track.manga.interactor.InsertMangaTrack import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.Date -import eu.kanade.tachiyomi.source.model.Filter as SourceModelFilter class BrowseMangaSourceScreenModel( private val sourceId: Long, @@ -280,7 +280,12 @@ class BrowseMangaSourceScreenModel( // Choose a category else -> { val preselectedIds = getCategories.await(manga.id).map { it.id } - setDialog(Dialog.ChangeMangaCategory(manga, categories.mapAsCheckboxState { it.id in preselectedIds })) + setDialog( + Dialog.ChangeMangaCategory( + manga, + categories.mapAsCheckboxState { it.id in preselectedIds } + ) + ) } } } @@ -297,7 +302,11 @@ class BrowseMangaSourceScreenModel( (service as TrackService).mangaService.bind(track) insertTrack.await(track.toDomainTrack()!!) - syncChapterProgressWithTrack.await(manga.id, track.toDomainTrack()!!, service.mangaService) + syncChapterProgressWithTrack.await( + manga.id, + track.toDomainTrack()!!, + service.mangaService + ) } } catch (e: Exception) { logcat(LogPriority.WARN, e) { "Could not match manga: ${manga.title} with service $service" } @@ -349,7 +358,10 @@ class BrowseMangaSourceScreenModel( sealed class Listing(open val query: String?, open val filters: FilterList) { data object Popular : Listing(query = GetRemoteManga.QUERY_POPULAR, filters = FilterList()) data object Latest : Listing(query = GetRemoteManga.QUERY_LATEST, filters = FilterList()) - data class Search(override val query: String?, override val filters: FilterList) : Listing(query = query, filters = filters) + data class Search(override val query: String?, override val filters: FilterList) : Listing( + query = query, + filters = filters + ) companion object { fun valueOf(query: String?): Listing { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/GlobalMangaSearchScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/GlobalMangaSearchScreen.kt index 6c0df3958..0b5a2a836 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/GlobalMangaSearchScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/GlobalMangaSearchScreen.kt @@ -33,7 +33,9 @@ class GlobalMangaSearchScreen( } val state by screenModel.state.collectAsState() var showSingleLoadingScreen by remember { - mutableStateOf(searchQuery.isNotEmpty() && !extensionFilter.isNullOrEmpty() && state.total == 1) + mutableStateOf( + searchQuery.isNotEmpty() && !extensionFilter.isNullOrEmpty() && state.total == 1 + ) } if (showSingleLoadingScreen) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/MangaSearchScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/MangaSearchScreenModel.kt index 101f5cc82..bff803ee0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/MangaSearchScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/MangaSearchScreenModel.kt @@ -9,6 +9,7 @@ import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.presentation.util.ioCoroutineScope import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager import eu.kanade.tachiyomi.source.CatalogueSource +import java.util.concurrent.Executors import kotlinx.coroutines.Job import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.async @@ -26,7 +27,6 @@ import tachiyomi.domain.entries.manga.model.Manga import tachiyomi.domain.source.manga.service.MangaSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.concurrent.Executors abstract class MangaSearchScreenModel( initialState: State = State(), @@ -124,7 +124,9 @@ abstract class MangaSearchScreenModel( // Reuse previous results if possible if (sameQuery) { val existingResults = state.value.items - updateItems(sources.associateWith { existingResults[it] ?: MangaSearchItemResult.Loading }) + updateItems( + sources.associateWith { existingResults[it] ?: MangaSearchItemResult.Loading } + ) } else { updateItems(sources.associateWith { MangaSearchItemResult.Loading }) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/anime/AnimeCategoryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/anime/AnimeCategoryScreenModel.kt index 5d091033c..1662009ff 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/anime/AnimeCategoryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/anime/AnimeCategoryScreenModel.kt @@ -69,7 +69,9 @@ class AnimeCategoryScreenModel( fun hideCategory(category: Category) { coroutineScope.launch { when (hideCategory.await(category)) { - is HideAnimeCategory.Result.InternalError -> _events.send(AnimeCategoryEvent.InternalError) + is HideAnimeCategory.Result.InternalError -> _events.send( + AnimeCategoryEvent.InternalError + ) else -> {} } } @@ -78,7 +80,9 @@ class AnimeCategoryScreenModel( fun deleteCategory(categoryId: Long) { coroutineScope.launch { when (deleteCategory.await(categoryId = categoryId)) { - is DeleteAnimeCategory.Result.InternalError -> _events.send(AnimeCategoryEvent.InternalError) + is DeleteAnimeCategory.Result.InternalError -> _events.send( + AnimeCategoryEvent.InternalError + ) else -> {} } } @@ -87,7 +91,9 @@ class AnimeCategoryScreenModel( fun moveUp(category: Category) { coroutineScope.launch { when (reorderCategory.moveUp(category)) { - is ReorderAnimeCategory.Result.InternalError -> _events.send(AnimeCategoryEvent.InternalError) + is ReorderAnimeCategory.Result.InternalError -> _events.send( + AnimeCategoryEvent.InternalError + ) else -> {} } } @@ -96,7 +102,9 @@ class AnimeCategoryScreenModel( fun moveDown(category: Category) { coroutineScope.launch { when (reorderCategory.moveDown(category)) { - is ReorderAnimeCategory.Result.InternalError -> _events.send(AnimeCategoryEvent.InternalError) + is ReorderAnimeCategory.Result.InternalError -> _events.send( + AnimeCategoryEvent.InternalError + ) else -> {} } } @@ -105,7 +113,9 @@ class AnimeCategoryScreenModel( fun renameCategory(category: Category, name: String) { coroutineScope.launch { when (renameCategory.await(category, name)) { - is RenameAnimeCategory.Result.InternalError -> _events.send(AnimeCategoryEvent.InternalError) + is RenameAnimeCategory.Result.InternalError -> _events.send( + AnimeCategoryEvent.InternalError + ) else -> {} } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/manga/MangaCategoryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/manga/MangaCategoryScreenModel.kt index f0de34ed5..501a54bd6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/manga/MangaCategoryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/manga/MangaCategoryScreenModel.kt @@ -69,7 +69,9 @@ class MangaCategoryScreenModel( fun hideCategory(category: Category) { coroutineScope.launch { when (hideCategory.await(category)) { - is HideMangaCategory.Result.InternalError -> _events.send(MangaCategoryEvent.InternalError) + is HideMangaCategory.Result.InternalError -> _events.send( + MangaCategoryEvent.InternalError + ) else -> {} } } @@ -78,7 +80,9 @@ class MangaCategoryScreenModel( fun deleteCategory(categoryId: Long) { coroutineScope.launch { when (deleteCategory.await(categoryId = categoryId)) { - is DeleteMangaCategory.Result.InternalError -> _events.send(MangaCategoryEvent.InternalError) + is DeleteMangaCategory.Result.InternalError -> _events.send( + MangaCategoryEvent.InternalError + ) else -> {} } } @@ -87,7 +91,9 @@ class MangaCategoryScreenModel( fun moveUp(category: Category) { coroutineScope.launch { when (reorderCategory.moveUp(category)) { - is ReorderMangaCategory.Result.InternalError -> _events.send(MangaCategoryEvent.InternalError) + is ReorderMangaCategory.Result.InternalError -> _events.send( + MangaCategoryEvent.InternalError + ) else -> {} } } @@ -96,7 +102,9 @@ class MangaCategoryScreenModel( fun moveDown(category: Category) { coroutineScope.launch { when (reorderCategory.moveDown(category)) { - is ReorderMangaCategory.Result.InternalError -> _events.send(MangaCategoryEvent.InternalError) + is ReorderMangaCategory.Result.InternalError -> _events.send( + MangaCategoryEvent.InternalError + ) else -> {} } } @@ -105,7 +113,9 @@ class MangaCategoryScreenModel( fun renameCategory(category: Category, name: String) { coroutineScope.launch { when (renameCategory.await(category, name)) { - is RenameMangaCategory.Result.InternalError -> _events.send(MangaCategoryEvent.InternalError) + is RenameMangaCategory.Result.InternalError -> _events.send( + MangaCategoryEvent.InternalError + ) else -> {} } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadHeaderHolder.kt index b49ba11e9..915a8f730 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadHeaderHolder.kt @@ -7,7 +7,10 @@ import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.viewholders.ExpandableViewHolder import eu.kanade.tachiyomi.databinding.DownloadHeaderBinding -class AnimeDownloadHeaderHolder(view: View, adapter: FlexibleAdapter<*>) : ExpandableViewHolder(view, adapter) { +class AnimeDownloadHeaderHolder(view: View, adapter: FlexibleAdapter<*>) : ExpandableViewHolder( + view, + adapter +) { private val binding = DownloadHeaderBinding.bind(view) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadQueueScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadQueueScreen.kt index 33d87f74a..3b3b613d6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadQueueScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadQueueScreen.kt @@ -37,12 +37,12 @@ import androidx.core.view.updatePadding import androidx.recyclerview.widget.LinearLayoutManager import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.DownloadListBinding +import kotlin.math.roundToInt import kotlinx.coroutines.CoroutineScope import tachiyomi.core.util.lang.launchUI import tachiyomi.presentation.core.components.material.ExtendedFloatingActionButton import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen -import kotlin.math.roundToInt @Composable fun AnimeDownloadQueueScreen( @@ -61,8 +61,16 @@ fun AnimeDownloadQueueScreen( return scrollBehavior.nestedScrollConnection.onPreScroll(available, source) } - override fun onPostScroll(consumed: Offset, available: Offset, source: NestedScrollSource): Offset { - return scrollBehavior.nestedScrollConnection.onPostScroll(consumed, available, source) + override fun onPostScroll( + consumed: Offset, + available: Offset, + source: NestedScrollSource + ): Offset { + return scrollBehavior.nestedScrollConnection.onPostScroll( + consumed, + available, + source + ) } override suspend fun onPreFling(available: Velocity): Velocity { @@ -129,12 +137,16 @@ fun AnimeDownloadQueueScreen( Box(modifier = Modifier.nestedScroll(nestedScrollConnection)) { AndroidView( factory = { context -> - screenModel.controllerBinding = DownloadListBinding.inflate(LayoutInflater.from(context)) + screenModel.controllerBinding = DownloadListBinding.inflate( + LayoutInflater.from(context) + ) screenModel.adapter = AnimeDownloadAdapter(screenModel.listener) screenModel.controllerBinding.recycler.adapter = screenModel.adapter screenModel.adapter?.isHandleDragEnabled = true screenModel.adapter?.fastScroller = screenModel.controllerBinding.fastScroller - screenModel.controllerBinding.recycler.layoutManager = LinearLayoutManager(context) + screenModel.controllerBinding.recycler.layoutManager = LinearLayoutManager( + context + ) ViewCompat.setNestedScrollingEnabled(screenModel.controllerBinding.root, true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadQueueScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadQueueScreenModel.kt index 15aa181e5..a7a7d07a0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadQueueScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/anime/AnimeDownloadQueueScreenModel.kt @@ -153,7 +153,10 @@ class AnimeDownloadQueueScreenModel( downloadManager.cancelQueuedDownloads(downloads) } - fun > reorderQueue(selector: (AnimeDownloadItem) -> R, reverse: Boolean = false) { + fun > reorderQueue( + selector: (AnimeDownloadItem) -> R, + reverse: Boolean = false + ) { val adapter = adapter ?: return val newAnimeDownloads = mutableListOf() adapter.headerItems.forEach { headerItem -> diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadHeaderHolder.kt index 21bceb4c0..1c8331fe0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadHeaderHolder.kt @@ -7,7 +7,10 @@ import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.viewholders.ExpandableViewHolder import eu.kanade.tachiyomi.databinding.DownloadHeaderBinding -class MangaDownloadHeaderHolder(view: View, adapter: FlexibleAdapter<*>) : ExpandableViewHolder(view, adapter) { +class MangaDownloadHeaderHolder(view: View, adapter: FlexibleAdapter<*>) : ExpandableViewHolder( + view, + adapter +) { private val binding = DownloadHeaderBinding.bind(view) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadQueueScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadQueueScreen.kt index 2ecd2ff04..212872691 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadQueueScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadQueueScreen.kt @@ -37,12 +37,12 @@ import androidx.core.view.updatePadding import androidx.recyclerview.widget.LinearLayoutManager import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.DownloadListBinding +import kotlin.math.roundToInt import kotlinx.coroutines.CoroutineScope import tachiyomi.core.util.lang.launchUI import tachiyomi.presentation.core.components.material.ExtendedFloatingActionButton import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen -import kotlin.math.roundToInt @Composable fun DownloadQueueScreen( @@ -61,8 +61,16 @@ fun DownloadQueueScreen( return scrollBehavior.nestedScrollConnection.onPreScroll(available, source) } - override fun onPostScroll(consumed: Offset, available: Offset, source: NestedScrollSource): Offset { - return scrollBehavior.nestedScrollConnection.onPostScroll(consumed, available, source) + override fun onPostScroll( + consumed: Offset, + available: Offset, + source: NestedScrollSource + ): Offset { + return scrollBehavior.nestedScrollConnection.onPostScroll( + consumed, + available, + source + ) } override suspend fun onPreFling(available: Velocity): Velocity { @@ -129,12 +137,16 @@ fun DownloadQueueScreen( Box(modifier = Modifier.nestedScroll(nestedScrollConnection)) { AndroidView( factory = { context -> - screenModel.controllerBinding = DownloadListBinding.inflate(LayoutInflater.from(context)) + screenModel.controllerBinding = DownloadListBinding.inflate( + LayoutInflater.from(context) + ) screenModel.adapter = MangaDownloadAdapter(screenModel.listener) screenModel.controllerBinding.recycler.adapter = screenModel.adapter screenModel.adapter?.isHandleDragEnabled = true screenModel.adapter?.fastScroller = screenModel.controllerBinding.fastScroller - screenModel.controllerBinding.recycler.layoutManager = LinearLayoutManager(context) + screenModel.controllerBinding.recycler.layoutManager = LinearLayoutManager( + context + ) ViewCompat.setNestedScrollingEnabled(screenModel.controllerBinding.root, true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadQueueScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadQueueScreenModel.kt index 608a0aba1..dd7ce943c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadQueueScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/manga/MangaDownloadQueueScreenModel.kt @@ -159,7 +159,10 @@ class MangaDownloadQueueScreenModel( downloadManager.cancelQueuedDownloads(downloads) } - fun > reorderQueue(selector: (MangaDownloadItem) -> R, reverse: Boolean = false) { + fun > reorderQueue( + selector: (MangaDownloadItem) -> R, + reverse: Boolean = false + ) { val adapter = adapter ?: return val newDownloads = mutableListOf() adapter.headerItems.forEach { headerItem -> diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt index e925c715f..332bc6385 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt @@ -124,7 +124,11 @@ class AnimeScreen( screenModel.toggleFavorite() haptic.performHapticFeedback(HapticFeedbackType.LongPress) }, - onWebViewClicked = { openAnimeInWebView(navigator, screenModel.anime, screenModel.source) }.takeIf { isAnimeHttpSource }, + onWebViewClicked = { openAnimeInWebView( + navigator, + screenModel.anime, + screenModel.source + ) }.takeIf { isAnimeHttpSource }, onWebViewLongClicked = { copyAnimeUrl(context, screenModel.anime, screenModel.source) }.takeIf { isAnimeHttpSource }, onTrackingClicked = screenModel::showTrackDialog.takeIf { successState.trackingAvailable }, onTagSearch = { scope.launch { performGenreSearch(navigator, it, screenModel.source!!) } }, @@ -213,7 +217,9 @@ class AnimeScreen( val sm = rememberScreenModel { AnimeCoverScreenModel(successState.anime.id) } val anime by sm.state.collectAsState() if (anime != null) { - val getContent = rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { + val getContent = rememberLauncherForActivityResult( + ActivityResultContracts.GetContent() + ) { if (it == null) return@rememberLauncherForActivityResult sm.editCover(context, it) } @@ -280,13 +286,22 @@ class AnimeScreen( } } - private suspend fun continueWatching(context: Context, unseenEpisode: Episode?, useExternalPlayer: Boolean) { + private suspend fun continueWatching( + context: Context, + unseenEpisode: Episode?, + useExternalPlayer: Boolean + ) { if (unseenEpisode != null) openEpisode(context, unseenEpisode, useExternalPlayer) } private suspend fun openEpisode(context: Context, episode: Episode, useExternalPlayer: Boolean) { withIOContext { - MainActivity.startPlayerActivity(context, episode.animeId, episode.id, useExternalPlayer) + MainActivity.startPlayerActivity( + context, + episode.animeId, + episode.id, + useExternalPlayer + ) } } @@ -361,7 +376,11 @@ class AnimeScreen( * * @param genreName the search genre to the parent controller */ - private suspend fun performGenreSearch(navigator: Navigator, genreName: String, source: AnimeSource) { + private suspend fun performGenreSearch( + navigator: Navigator, + genreName: String, + source: AnimeSource + ) { if (navigator.size < 2) { return } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreenModel.kt index a9f9f19d4..185d84bcb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreenModel.kt @@ -36,6 +36,7 @@ import eu.kanade.tachiyomi.util.AniChartApi import eu.kanade.tachiyomi.util.episode.getNextUnseen import eu.kanade.tachiyomi.util.removeCovers import eu.kanade.tachiyomi.util.shouldDownloadNewEpisodes +import java.util.Calendar import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.flow.catch @@ -78,7 +79,6 @@ import tachiyomi.domain.track.anime.interactor.GetAnimeTracks import tachiyomi.source.local.entries.anime.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.Calendar class AnimeScreenModel( val context: Context, @@ -295,7 +295,9 @@ class AnimeScreenModel( if (checkDuplicate) { val duplicate = getDuplicateLibraryAnime.await(anime).getOrNull(0) if (duplicate != null) { - updateSuccessState { it.copy(dialog = Dialog.DuplicateAnime(anime, duplicate)) } + updateSuccessState { it.copy( + dialog = Dialog.DuplicateAnime(anime, duplicate) + ) } return@launchIO } } @@ -509,7 +511,12 @@ class AnimeScreenModel( val downloaded = if (isLocal) { true } else { - downloadManager.isEpisodeDownloaded(episode.name, episode.scanlator, anime.title, anime.source) + downloadManager.isEpisodeDownloaded( + episode.name, + episode.scanlator, + anime.title, + anime.source + ) } val downloadState = when { activeDownload != null -> activeDownload.status @@ -733,7 +740,11 @@ class AnimeScreenModel( * Downloads the given list of episodes with the manager. * @param episodes the list of episodes to download. */ - private fun downloadEpisodes(episodes: List, alt: Boolean = false, video: Video? = null) { + private fun downloadEpisodes( + episodes: List, + alt: Boolean = false, + video: Video? = null + ) { val anime = successState?.anime ?: return downloadManager.downloadEpisodes(anime, episodes, true, alt, video) toggleAllSelection(false) @@ -778,7 +789,12 @@ class AnimeScreenModel( coroutineScope.launchNonCancellable { val anime = successState?.anime ?: return@launchNonCancellable val categories = getCategories.await(anime.id).map { it.id } - if (episodes.isEmpty() || !anime.shouldDownloadNewEpisodes(categories, downloadPreferences)) return@launchNonCancellable + if (episodes.isEmpty() || !anime.shouldDownloadNewEpisodes( + categories, + downloadPreferences + )) { + return@launchNonCancellable + } downloadEpisodes(episodes) } } @@ -867,7 +883,9 @@ class AnimeScreenModel( if (applyToExisting) { setAnimeDefaultEpisodeFlags.awaitAll() } - snackbarHostState.showSnackbar(message = context.getString(R.string.episode_settings_updated)) + snackbarHostState.showSnackbar( + message = context.getString(R.string.episode_settings_updated) + ) } } @@ -971,7 +989,10 @@ class AnimeScreenModel( .map { tracks -> loggedServices // Map to TrackItem - .map { service -> AnimeTrackItem(tracks.find { it.syncId == service.id }, service) } + .map { service -> AnimeTrackItem( + tracks.find { it.syncId == service.id }, + service + ) } // Show only if the service supports this anime's source .filter { (it.service as? EnhancedAnimeTrackService)?.accept(source!!) ?: true } } @@ -983,7 +1004,11 @@ class AnimeScreenModel( } } - private suspend fun updateAiringTime(anime: Anime, trackItems: List, manualFetch: Boolean) { + private suspend fun updateAiringTime( + anime: Anime, + trackItems: List, + manualFetch: Boolean + ) { val airingEpisodeData = AniChartApi().loadAiringTime(anime, trackItems, manualFetch) setAnimeViewerFlags.awaitSetNextEpisodeAiring(anime.id, airingEpisodeData) updateSuccessState { it.copy(nextAiringEpisode = airingEpisodeData) } @@ -992,7 +1017,10 @@ class AnimeScreenModel( // Track sheet - end sealed interface Dialog { - data class ChangeCategory(val anime: Anime, val initialSelection: List>) : Dialog + data class ChangeCategory( + val anime: Anime, + val initialSelection: List> + ) : Dialog data class DeleteEpisodes(val episodes: List) : Dialog data class DuplicateAnime(val anime: Anime, val duplicate: Anime) : Dialog data class SetAnimeFetchInterval(val anime: Anime) : Dialog @@ -1045,7 +1073,10 @@ class AnimeScreenModel( val isRefreshingData: Boolean = false, val dialog: Dialog? = null, val hasPromptedToAddBefore: Boolean = false, - val nextAiringEpisode: Pair = Pair(anime.nextEpisodeToAir, anime.nextEpisodeAiringAt), + val nextAiringEpisode: Pair = Pair( + anime.nextEpisodeToAir, + anime.nextEpisodeAiringAt + ), ) : State { val processedEpisodes by lazy { @@ -1062,7 +1093,9 @@ class AnimeScreenModel( get() = nextAiringEpisode.first.toDouble() val airingTime: Long - get() = nextAiringEpisode.second.times(1000L).minus(Calendar.getInstance().timeInMillis) + get() = nextAiringEpisode.second.times(1000L).minus( + Calendar.getInstance().timeInMillis + ) /** * Applies the view filters to the list of episodes obtained from the database. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/track/AnimeTrackInfoDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/track/AnimeTrackInfoDialog.kt index 7889672da..950f27507 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/track/AnimeTrackInfoDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/track/AnimeTrackInfoDialog.kt @@ -59,6 +59,10 @@ import eu.kanade.tachiyomi.data.track.model.AnimeTrackSearch import eu.kanade.tachiyomi.util.lang.convertEpochMillisZone import eu.kanade.tachiyomi.util.system.openInBrowser import eu.kanade.tachiyomi.util.system.toast +import java.time.Instant +import java.time.LocalDate +import java.time.ZoneId +import java.time.ZoneOffset import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.distinctUntilChanged @@ -75,15 +79,11 @@ import tachiyomi.domain.source.anime.service.AnimeSourceManager import tachiyomi.domain.track.anime.interactor.DeleteAnimeTrack import tachiyomi.domain.track.anime.interactor.GetAnimeTracks import tachiyomi.domain.track.anime.model.AnimeTrack +import tachiyomi.domain.track.anime.model.AnimeTrack as DbAnimeTrack import tachiyomi.presentation.core.components.material.AlertDialogContent import tachiyomi.presentation.core.components.material.padding import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.time.Instant -import java.time.LocalDate -import java.time.ZoneId -import java.time.ZoneOffset -import tachiyomi.domain.track.anime.model.AnimeTrack as DbAnimeTrack data class AnimeTrackInfoDialogHomeScreen( private val animeId: Long, @@ -96,7 +96,9 @@ data class AnimeTrackInfoDialogHomeScreen( val context = LocalContext.current val sm = rememberScreenModel { Model(animeId, sourceId) } - val dateFormat = remember { UiPreferences.dateFormat(Injekt.get().dateFormat().get()) } + val dateFormat = remember { UiPreferences.dateFormat( + Injekt.get().dateFormat().get() + ) } val state by sm.state.collectAsState() AnimeTrackInfoDialogHome( @@ -197,7 +199,9 @@ data class AnimeTrackInfoDialogHomeScreen( .catch { logcat(LogPriority.ERROR, it) } .distinctUntilChanged() .map { it.mapToTrackItem() } - .collectLatest { trackItems -> mutableState.update { it.copy(trackItems = trackItems) } } + .collectLatest { trackItems -> mutableState.update { it.copy( + trackItems = trackItems + ) } } } } @@ -351,7 +355,10 @@ private data class TrackEpisodeSelectorScreen( fun setEpisode() { coroutineScope.launchNonCancellable { - service.animeService.setRemoteLastEpisodeSeen(track.toDbTrack(), state.value.selection) + service.animeService.setRemoteLastEpisodeSeen( + track.toDbTrack(), + state.value.selection + ) } } @@ -584,7 +591,10 @@ private data class TrackDateRemoverScreen( buttons = { Row( modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small, Alignment.End), + horizontalArrangement = Arrangement.spacedBy( + MaterialTheme.padding.small, + Alignment.End + ), ) { TextButton(onClick = navigator::pop) { Text(text = stringResource(android.R.string.cancel)) @@ -748,8 +758,16 @@ private data class TrackAnimeServiceRemoveScreen( ) if (sm.isServiceDeletable()) { Row(verticalAlignment = Alignment.CenterVertically) { - Checkbox(checked = removeRemoteTrack, onCheckedChange = { removeRemoteTrack = it }) - Text(text = stringResource(R.string.track_delete_remote_text, serviceName)) + Checkbox( + checked = removeRemoteTrack, + onCheckedChange = { removeRemoteTrack = it } + ) + Text( + text = stringResource( + R.string.track_delete_remote_text, + serviceName + ) + ) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt index a966d7e22..d96b6b4b5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt @@ -112,7 +112,11 @@ class MangaScreen( screenModel.toggleFavorite() haptic.performHapticFeedback(HapticFeedbackType.LongPress) }, - onWebViewClicked = { openMangaInWebView(navigator, screenModel.manga, screenModel.source) }.takeIf { isHttpSource }, + onWebViewClicked = { openMangaInWebView( + navigator, + screenModel.manga, + screenModel.source + ) }.takeIf { isHttpSource }, onWebViewLongClicked = { copyMangaUrl(context, screenModel.manga, screenModel.source) }.takeIf { isHttpSource }, onTrackingClicked = screenModel::showTrackDialog.takeIf { successState.trackingAvailable }, onTagSearch = { scope.launch { performGenreSearch(navigator, it, screenModel.source!!) } }, @@ -195,7 +199,9 @@ class MangaScreen( val sm = rememberScreenModel { MangaCoverScreenModel(successState.manga.id) } val manga by sm.state.collectAsState() if (manga != null) { - val getContent = rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { + val getContent = rememberLauncherForActivityResult( + ActivityResultContracts.GetContent() + ) { if (it == null) return@rememberLauncherForActivityResult sm.editCover(context, it) } @@ -306,7 +312,11 @@ class MangaScreen( * * @param genreName the search genre to the parent controller */ - private suspend fun performGenreSearch(navigator: Navigator, genreName: String, source: MangaSource) { + private suspend fun performGenreSearch( + navigator: Navigator, + genreName: String, + source: MangaSource + ) { if (navigator.size < 2) { return } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreenModel.kt index d5778baf5..ec2d5bba1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreenModel.kt @@ -292,7 +292,9 @@ class MangaScreenModel( val duplicate = getDuplicateLibraryManga.await(manga).getOrNull(0) if (duplicate != null) { - updateSuccessState { it.copy(dialog = Dialog.DuplicateManga(manga, duplicate)) } + updateSuccessState { it.copy( + dialog = Dialog.DuplicateManga(manga, duplicate) + ) } return@launchIO } } @@ -506,7 +508,12 @@ class MangaScreenModel( val downloaded = if (isLocal) { true } else { - downloadManager.isChapterDownloaded(chapter.name, chapter.scanlator, manga.title, manga.source) + downloadManager.isChapterDownloaded( + chapter.name, + chapter.scanlator, + manga.title, + manga.source + ) } val downloadState = when { activeDownload != null -> activeDownload.status @@ -769,7 +776,10 @@ class MangaScreenModel( coroutineScope.launchNonCancellable { val manga = successState?.manga ?: return@launchNonCancellable val categories = getCategories.await(manga.id).map { it.id } - if (chapters.isEmpty() || !manga.shouldDownloadNewChapters(categories, downloadPreferences)) return@launchNonCancellable + if (chapters.isEmpty() || !manga.shouldDownloadNewChapters( + categories, + downloadPreferences + )) return@launchNonCancellable downloadChapters(chapters) } } @@ -858,7 +868,9 @@ class MangaScreenModel( if (applyToExisting) { setMangaDefaultChapterFlags.awaitAll() } - snackbarHostState.showSnackbar(message = context.getString(R.string.chapter_settings_updated)) + snackbarHostState.showSnackbar( + message = context.getString(R.string.chapter_settings_updated) + ) } } @@ -963,7 +975,10 @@ class MangaScreenModel( .map { tracks -> loggedServices // Map to TrackItem - .map { service -> MangaTrackItem(tracks.find { it.syncId.toLong() == service.id }, service) } + .map { service -> MangaTrackItem( + tracks.find { it.syncId.toLong() == service.id }, + service + ) } // Show only if the service supports this manga's source .filter { (it.service as? EnhancedMangaTrackService)?.accept(source!!) ?: true } } @@ -977,7 +992,10 @@ class MangaScreenModel( // Track sheet - end sealed interface Dialog { - data class ChangeCategory(val manga: Manga, val initialSelection: List>) : Dialog + data class ChangeCategory( + val manga: Manga, + val initialSelection: List> + ) : Dialog data class DeleteChapters(val chapters: List) : Dialog data class DuplicateManga(val manga: Manga, val duplicate: Manga) : Dialog data class SetMangaFetchInterval(val manga: Manga) : Dialog diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/track/MangaTrackInfoDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/track/MangaTrackInfoDialog.kt index 1f8207fcf..1ea4f427e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/track/MangaTrackInfoDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/track/MangaTrackInfoDialog.kt @@ -59,6 +59,10 @@ import eu.kanade.tachiyomi.data.track.model.MangaTrackSearch import eu.kanade.tachiyomi.util.lang.convertEpochMillisZone import eu.kanade.tachiyomi.util.system.openInBrowser import eu.kanade.tachiyomi.util.system.toast +import java.time.Instant +import java.time.LocalDate +import java.time.ZoneId +import java.time.ZoneOffset import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.distinctUntilChanged @@ -75,15 +79,11 @@ import tachiyomi.domain.source.manga.service.MangaSourceManager import tachiyomi.domain.track.manga.interactor.DeleteMangaTrack import tachiyomi.domain.track.manga.interactor.GetMangaTracks import tachiyomi.domain.track.manga.model.MangaTrack +import tachiyomi.domain.track.manga.model.MangaTrack as DbMangaTrack import tachiyomi.presentation.core.components.material.AlertDialogContent import tachiyomi.presentation.core.components.material.padding import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.time.Instant -import java.time.LocalDate -import java.time.ZoneId -import java.time.ZoneOffset -import tachiyomi.domain.track.manga.model.MangaTrack as DbMangaTrack data class MangaTrackInfoDialogHomeScreen( private val mangaId: Long, @@ -96,7 +96,9 @@ data class MangaTrackInfoDialogHomeScreen( val context = LocalContext.current val sm = rememberScreenModel { Model(mangaId, sourceId) } - val dateFormat = remember { UiPreferences.dateFormat(Injekt.get().dateFormat().get()) } + val dateFormat = remember { UiPreferences.dateFormat( + Injekt.get().dateFormat().get() + ) } val state by sm.state.collectAsState() MangaTrackInfoDialogHome( @@ -197,7 +199,9 @@ data class MangaTrackInfoDialogHomeScreen( .catch { logcat(LogPriority.ERROR, it) } .distinctUntilChanged() .map { it.mapToTrackItem() } - .collectLatest { trackItems -> mutableState.update { it.copy(trackItems = trackItems) } } + .collectLatest { trackItems -> mutableState.update { it.copy( + trackItems = trackItems + ) } } } } @@ -351,7 +355,10 @@ private data class TrackChapterSelectorScreen( fun setChapter() { coroutineScope.launchNonCancellable { - service.mangaService.setRemoteLastChapterRead(track.toDbTrack(), state.value.selection) + service.mangaService.setRemoteLastChapterRead( + track.toDbTrack(), + state.value.selection + ) } } @@ -584,7 +591,10 @@ private data class TrackDateRemoverScreen( buttons = { Row( modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small, Alignment.End), + horizontalArrangement = Arrangement.spacedBy( + MaterialTheme.padding.small, + Alignment.End + ), ) { TextButton(onClick = navigator::pop) { Text(text = stringResource(android.R.string.cancel)) @@ -748,8 +758,16 @@ private data class TrackMangaServiceRemoveScreen( ) if (sm.isServiceDeletable()) { Row(verticalAlignment = Alignment.CenterVertically) { - Checkbox(checked = removeRemoteTrack, onCheckedChange = { removeRemoteTrack = it }) - Text(text = stringResource(R.string.track_delete_remote_text, serviceName)) + Checkbox( + checked = removeRemoteTrack, + onCheckedChange = { removeRemoteTrack = it } + ) + Text( + text = stringResource( + R.string.track_delete_remote_text, + serviceName + ) + ) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryScreenModel.kt index 2c8385890..c2708bc0f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryScreenModel.kt @@ -6,6 +6,7 @@ import cafe.adriel.voyager.core.model.coroutineScope import eu.kanade.core.util.insertSeparators import eu.kanade.presentation.history.anime.AnimeHistoryUiModel import eu.kanade.tachiyomi.util.lang.toDateKey +import java.util.Date import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow @@ -31,7 +32,6 @@ import tachiyomi.domain.history.anime.model.AnimeHistoryWithRelations import tachiyomi.domain.items.episode.model.Episode import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.Date class AnimeHistoryScreenModel( private val getHistory: GetAnimeHistory = Injekt.get(), @@ -73,7 +73,9 @@ class AnimeHistoryScreenModel( val beforeDate = before?.item?.seenAt?.time?.toDateKey() ?: Date(0) val afterDate = after?.item?.seenAt?.time?.toDateKey() ?: Date(0) when { - beforeDate.time != afterDate.time && afterDate.time != 0L -> AnimeHistoryUiModel.Header(afterDate) + beforeDate.time != afterDate.time && afterDate.time != 0L -> AnimeHistoryUiModel.Header( + afterDate + ) // Return null to avoid adding a separator between two items. else -> null } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryTab.kt index 24cd053a8..bba5600b8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryTab.kt @@ -102,10 +102,17 @@ fun Screen.animeHistoryTab( screenModel.events.collectLatest { e -> when (e) { AnimeHistoryScreenModel.Event.InternalError -> - snackbarHostState.showSnackbar(context.getString(R.string.internal_error)) + snackbarHostState.showSnackbar( + context.getString(R.string.internal_error) + ) AnimeHistoryScreenModel.Event.HistoryCleared -> - snackbarHostState.showSnackbar(context.getString(R.string.clear_history_completed)) - is AnimeHistoryScreenModel.Event.OpenEpisode -> openEpisode(context, e.episode) + snackbarHostState.showSnackbar( + context.getString(R.string.clear_history_completed) + ) + is AnimeHistoryScreenModel.Event.OpenEpisode -> openEpisode( + context, + e.episode + ) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryScreenModel.kt index 222e73f4f..265904bac 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryScreenModel.kt @@ -6,6 +6,7 @@ import cafe.adriel.voyager.core.model.coroutineScope import eu.kanade.core.util.insertSeparators import eu.kanade.presentation.history.manga.MangaHistoryUiModel import eu.kanade.tachiyomi.util.lang.toDateKey +import java.util.Date import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow @@ -31,7 +32,6 @@ import tachiyomi.domain.history.manga.model.MangaHistoryWithRelations import tachiyomi.domain.items.chapter.model.Chapter import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.Date class MangaHistoryScreenModel( private val getHistory: GetMangaHistory = Injekt.get(), @@ -73,7 +73,9 @@ class MangaHistoryScreenModel( val beforeDate = before?.item?.readAt?.time?.toDateKey() ?: Date(0) val afterDate = after?.item?.readAt?.time?.toDateKey() ?: Date(0) when { - beforeDate.time != afterDate.time && afterDate.time != 0L -> MangaHistoryUiModel.Header(afterDate) + beforeDate.time != afterDate.time && afterDate.time != 0L -> MangaHistoryUiModel.Header( + afterDate + ) // Return null to avoid adding a separator between two items. else -> null } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryTab.kt index 3c3749c03..4220dd55b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryTab.kt @@ -100,10 +100,17 @@ fun Screen.mangaHistoryTab( screenModel.events.collectLatest { e -> when (e) { MangaHistoryScreenModel.Event.InternalError -> - snackbarHostState.showSnackbar(context.getString(R.string.internal_error)) + snackbarHostState.showSnackbar( + context.getString(R.string.internal_error) + ) MangaHistoryScreenModel.Event.HistoryCleared -> - snackbarHostState.showSnackbar(context.getString(R.string.clear_history_completed)) - is MangaHistoryScreenModel.Event.OpenChapter -> openChapter(context, e.chapter) + snackbarHostState.showSnackbar( + context.getString(R.string.clear_history_completed) + ) + is MangaHistoryScreenModel.Event.OpenChapter -> openChapter( + context, + e.chapter + ) } } } 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 ef74eee93..2ec39cc82 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 @@ -155,7 +155,10 @@ object HomeScreen : Screen() { AnimatedContent( targetState = tabNavigator.current, transitionSpec = { - materialFadeThroughIn(initialScale = 1f, durationMillis = TabFadeDuration) togetherWith + materialFadeThroughIn( + initialScale = 1f, + durationMillis = TabFadeDuration + ) togetherWith materialFadeThroughOut(durationMillis = TabFadeDuration) }, content = { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryScreenModel.kt index 157daa6af..6fdf4f766 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryScreenModel.kt @@ -29,6 +29,9 @@ import eu.kanade.tachiyomi.data.track.AnimeTrackService import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.util.episode.getNextUnseen import eu.kanade.tachiyomi.util.removeCovers +import java.text.Collator +import java.util.Collections +import java.util.Locale import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.combine @@ -65,9 +68,6 @@ import tachiyomi.domain.track.anime.interactor.GetTracksPerAnime import tachiyomi.source.local.entries.anime.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.text.Collator -import java.util.Collections -import java.util.Locale /** * Typealias for the library anime, using the category as keys, and list of anime as values. @@ -92,7 +92,9 @@ class AnimeLibraryScreenModel( private val trackManager: TrackManager = Injekt.get(), ) : StateScreenModel(State()) { - var activeCategoryIndex: Int by libraryPreferences.lastUsedAnimeCategory().asState(coroutineScope) + var activeCategoryIndex: Int by libraryPreferences.lastUsedAnimeCategory().asState( + coroutineScope + ) init { coroutineScope.launchIO { @@ -243,7 +245,10 @@ class AnimeLibraryScreenModel( strength = Collator.PRIMARY } val sortAlphabetically: (AnimeLibraryItem, AnimeLibraryItem) -> Int = { i1, i2 -> - collator.compare(i1.libraryAnime.anime.title.lowercase(locale), i2.libraryAnime.anime.title.lowercase(locale)) + collator.compare( + i1.libraryAnime.anime.title.lowercase(locale), + i2.libraryAnime.anime.title.lowercase(locale) + ) } val sortFn: (AnimeLibraryItem, AnimeLibraryItem) -> Int = { i1, i2 -> @@ -280,7 +285,9 @@ class AnimeLibraryScreenModel( AnimeLibrarySort.Type.AiringTime -> when { i1.libraryAnime.anime.nextEpisodeAiringAt == 0L -> if (sort.isAscending) 1 else -1 i2.libraryAnime.anime.nextEpisodeAiringAt == 0L -> if (sort.isAscending) -1 else 1 - i1.libraryAnime.unseenCount == i2.libraryAnime.unseenCount -> i1.libraryAnime.anime.nextEpisodeAiringAt.compareTo(i2.libraryAnime.anime.nextEpisodeAiringAt) + i1.libraryAnime.unseenCount == i2.libraryAnime.unseenCount -> i1.libraryAnime.anime.nextEpisodeAiringAt.compareTo( + i2.libraryAnime.anime.nextEpisodeAiringAt + ) else -> i1.libraryAnime.unseenCount.compareTo(i2.libraryAnime.unseenCount) } } @@ -511,7 +518,11 @@ class AnimeLibraryScreenModel( * @param addCategories the categories to add for all animes. * @param removeCategories the categories to remove in all animes. */ - fun setAnimeCategories(animeList: List, addCategories: List, removeCategories: List) { + fun setAnimeCategories( + animeList: List, + addCategories: List, + removeCategories: List + ) { coroutineScope.launchNonCancellable { animeList.forEach { anime -> val categoryIds = getCategories.await(anime.id) @@ -530,7 +541,9 @@ class AnimeLibraryScreenModel( } fun getColumnsPreferenceForCurrentOrientation(isLandscape: Boolean): PreferenceMutableState { - return (if (isLandscape) libraryPreferences.animeLandscapeColumns() else libraryPreferences.animePortraitColumns()).asState(coroutineScope) + return (if (isLandscape) libraryPreferences.animeLandscapeColumns() else libraryPreferences.animePortraitColumns()).asState( + coroutineScope + ) } suspend fun getRandomAnimelibItemForCurrentCategory(): AnimeLibraryItem? { @@ -666,7 +679,10 @@ class AnimeLibraryScreenModel( sealed interface Dialog { data object SettingsSheet : Dialog - data class ChangeCategory(val anime: List, val initialSelection: List>) : Dialog + data class ChangeCategory( + val anime: List, + val initialSelection: List> + ) : Dialog data class DeleteAnime(val anime: List) : Dialog } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibrarySettingsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibrarySettingsScreenModel.kt index 808cdd3a7..c283a82b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibrarySettingsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibrarySettingsScreenModel.kt @@ -42,7 +42,11 @@ class AnimeLibrarySettingsScreenModel( setAnimeDisplayMode.await(mode) } - fun setSort(category: Category?, mode: AnimeLibrarySort.Type, direction: AnimeLibrarySort.Direction) { + fun setSort( + category: Category?, + mode: AnimeLibrarySort.Type, + direction: AnimeLibrarySort.Direction + ) { coroutineScope.launchIO { setSortModeForCategory.await(category, mode, direction) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryTab.kt index 08213f64e..43dc80f8c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryTab.kt @@ -77,7 +77,9 @@ object AnimeLibraryTab : Tab() { R.string.label_anime_library } val isSelected = LocalTabNavigator.current.current.key == key - val image = AnimatedImageVector.animatedVectorResource(R.drawable.anim_animelibrary_leave) + val image = AnimatedImageVector.animatedVectorResource( + R.drawable.anim_animelibrary_leave + ) return TabOptions( index = 0u, title = stringResource(title), @@ -118,7 +120,13 @@ object AnimeLibraryTab : Tab() { MainActivity.startPlayerActivity(context, episode.animeId, episode.id, extPlayer) } - val defaultTitle = if (fromMore) stringResource(R.string.label_library) else stringResource(R.string.label_anime_library) + val defaultTitle = if (fromMore) { + stringResource(R.string.label_library) + } else { + stringResource( + R.string.label_anime_library + ) + } Scaffold( topBar = { scrollBehavior -> @@ -134,9 +142,13 @@ object AnimeLibraryTab : Tab() { title = title, onClickUnselectAll = screenModel::clearSelection, onClickSelectAll = { screenModel.selectAll(screenModel.activeCategoryIndex) }, - onClickInvertSelection = { screenModel.invertSelection(screenModel.activeCategoryIndex) }, + onClickInvertSelection = { screenModel.invertSelection( + screenModel.activeCategoryIndex + ) }, onClickFilter = screenModel::showSettingsDialog, - onClickRefresh = { onClickRefresh(state.categories[screenModel.activeCategoryIndex]) }, + onClickRefresh = { onClickRefresh( + state.categories[screenModel.activeCategoryIndex] + ) }, onClickGlobalUpdate = { onClickRefresh(null) }, onClickOpenRandomEntry = { scope.launch { @@ -144,7 +156,9 @@ object AnimeLibraryTab : Tab() { if (randomItem != null) { navigator.push(AnimeScreen(randomItem.libraryAnime.anime.id)) } else { - snackbarHostState.showSnackbar(context.getString(R.string.information_no_entries_found)) + snackbarHostState.showSnackbar( + context.getString(R.string.information_no_entries_found) + ) } } }, @@ -178,7 +192,9 @@ object AnimeLibraryTab : Tab() { EmptyScreenAction( stringResId = R.string.getting_started_guide, icon = Icons.Outlined.HelpOutline, - onClick = { handler.openUri("https://aniyomi.org/help/guides/getting-started") }, + onClick = { handler.openUri( + "https://aniyomi.org/help/guides/getting-started" + ) }, ), ), ) @@ -208,11 +224,15 @@ object AnimeLibraryTab : Tab() { }, onRefresh = onClickRefresh, onGlobalSearchClicked = { - navigator.push(GlobalAnimeSearchScreen(screenModel.state.value.searchQuery ?: "")) + navigator.push( + GlobalAnimeSearchScreen(screenModel.state.value.searchQuery ?: "") + ) }, getNumberOfAnimeForCategory = { state.getAnimeCountForCategory(it) }, getDisplayMode = { screenModel.getDisplayMode() }, - getColumnsForOrientation = { screenModel.getColumnsPreferenceForCurrentOrientation(it) }, + getColumnsForOrientation = { screenModel.getColumnsPreferenceForCurrentOrientation( + it + ) }, ) { state.getAnimelibItemsByPage(it) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryScreenModel.kt index 2b9f76c6d..5c53b3a6d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryScreenModel.kt @@ -29,6 +29,9 @@ import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.chapter.getNextUnread import eu.kanade.tachiyomi.util.removeCovers +import java.text.Collator +import java.util.Collections +import java.util.Locale import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.combine @@ -65,9 +68,6 @@ import tachiyomi.domain.track.manga.interactor.GetTracksPerManga import tachiyomi.source.local.entries.manga.isLocal import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.text.Collator -import java.util.Collections -import java.util.Locale /** * Typealias for the library manga, using the category as keys, and list of manga as values. @@ -92,7 +92,9 @@ class MangaLibraryScreenModel( private val trackManager: TrackManager = Injekt.get(), ) : StateScreenModel(State()) { - var activeCategoryIndex: Int by libraryPreferences.lastUsedMangaCategory().asState(coroutineScope) + var activeCategoryIndex: Int by libraryPreferences.lastUsedMangaCategory().asState( + coroutineScope + ) init { coroutineScope.launchIO { @@ -243,7 +245,10 @@ class MangaLibraryScreenModel( strength = Collator.PRIMARY } val sortAlphabetically: (MangaLibraryItem, MangaLibraryItem) -> Int = { i1, i2 -> - collator.compare(i1.libraryManga.manga.title.lowercase(locale), i2.libraryManga.manga.title.lowercase(locale)) + collator.compare( + i1.libraryManga.manga.title.lowercase(locale), + i2.libraryManga.manga.title.lowercase(locale) + ) } val sortFn: (MangaLibraryItem, MangaLibraryItem) -> Int = { i1, i2 -> @@ -505,7 +510,11 @@ class MangaLibraryScreenModel( * @param addCategories the categories to add for all mangas. * @param removeCategories the categories to remove in all mangas. */ - fun setMangaCategories(mangaList: List, addCategories: List, removeCategories: List) { + fun setMangaCategories( + mangaList: List, + addCategories: List, + removeCategories: List + ) { coroutineScope.launchNonCancellable { mangaList.forEach { manga -> val categoryIds = getCategories.await(manga.id) @@ -524,7 +533,9 @@ class MangaLibraryScreenModel( } fun getColumnsPreferenceForCurrentOrientation(isLandscape: Boolean): PreferenceMutableState { - return (if (isLandscape) libraryPreferences.mangaLandscapeColumns() else libraryPreferences.mangaPortraitColumns()).asState(coroutineScope) + return (if (isLandscape) libraryPreferences.mangaLandscapeColumns() else libraryPreferences.mangaPortraitColumns()).asState( + coroutineScope + ) } suspend fun getRandomLibraryItemForCurrentCategory(): MangaLibraryItem? { @@ -660,7 +671,10 @@ class MangaLibraryScreenModel( sealed interface Dialog { data object SettingsSheet : Dialog - data class ChangeCategory(val manga: List, val initialSelection: List>) : Dialog + data class ChangeCategory( + val manga: List, + val initialSelection: List> + ) : Dialog data class DeleteManga(val manga: List) : Dialog } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibrarySettingsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibrarySettingsScreenModel.kt index da086b065..9bb9463b5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibrarySettingsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibrarySettingsScreenModel.kt @@ -42,7 +42,11 @@ class MangaLibrarySettingsScreenModel( setMangaDisplayMode.await(mode) } - fun setSort(category: Category?, mode: MangaLibrarySort.Type, direction: MangaLibrarySort.Direction) { + fun setSort( + category: Category?, + mode: MangaLibrarySort.Type, + direction: MangaLibrarySort.Direction + ) { coroutineScope.launchIO { setSortModeForCategory.await(category, mode, direction) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryTab.kt index cfe0743b0..7de5f2d75 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryTab.kt @@ -114,7 +114,13 @@ object MangaLibraryTab : Tab() { val navigateUp: (() -> Unit)? = if (fromMore) navigator::pop else null - val defaultTitle = if (fromMore) stringResource(R.string.label_library) else stringResource(R.string.label_manga_library) + val defaultTitle = if (fromMore) { + stringResource(R.string.label_library) + } else { + stringResource( + R.string.label_manga_library + ) + } Scaffold( topBar = { scrollBehavior -> @@ -130,9 +136,13 @@ object MangaLibraryTab : Tab() { title = title, onClickUnselectAll = screenModel::clearSelection, onClickSelectAll = { screenModel.selectAll(screenModel.activeCategoryIndex) }, - onClickInvertSelection = { screenModel.invertSelection(screenModel.activeCategoryIndex) }, + onClickInvertSelection = { screenModel.invertSelection( + screenModel.activeCategoryIndex + ) }, onClickFilter = screenModel::showSettingsDialog, - onClickRefresh = { onClickRefresh(state.categories[screenModel.activeCategoryIndex]) }, + onClickRefresh = { onClickRefresh( + state.categories[screenModel.activeCategoryIndex] + ) }, onClickGlobalUpdate = { onClickRefresh(null) }, onClickOpenRandomEntry = { scope.launch { @@ -140,7 +150,9 @@ object MangaLibraryTab : Tab() { if (randomItem != null) { navigator.push(MangaScreen(randomItem.libraryManga.manga.id)) } else { - snackbarHostState.showSnackbar(context.getString(R.string.information_no_entries_found)) + snackbarHostState.showSnackbar( + context.getString(R.string.information_no_entries_found) + ) } } }, @@ -175,7 +187,9 @@ object MangaLibraryTab : Tab() { EmptyScreenAction( stringResId = R.string.getting_started_guide, icon = Icons.Outlined.HelpOutline, - onClick = { handler.openUri("https://aniyomi.org/help/guides/getting-started") }, + onClick = { handler.openUri( + "https://aniyomi.org/help/guides/getting-started" + ) }, ), ), ) @@ -195,9 +209,17 @@ object MangaLibraryTab : Tab() { scope.launchIO { val chapter = screenModel.getNextUnreadChapter(it.manga) if (chapter != null) { - context.startActivity(ReaderActivity.newIntent(context, chapter.mangaId, chapter.id)) + context.startActivity( + ReaderActivity.newIntent( + context, + chapter.mangaId, + chapter.id + ) + ) } else { - snackbarHostState.showSnackbar(context.getString(R.string.no_next_chapter)) + snackbarHostState.showSnackbar( + context.getString(R.string.no_next_chapter) + ) } } Unit @@ -209,11 +231,15 @@ object MangaLibraryTab : Tab() { }, onRefresh = onClickRefresh, onGlobalSearchClicked = { - navigator.push(GlobalMangaSearchScreen(screenModel.state.value.searchQuery ?: "")) + navigator.push( + GlobalMangaSearchScreen(screenModel.state.value.searchQuery ?: "") + ) }, getNumberOfMangaForCategory = { state.getMangaCountForCategory(it) }, getDisplayMode = { screenModel.getDisplayMode() }, - getColumnsForOrientation = { screenModel.getColumnsPreferenceForCurrentOrientation(it) }, + getColumnsForOrientation = { screenModel.getColumnsPreferenceForCurrentOrientation( + it + ) }, ) { state.getLibraryItemsByPage(it) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 957ab2f6e..94d39cfa7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -37,6 +37,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color.Companion as ComposeColor import androidx.compose.ui.graphics.luminance import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource @@ -113,7 +114,6 @@ import tachiyomi.presentation.core.util.collectAsState import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy -import androidx.compose.ui.graphics.Color.Companion as ComposeColor class MainActivity : BaseActivity() { @@ -213,7 +213,10 @@ class MainActivity : BaseActivity() { Navigator( screen = HomeScreen, - disposeBehavior = NavigatorDisposeBehavior(disposeNestedNavigators = false, disposeSteps = true), + disposeBehavior = NavigatorDisposeBehavior( + disposeNestedNavigators = false, + disposeSteps = true + ), ) { navigator -> LaunchedEffect(navigator) { @@ -276,7 +279,9 @@ class MainActivity : BaseActivity() { if (showChangelog) { AlertDialog( onDismissRequest = { showChangelog = false }, - title = { Text(text = stringResource(R.string.updated_version, BuildConfig.VERSION_NAME)) }, + title = { Text( + text = stringResource(R.string.updated_version, BuildConfig.VERSION_NAME) + ) }, dismissButton = { TextButton(onClick = { openInBrowser(RELEASE_URL) }) { Text(text = stringResource(R.string.whats_new)) @@ -303,7 +308,9 @@ class MainActivity : BaseActivity() { episodeCache.clear() } - externalPlayerResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult -> + externalPlayerResult = registerForActivityResult( + ActivityResultContracts.StartActivityForResult() + ) { result: ActivityResult -> if (result.resultCode == Activity.RESULT_OK) { ExternalIntents.externalIntents.onActivityResult(result.data) } @@ -413,7 +420,11 @@ class MainActivity : BaseActivity() { private fun handleIntentAction(intent: Intent, navigator: Navigator): Boolean { val notificationId = intent.getIntExtra("notificationId", -1) if (notificationId > -1) { - NotificationReceiver.dismissNotification(applicationContext, notificationId, intent.getIntExtra("groupId", 0)) + NotificationReceiver.dismissNotification( + applicationContext, + notificationId, + intent.getIntExtra("groupId", 0) + ) } val tabToOpen = when (intent.action) { @@ -446,7 +457,9 @@ class MainActivity : BaseActivity() { // or the Google-specific search intent (triggered by saying or typing "search *query* on *Tachiyomi*" in Google Search/Google Assistant) // Get the search query provided in extras, and if not null, perform a global search with it. - val query = intent.getStringExtra(SearchManager.QUERY) ?: intent.getStringExtra(Intent.EXTRA_TEXT) + val query = intent.getStringExtra(SearchManager.QUERY) ?: intent.getStringExtra( + Intent.EXTRA_TEXT + ) if (!query.isNullOrEmpty()) { navigator.popUntilRoot() navigator.push(GlobalMangaSearchScreen(query)) @@ -496,7 +509,13 @@ class MainActivity : BaseActivity() { private var externalPlayerResult: ActivityResultLauncher? = null - suspend fun startPlayerActivity(context: Context, animeId: Long, episodeId: Long, extPlayer: Boolean, video: Video? = null) { + suspend fun startPlayerActivity( + context: Context, + animeId: Long, + episodeId: Long, + extPlayer: Boolean, + video: Video? = null + ) { if (extPlayer) { val intent = try { ExternalIntents.newIntent(context, animeId, episodeId, video) 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 0e9b5d03d..7c52dc41e 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 @@ -104,7 +104,9 @@ private class MoreScreenModel( var downloadedOnly by preferences.downloadedOnly().asState(coroutineScope) var incognitoMode by preferences.incognitoMode().asState(coroutineScope) - private var _state: MutableStateFlow = MutableStateFlow(DownloadQueueState.Stopped) + private var _state: MutableStateFlow = MutableStateFlow( + DownloadQueueState.Stopped + ) val downloadQueueState: StateFlow = _state.asStateFlow() init { @@ -118,7 +120,10 @@ private class MoreScreenModel( combine( animeDownloadManager.isDownloaderRunning, animeDownloadManager.queueState, - ) { isRunningAnime, animeDownloadQueue -> Pair(isRunningAnime, animeDownloadQueue.size) } + ) { isRunningAnime, animeDownloadQueue -> Pair( + isRunningAnime, + animeDownloadQueue.size + ) } .collectLatest { (isDownloadingAnime, animeDownloadQueueSize) -> val isDownloading = isDownloadingAnime || isDownloadingManga val downloadQueueSize = mangaDownloadQueueSize + animeDownloadQueueSize diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt index 7d76dfe8a..23bad98a4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt @@ -27,6 +27,8 @@ import eu.kanade.tachiyomi.ui.player.settings.PlayerPreferences import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.util.system.isOnline import eu.kanade.tachiyomi.util.system.toast +import java.io.File +import java.util.Date import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll @@ -53,8 +55,6 @@ import tachiyomi.source.local.entries.anime.LocalAnimeSource import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy -import java.io.File -import java.util.Date class ExternalIntents { @@ -73,7 +73,12 @@ class ExternalIntents { * @param animeId the id of the anime. * @param episodeId the id of the episode. */ - suspend fun getExternalIntent(context: Context, animeId: Long?, episodeId: Long?, chosenVideo: Video?): Intent? { + suspend fun getExternalIntent( + context: Context, + animeId: Long?, + episodeId: Long?, + chosenVideo: Video? + ): Intent? { anime = getAnime.await(animeId!!) ?: return null source = sourceManager.get(anime.source) ?: return null episode = getEpisodeByAnimeId.await(anime.id).find { it.id == episodeId } ?: return null @@ -299,7 +304,10 @@ class ExternalIntents { private fun getComponent(packageName: String): ComponentName? { return when (packageName) { MPV_PLAYER -> ComponentName(packageName, "$packageName.MPVActivity") - MX_PLAYER, MX_PLAYER_FREE, MX_PLAYER_PRO -> ComponentName(packageName, "$packageName.ActivityScreen") + MX_PLAYER, MX_PLAYER_FREE, MX_PLAYER_PRO -> ComponentName( + packageName, + "$packageName.ActivityScreen" + ) VLC_PLAYER -> ComponentName(packageName, "$packageName.gui.video.VideoPlayerActivity") MPV_REMOTE -> ComponentName(packageName, "$packageName.MainActivity") JUST_PLAYER -> ComponentName(packageName, "$packageName.PlayerActivity") @@ -366,7 +374,12 @@ class ExternalIntents { // Update the episode's progress and history launchIO { if (cause == "playback_completion" || (currentPosition == duration && duration == 0L)) { - saveEpisodeProgress(currentExtEpisode, anime, currentExtEpisode.totalSeconds, currentExtEpisode.totalSeconds) + saveEpisodeProgress( + currentExtEpisode, + anime, + currentExtEpisode.totalSeconds, + currentExtEpisode.totalSeconds + ) } else { saveEpisodeProgress(currentExtEpisode, anime, currentPosition, duration) } @@ -410,7 +423,12 @@ class ExternalIntents { * @param lastSecondSeen the position of the episode. * @param totalSeconds the duration of the episode. */ - private suspend fun saveEpisodeProgress(currentEpisode: Episode?, anime: Anime, lastSecondSeen: Long, totalSeconds: Long) { + private suspend fun saveEpisodeProgress( + currentEpisode: Episode?, + anime: Anime, + lastSecondSeen: Long, + totalSeconds: Long + ) { if (basePreferences.incognitoMode().get()) return val currEp = currentEpisode ?: return @@ -516,7 +534,12 @@ class ExternalIntents { * @param anime the anime of the episode. */ private suspend fun enqueueDeleteSeenEpisodes(episode: Episode, anime: Anime) { - if (episode.seen) withIOContext { downloadManager.enqueueEpisodesToDelete(listOf(episode), anime) } + if (episode.seen) { + withIOContext { downloadManager.enqueueEpisodesToDelete( + listOf(episode), + anime + ) } + } } companion object { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt index 688e630c7..431057d5e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt @@ -80,7 +80,11 @@ import eu.kanade.tachiyomi.util.system.toShareIntent import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.view.setComposeContent import `is`.xyz.mpv.MPVLib +import `is`.xyz.mpv.MPVView.Chapter as VideoChapter import `is`.xyz.mpv.Utils +import java.io.File +import kotlin.math.abs +import kotlin.math.roundToInt import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.update @@ -94,10 +98,6 @@ import tachiyomi.core.util.lang.withUIContext import tachiyomi.core.util.system.logcat import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.io.File -import kotlin.math.abs -import kotlin.math.roundToInt -import `is`.xyz.mpv.MPVView.Chapter as VideoChapter class PlayerActivity : BaseActivity() { @@ -122,7 +122,11 @@ class PlayerActivity : BaseActivity() { finish() return } - NotificationReceiver.dismissNotification(this, animeId.hashCode(), Notifications.ID_NEW_EPISODES) + NotificationReceiver.dismissNotification( + this, + animeId.hashCode(), + Notifications.ID_NEW_EPISODES + ) viewModel.saveCurrentEpisodeWatchingProgress() @@ -133,7 +137,9 @@ class PlayerActivity : BaseActivity() { val initResult = viewModel.init(animeId, episodeId) if (!initResult.second.getOrDefault(false)) { - val exception = initResult.second.exceptionOrNull() ?: IllegalStateException("Unknown error") + val exception = initResult.second.exceptionOrNull() ?: IllegalStateException( + "Unknown error" + ) withUIContext { setInitialEpisodeError(exception) } @@ -396,7 +402,11 @@ class PlayerActivity : BaseActivity() { is PlayerViewModel.Sheet.VideoChapters -> { fun setChapter(videoChapter: VideoChapter, text: String) { val seekDifference = videoChapter.time.roundToInt() - (player.timePos ?: 0) - doubleTapSeek(time = seekDifference, isDoubleTap = false, videoChapterText = text) + doubleTapSeek( + time = seekDifference, + isDoubleTap = false, + videoChapterText = text + ) } VideoChaptersSheet( timePosition = player.timePos ?: 0, @@ -434,7 +444,14 @@ class PlayerActivity : BaseActivity() { it.mpvId.toString() == subtitleTracks[index].url } selectedLoadedTrack?.let { player.sid = it.mpvId } - ?: MPVLib.command(arrayOf("sub-add", subtitleTracks[index].url, "select", subtitleTracks[index].url)) + ?: MPVLib.command( + arrayOf( + "sub-add", + subtitleTracks[index].url, + "select", + subtitleTracks[index].url + ) + ) } fun onAudioSelected(index: Int) { @@ -450,7 +467,14 @@ class PlayerActivity : BaseActivity() { it.mpvId.toString() == audioTracks[index].url } selectedLoadedTrack?.let { player.aid = it.mpvId } - ?: MPVLib.command(arrayOf("audio-add", audioTracks[index].url, "select", audioTracks[index].url)) + ?: MPVLib.command( + arrayOf( + "audio-add", + audioTracks[index].url, + "select", + audioTracks[index].url + ) + ) } StreamsCatalogSheet( @@ -468,7 +492,10 @@ class PlayerActivity : BaseActivity() { is PlayerViewModel.Sheet.SubtitleSettings -> { SubtitleSettingsSheet( - screenModel = PlayerSettingsScreenModel(viewModel.playerPreferences, streams.subtitle.tracks.size > 1), + screenModel = PlayerSettingsScreenModel( + viewModel.playerPreferences, + streams.subtitle.tracks.size > 1 + ), onDismissRequest = pauseForDialogSheet(fadeControls = true), ) } @@ -531,7 +558,9 @@ class PlayerActivity : BaseActivity() { val currentPlayerStatisticsPage = playerPreferences.playerStatisticsPage().get() if (currentPlayerStatisticsPage != 0) { MPVLib.command(arrayOf("script-binding", "stats/display-stats-toggle")) - MPVLib.command(arrayOf("script-binding", "stats/display-page-$currentPlayerStatisticsPage")) + MPVLib.command( + arrayOf("script-binding", "stats/display-page-$currentPlayerStatisticsPage") + ) } MPVLib.setOptionString("input-default-bindings", "yes") @@ -594,7 +623,10 @@ class PlayerActivity : BaseActivity() { MPVLib.setPropertyInt("sub-font-size", subtitleFontSize().get()) MPVLib.setPropertyString("sub-color", textColorSubtitles().get().toHexString()) MPVLib.setPropertyString("sub-border-color", borderColorSubtitles().get().toHexString()) - MPVLib.setPropertyString("sub-back-color", backgroundColorSubtitles().get().toHexString()) + MPVLib.setPropertyString( + "sub-back-color", + backgroundColorSubtitles().get().toHexString() + ) } } @@ -775,7 +807,11 @@ class PlayerActivity : BaseActivity() { override fun onResume() { super.onResume() refreshUi() - if (pip.supportedAndEnabled && PipState.mode == PipState.ON) player.paused?.let { pip.update(!it) } + if (pip.supportedAndEnabled && PipState.mode == PipState.ON) { + player.paused?.let { pip.update( + !it + ) } + } } override fun onPause() { @@ -947,7 +983,9 @@ class PlayerActivity : BaseActivity() { else -> { if (switchMethod.first != null) { when { - switchMethod.first!!.isEmpty() -> setInitialEpisodeError(Exception("Video list is empty.")) + switchMethod.first!!.isEmpty() -> setInitialEpisodeError( + Exception("Video list is empty.") + ) else -> setVideoList(qualityIndex = 0, switchMethod.first!!) } } else { @@ -1092,7 +1130,13 @@ class PlayerActivity : BaseActivity() { playerControls.hideUiForSeek() } binding.secondsView.start() - ViewAnimationUtils.createCircularReveal(view, x, y, 0f, kotlin.math.max(view.height, view.width).toFloat()).setDuration(500).start() + ViewAnimationUtils.createCircularReveal( + view, + x, + y, + 0f, + kotlin.math.max(view.height, view.width).toFloat() + ).setDuration(500).start() ObjectAnimator.ofFloat(view, "alpha", 0f, 0.15f).setDuration(500).start() ObjectAnimator.ofFloat(view, "alpha", 0.15f, 0.15f, 0f).setDuration(1000).start() @@ -1117,14 +1161,25 @@ class PlayerActivity : BaseActivity() { return } val newPos = (initialSeek + diff.toInt()).coerceIn(0, duration) - if (playerPreferences.playerSmoothSeek().get() && final) player.timePos = newPos else MPVLib.command(arrayOf("seek", newPos.toString(), "absolute+keyframes")) + if (playerPreferences.playerSmoothSeek().get() && final) { + player.timePos = newPos + } else { + MPVLib.command( + arrayOf("seek", newPos.toString(), "absolute+keyframes") + ) + } val newDiff = newPos - initialSeek playerControls.showSeekText(newPos, newDiff) } fun verticalScrollRight(diff: Float) { - if (diff != 0F) fineVolume = (fineVolume + (diff * maxVolume)).coerceIn(0F, maxVolume.toFloat()) + if (diff != 0F) { + fineVolume = (fineVolume + (diff * maxVolume)).coerceIn( + 0F, + maxVolume.toFloat() + ) + } val newVolume = fineVolume.toInt() audioManager!!.setStreamVolume(AudioManager.STREAM_MUSIC, newVolume, 0) @@ -1273,7 +1328,13 @@ class PlayerActivity : BaseActivity() { waitingAniSkip = -1 return } - skipType.let { MPVLib.command(arrayOf("seek", "${aniSkipInterval!!.first{it.skipType == skipType}.interval.endTime}", "absolute")) } + skipType.let { MPVLib.command( + arrayOf( + "seek", + "${aniSkipInterval!!.first{it.skipType == skipType}.interval.endTime}", + "absolute" + ) + ) } AniSkipApi.PlayerUtils(binding, aniSkipInterval!!).skipAnimation(skipType!!) } else if (playerControls.binding.controlsSkipIntroBtn.text != "") { doubleTapSeek(viewModel.getAnimeSkipIntroLength(), isDoubleTap = false) @@ -1381,7 +1442,12 @@ class PlayerActivity : BaseActivity() { finish() } - private fun setVideoList(qualityIndex: Int, videos: List